Skip to main content
adding test cases to question, as per the consensus in Meta "discussion"
Source Link

Additional examples (provided by Scott Leadley, any errors are mine and not ypnypn's)

Some difficult cases:

  • IN => OUT
  • 6 xx aa dd bb ee cc => dd L ee L xx L
  • 7 aa bb ee cc dd ff gg => ee D D
  • 8 dd ww aa bb cc xx yy zz => ww D D D dd D D D
    • (not the minimial number of moves, which would be cc F bb F aa F)

Permutations of 4 items aa bb cc dd with sort paths of length >1:

  • IN => OUT
  • 4 aa cc dd bb => bb F D
  • 4 aa dd cc bb => aa L R
  • 4 bb aa dd cc => aa F cc U
  • 4 bb dd aa cc => aa F cc U
  • 4 bb dd cc aa => bb D D R
  • 4 cc aa bb dd => cc D D
  • 4 cc aa dd bb => bb F aa F
  • 4 cc bb aa dd => dd F R
  • 4 cc bb dd aa => dd F R
  • 4 cc dd aa bb => bb F aa F
  • 4 cc dd bb aa => cc D R
  • 4 dd aa cc bb => aa L R
  • 4 dd bb aa cc => cc F D R
  • 4 dd bb cc aa => bb D R
  • 4 dd cc aa bb => aa D R

Variations on a theme, 4 items aaaaa bbbb ccc dd where string length makes a difference:

  • IN => OUT
  • 4 ccc dd aaaaa bbbb => ccc L dd L
  • 4 bbbb aaaaa dd ccc => bbbb D dd D
  • 4 bbbb dd aaaaa ccc => dd L bbbb D
  • 4 ccc aaaaa dd bbbb => ccc L dd L
  • 4 ccc dd bbbb aaaaa => dd F R
  • 4 dd bbbb ccc aaaaa => ccc R D
  • 4 dd ccc aaaaa bbbb => bbbb R D

Additional examples (provided by Scott Leadley, any errors are mine and not ypnypn's)

Some difficult cases:

  • IN => OUT
  • 6 xx aa dd bb ee cc => dd L ee L xx L
  • 7 aa bb ee cc dd ff gg => ee D D
  • 8 dd ww aa bb cc xx yy zz => ww D D D dd D D D
    • (not the minimial number of moves, which would be cc F bb F aa F)

Permutations of 4 items aa bb cc dd with sort paths of length >1:

  • IN => OUT
  • 4 aa cc dd bb => bb F D
  • 4 aa dd cc bb => aa L R
  • 4 bb aa dd cc => aa F cc U
  • 4 bb dd aa cc => aa F cc U
  • 4 bb dd cc aa => bb D D R
  • 4 cc aa bb dd => cc D D
  • 4 cc aa dd bb => bb F aa F
  • 4 cc bb aa dd => dd F R
  • 4 cc bb dd aa => dd F R
  • 4 cc dd aa bb => bb F aa F
  • 4 cc dd bb aa => cc D R
  • 4 dd aa cc bb => aa L R
  • 4 dd bb aa cc => cc F D R
  • 4 dd bb cc aa => bb D R
  • 4 dd cc aa bb => aa D R

Variations on a theme, 4 items aaaaa bbbb ccc dd where string length makes a difference:

  • IN => OUT
  • 4 ccc dd aaaaa bbbb => ccc L dd L
  • 4 bbbb aaaaa dd ccc => bbbb D dd D
  • 4 bbbb dd aaaaa ccc => dd L bbbb D
  • 4 ccc aaaaa dd bbbb => ccc L dd L
  • 4 ccc dd bbbb aaaaa => dd F R
  • 4 dd bbbb ccc aaaaa => ccc R D
  • 4 dd ccc aaaaa bbbb => bbbb R D
added 15 characters in body
Source Link
Ypnypn
  • 10.9k
  • 2
  • 31
  • 80

With a window similar to the one pictured below, you are given a list of strings, which you want to put in alphabetical order.

![Sort order dialog][1] [1]: https://i.sstatic.net/Tn4JU.png

As shown, you have five operations:

  • Move up [U] - moves the selected string up one place
  • Move down [D] - moves the selected string down one place
  • Move first [F] - moves the selected string to the top of the list
  • Move last [L] - moves the selected string to the bottom of the list
  • Reverse [R] - reverses the order of the list

Using STDIN, accept a number (how many strings), followed by the unordered list of strings. Each string consists of 2-99 lower case English letters. (The example above would not be a valid input.)

Using STDOUT, print the way to put the list in order. First, mention an item to select, and then the operations(s) to perform on it in order to put the list in alphabetical order.

For example: February U December F May D D June D R D...

Explanation: Click February, move it up 1. Select December, move it to top. May, move it down twice. June, move down once, reverse the list, move down again...

Since there are obviously many valid solutions, you must choose the shortest possible. That is, choose the method with the fewest number of operations (7 in the above example).

If there's a tie among correct outputs to the input, resolve it in the following order.

  1. Choose the one with the fewest string selections (4 in the above example).

  2. Choose the one with the fewest operations, counting consecutive identical operations (on one string) as one (6 in the above example).

  3. Choose the one with shortest output (least number of total characters, counting spaces).

  4. Choose the one with the output that comes first alphabetically.

This is code-golf; the shortest submission which always produces the correct output wins.

Examples

  • IN 2 aazz babc
  • OUT bzz FD
  • IN 3 ccc bbb aaa
  • OUT aaa R
  • IN 4 abc def cd ccc
  • OUT abc L R
  • IN 6 rrr mmm nnn ooo qqq ppp
  • OUT ppp U rrr L

With a window similar to the one pictured below, you are given a list of strings, which you want to put in alphabetical order.

![Sort order dialog][1] [1]: https://i.sstatic.net/Tn4JU.png

As shown, you have five operations:

  • Move up [U] - moves the selected string up one place
  • Move down [D] - moves the selected string down one place
  • Move first [F] - moves the selected string to the top of the list
  • Move last [L] - moves the selected string to the bottom of the list
  • Reverse [R] - reverses the order of the list

Using STDIN, accept a number (how many strings), followed by the unordered list of strings. Each string consists of 2-99 lower case English letters. (The example above would not be a valid input.)

Using STDOUT, print the way to put the list in order. First, mention an item to select, and then the operations(s) to perform on it in order to put the list in alphabetical order.

For example: February U December F May D D June D R D...

Explanation: Click February, move it up 1. Select December, move it to top. May, move it down twice. June, move down once, reverse the list, move down again...

Since there are obviously many valid solutions, you must choose the shortest possible. That is, choose the method with the fewest number of operations (7 in the above example).

If there's a tie among correct outputs to the input, resolve it in the following order.

  1. Choose the one with the fewest string selections (4 in the above example).

  2. Choose the one with the fewest operations, counting consecutive identical operations (on one string) as one (6 in the above example).

  3. Choose the one with shortest output (least number of total characters, counting spaces).

  4. Choose the one with the output that comes first alphabetically.

This is code-golf; the shortest submission which always produces the correct output wins.

Examples

  • IN 2 aa b
  • OUT b F
  • IN 3 c b a
  • OUT a R
  • IN 4 abc def cd ccc
  • OUT abc L R
  • IN 6 r m n o q p
  • OUT p U r L

With a window similar to the one pictured below, you are given a list of strings, which you want to put in alphabetical order.

![Sort order dialog][1] [1]: https://i.sstatic.net/Tn4JU.png

As shown, you have five operations:

  • Move up [U] - moves the selected string up one place
  • Move down [D] - moves the selected string down one place
  • Move first [F] - moves the selected string to the top of the list
  • Move last [L] - moves the selected string to the bottom of the list
  • Reverse [R] - reverses the order of the list

Using STDIN, accept a number (how many strings), followed by the unordered list of strings. Each string consists of 2-99 lower case English letters. (The example above would not be a valid input.)

Using STDOUT, print the way to put the list in order. First, mention an item to select, and then the operations(s) to perform on it in order to put the list in alphabetical order.

For example: February U December F May D D June D R D...

Explanation: Click February, move it up 1. Select December, move it to top. May, move it down twice. June, move down once, reverse the list, move down again...

Since there are obviously many valid solutions, you must choose the shortest possible. That is, choose the method with the fewest number of operations (7 in the above example).

If there's a tie among correct outputs to the input, resolve it in the following order.

  1. Choose the one with the fewest string selections (4 in the above example).

  2. Choose the one with the fewest operations, counting consecutive identical operations (on one string) as one (6 in the above example).

  3. Choose the one with shortest output (least number of total characters, counting spaces).

  4. Choose the one with the output that comes first alphabetically.

This is code-golf; the shortest submission which always produces the correct output wins.

Examples

  • IN 2 zz abc
  • OUT zz D
  • IN 3 cc bb aa
  • OUT aa R
  • IN 4 abc def cd ccc
  • OUT abc L R
  • IN 6 rr mm nn oo qq pp
  • OUT pp U rr L
examples
Source Link
Ypnypn
  • 10.9k
  • 2
  • 31
  • 80

With a window similar to the one pictured below, you are given a list of strings, which you want to put in alphabetical order.

![Sort order dialog][1] [1]: https://i.sstatic.net/Tn4JU.png

As shown, you have five operations:

  • Move up [U] - moves the selected string up one place
  • Move down [D] - moves the selected string down one place
  • Move first [F] - moves the selected string to the top of the list
  • Move last [L] - moves the selected string to the bottom of the list
  • Reverse [R] - reverses the order of the list

Using STDIN, accept a number (how many strings), followed by the unordered list of strings. Each string consists of 2-99 lower case English letters. (The example above would not be a valid input.)

Using STDOUT, print the way to put the list in order. First, mention an item to select, and then the operations(s) to perform on it in order to put the list in alphabetical order.

For example: February U December F May D D June D R D...

Explanation: Click February, move it up 1. Select December, move it to top. May, move it down twice. June, move down once, reverse the list, move down again...

Since there are obviously many valid solutions, you must choose the shortest possible. That is, choose the method with the fewest number of operations (7 in the above example).

If there's a tie among correct outputs to the input, resolve it in the following order.

  1. Choose the one with the fewest string selections (4 in the above example).

  2. Choose the one with the fewest operations, counting consecutive identical operations (on one string) as one (6 in the above example).

  3. Choose the one with shortest output (least number of total characters, counting spaces).

  4. Choose the one with the output that comes first alphabetically.

This is code-golf; the shortest submission which always produces the correct output wins.

Examples

  • IN 2 aa b
  • OUT b F
  • IN 3 c b a
  • OUT a R
  • IN 4 abc def cd ccc
  • OUT abc L R
  • IN 6 r m n o q p
  • OUT p U r L

With a window similar to the one pictured below, you are given a list of strings, which you want to put in alphabetical order.

![Sort order dialog][1] [1]: https://i.sstatic.net/Tn4JU.png

As shown, you have five operations:

  • Move up [U] - moves the selected string up one place
  • Move down [D] - moves the selected string down one place
  • Move first [F] - moves the selected string to the top of the list
  • Move last [L] - moves the selected string to the bottom of the list
  • Reverse [R] - reverses the order of the list

Using STDIN, accept a number (how many strings), followed by the unordered list of strings. Each string consists of 2-99 lower case English letters. (The example above would not be a valid input.)

Using STDOUT, print the way to put the list in order. First, mention an item to select, and then the operations(s) to perform on it in order to put the list in alphabetical order.

For example: February U December F May D D June D R D...

Explanation: Click February, move it up 1. Select December, move it to top. May, move it down twice. June, move down once, reverse the list, move down again...

Since there are obviously many valid solutions, you must choose the shortest possible. That is, choose the method with the fewest number of operations (7 in the above example).

If there's a tie among correct outputs to the input, resolve it in the following order.

  1. Choose the one with the fewest string selections (4 in the above example).

  2. Choose the one with the fewest operations, counting consecutive identical operations (on one string) as one (6 in the above example).

  3. Choose the one with shortest output (least number of total characters, counting spaces).

  4. Choose the one with the output that comes first alphabetically.

This is code-golf; the shortest submission which always produces the correct output wins.

With a window similar to the one pictured below, you are given a list of strings, which you want to put in alphabetical order.

![Sort order dialog][1] [1]: https://i.sstatic.net/Tn4JU.png

As shown, you have five operations:

  • Move up [U] - moves the selected string up one place
  • Move down [D] - moves the selected string down one place
  • Move first [F] - moves the selected string to the top of the list
  • Move last [L] - moves the selected string to the bottom of the list
  • Reverse [R] - reverses the order of the list

Using STDIN, accept a number (how many strings), followed by the unordered list of strings. Each string consists of 2-99 lower case English letters. (The example above would not be a valid input.)

Using STDOUT, print the way to put the list in order. First, mention an item to select, and then the operations(s) to perform on it in order to put the list in alphabetical order.

For example: February U December F May D D June D R D...

Explanation: Click February, move it up 1. Select December, move it to top. May, move it down twice. June, move down once, reverse the list, move down again...

Since there are obviously many valid solutions, you must choose the shortest possible. That is, choose the method with the fewest number of operations (7 in the above example).

If there's a tie among correct outputs to the input, resolve it in the following order.

  1. Choose the one with the fewest string selections (4 in the above example).

  2. Choose the one with the fewest operations, counting consecutive identical operations (on one string) as one (6 in the above example).

  3. Choose the one with shortest output (least number of total characters, counting spaces).

  4. Choose the one with the output that comes first alphabetically.

This is code-golf; the shortest submission which always produces the correct output wins.

Examples

  • IN 2 aa b
  • OUT b F
  • IN 3 c b a
  • OUT a R
  • IN 4 abc def cd ccc
  • OUT abc L R
  • IN 6 r m n o q p
  • OUT p U r L
added 128 characters in body
Source Link
Ypnypn
  • 10.9k
  • 2
  • 31
  • 80
Loading
Source Link
Ypnypn
  • 10.9k
  • 2
  • 31
  • 80
Loading