[Bug][Haskell] The Descent: 0 values do not appear to be provided on input

As far as I can tell, I only receive the non-zero values. The way I validated this was by printing the value of mountainh, in the replicateM block provided, to err. In the first three tests, only the the non-zero value appears, but in the 4th test all values print out (as they are all non-zero).

Hey @FrakkingGameDev,

I just test it, writing:

replicateM 8 $ do
    input_line <- getLine
    let mountainh = read input_line :: Int
    hPutStrLn stderr (show (mountainh + 1))
    return () 

Doing so, I do not face your issue. however, if I remove “+ 1” after mountainh, I only write mountainh higher than 0, as you mentionned.
I’m not a Haskell coder and I can’t tell why it does not print zero values, but you do receive inputs correctly :wink:

1 Like

Thanks!
I am still learning it, and didn’t understand how to pull the items out of replicateM at the time. Much appreciated!

I’ve just tested it myself and each mountainh is printed on stderr as one would expect. No need to add 1. Are you both still experiencing your problems or was it some ephemeral glitch in the Matrix?

Various ways to get the mountain heights from the replicateM:

-- Iteration 1
mountainHeights <- replicateM 8 $ do
    input_line <- getLine
    let mountainHeight = read input_line :: Int
    hPutStrLn stderr (show mountainHeight)
    return mountainHeight

-- Iteration 2
mountainHeights <- replicateM 8 $ do
    mountainHeight <- fmap read getLine :: IO Int
    hPutStrLn stderr (show mountainHeight)
    return mountainHeight

-- Iteration 3
mountainHeights <- replicateM 8 $ do
    mountainHeight <- fmap read getLine :: IO Int
    return mountainHeight

-- Iteration 4
mountainHeights <- replicateM 8 $ do
    fmap read getLine :: IO Int

-- Iteration 5
mountainHeights <- replicateM 8 (fmap read getLine :: IO Int)

-- Iteration 6 (the operator <$> is defined in Control.Applicative)
mountainHeights <- replicateM 8 (read <$> getLine :: IO Int)
1 Like

I didn’t check to see if printing to stderr would start to show the 0s but I did manage to solve it since the input did exist.

Yup, I am not facing the issue anymore.