i'm attempting combine few random numbers. numbers supposed represent dice.
for example, want roll dice 5 times , following results: 4 2 1 4 6.
these individual numbers want combine 42146.
this might simple question apologize i'm still new ruby.
i'm generating numbers between [1,6] through this:
number = 1 + rand(6)
1.upto(5).map { rand(1..6) }.join.to_i
1.upto(5)
give enumerator 5 elementsmap { rand(1..6) }
map random number between 1 , 6 each of above elementsjoin
concatenate elements of got farto_i
transform above result string integer
Comments
Post a Comment