Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 17 lines (11 sloc) 0.258 kb
dc4e79d More problems solved
Andrey Paramonov authored
1 // Bottom-up dynamic programming
2
3 int TOTAL = 200
4
5 int[] coins = [1, 2, 5, 10, 20, 50, 100, 200]
6 int[] ways = new int[TOTAL + 1]
7 ways[0] = 1
8
9 coins.each { coin ->
10 (coin..TOTAL).each { i ->
11 ways[i] += ways[i - coin]
12 }
13 }
14
15 println ways[TOTAL]
16
Something went wrong with that request. Please try again.