Skip to main content
Code Golf deletes trailing whitespace by default
Source Link
user85052
user85052

Can the cursor reach the bottom?

A cursor position is valid if either of its two sides touches whitespace (i.e. a space or a newline(CR+LF or LF, depending on your OS)). The input will always consist of valid cursor positions.

This takes one input(a character matrix), and for a cursor on the up right corner of the input, can the cursor reach the bottom of the input?

Example input:

 ..... Same, delete text like this in order
 ......
. . . .
.      Same to get normal input
...... Same

The cursor can reach the bottom in this case. This process of moving the cursor will work: down, right(touches spaces on the left), down(touches spaces on the right), down, right(touches spaces on both sides) 6 times, and down(touching spaces and a linefeed).

Notably, this will also work:

  Code Golf deletes trailing whitespace by default
..
.
  trailing

The cursor starts at the up-right corner. After moving right two times, it can move down (due to touching a newline character). Then, it can move down, which touches the bottom of the line.

This example will not work:

 ...
... Same reason as above

The cursor cannot move down, as there is no sufficient whitespace to be touched.

Can the cursor reach the bottom?

A cursor position is valid if either of its two sides touches whitespace (i.e. a space or a newline(CR+LF or LF, depending on your OS)). The input will always consist of valid cursor positions.

This takes one input(a character matrix), and for a cursor on the up right corner of the input, can the cursor reach the bottom of the input?

Example input:

 .....
 ......
. . . .
.      
...... 

The cursor can reach the bottom in this case. This process of moving the cursor will work: down, right(touches spaces on the left), down(touches spaces on the right), down, right(touches spaces on both sides) 6 times, and down(touching spaces and a linefeed).

Notably, this will also work:

  
..
.
 

The cursor starts at the up-right corner. After moving right two times, it can move down (due to touching a newline character). Then, it can move down, which touches the bottom of the line.

This example will not work:

 ...
...

The cursor cannot move down, as there is no sufficient whitespace to be touched.

Can the cursor reach the bottom?

A cursor position is valid if either of its two sides touches whitespace (i.e. a space or a newline(CR+LF or LF, depending on your OS)). The input will always consist of valid cursor positions.

This takes one input(a character matrix), and for a cursor on the up right corner of the input, can the cursor reach the bottom of the input?

Example input:

 ..... Same, delete text like this in order
 ......
. . . .
.      Same to get normal input
...... Same

The cursor can reach the bottom in this case. This process of moving the cursor will work: down, right(touches spaces on the left), down(touches spaces on the right), down, right(touches spaces on both sides) 6 times, and down(touching spaces and a linefeed).

Notably, this will also work:

  Code Golf deletes trailing whitespace by default
..
. trailing

The cursor starts at the up-right corner. After moving right two times, it can move down (due to touching a newline character). Then, it can move down, which touches the bottom of the line.

This example will not work:

 ...
... Same reason as above

The cursor cannot move down, as there is no sufficient whitespace to be touched.

Source Link
user85052
user85052

Can the cursor reach the bottom?

A cursor position is valid if either of its two sides touches whitespace (i.e. a space or a newline(CR+LF or LF, depending on your OS)). The input will always consist of valid cursor positions.

This takes one input(a character matrix), and for a cursor on the up right corner of the input, can the cursor reach the bottom of the input?

Example input:

 .....
 ......
. . . .
.      
...... 

The cursor can reach the bottom in this case. This process of moving the cursor will work: down, right(touches spaces on the left), down(touches spaces on the right), down, right(touches spaces on both sides) 6 times, and down(touching spaces and a linefeed).

Notably, this will also work:

  
..
.

The cursor starts at the up-right corner. After moving right two times, it can move down (due to touching a newline character). Then, it can move down, which touches the bottom of the line.

This example will not work:

 ...
...

The cursor cannot move down, as there is no sufficient whitespace to be touched.