Suppose the lanternfish live forever and have unlimited food and space. Would they take over the entire ocean?
After 256 days in the example above, there would be a total of 26984457539 lanternfish!
How many lanternfish would there be after 256 days? Determine this in the following way:
Write a function lanternfish that takes the pathname (String) of a text file containing the ages of several hundred nearby lanternfish. The function must return how many lanternfish (Int) there would be after 256 days.
The return value should be wrapped in the IO monad if needed.
In this interactive session we assume the text files ages01.txt1 and ages02.txt2 to be located in the current directory.
> lanternfish ("ages01.txt")
26984457539 :: Int
> lanternfish ("ages02.txt")
1650309278600 :: Int
Jari Komppa (@Sol_HSA3) animated his solution.