Ruby scambler

  • Thread starter Thread starter Owen
  • Start date Start date
O

Owen

Guest
I just started ruby, so I made a scamble generator. It just comes up with random moves, so it's not very good (I got U U' U'). Made in 15 minutes.


20.times do

number = rand 9
if number == 1
puts "U"
elsif number == 2
puts "D"
elsif number == 3
puts "R"
elsif number == 4
puts "L"
elsif number == 5
puts "U'"
elsif number == 6
puts "R'"
elsif number == 7
puts "L'"
elsif number == 8
puts "B'"
end



end




Note: If you use the facepalm emoticon, on this thread, I will freak out.
 
Last edited by a moderator:
Code:
StringJoin/@Tuples[{{"U", "R", "D", "L"}, {"", "'"}}[[Table[Random[Integer, {1, 8}], {20}]]] // StringJoin
Whee!

Edit: Except that your code is even WORSE than that. Do you even know how rand works in Ruby (or any other decent language)?
 
Last edited:
Code:
20.times do

 number = rand 9
  if number == 1
    puts "U"
  elsif number == 2
    puts "D"
  elsif number == 3
    puts "R"
  elsif number == 4
    puts "L"
  elsif number == 5
    puts "U'"
  elsif number == 6
    puts "R'"
  elsif number == 7
    puts "L'"
  elsif number == 8
    puts "B'"
  end
  
  
  
end

1.) What about the random newlines?
2.) Use arrays like so:
Code:
moves = %w(U D R L F B)
20.times do
  number = rand 6
  puts moves[number]
end

3.) Learn some Ruby by getting this to work:
Code:
moves = %w(U D R L F B)
20.times do
  puts moves.rand
end
 
Oh, don't complain about my Ruby knowlage. I didn't say it was good.


"I just started ruby, so I made a scamble generator. It just comes up with random moves, so it's not very good (I got U U' U'). Made in 15 minutes."



I also added F.


20.times do

number = rand 11
if number == 1
puts "U"
elsif number == 2
puts "D"
elsif number == 3
puts "R"
elsif number == 4
puts "L"
elsif number == 5
puts "U'"
elsif number == 6
puts "R'"
elsif number == 7
puts "L'"
elsif number == 8
puts "B'"
elsif number == 9
puts "F"
elsif number == 10
puts "F'"
end



end
 
Last edited by a moderator:
Saying "it's not very good" is an incredible understatement. This is seriously the worst attempt at a scrambler I've ever seen. I'm sure you're a beginning programmer, but you should at least put some more work into something before posting it on a forum - test it out, play with it a bit, fix all the really obvious errors (like having no F moves, or D', or B, or double turns...). Your scrambler doesn't even *work* - it doesn't turn all faces, it doesn't do the right number of moves (for random turns you should do 25, not 20), and it doesn't have even the most rudimentary move canceling.
 
hey so after seeing this i decided to make a scrambler for the lols it probably took a little more than 15 mins though (because was typed on a calculator darn and i had to learn 1 thing) but yeah it doesn't do F moves either so it must be good right.

less Fs in the scramble less possible to get F perm amirite?
 
How does this deserve to be in "Speedcubing Discussion"?

Your right! This is not a disscusion, but a bunch of people insulting my scrambler! (I acually put this in "Puzzle theory", but I guess it got moved).
It really didn't belong in Puzzle Theory.

I put it there because thats were all the other scramblers were.
False. Second results if you searcher for "Scrambler" in the big Google field at the top. And the first result contains legitimate theory.

EDIT: Actually, NONE of the other results on the first search results page are in puzzle theory. If you're going to post any more in this thread, could you please check your facts? It's embarrassing.
 
Back
Top