Church Numerals in ski

Submit

Your name:
File:
Open code-statistics:

Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.

Problem

Convert from Church numerals in unlambda style SKI combinators to decimal.

` = apply
s = \xyz.xz(yz)
k = \xy.x
i = \x.x

0 = \fx.x
1 = \fx.fx
2 = \fx.f(fx)
3 = \fx.f(f(f(x)))
...

See also:
http://en.wikipedia.org/wiki/Church_encoding
http://esoteric.sange.fi/essie2/download/lazy-k/

Test cases generated using lazier from lazy-k. Sorry for the large number of test cases, might make it hard for slow languages to compute in time (takes about 0.4 seconds each in ruby using a naive approach), but needed to stop embedded solutions.

Options

exec is denied

now post-mortem time, all source codes will be revealed

Sample input:_

``s``s`ksk``s`k``s``s`kski``s``s`ksk```s``siii``s``s`kski
``s``s`ksk```s``siii``s``s`kski
```sii``s``s`kski
``s``s`ksk``s`k``s``s`kski``s``s`ksk```sii``s``s`kski
```s``s`kski``s`k``s``s`kski``s``s`ksk``s``s`kski
``s`k``s``s`kski``s``s`ksk``s``s`kski
```s``s`kski``s``s`ksk``s``s`kski
``s``s`kski
i
````s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski`s``s`ksk```s``siii``s``s`kski
```s``s`kski``s``s`ksk```sii``s``s`kski
`ki
``s``s`ksk```s``s`kski``s`k``s``s`kski``s``s`ksk``s``s`kski
``s``s`ksk``s``s`ksk``s``s`ksk```sii``s``s`ksk``s``s`kski
```s``siii``s``s`kski
``s``s`ksk``s``s`ksk``s``s`ksk```s``siii``s``s`kski
```s``s`ksk``s``s`kski``s``s`kski
``s`k``s``s`kski``s``s`ksk```s``siii``s``s`kski
``s`k```sii``s``s`kski``s``s`ksk```sii``s``s`kski
``s``s`ksk```sii``s``s`ksk``s``s`kski
``s``s`ksk```sii``s``s`kski
``s`k```sii``s``s`kski``s`k``s``s`kski``s``s`ksk``s``s`kski
`````sii``s``s`kski`s``s`ksk```sii``s``s`ksk``s``s`kski
``s``s`ksk``s`k``s``s`ksk``s``s`kski```sii``s``s`kski
``s`k``s``s`kski``s``s`ksk``s``s`ksk``s``s`ksk```s``siii``s``s`kski
``s``s`ksk```s``s`kski``s``s`ksk```sii``s``s`kski
``s`k``s``s`kski``s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski
``s`k``s``s`kski``s``s`ksk``s`k``s``s`kski``s``s`ksk```sii``s``s`kski
````s``s`ksk```sii``s``s`kski`s``s`ksk```s``siii``s``s`kski
``s``s`ksk``s``s`ksk```s``siii``s``s`kski
``s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`ksk``s``s`ksk```s``siii``s``s`kski
``s`k``s``s`ksk``s``s`kski```sii``s``s`kski
``s`k``s``s`ksk```sii``s``s`kski```s``s`ksk``s``s`kski``s``s`kski
``s``s`ksk``s`k``s``s`kski```s``siii``s``s`kski
``s`k``s``s`ksk``s``s`kski``s``s`ksk```sii``s``s`kski
```sii``s``s`ksk``s``s`kski
``s``s`ksk``s``s`kski
``s``s`ksk``s``s`ksk```sii``s``s`ksk``s``s`kski
``s`k``s``s`kski```s``siii``s``s`kski
``s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski
``s`k``s``s`kski``s``s`ksk```sii``s``s`kski

Sample output:

35
17
4
11
36
6
9
2
1
23
25
0
37
30
16
19
8
34
20
28
5
24
31
13
38
26
14
22
21
18
39
12
40
33
15
27
3
29
32
7
10

Sample input:_

``s``s`ksk``s``s`ksk``s``s`ksk``s``s`kski
```sii```sii``s``s`kski
``s`k``s``s`ksk``s``s`kski``s`k``s``s`kski```s`s``s`ksk``sii``s``s`kski
``s``s`ks``s``s`ks``s`kk``s`k```s`s``s`ksk``sii``s``s`kski``s`k`s`k`si``s`k`s`kk``s`k`sik`kk`k`ki
`````s``s`ksk```sii``s``s`kski``si`k``s``s`ks``s`k`s`k``s``s`ks``s`kk``s`ks``s`k`sik`kk``s`k`s``s`kskk`k`s``s`ksk``s``si`ki`kik
`````s``s`kski```s``s`ksk``s``s`kski``si`k``s``s`ks``s`k`s`k``s``s`ks``s`kk``s`ks``s`k`sik`kk``s`k`s``si`k`s``s`kskk`k`s``s`ksk``s``si`k`ki`kik
```````kkkkkkki
``s`k`ki``s``s`ksk```sii``s``s`kski
`````s``s`kski```s``s`ksk``s``s`kski``si`k``s``s`ks``s`k`s`k``s``s`ks``s`kk``s`ks``s`k`sik`kk``s`k`s``s``s``s`kski`k`s``s`kskk`k`s``s`ksk``s``si`k`ki`kik
``````s``s`ksk``s``s`kski``s``s`kski``si`k``s``s`ks``s`k`s`k``s``s`ks``s`kk``s`ks``s`k`sik`kk``s`k`s``si`k`s``s`kskkk``s``si`ki`kik
``s`k`ki````s``s`ksk``s``s`kski`s``s`ksk``s``s`ksk``s``s`kski
``s``s`ksk````s``s`kski`s``s`ksk``s``s`kski
``s`k``s``s`kski````s``s`ksk``s``s`kski`s``s`ksk`ki
``s`k``s``s`kski``s``s`ksk`ki
``s`k``s``s`ksk``s``s`kski````s``s`kski`s``s`kski
````s``s`ksk``s``s`kski`s``s`ksk``s``s`kski
``s`k``s``s`ksk``s``s`kski``s`k``s``s`kski`ki
``s`ki``s`kii
``s`k`ki````s``s`kski`s``s`ksk``s``s`kski
``s`ki````s``s`kski`s``s`kski

Sample output:

5
256
384
63
120
21
0
0
91
55
0
5
6
2
9
5
0
1
0
3

Sample input:_

`````s``s`kski``s``s`ksk``s``s`kski`s``s`ksk``s`k``s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski``s``s`ksk```sii``s``s`kski
`````s``s`kski``s``s`ksk``s``s`kski`s``s`ksk````s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski`s``s`ksk```s``s`kski``s``s`ksk``s``s`kski
``s`k``s`k``s``s`kski``s``s`ksk``s``s`kski``s`kii
````s``s`ksk``s``s`kski`s``s`ksk```s``s`kski``s``s`ksk``s``s`kski
````s``s`kski```s``s`ksk``s``s`kski`s``s`ksk````s``s`ksk```sii``s``s`kski`s``s`ksk``s``s`kski
````s``s`kski`s``s`ksk````s``s`kski`s``s`ksk```s``s`ksk``s``s`kski``s``s`kski
````s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski`s``s`ksk``s`k```s``s`kski``s``s`ksk``s``s`kski`ki
``s`k```sii``s``s`kski`````sii``s``s`kski`s``s`ksk``s``s`kski
``s`k```s``s`kski``s``s`ksk``s``s`kski````s``s`ksk``s``s`kski`s``s`ksk``s``s`kski
``s`ki````s``s`ksk```sii``s``s`kski`s``s`ksk``s``s`ksk``s``s`kski
````s``s`ksk```sii``s``s`kski`s``s`ksk``s`k```s``s`kski``s``s`ksk``s``s`kski``s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski
``s`k``s``s`ksk```sii``s``s`kski``s`k```s``s`ksk``s``s`kski``s``s`kski``s``s`kski
``s`k``s``s`kski``s`k```s``s`kski``s``s`ksk``s``s`kski``s`k``s``s`kski``s``s`ksk``s``s`kski
``s`k```s``s`ksk``s``s`kski``s``s`kski````s``s`kski`s``s`kski
``s`k``s``s`ksk``s``s`kski`````sii``s``s`kski`s``s`ksk```sii``s``s`kski
`````sii``s``s`kski`s``s`ksk``s`k`ki``s``s`ksk``s``s`kski
````s``s`kski`s``s`ksk``s`k``s``s`ksk```sii``s``s`kskii
````s``s`kski```s``s`ksk``s``s`kski`s``s`ksk``s``s`ksk``s``s`kski
``s`k```sii``s``s`kski``s``s`ksk``s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski
``s``s`ksk``s`k```s``s`ksk``s``s`kski``s``s`kski``s``s`ksk```sii``s``s`kski
`````s``s`ksk``s``s`kski``s``s`kski`s``s`ksk`````s``s`kski``s``s`ksk``s``s`kski`s``s`ksk`ki
``s`k``s``s`ksk```sii``s``s`kski````s``s`ksk```sii``s``s`kski`s``s`ksk`ki
``s`k```s``s`kski``s``s`ksk``s``s`kski``s`k```sii``s``s`kski``s``s`ksk``s``s`kski
````s``s`kski```s``s`ksk``s``s`kski`s``s`ksk`ki
``s`k`ki````s``s`ksk```sii``s``s`kski`s``s`ksk```s``s`ksk``s``s`kski``s``s`kski
``s`k```s``s`kski``s``s`ksk``s``s`kski`````s``s`ksk``s``s`kski``s``s`kski`s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski
``s`k``s``s`ksk```sii``s``s`kski``s`k``s``s`ksk```sii``s``s`kski```sii``s``s`kski
``s`ki``s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski
``s`ki````s``s`ksk``s``s`kski`s``s`ksk```sii``s``s`kski
`````s``s`kski``s``s`ksk``s``s`kski`s``s`ksk````s``s`kski```s``s`ksk``s``s`kski`s``s`ksk``s``s`ksk``s``s`kski
````s``s`kski`s``s`ksk````s``s`ksk``s``s`kski`s``s`ksk``s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski
``s`k```s``s`kski``s``s`ksk``s``s`kski``s``s`ksk``s`k``s``s`kski``s``s`ksk``s`k``s``s`kski```sii``s``s`ksk``s``s`kski
`````s``s`kski``s``s`ksk``s``s`kski`s``s`ksk````s``s`kski```s``s`ksk``s``s`kski`s``s`ksk``s``s`ksk```sii``s``s`kski
``s`k``s``s`ksk``s``s`kski``s``s`ksk`ki
``s`k``s`k``s``s`kski``s``s`ksk``s``s`kski``s`k```s``s`kski``s``s`ksk``s``s`kski```s``s`ksk``s``s`kski``s``s`kski
``s`k`ki``s`k``s``s`ksk``s`k``s``s`kski``s``s`ksk``s``s`kski```s``s`kski``s``s`ksk``s``s`kski
````s``s`ksk``s``s`kski`s``s`ksk````s``s`ksk``s``s`kski`s``s`ksk```s``s`kski``s``s`ksk``s``s`kski
````s``s`kski```s``s`ksk``s``s`kski`s``s`ksk``s`k``s``s`ksk```sii``s``s`kski```s``s`kski``s``s`ksk``s``s`kski
````s``s`kski`s``s`ksk`````sii``s``s`kski`s``s`ksk```sii``s``s`kski
``s``s`ksk``s`k```sii``s``s`kskii
``s`k``s`k``s``s`kski``s``s`ksk``s``s`kski`````s``s`kski``s``s`ksk``s``s`kski`s``s`kski

Sample output:

44
25
6
12
13
12
7
24
45
8
68
80
108
24
24
4
7
9
32
41
17
25
108
6
0
126
100
7
7
18
12
999
20
3
432
0
15
51
10
5
60

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1ksk1051.12812008/11/13 21:23:410B / 48B / 52B
2irori1161.92442008/11/13 23:36:540B / 54B / 55B
3flagitious1211.95202008/10/31 08:45:480B / 59B / 54B
4leonid1271.14632008/11/14 02:20:080B / 46B / 71B
5kaki1461.18752008/11/13 00:00:460B / 69B / 65B
6shinh1821.17902008/11/09 15:13:170B / 70B / 98B
7leonid1041.20352008/11/14 06:31:440B / 50B / 49B

Python _

RankUserSizeTimeDateStatistics
1Defenestrator1680.55532008/10/31 10:02:570B / 85B / 77B
2irie1570.74482009/11/11 00:29:110B / ?B / ?B

Scheme _

RankUserSizeTimeDateStatistics
1kaki2060.32582008/11/13 13:42:030B / 90B / 100B
2kaki1800.32672011/06/12 05:26:250B / 73B / 93B

Common LISP _

RankUserSizeTimeDateStatistics
1kozima1810.55812008/11/07 20:17:180B / 82B / 94B

C _

RankUserSizeTimeDateStatistics
1hinoe2470.03502008/11/03 20:45:280B / 107B / 140B
251b4160.09692008/11/09 01:24:550B / 182B / 234B

OCaml _

RankUserSizeTimeDateStatistics
1ksk1750.34912008/11/05 13:25:120B / 96B / 62B
2kozima1940.23212008/11/10 14:07:230B / 106B / 67B

Haskell _

RankUserSizeTimeDateStatistics
1hinoe1970.06512008/11/08 07:09:080B / 90B / 91B
2Defenestrator2270.26382008/11/11 11:19:420B / 110B / 83B
3hinoe1570.04112011/05/17 22:39:190B / 90B / 54B
4hinoe(rst76)1720.00692011/04/22 21:37:430B / 81B / 74B
5notogawa1840.46742008/11/18 20:50:230B / 82B / 91B
6rst761840.00612010/05/17 12:58:470B / 86B / 80B

wake _

RankUserSizeTimeDateStatistics
1hinoe2271.56022010/10/09 00:49:210B / 52B / 163B

Postscript _

RankUserSizeTimeDateStatistics
1yshl(bin)1621.23432008/11/09 01:38:2965B / 40B / 57B
2yshl2821.58102008/11/09 01:38:150B / 198B / 51B

Unlambda _

RankUserSizeTimeDateStatistics
1irori5510.43292008/11/04 23:51:350B / 267B / 284B

Universal Lambda _

RankUserSizeTimeDateStatistics
1hinoe1321.68252009/03/23 00:40:51100B / 11B / 18B

Language Ranking_

RankLangUserSizeScore
1Rubyleonid10410000
2Universal Lambdahinoe1327878
3Pythonirie1576624
4Haskellhinoe1576624
5Postscriptyshl(bin)1626419
6OCamlksk1755942
7Schemekaki1805777
8Common LISPkozima1815745
9wakehinoe2274581
10Chinoe2474210
11Unlambdairori5511887

return top