%!PS % begin included library code % see https://codeberg.org/Firedrake/postscript-libraries/ /test.end { ( ) print test.count 0 gt { (Passed ) print test.pass (...) cvs print (/) print test.count (...) cvs print ( \() print test.pass 100 mul test.count idiv (...) cvs print (%\)) print (\r\n) print } if } bind def /filter { % array proc(bool) -> array 1 dict begin /p exch def [ exch { dup p not { pop } if } forall ] end } bind def /toset { % array -> dict of (value, true) << exch { true } forall >> } bind def /test { /test.count test.count 1 add def { /test.pass test.pass 1 add def } { ( ) print test.count (....) cvs print (-fail) print } ifelse } bind def /test.start { print (:) print /test.pass 0 def /test.count 0 def } bind def % end included library code /arithmetictriplets { 0 dict begin /diff exch def /nums exch def /ns nums toset def nums { diff add dup ns exch known exch diff add ns exch known and } filter length end } bind def (arithmetictriplets) test.start [0 1 4 6 7 10] 3 arithmetictriplets 2 eq test [4 5 6 7 8 9] 2 arithmetictriplets 2 eq test test.end