how to handle very large array?

ag0aep6g anonymous at example.com
Wed Feb 9 10:29:03 UTC 2022


On 09.02.22 11:09, MichaelBi wrote:
> On Wednesday, 9 February 2022 at 10:05:23 UTC, MichaelBi wrote:
[...]
>> got outofmemory error:
>> core.exception.OutOfMemoryError at src\core\lifetime.d(126): Memory 
>> allocation failed
> 
> https://adventofcode.com/2021/day/6#part2
> 
> "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"
> 
> 26984457539 in above is the array length.

If you store one byte per lanternfish, that's 25 GiB. You don't seem to 
have enough RAM for such a large array.

Try to think of a more efficient way of storing the information.


More information about the Digitalmars-d-learn mailing list