Hacker News new | ask | show | jobs
by chapel 4393 days 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
1 comments

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