Skip to content

Instantly share code, notes, and snippets.

@jubishop
Created June 16, 2019 20:38
Show Gist options
  • Save jubishop/01b853e8e017e704d33280dc22a112c5 to your computer and use it in GitHub Desktop.
Save jubishop/01b853e8e017e704d33280dc22a112c5 to your computer and use it in GitHub Desktop.
class Integer
BASE = 95
def convert_to_string
num = self
answer = ""
while (num > 0)
num -= 1
digit = num % BASE
num /= BASE
answer = digit_to_char(digit) + answer
end
return answer
end
private
def digit_to_char(digit)
(digit + 32).chr
end
end
1000.upto(3000) { |x| puts x.convert_to_string }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment