how to handle very large array?

MichaelBi at
Wed Feb 9 10:09:36 UTC 2022

On Wednesday, 9 February 2022 at 10:05:23 UTC, MichaelBi wrote:
> On Wednesday, 9 February 2022 at 10:03:21 UTC, MichaelBi wrote:
>> day6 of the advent of code 2021 needs to handle an array of 
>> 10^12 length, or even bigger... plus change elements and 
>> append elements. normal implementation such as length, 
>> appender and ref element etc, seems cannot handle that big 
>> array? is there any alternative data structure or algorithm 
>> can handle such large array properly? thanks.
> got outofmemory error:
> core.exception.OutOfMemoryError at src\core\lifetime.d(126): 
> Memory allocation failed

"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.

More information about the Digitalmars-d-learn mailing list