It was the second ruby dojo yesterday (Thu. 9/2/2012). A few more people turned up this time. No pizza, sadly, but understandable that they can't buy pizza and drinks every time.
This time, it was more organised. If you are agile, you get better at each iteration.
3 problems were given.
- Reverse the string: "Welcome! Today's challenges: Reverse the string"
- Find all permutations of the letters: "welcome"
- Find all 10-digit binary numbers with no consecutive 1s
The first and the third were relatively straightforward, but permutations of "welcome" was a real challenge. We ended up using ruby's "permutation" method, which was a cheat.
Reverse the string
string = "Hello Welcome to Ruby Dojo"
reverse = 
string.each_char do |char|
filtered = 
max = "1100000000".to_i(2)
(0..max).each do |number|
n = number.to_s(2)
filtered << n unless n.match /11/
string = "welcome".split("")
string.permutation do |str|