top | item 7856309

(no title)

chapel | 11 years ago

The code is very inefficient to say the least.

I made some modifications (diverging further from the "functional" nature, if you could call it that) and as you can see it is much faster[0].

Output:

  $ node new-magicForest.js 2017 2055 2006
  total forests: 6128
  { goats: 0, wolves: 0, lions: 4023 }
  total time: 20ms
[0] https://gist.github.com/chapel/1c038b2bf64b3037aaea

discuss

order

skratky|11 years ago

Your code contains a bug in the function getForestKey. See gist.