知っている方は知っている問題

Groovyで解いてみた。

answer.groovy

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env groovy
def code = args[0]
def parts = []
def life = 0
code.chars.each {
    if (life == 0) {
        parts << ""
        life = Integer.parseInt(it as String, 16)
    } else {
        parts[-1] += it
        life--
    }
}
parts.each {
    def mod = (it.toLong() % 26).toInteger()
    print(("a".."z")[mod])
}
println()

実行

1
2
$ ./answer.groovy 500001
b