%!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 /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 /combinations { 4 dict begin /k exch def /arr exch def /c [ 0 1 k 1 sub { } for arr length 0 ] def [ { [ k 1 sub -1 0 { c exch get arr exch get } for ] /j 0 def { c j get 1 add c j 1 add get ne { exit } if c j j put /j j 1 add def } loop j k ge { exit } if c j c j get 1 add put } loop ] end } bind def /reduce { % array proc -> value 2 dict begin /p exch def /a exch def a 0 get 1 1 a length 1 sub { a exch get p } for end } bind def % end included library code /splitsameaverage { 6 dict begin /a exch def /ss a { add } reduce def /ml a length def /mx ml 2 idiv def /ssa false def 1 1 mx { /n exch def a n combinations { { add } reduce /ca exch def ca cvr n cvr div ss ca sub cvr ml n sub cvr div eq { /ssa true def exit } if } forall ssa { exit } if } for ssa end } bind def (splitsameaverage) test.start [1 2 3 4 5 6 7 8] splitsameaverage test [1 3] splitsameaverage not test [1 2 3] splitsameaverage test test.end