Created
June 16, 2019 20:38
-
-
Save jubishop/01b853e8e017e704d33280dc22a112c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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