Created
August 30, 2017 07:54
-
-
Save akouryy/3c5185465fe7fdd088e8f533f13fa690 to your computer and use it in GitHub Desktop.
This file contains 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
{M[m | |
a A! s S! i I! o O! # staticっぽいメソッドもインスタンスを介して呼び出す必要があるのでインスタンスを作成 | |
N <50> = | |
/N | |
<0> <-1> # スタック: 上←[-1,0]→下 | |
N N* 2 aa.? = # 「2」というのはスタック([N*,N,-1,0])の上から2番目に積まれている<-1>のこと | |
1 # 1は<0> | |
J <8> = | |
/J | |
J J* 3 aa.? = # 3は<-1> | |
0 aa.? ic.? s(sn).? <48> as.? aa.? | |
# スタックの先頭にある b を b+b+(入力の文字コード-48) にする | |
\ | |
B 1 = , # 1は入力の値 | |
ic.?, | |
J <23> = | |
/J | |
J* 1 aa.? # 1は<-1>。スタック: [J-1,-1,0] | |
0 J* am.? <2> ad.? # 0は<J-1>。スタック: [J*(J-1)/2,J-1,-1,0] | |
E B* 2 ae.? = # 2:J*(J-1)/2 | |
/E | |
"1" oo.? | |
B 3 = # 3は<-1>。 | |
E 4 = # 4は<0>。繰り返しを1回で止める。 | |
\ | |
E B* 2 a(gt).? = | |
/E | |
"0" oo.? | |
B 3 = | |
E 4 = | |
\ | |
J 2 = # 2は<J-1>。 | |
,, # スタック: [-1,0] | |
\ | |
\ | |
]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment