Yan Cui
I help clients go faster for less using serverless technologies.
Problem
It is possible to write five as a sum in exactly six different ways:
4 + 1
3 + 2
3 + 1 + 1
2 + 2 + 1
2 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1
How many different ways can one hundred be written as a sum of at least two positive integers?
Solution
// implement the coin change algorithm let rec count n m (coins:int list) = if n = 0 then 1 else if n < 0 then 0 else if (m <= 0 && n >= 1) then 0 else (count n (m-1) coins) + (count (n-coins.[m-1]) m coins) let answer = count 100 99 [1..99]
This is basically problem 31 with a twist, using the same coin change algorithm but substitute the set coins with the numbers less than 100 and you’ll have your solution!
Whenever you’re ready, here are 4 ways I can help you:
- If you want a one-stop shop to help you quickly level up your serverless skills, you should check out my Production-Ready Serverless workshop. Over 20 AWS Heroes & Community Builders have passed through this workshop, plus 1000+ students from the likes of AWS, LEGO, Booking, HBO and Siemens.
- If you want to learn how to test serverless applications without all the pain and hassle, you should check out my latest course, Testing Serverless Architectures.
- If you’re a manager or founder and want to help your team move faster and build better software, then check out my consulting services.
- If you just want to hang out, talk serverless, or ask for help, then you should join my FREE Community.
Pingback: Project Euler - Problem 77 Solution | theburningmonk.com