Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,2 @@
say 60272032366.base(36) # convert number to string
say Number("rosetta", 36) # convert string to number

View file

@ -0,0 +1,20 @@
static to = [@|'0'..'9', @|'a'..'z']
static from = Hash(to.pairs.map{@|_}.flip...)
func base_to(n, b) {
var s = ""
while (n) {
s += to[n % b]
n //= b
}
s.reverse
}
func base_from(n, b) {
var t = 0
n.each { |c| t = (b*t + from{c}) }
t
}
say base_from("rosetta", 36) # string to number
say base_to(60272032366, 36) # number to string