codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
-- Written by Mohit to solve Pikachu problem -- Pikachu is a character from Pokemon and he can speak -- only 3 syllables: pi, ka and chu. -- Aim of this program is to write a function that can verify -- whether pikachu can speak a sentence or not -- Input contains string (all lowercase, no spaces), output is true or false module Main where checkSyllables :: String -> Bool checkSyllables [] = True checkSyllables ('p':'i':rest) = checkSyllables rest checkSyllables ('k':'a':rest) = checkSyllables rest checkSyllables ('c':'h':'u':rest) = checkSyllables rest checkSyllables _ = False checkPikachu :: String -> String checkPikachu str = str ++ " " ++ show (checkSyllables str) main = putStrLn $ unlines $ map checkPikachu ["", "pi", "chu", "chupi", "p", "pika", "pipipikapikakachuchupichuchukapi", "pipipikapikakaachuchupichuchukapi"]
Private
[
?
]
Run code
Submit