Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Haskell
Unfortunately, this section is not ready yet, as I lack the necessary skills in Haskell... (Volunteer contributors are welcome!)
Checking the sample code
Well, I managed to make the puzzle work, but it is most likely a rather inferior Haskell code...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import System.IO
import Control.Monad
import Data.Char
import Numeric
pad0 :: Int -> String -> String
pad0 n x = take (n - length x) (cycle "0") ++ x
nextStr c curr prev = if curr == prev
then "0"
else " " ++ c !! (ord curr - ord '0') ++ " 0"
main :: IO ()
main = do
hSetBuffering stdout NoBuffering -- DO NOT REMOVE
m <- getLine
let c = ["00", "0"]
let b = concatMap (\x -> pad0 7 $ showIntAtBase 2 intToDigit (ord x) "") m
hPrint stderr m
hPrint stderr b
let start = c !! (ord (head b) - ord '0') ++ " 0"
let z = zip (tail b) b
let ansRest = concatMap (uncurry (nextStr c)) z
let ans = start ++ ansRest
putStrLn ans
return ()
-- hPutStrLn stderr "Debug messages..."
Enter to Rename, Shift+Enter to Preview
Looking at the syntax
- TODO
Other characteristics
- TODO
Resources to check
Coming next...
Before we move on to some more serious matters, let's focus on a language, which saw an enormous growth in popularity in the past 5+ years: Python!
Suggested playgrounds
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content