Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created October 14, 2008 10:30
Show Gist options
  • Save hitode909/16697 to your computer and use it in GitHub Desktop.
Save hitode909/16697 to your computer and use it in GitHub Desktop.
#! /usr/bin/ruby
def parse(string)
string.each_line do |line|
list = line.split(" ")
print "#{list.first}: "
list[1..-1].each do |token|
raise "input's size should 2(#{token})" if token.size != 2
token.split("").each do |char|
num = char.chomp.hex.to_s(2)
print "#{'0'*(4-num.size%4) if num.size%4 != 0}#{num}"
end
print " "
end
puts
end
end
parse(ARGF.read)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment