Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Ruby
Checking the sample code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#m = gets.chomp
m = "CG"
b = ""
m.each_byte { |w|
b += ('%7.7s' % w.ord.to_s(2)).gsub(' ', '0')
}
c = ["00", "0"]
ans = c[b[0].to_i] + " 0"
for i in 1..b.length-1
ans += (b[i] == b[i - 1] ? "0" : " " + c[b[i].to_i] + " 0")
end
# STDERR.puts "Debug messages..."
print ans
Enter to Rename, Shift+Enter to Preview
Looking at the syntax
- TODO
Other characteristics
- TODO
- Ruby excels at Code Golf. You can write really short code in it.
Resources to check
Coming next...
Suggested playgrounds
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content