PeterNewton
Regular
- Joined
- Mar 3, 2009
- Messages
- 166
i wrote a program for mirroring and/or inversing algorithms. it only deals with regular face movements, so cube rotations and double-layer moves are not allowed, but i will incorporate them in soon. it should be simple enough.
i am a beginner at programming so it was written using Turing.
could someone show me how to make the program more efficient?
here is the code:
thanks!
EDIT: what the heck, why is the indentation ok when i view it when writing, but everything gets left-aligned in the actual post..?
i guess the only way someone can help is by copy/pasting the code to Turing and pressing indent. this is too confusing. even i cant understand what it says.
i am a beginner at programming so it was written using Turing.
could someone show me how to make the program more efficient?
here is the code:
Code:
setscreen ("graphics:1000;10000")
var ans, alg1, alg2 : string
var c : int
put "Note: do not type spaces between moves"
put ""
put "| Face Turn | Single Layer | Double Layer |"
put "| Front | F | f |"
put "| Back | B | b |"
put "| Up | U | u |"
put "| Down | D | d |"
put "| Right | R | r |"
put "| Left | L | l |"
put "| Middle | M |"
put "| Equator | E |"
put "| Side | S |"
put ""
put "Note: M is based on L"
put "Note: E is based on D"
put "Note: S is based on F"
put ""
put "| Cube Turn | Single Move |"
put "| Pivot on x-axis | x |"
put "| Pivot on y-axis | y |"
put "| Pivot on z-axis | z |"
put ""
put "Note: x is based on R with pivot on RL"
put "Note: y is based on U with pivot on UD"
put "Note: z is based on F with pivot on FB"
put ""
put "90 degree = + (N/A)"
put "180 degree = + (2)"
put "Clockwise = + (N/A)"
put "Counter-clockwise = + (')"
put ""
put "Note: 180 turn notation is used before Counter-clockwise notation"
put ""
loop
alg2 := ""
put "mirror or inverse (M/I)?"
get ans
if ans = "M" or ans = "I" then
put "please enter algorithm"
get alg1
end if
if ans = "M" then
c := 1
loop
if alg1 (c) = "F" or alg1 (c) = "B" or alg1 (c) = "U" or alg1 (c) = "D" then
alg2 := alg2 + alg1 (c)
elsif alg1 (c) = "R" then
alg2 := alg2 + "L"
elsif alg1 (c) = "L" then
alg2 := alg2 + "R"
elsif alg1 (c) = "f" or alg1 (c) = "b" or alg1 (c) = "u" or alg1 (c) = "d" then
alg2 := alg2 + alg1 (c)
elsif alg1 (c) = "M" or alg1 (c) = "E" or alg1 (c) = "S" then
alg2 := alg2 + alg1 (c)
elsif alg1 (c) = "x" or alg1 (c) = "y" or alg1 (c) = "z" then
alg2 := alg2 + alg1 (c)
end if
if c = length (alg1) then
if alg1 (c) not= "'" and alg1 (c) not= "2" then
alg2 := alg2 + "'"
end if
else
if alg1 (c + 1) = "'" then
c := c + 1
elsif alg1 (c + 1) = "2" then
alg2 := alg2 + "2"
if c < length (alg1) - 1 then
if alg1 (c + 2) not= "'" then
alg2 := alg2 + "'"
elsif alg1 (c + 2) = "'" then
c := c + 1
end if
elsif c < length (alg1) then
alg2 := alg2 + "'"
end if
c := c + 1
elsif alg1 (c + 1) not= "'" and alg1 (c + 1) not= "2" then
alg2 := alg2 + "'"
end if
end if
exit when c = length (alg1)
c := c + 1
end loop
put "mirror: ", alg2
put ""
elsif ans = "I" then
c := length (alg1)
loop
if alg1 (c) = "'" or alg1 (c) = "2" then
c := c - 1
if alg1 (c) = "2" then
c := c - 1
end if
end if
alg2 := alg2 + alg1 (c)
if c = length (alg1) then
if alg1 (c) not= "'" and alg1 (c) not= "2" then
alg2 := alg2 + "'"
end if
else
if alg1 (c + 1) = "2" then
alg2 := alg2 + "2"
if c < length (alg1) - 1 and alg1 (c + 2) not= "'" then
alg2 := alg2 + "'"
elsif c < length (alg1) then
alg2 := alg2 + "'"
end if
elsif alg1 (c + 1) not= "'" and alg1 (c + 1) not= "2" then
alg2 := alg2 + "'"
end if
end if
exit when c = 1
c := c - 1
end loop
put "inverse: ", alg2
put ""
else
put "invalid option"
end if
end loop
thanks!
EDIT: what the heck, why is the indentation ok when i view it when writing, but everything gets left-aligned in the actual post..?
i guess the only way someone can help is by copy/pasting the code to Turing and pressing indent. this is too confusing. even i cant understand what it says.
Last edited: