%!PS % begin included library code % see https://codeberg.org/Firedrake/postscript-libraries/ /strsplit % (ajbjc) (j) -> [ (a) (b) (c) ] { 1 dict begin /sep exch def [ exch { dup length 0 eq { pop exit } { sep search { exch pop dup length 0 eq { pop } { exch } ifelse } { () } ifelse } ifelse } loop ] end } bind def /test.start { print (:) print /test.pass 0 def /test.count 0 def } bind def /toset { % array -> dict of (value, true) << exch { true } forall >> } bind def /tolower { s2a [ exch { dup dup 65 ge exch 90 le and { 32 add } if } forall ] a2s } 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 /a2s { 2 dict begin /i exch def i length dup string /o exch def 1 sub 0 exch 1 exch { dup i 3 -1 roll get o 3 1 roll put } for o end } bind def /set.intersection { 4 dict begin /s 0 dict def /b exch def /a exch def a keys { /k exch def b k known { s k true put } if } forall s end } bind def /map { % array proc -> array 2 dict begin /p exch def [ exch { p } forall ] end } bind def /keys { % dict -> array of dict keys [ exch { pop } forall ] } bind def /s2a { [ exch { } forall ] } bind def % end included library code /brokenkeyboard { 0 dict begin /bk exch { tolower s2a 0 get } map toset def 0 exch tolower ( ) strsplit { /valid true def s2a toset bk set.intersection length 0 eq { 1 add } if } forall end } bind def (brokenkeyboard) test.start (Hello World) [(d)] brokenkeyboard 1 eq test (apple banana cherry) [(a) (e)] brokenkeyboard 0 eq test (Coding is fun) [] brokenkeyboard 3 eq test (The Weekly Challenge) [(a) (b)] brokenkeyboard 2 eq test (Perl and Python) [(p)] brokenkeyboard 1 eq test test.end