# Ruby scambler



## Owen (Dec 14, 2009)

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.


----------



## Pedro (Dec 14, 2009)

why don't you have F moves?

to avoid U U' U, you have to first choose and axis, then choose a move

you have to allow R L, but not R L R


----------



## Owen (Dec 14, 2009)

Pedro said:


> why don't you have F moves?
> 
> to avoid U U' U, you have to first choose and axis, then choose a move
> 
> you have to allow R L, but not R L R



I new I was missing something.....


----------



## joey (Dec 14, 2009)

Missing F... is not the most important thing you're missing.

You're not really understanding how to really use ruby.


----------



## Lucas Garron (Dec 14, 2009)

```
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)?


----------



## Stefan (Dec 14, 2009)

Judging by this, I say Ruby is an utterly ugly and inelegant language.


----------



## Swordsman Kirby (Dec 14, 2009)

Huh? It's missing D', B, F, F', U2, R2, L2, B2, F2, D2.


----------



## Stefan (Dec 14, 2009)

Swordsman Kirby said:


> Huh? It's missing D', B, F, F', U2, R2, L2, B2, F2, D2.


Shut up! All of those can be achieved with combinations of the moves it does have!


----------



## tim (Dec 14, 2009)

Owen said:


> ```
> 20.times do
> 
> number = rand 9
> ...



1.) What about the random newlines?
2.) Use arrays like so:

```
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:

```
moves = %w(U D R L F B)
20.times do
  puts moves.rand
end
```


----------



## Owen (Dec 14, 2009)

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


----------



## blade740 (Dec 14, 2009)

Gratuitous :fp


----------



## qqwref (Dec 14, 2009)

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.


----------



## Owen (Dec 14, 2009)

blade740 said:


> Gratuitous :fp



I am currently freaking out.


----------



## Owen (Dec 14, 2009)

StefanPochmann said:


> 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).


----------



## Lucas Garron (Dec 14, 2009)

Owen said:


> StefanPochmann said:
> 
> 
> > How does this deserve to be in "Speedcubing Discussion"?
> ...


It _really_ didn't belong in Puzzle Theory.


----------



## Owen (Dec 14, 2009)

Lucas Garron said:


> Owen said:
> 
> 
> > StefanPochmann said:
> ...



I put it there because thats were all the other scramblers were.


----------



## keemy (Dec 14, 2009)

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?


----------



## Lucas Garron (Dec 14, 2009)

Owen said:


> Lucas Garron said:
> 
> 
> > Owen said:
> ...


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.


----------



## Swordsman Kirby (Dec 14, 2009)

StefanPochmann said:


> Swordsman Kirby said:
> 
> 
> > Huh? It's missing D', B, F, F', U2, R2, L2, B2, F2, D2.
> ...



Ah, of course. Unfortunately it can't possibly generate all possible states in 20 moves.


----------



## zeroxorxdiexskater (Jan 4, 2010)

haha jeez harsh


----------



## PHPJaguar (Jan 4, 2010)

zeroxorxdiexskater said:


> haha jeez harsh


Rule #32 of the Internet: don't bump an old thread unless you have something new/informative to add.


----------



## hansho13 (Feb 2, 2010)

EAT THIS>:fp:fp:fp:fp:fp:fp


----------



## Caedus (Feb 2, 2010)

hansho13 said:


> EAT THIS>:fp:fp:fp:fp:fp:fp



EAT THAT BAN FOR EXCESSIVE FACEPALMS!!!

Seriously, though, for a first attempt, it's not _that_ bad.
Although, it does seem like it was written in about 45 seconds.


----------

