Jump to content
BrainDen.com - Brain Teasers

wilbloodworth

Members
  • Posts

    1
  • Joined

  • Last visited

wilbloodworth's Achievements

Newbie

Newbie (1/14)

  • First Post
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

0

Reputation

  1. I think 89 is correct. Here's a simple C# implementation that you can test out if you want to use LinqPad: void Main() { countWays(10).Dump(); } int countWays(int steps) { if (steps < 0) return 0; if (steps == 0) return 1; if (_map.ContainsKey(steps)) return _map[steps]; _map[steps] = countWays(steps - 1) + countWays(steps - 2); return _map[steps]; } private readonly Dictionary<int, int> _map = new Dictionary<int, int>();
×
×
  • Create New...