-
Notifications
You must be signed in to change notification settings - Fork 0
/
202Easy.rb
19 lines (15 loc) · 854 Bytes
/
202Easy.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Challenge #202 [Easy]: I AM BENDER (2015-02-16)
# from reddit.com/r/dailyprogrammer
# Run instructions for windows:
# ruby 202Easy.rb (binary)
# or
# ruby 202Easy.rb e (text)
# Test cases:
# 010010000110010101101100011011000110111100100 0000101011101101111011100100110110001100100
#
# 011100000110110001100101011000 010111001101100101001000000111 010001100001011011000110101100 100000011101000110111100100000 0110110101100101
#
# 011011000110100101100110011001 010010000001110010011010010110 011101101000011101000010000001 101110011011110111011100100000 011010010111001100100000011011
# 000110111101101110011001010110 110001111001
# Just for fun, I added functionality for the reverse! To use it just add 'e' on the command line (see above)
p ARGV[0] != 'e' ? ARGV.join.scan(/.{8}/).map { |d| d.to_i(2).chr }.join : ARGV.join(" ").unpack("B*")[0]