%!PS % begin included library code % see https://codeberg.org/Firedrake/postscript-libraries/ /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 /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 /listmin { { min } reduce } 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 /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 % end included library code /shortesttime { [ exch { dup 0 2 getinterval cvi 60 mul exch 3 2 getinterval cvi add } forall ] [ exch 2 combinations { aload pop sub abs dup 1440 exch sub } forall ] listmin } bind def (shortesttime) test.start [(00:00) (23:55) (20:00)] shortesttime 5 eq test [(01:01) (00:50) (00:57)] shortesttime 4 eq test [(10:10) (09:30) (09:00) (09:55)] shortesttime 15 eq test test.end