Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/ABC-problem/Miranda/abc-problem.miranda
Normal file
30
Task/ABC-problem/Miranda/abc-problem.miranda
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
main :: [sys_message]
|
||||
main = [Stdout (lay [word ++ ": " ++ show (canmakeword blocks word) | word <- tests])]
|
||||
|
||||
tests :: [[char]]
|
||||
tests = ["A","BARK","BOOK","TREAT","common","SqUaD","cOnFuSe"]
|
||||
|
||||
canmakeword :: [[char]]->[char]->bool
|
||||
canmakeword [] word = False
|
||||
canmakeword blocks [] = True
|
||||
canmakeword blocks (a:as) = #match ~= 0 & canmakeword rest as
|
||||
where match = [b | b<-blocks; ucase a $in b]
|
||||
rest = hd match $del blocks
|
||||
|
||||
del :: *->[*]->[*]
|
||||
del item [] = []
|
||||
del item (a:as) = a:del item as, if a ~= item
|
||||
= as, otherwise
|
||||
|
||||
in :: *->[*]->bool
|
||||
in item [] = False
|
||||
in item (a:as) = a = item \/ item $in as
|
||||
|
||||
ucase :: char->char
|
||||
ucase ch = ch, if n<code 'a' \/ n>code 'z'
|
||||
= decode (n-32), otherwise
|
||||
where n = code ch
|
||||
|
||||
blocks :: [[char]]
|
||||
blocks = ["BO","XK","DQ","CP","NA","GT","RE","TG","QD","FS",
|
||||
"JW","HU","VI","AN","OB","ER","FS","LY","PC","ZM"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue