Skip to content

Instantly share code, notes, and snippets.

@xntrik
Created August 16, 2012 03:16
Show Gist options
  • Save xntrik/3366173 to your computer and use it in GitHub Desktop.
Save xntrik/3366173 to your computer and use it in GitHub Desktop.
Working with Hex in Ruby
#!/usr/bin/env ruby
start = ARGV[0].to_s.hex
len = ARGV[0].to_s.length
count = 0
until count == ARGV[1].to_i
puts "%0#{len.to_s}x" % start
zeros = ""
[0..len-1].each do
zeros += "0"
end
zeros += "1"
start -= zeros.hex
count += 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment