Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 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