# Oat in January (Ruby scrambler 2.0)

#### Owen

##### Member
Still not perfect, but I improved the code, and added a little bit of move canceling.

lastnum = -1
moves = ["U","D","L","R","F","B","U'","D'","L'","R'","F'","B'","U2","D2","L2","R2","F2","B2"]
25.times do

pick = rand(18)
if lastnum == pick
until not pick == lastnum
pick = rand(18)
end
end
print moves[pick]
print " "
lastnum = pick
end

#### Edward

##### Member
I can't say if its good or not because I don't know about programming in ruby.
But couldn't you wait until you're completely done and THEN release it?
I say this because I make the same mistake all the time.

#### Owen

##### Member
I can't say if its good or not because I don't know about programming in ruby.
But couldn't you wait until you're completely done and THEN release it?
I say this because I make the same mistake all the time.
I am completely done. It's just an experiment, not a huge project

#### Lucas Garron

##### Member
Code:
~/ruby a.rb
L D R' D2 B2 U R L2 L L' R D' U R2 U' B2 U' U2 U' R D U R2 D' U
U' U2 U', seriously?
Just separate your suffices from the moves: ["U","D","L","R","F","B"] and ["", "2", "'"]. Makes move checking easier, and makes for cleaner code instead of hardcoding all the moves.

##### Member
You should get into the habit of using indentation so that your code is readable. I'm not sure about the specifics of Ruby, but I would do something like this:

(without Lucas' suggestion implemented, which is a good one by the way)
Code:
lastnum = -1
moves = ["U","D","L","R","F","B","U'","D'","L'","R'","F'"," B'","U2","D2","L2","R2","F2","B2"]

25.times do
pick = rand(18)
if lastnum == pick
until not pick == lastnum
pick = rand(18)
end
end
print moves[pick]
print " "
lastnum = pick
end
You should keep working on this. It's not a successful "experiment" if it doesn't work right. You won't learn anything by stopping before your code works correctly.

My result: L' D B' B2 U2 R D U2 F D U U' L2 U' B' R' L2 B2 L2 L B F' B' B2 F2

#### Owen

##### Member
You should get into the habit of using indentation so that your code is readable. I'm not sure about the specifics of Ruby, but I would do something like this:

(without Lucas' suggestion implemented, which is a good one by the way)
Code:
lastnum = -1
moves = ["U","D","L","R","F","B","U'","D'","L'","R'","F'"," B'","U2","D2","L2","R2","F2","B2"]

25.times do
pick = rand(18)
if lastnum == pick
until not pick == lastnum
pick = rand(18)
end
end
print moves[pick]
print " "
lastnum = pick
end
You should keep working on this. It's not a successful "experiment" if it doesn't work right. You won't learn anything by stopping before your code works correctly.

My result: L' D B' B2 U2 R D U2 F D U U' L2 U' B' R' L2 B2 L2 L B F' B' B2 F2

It was indented, but the indentation was lost when I copied and pasted it.