%!PS % begin included library code % see https://codeberg.org/Firedrake/postscript-libraries/ /s2a { [ exch { } forall ] } bind def /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 /test.start { print (:) print /test.pass 0 def /test.count 0 def } bind def /filter { % array proc(bool) -> array 1 dict begin /p exch def [ exch { dup p not { pop } if } forall ] end } bind def /values { % dict -> array of dict values [ exch { exch pop } 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 /enumerate.array { 1 dict begin /a exch def [ 0 1 a length 1 sub { [ exch dup a exch get ] } for ] end } bind def % end included library code /ballsandboxes { 0 dict begin /boxes 0 dict def /colour 64 def s2a enumerate.array { aload pop /c exch def /i exch def i 2 mod 0 eq { /colour c def } { /boxid c 48 sub def /s 1 dict def boxes boxid known { /s boxes boxid get def } if s colour true put boxes boxid s put } ifelse } forall boxes values { length 3 ge } filter length end } bind def (ballsandboxes) test.start (G0B1R2R0B0) ballsandboxes 1 eq test (G1R3R6B3G6B1B6R1G3) ballsandboxes 3 eq test (B3B2G1B3) ballsandboxes 0 eq test test.end