%!PS % begin included library code % see https://github.com/Firedrake/postscript-libraries/ /test.start { print (:) print /test.pass 0 def /test.count 0 def } 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.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 % end included library code % from https://www.rosettacode.org/wiki/Reverse_a_string#PostScript /reverse { 3 dict begin /str exch def /temp str 0 get def /i 0 def str length 2 idiv { /temp str i get def str i str str length i sub 1 sub get put str str length i sub 1 sub temp put /i i 1 add def } repeat str end } bind def /damm { 1 dict begin /tab [ [0 3 1 7 5 9 8 6 4 2] [7 0 9 2 1 5 4 8 6 3] [4 2 0 6 8 7 1 3 5 9] [1 7 5 0 9 8 3 4 2 6] [6 1 2 3 0 4 5 9 7 8] [3 6 7 4 2 0 9 5 8 1] [5 8 6 9 7 2 0 1 3 4] [8 9 4 5 3 6 2 0 1 7] [9 4 3 8 6 1 7 2 0 5] [2 5 8 1 4 3 6 7 9 0] ] def [ exch { dup 0 gt { dup 10 mod exch 10 idiv } { pop exit } ifelse } loop ] reverse 0 exch { tab 3 -1 roll get exch get } forall end } bind def /checkdamm { damm 0 eq } bind def (damm) test.start 5724 checkdamm test 5727 checkdamm not test test.end