-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
6,373 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
BEGIN | ||
on logical file end(stand in, (REF FILE f)BOOL: finished); | ||
INT x := 0, buf, acc := 0; | ||
REF INT last := x; | ||
DO | ||
read((x)); | ||
IF x > last THEN acc +:= 1 FI; | ||
REF INT(last := buf) := x | ||
OD; | ||
finished: | ||
print((acc, new line)) | ||
END |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
BEGIN | ||
on logical file end(stand in, (REF FILE f)BOOL: finished); | ||
[3]INT window := (0,0,0); | ||
REF INT a = window[1]; | ||
REF INT b = window[2]; | ||
REF INT c = window[3]; | ||
read(window); | ||
INT acc := 0; | ||
DO | ||
INT d := 0; | ||
read((d)); | ||
IF a + b + c < b + c + d THEN acc +:= 1 FI; | ||
window := (b, c, d) | ||
OD; | ||
finished: | ||
print((acc, new line)) | ||
END |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<<{(({<{[<[{<<<><>>{[]()}>[[{}<>]{[]{}}]}<<<{}<>>[(){})>[[<>{}]]>]>]<{((((<>{})([]{}))[[<> | ||
[({[(<[{<(({({[]<>}){({})<{}[]>}}{[{[]<>}{()[]}]((<>[]))})[({{{}()}([]{})}[[[][]]{{}<>}]){[({}<>)<[][]>]{[[ | ||
{<<[<<<<[[<[<<()><[]{}>>([<><>])][<[[]()]({})>{<<><>><<>()>}]>]<<{{<[]<>><<>>>(<{}[]>[[]<>])}{<(()<>)<{}()> | ||
[({{{[((<[[{<(()<>){<>()}>}[[({}{})<(){}>]<([]{})>]]]((<((<>())<[]{}>)<<<>>[[][]]>>{[[<>{}][( | ||
[{<([{[([<[{[<()[]>{[]{}}](<{}<>>(()[]))}({(<>())[()()]}{[{}<>]{<><>}})]({(([]{}){{}<>})})>[{([{[ | ||
<({[[[({[[[{({{}[]}<[]{}>){{{}[]}[[]()]}}<(<{}[]>[{}<>])(<()<>>[[]{}])>]{(<{{}<>}[<><>]>((<>())({}[])))<<<() | ||
<((<([{([{<<<[()()]<{}[]>><([]<>)([]<>)>>(({[]()}<{}[]>)(<()[]>(()())))><[<[<>{}](<>[])>(<{}<>>{[]{}})]>} | ||
(<(({{[<<[[((<{}[]>(<>{}))(<<>()>({}<>)))[<([]{})<{}[]>><{[]<>}>]](<<([]<>)[[]]>({()[]}[<>])>{([ | ||
<<((<<{[[(<{{[<>[]}([]{})}({[]<>}[()[]])}{[({}{}){[]<>}]<<()<>>{<><>}>}>{({{{}()}<[]<>>}<(<>[]){ | ||
({([(([({[((((()<>){[]<>>))[<{[]{}}[[][]]>[(<>{})<{}<>>]])([{[{}<>]}<(()<>){[]{}}>]<[{[]<>}<[]>]<{( | ||
([{{({(([[[<{[()()]{{}()}}{{()<>}<{}()>}><((<><>)<()[]>)<[<><>][[]<>]>>]<{<([][])({}<>)><{<>[]}{<>}>}{(<{}{ | ||
{{([{[(<[[<{<{[][]}(())>([(){}]{[]<>})}[([[]{}]{[]{}}){(<>())<[]{}>}]>{{<[()[]]{{}{}}>}[(([]<>)<[]<>})]}] | ||
[({{<([([[{([{<>[]}]<<()[]>>){[<(){}>[[]<>]][{{}<>}<<><>>]}}]<[[<[<>{}](<>{})>{{<>{}}<<>()>}]] | ||
<(<<((<<{[{((({}[])[<>{}])[{()()}{[]<>}])}]}>[{{<[<[()()][[]{}]>[([]())<<>[]>]]{([[][]][{}()])(([]<>)( | ||
<<[({{([([({[{()[]}[<><>]]{[<><>]({}<>)}})([<(<>())><{{}()}>][{<<>><[]()>}<({}{})({}<>)>])] | ||
[[<((<[<{<<<(<{}()>{[][]}){<[]<>>({}{})}><<[(){}]{{}{}}>>>>}([{{{{()()}}}<([<>[]]<<>>]<{(){}}> | ||
{<[[[(<<([{{[[{}[]>]}}])[[{<<<()<>>({}{})>(<{}{}><<>()>)>}]{[([(()[])[[][]]]<<<>{}><[]<>>>)<<{(){}}< | ||
([[<<((<[(([<{()<>}<{}[]>><(()[])>]([<(){}><{}{}>](<<>[]><[][]>)))<{<(()[])>({<>{}})}{((()[]){[]{} | ||
{<[([(<({(<(({{}[]}([]<>})(([]<>)[{}{}]))<(<<>[]><{}<>>)<({}{}){<><>}>>>)(<({((){})[{}{}]}<<<>()>[[] | ||
{<[({(<{[[[[[<()<>>[[][]]]{[{}<>]{[]<>}}][([()[]]<()[]>)[<[][]>]]]](<({(()())[<><>]}<{<>}({}<>) | ||
(<([[[[[(((<[{{}{}}{(){}})>))(({<<(){}>[{}()]>}<[(<>{})]([{}{}]<[]>)>)([{[{}()]<{}<>>}][<{<>{}}(<>{ | ||
{((<[(([{{[<<<[]{}>{()<>}>>({[{}<>]<{}<>>}(<<>[]><[]<>>))][[[[[][]]{{}()}][<[][]>]]]}<(<<{ | ||
<{[<{<<{<(((((<>[]][[][]]){[<><>]})(<([][])>)))([([{<>}(()[])]{(()<>)(()<>)}){{[{}{}]}}])>}>{[<< | ||
<{((<<<[({[{[(()<>)((){})]}[{[<>{}]{{}{}}}(<{}()>(()<>))]]}(<{[[<>[]]](<()()><<>()>)})({<<[][]>[[] | ||
(<[(<{(<[({[(<(){}>([][]))<(()())[<>{}]>]{<{()<>}<(){}>><{{}{}}({})>)}<<{{{}[]}(())}[({}())< | ||
[{{[[{{<<([[([[][]](<><>))<{<>[]}<()[]>>]][<[[<>[]](<><>)]{[[]()]<{}()>}>[<([]{}}<{}()>>{(()()){<>()}}]] | ||
[(<(<{{{[([(<{{}{}}<{}{}>>[[<>[]][(){}]])<(({}())[{}{}]>((()[])([]()))>])[(<{<{}{}>}>{{([][])([][] | ||
[(<<{<(<(<(<<[()()]({}{}}>{([]{})[()<>]}>)>)><{({{(<<>[]>){(()[])({}())}}((<{}[]>{<>[]})([()<>][< | ||
{{<<[(<{<{{([((){})[[]<>]]{([]{})([]()}})<[<{}<>>([]())]{<[]()>{{}[]}}>}{<{<[]{}>{()[]}}(<{}[]>[[]{}])> | ||
<{[[{[({<[(({(<>{})[()[]]}{[()[]]<[]()>}))(([(<>[])<()()>])({<()[]>(()[])}))]<[[{{[]}(<>{})}[[()[]){[]< | ||
(((([<{(({<<[{{}()}][{{}{}}<<><>>]>>((([<><>]<<>{}>)[(()())[<>[]]]))}{[<({()[]}[()[]])<([]())<{ | ||
(<<{[({[<((<[([]<>){(){}}]{<()()>[(){}]}>(<[{}[]][()<>]>{([][]){[][]}})){{{<()[]><<>()>}(({}<>)<[]{}> | ||
<{[[[{[<({[{((()<>)(<>[]})<{()[]}{()<>}>}[{<<>()>[{}[]]}<[()()][[][]]>]]}{<[<{<>()}<[]<>>><[()[ | ||
([[{<{[{{{{(<<<>()>>[(())<[]>]){[[{})]<({}()){<>[]}>}}((<[<>]<{}()>>{[()()]<()()>}))}{[[{{{}<> | ||
[(<({<{{<[{<[[<>{}]({}())]]}]{({{[<><>](()())}([{}])}[[<<>()>({}<>)]<[<>][[]()]>])[{[[()[]][<>]]}[ | ||
{([{<[<[{[(<<{<><>}[<>()]>(((){})(()()))>[<<{}()>[<>{})>]){<<<[]<>>[[]<>]>{{<>{}}{(){}}}>([[()()][{}[]]](< | ||
{{(([<{[{<({<({})[[]<>]>([[]]<{}{}>)}([[()()]<{}{}>])){{{{[]<>}<[]<>>}<(<>())<<>()>>}}>}]} | ||
(<[{{<({{(<([[[]<>]]{{{}()}([]<>)})<(([][]))>>{[{{(){}}<[][]>}[[()]<()()>]](({[]{}}(<>())))})( | ||
({{[{{[{({[(<(<>{})<(){}>><<[]{}>[[][]]>)[((()[])(()<>))]]<([[(){}]{[]<>}]<<()[]>([]<>)>)>}[{[{[()<>]}<< | ||
(<[<<<([{{{[<([][])<(){}>>{<<><>>(<><>)}]{((()<>)<{}{}>)[{<><>}<[]<>>]}}}(([<{{}{}}{<><>}>]{{[{}() | ||
({[[((([[<<([{(){}}(<><>)](<{}{}>{[]{}}))(<<[]()>([])>([[]{}]({}{})))><{{[[][]]{[][]}}({()[]})}{(([]<> | ||
({<<({<[[[[[{<()<>>}({<>()}[<>[]])]]]<{{[[{}()](()())]}({([]())})}>]<({<<{(){}}<{}{})>((()[ | ||
((<{[<{<{<[[[<[][]>{{}()}]][({<><>}{()[]})<<[]()>(()<>)>]][[(<{}{}>({}))(({}<>){[]()})][[{()[]}(()[])]{(<> | ||
<<<[(<{<{<(<<[<><>](()[])>([[]<>]<[]{}>)>)((<{<>{}}[{}<>]>[{{}()}(()<>)])[{(<>{}){()()}}])><({{{< | ||
<<<{[([[(({<<{<>{}}>[<<><>>(<><>)]><([[]()][{}<>])<[{}{}]>>})<<<[[{}<>](<>())><(()[]){<>()}>>([( | ||
[{{[(<<({[{{(([]{}))[[{}()]<[]{}>]})(([{[]{}}<{}[]>]<<()[]>>)<({(){}}[[]()])<{<>()}[[]<>]>>)]} | ||
(<[[[<[<{[[[{{()<>}[{}<>]}[(<><>)<<>{}>]]]<<[(()<>)<[]{}>]{{{}<>}(()())}><<{[]<>}[[]{}]><{<>{}}{<>{}}>>>][ | ||
(((({<(<[{<{<(<>{})(<><>)>{(<>[])[()[]>}}[[(<>[])({})](<{}[]><{}()>)]>(<<[[]<>]({}())>(({}{})<{}{}>)> | ||
{(([<[[<({<[{({}())<<>()>}{[{}()]<()[]>}]>(([{(){}}{()[]}])(<[[]{}][{}()]>[({}{})<{}{}>])}}(<([{()[] | ||
[{<{{({({{<({<<>[]>[()()]>[{[]{}}([]{})])([(<>())[[][]]]([{}()](()<>)))>(<({<>[]}{<>{}})>([(()[])]))}} | ||
{{({({[{([[{[[()[]][[]{}]][{[]<>}(<>{})]}{{[()()][[]()]}[<<>[]>((){})]}]])}]}<{[[{[((<{}{}>[(){}] | ||
[{[({[[(<<{{[(()<>){{}()}]}<([{}])({{}{}}{<>()})>}<[[[{}[]]<<>{}>][[{}[]]([]())]]>>((<({(){}}<[]>){<{}()> | ||
[([[<<[{[(([[{<>{}}]]}){(([{<>[]}])[([(){}]{<>[]})({{}{}}[(){}])])}]}]({<[{<{[(){}]<()()>}([< | ||
{[[[({[[{<({{({}[]]}<(()<>)>}[([[][]])({{}{}}[[]()])])><([{<<>[]><{}<>>}(({}<>))][({<>}({}<>))])(<{([][])[()[ | ||
([{<{{<(<[{<[(()[]){{}()}]{(()())[<><>]}>}(<<<()<>>{<><>}>[(()[]){()<>}]>[{{()()}<[][]>}])]>)(<<[ | ||
[<(<({[[[{({([<>[]]<()<>>)[{[]()}]})<[[[[]<>]<{}<>>]([()[]){[]()})]{([{}<>][<>[]])[{()()}([ | ||
([<[{[(<[{[(([<>[]]<<>[]>))][({(<>())({}<>)}<<()()>[{}()]>][[([][]){<>()}]({[]{}}<{}[]>)]]} | ||
[(((<[{<{{([[[{}]<()<>>]<{()<>}([][])>]){(<{{}()}{{}{}}>(<<>{}>{{}<>})){{([][]}{{}<>}}[[[][]][[]<>]]}}} | ||
[<[{([(<(<<{<(<>{})<{}<>>>{(<>)({}[])}}><([(<>()}[<>{}]][<{}{}>[<>[]]])[{([][])<[][]>}[({}<>)({}())] | ||
[[<<([[{[{[<((<><>){{}<>})>(<({}<>)[()()]>[{(){}}])][[((<>{})<[]()>)(({}())({}<>))]<{<{}{} | ||
({<(({<[([{(({()<>}[[]<>])<(<><>)>)}[{[<<>()>]<({}<>)[[]{}>>}(<<{}{}>[()()]>)]])(<({({{}<>})([[]<>](<>[] | ||
<{{{({{{{{[([([]{})({}[])]{{[]()}<(){}>})]}[[<<{[]()}<[]<>>><<{}()>((){})>>](<{{{}[]}<<>>}< | ||
((([<{<<(<<({[<><>]{{}{}}}[{()()}{[]}])(({()()}[{}<>])[({}())<()[]>])>([<<[]{}>{{}[]}>{[<>[]](()) | ||
((<(<[(<[[[({(<><>)[{}()]}{<(){}><{}()>})<<<[][]>{<>{}}><{{}[]}<()[]>>>]<[[[{}][[]{}]][({}{})((){})]] | ||
[<<{[<<[{{[{<[()<>]>(<{}{}>(<><>))}<<((){})<(){}>>>]}[{(<[{}[]][{}[]]>((()<>)([]()))){{<(){}> | ||
<{[<[{<{<{({<[{}()][[][]]>[{()<>}{[][]}]}<[([]<>)]>>}>[([{{<[]()><()[]>}{[<>{}]{[][]}}}(<[[]<>] | ||
{<[<[(([<<({[({}())([]{})][{{}}{[]{}}]}[[<[][]>[{}[]]][[<>()]]])[[[<(){}>{()<>}]((<>{}){()[]})]]>>]{[{ | ||
{{[{<[[{([({[[<>[]]{[]()}][[<>()](()[])]}[[(<><>)[()<>]]<([]<>)<{}>>])]<(<{{[]<>}}>[{[{}{}]< | ||
[{{{(({(<[{(<{<>[]}<[]<>>>)}([<[<>()]<<>[]>>{<()<>>(<>{})}]<<(<><>){(){}}]{[[]<>]{<><>}}>)]>)<{[ | ||
[[[(({<{(<<{{<<>><<>{}>}[((){})<{}[]>]}{([[]{}]<<><>>)[(<>{})]}>>[<{<{{}{}}[{}[]]>{<[]>[() | ||
((<(({<[<[[(((<><>){{}{}})[{()[]}[{}<>]])({([][])<{}()>}<{{}()}({}[])>)]][{<({()()}{<><>})>([({}[])<<> | ||
{{<{[([<({<[((()())<[]()>)<({}[])({}{}}>]<{({}{})<<>>}(([]{})[{}{}])>>[<[<()<>>]>((<<>{}>{() | ||
<[{[[[<{[[<{[{<>()}][<(){}>[{}{}]]}((<[]{}>({}[])){(<>{})})>]]}>(((([<({()<>}<()>)[{{}()}<{ | ||
[(<{[[(({({<<[(){}]{[][]}><{[]{}}([][])>>({<{}()>{<>{}}}({{}<>}<{}<>>))})<{<<({}[])>{([]())[{}{}]}>[{ | ||
[<<{{<<<[(<[(([][])[<>[]])][<[()[]]<[][]>>]>)]{[<[{{[][])({}[])}<<<>()>(<>[])>](((<>{})<<>{}>)((<>[]) | ||
<<{<[{((<[([{<{}()><{}{}>}{[{}{}]({}())}]{{{<>[]}<{}[]>}<<<>[]>{[]<>}>})][{[{{()[]}{()()}}({<>{}}<{} | ||
[(<{{[{[<{<[[{()<>}(())][{{}[]}{[]<>}]][((<><>)(<>()))(<(){}>)]>(<({[]<>}(<>()))((()<>)<[]>)>{<[{ | ||
<[(((([[{{[[({()()}((){}))]<<([]<>)[<>{}]>([{}{}]<<>{}>)>][{<[{}[]][[][]]>[<{}>[[]{}]]}{([ | ||
{{(({[[({[<([{<><>}[[][]]]{[<>{}](<>())})>({(<{}()>(<><>))((()())[{}[]])}<<<()><{}()>>>)]}<<(([[<>{}]{[]< | ||
({([[<[{<{[[{{[]<>}({}{})}{<[]()>{()<>}}]]}([{<[[]()]{[]{}}>{[()<>]<(){}>}}])>}[(<[{<[<><>)><[{}{ | ||
[<[(<({<[<{[<[(){}](<>())>]([<[]<>><[][]>]<[[]<>]{{}{}}>)}>(((((()[])<{}{}>))([<(){}>[[][]]] | ||
<({(<{[(<{([([[]()]{<>()})[({}[])(<><>)]]<({[][]}{[]()})({[][]}(<>{}))>)}>([([<(<><>)<[]()>>{[{}<>]{<> | ||
(<<<[((<{[(({({}())<{}()>}{{{}[]}<<>{}>})<((()())[[]()]){[<>{}]}>)[{([{}()]{{}{}})[([]())[(){}]]}]] | ||
[[<<<[(<[{((<[{}<>]{[]{}}><(<><>)([]<>)>)[<({}[])<[]()>>(<<>[]><{}[]>)]}[<<[[]{}][{}[]]>(([][ | ||
{<[[((({[[[(<[()[]][[][]]>(<[]()>({}())))]<{{[{}<>]<<>{}>}{(()<>){()}}}{(({}[]){<>[]}){({}{})<()[]>}}>}][[ | ||
{<{{{{<([([<{{<>()}<(){}>}[{{}}([]<>)]>[{({}())(()[])}]]<{<(<>())[{}[]]}{((){}){[]{}}}}(((<>)<[]()>)< | ||
{<{{{{{({{({([[]<>])[<()<>>>})<({[[]()][{}[]]}({[]<>}[{}()]))[<<{}()><<><>>>{[()<>]{()}}]>}})}<[({<(<{[]()}{ | ||
(<{[[{{<[[<(({[]()}<[]>)<[{}()]([]{})>)(<([][])(()<>)>[[()()][()()]])>][[{{(())([]<>)}<{[]()}(()<>)>>]( | ||
[[<[{((<{[[(({[]<>}([]())))]{<{<<><>>[{}<>]){{[]()}<<>()>}><{<()()>{[]()}}<{[][]}[[][]]>>}]{<<([< | ||
[[[<(<([(([{((()[])[[]<>]){{<>}{<><>}}}]))])>)>][(({([<([<(<()[]>{<>()})<{[]()}<(){}>>>[<{[]<>}>{{<>{}}<<> | ||
[<(({{(<(<[<{[<>()]([][])}{{{}[]}{{}{})}>[([()<>]([]()))[{[][]}<<>()>]]](({[()<>]{{}<>}}<({}) | ||
(<<<<([{{[{{<{{}()}[<>[]]><{()()}[<><>]>}<[[{}()]{[]<>}]{({}[])({}[])}>}]({<({(){}}{<>()})([{}()][ | ||
({([{(<<[(({((<>())([]<>))[[[]()]<<>[])]}))]{<{{{{{}()}{[]<>}}}(<({}{})[{}[]]>)}>}>[{((<{((){}) | ||
((<[<{<(<[((((<>[])([]{}))[{{}{}}[<>[]]]}{[[[]<>]([]{})]{(<>[])[()()]}})<{{<{}()>[[]<>]}}>]>([{[[<<>{ | ||
<<(<{{<<<({[[([]()){[]}]{<<><>><()()>}][[[(){}]<<><>>]]}[{<[()[]]>{([]<>)}}{({()[]})}])(([{(()[] | ||
<{[(<{[<((<[<([]())<()[]>>[({}<>)[[]{}]]]<(<{}{}>(<>{}))<({}{}){{}()}>>>[({([]())<{}()]})<<[()[]]{ | ||
{<[<[{<{[[{<<<()[]>{()}>{<{}<>>{<>}}>}{[[([]())]{([])]][(<()[]>(()())){[{}{}](()[])}]}]]}>( | ||
{(((<[<<{{[[(<<>{}>(()<>))][({[]{}}<{}<>>)<[<>](<>[])>]]<{([[]]{(){}})((<><>)[{}])}[{({}<>}<{}[]>}{(<>())< | ||
[[[[[<({(<{([{[]<>}[{}[]]][{[]{}}<{}{}>])[([{}[]]<[]()>)<<<>{}>>]}>)})<(({({(([]{}))}(<[<>() | ||
[<{<(([(<<{<(([]<>)[<><>]){<()()>[<>{}]}>}({{({}[])([]<>)}})>><([(<[()()][[]()]><[[]<>]{[][]}>)( | ||
[<(<(<{([<(<{<<><>>{<>()}}((<><>)[{}])>)((({()<>}({}())){([]{})([]{})})(<(<>{})([]())>))><<((<( | ||
[<<[[{[{{<([({(){}}({}()))[[[][]]]])([([[]]({}())){({}())({}{})}]<[[<><>]<<>()>]{[<>{}]{()[]}}>)><({[[()()](( | ||
{([{(([(({({{[(){}]([])}({<>()})}{<[(){}]<<>[]>><{[]<>}[[]()]>})}))<{{[[{[()[]]<<><>>}([[]()]([]()))]]{{<[[ | ||
{((([<[<[{{(((<>()>))[[<()()>]{([][])[{}()]}]}(([{()[]}<<><>>][<[]()>])(({{}{}}((){}))({<>() | ||
{<(<<(<{([{{[[<>()]{{}<>}]<<<>[]>[[]{}]>}{([[][]][<>{}]){[{}()][(){}]}}}]}<{{{[<<>[]>(<>{})][[<><>]]}{ | ||
[<<([{<({([[({{}<>}<<>{}>)((()())<{}()>)]<{(<>{})}([()()]<[][]>)>])}{[[(<<[]{}>(()<>)>{[(){}]([][])})[(( |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
BEGIN | ||
on logical file end(stand in, (REF FILE f)BOOL: done reading); | ||
INT score := 0; | ||
DO | ||
PROC error = (STRING s)STRING: | ||
BEGIN | ||
IF s[1] = ")" THEN score +:= 3 | ||
ELIF s[1] = "]" THEN score +:= 57 | ||
ELIF s[1] = "}" THEN score +:= 1197 | ||
ELIF s[1] = ">" THEN score +:= 25137 | ||
FI; | ||
break | ||
END; | ||
|
||
PROC parse = (STRING s)STRING: | ||
IF (UPB s = 0 | TRUE | NOT char in string(s[1], LOC INT, "<({[")) THEN s ELSE | ||
CHAR close char | ||
= IF s[1] = "{" THEN "}" | ||
ELIF s[1] = "<" THEN ">" | ||
ELIF s[1] = "[" THEN "]" | ||
ELIF s[1] = "(" THEN ")" | ||
FI; | ||
STRING rest = parse(s[2:]); | ||
IF UPB rest = 0 THEN "" | ||
ELIF rest[1] = close char THEN parse(rest[2:]) | ||
ELSE error(rest) | ||
FI | ||
FI; | ||
STRING s; read((s, new line)); | ||
print((s,new line)); | ||
parse(s); | ||
break: | ||
SKIP | ||
OD; | ||
done reading: | ||
print((score, new line)) | ||
END |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
PROC score = (STRING s)LONG INT: | ||
BEGIN | ||
LONG INT acc := 0; | ||
FOR i TO UPB s DO | ||
INT p; | ||
IF char in string(s[i], p, ")]}>") THEN acc := 5*acc + p FI | ||
OD; | ||
acc | ||
END; | ||
|
||
CO more plumbing CO | ||
PROC insert = (REF FLEX[]LONG INT arr, LONG INT value)VOID: | ||
BEGIN | ||
[]LONG INT copy = arr; | ||
arr := LOC [LWB arr:UPB arr+1]LONG INT; | ||
FOR i FROM LWB copy TO UPB copy DO | ||
arr[i] := copy[i] | ||
OD; | ||
arr[UPB arr] := value; | ||
FOR i FROM UPB arr DOWNTO LWB arr+1 | ||
WHILE arr[i-1] > arr[i] DO | ||
LONG INT tmp = arr[i-1]; arr[i-1] := arr[i]; arr[i] := tmp | ||
OD | ||
END; | ||
|
||
BEGIN | ||
FLEX[0]LONG INT scores; | ||
on logical file end(stand in, (REF FILE f)BOOL: done reading); | ||
DO | ||
STRING complete := ""; | ||
PROC parse = (STRING s)STRING: | ||
IF (UPB s = 0 | TRUE | NOT char in string(s[1], LOC INT, "<({[")) THEN s ELSE | ||
CHAR close char | ||
= IF s[1] = "{" THEN "}" | ||
ELIF s[1] = "<" THEN ">" | ||
ELIF s[1] = "[" THEN "]" | ||
ELIF s[1] = "(" THEN ")" | ||
FI; | ||
STRING rest = parse(s[2:]); | ||
IF UPB rest = 0 THEN | ||
complete := complete + close char; "" | ||
ELIF rest[1] = close char THEN parse(rest[2:]) | ||
ELSE break | ||
FI | ||
FI; | ||
STRING s; read((s, new line)); | ||
parse(s); | ||
LONG INT this score = score(complete); | ||
print((complete, this score, new line)); | ||
insert(scores, this score); | ||
break: | ||
SKIP | ||
OD; | ||
done reading: | ||
print((scores[(LWB scores+UPB scores)%2], new line)) | ||
END |
Oops, something went wrong.