(25C) 1D Rubik's Cube
|
04-21-2017, 11:45 PM
(This post was last modified: 04-26-2017 04:53 AM by nsg.)
Post: #1
|
|||
|
|||
(25C) 1D Rubik's Cube
This is an implementation of one-dimensional equivalent of Rubiks cube.
The string of 8 digits (colors) can has to be manipulated to produce an initial position. Move consists of the following: any 4 consecutive characters in the string turn 180 degrees in their place (4-substring reverses its order). For example 12345678 may be transformed into 1(2345)678 --> 1(5432)678 = 15432678 by reversing substring of length 4 starting from second character. If the input is some permutation of digits 12345678, then only even permutations can be completely sorted. Here are several challenges: 1. Warm up challenge. 12121212 STO 0 turn into 11112222 12341234 STO 0 turn into 11223344 2. Standard mode. a) 62783541 b) 87236451 c) 51382764 d) 53847261 e) 64381257 Select one of the initial permutaions a)-e). Save it to R0 Sort all digits to get 12345678 3. Extra credit. Extra challenging variant of the puzzle reverses substrings of length 6, rather than 4. This variant allows to sort all permutations, even and odd. To implement this variant modify lines 06 and 23 in the program (they are marked "variant" in the listing). change "06. 6" to "06. 4" and "23. 4" to "23. 6". Convert 87654321 to 12345678 (there are only 3 substrings of length 6, so at each moment only move 1,2 or 3 are acceptable) Code:
Initial setting: f PRGM FIX 0 10 STO 1 <starting combination of exactly 8 non-zero digits> STO 0 For example: 12121212 STO 0 To make a move: <n> R/S n=1..5, position of the first character of substring to reverse Output: updated position. For example: 3 R/S --> 12212112 Repeat moves until you achieve final position. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(25C) 1D Rubik's Cube - nsg - 04-21-2017 11:45 PM
RE: (25C) 1D Rubik's Cube - nsg - 04-22-2017, 12:06 AM
|
User(s) browsing this thread: 1 Guest(s)