From 0ea82e2833f6b6643df0e51dba7ff791e289eb0d Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Thu, 27 Aug 2020 20:05:37 +0100 Subject: - Added solution by Lubos Kolouch. --- challenge-075/lubos-kolouch/python/ch-1.py | 21 +++++++++++++++++++++ challenge-075/lubos-kolouch/python/ch_1.py | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 challenge-075/lubos-kolouch/python/ch-1.py delete mode 100644 challenge-075/lubos-kolouch/python/ch_1.py (limited to 'challenge-075') diff --git a/challenge-075/lubos-kolouch/python/ch-1.py b/challenge-075/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..c706f7f5a0 --- /dev/null +++ b/challenge-075/lubos-kolouch/python/ch-1.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +""" Perl weekly challenge 075 Task 1 - Coins sum """ + + +def count(coins, target_sum): + """ count the ways we can sum coins """ + + ways = [0] * (target_sum + 1) + + ways[0] = 1 + + for value in coins: + for j, _ in enumerate(ways): + if value <= j: + ways[j] += ways[j - value] + + return ways[target_sum] + + +assert count([1, 2, 4], 6) == 6 +assert count([1, 5, 10], 12) == 4 diff --git a/challenge-075/lubos-kolouch/python/ch_1.py b/challenge-075/lubos-kolouch/python/ch_1.py deleted file mode 100644 index c706f7f5a0..0000000000 --- a/challenge-075/lubos-kolouch/python/ch_1.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -""" Perl weekly challenge 075 Task 1 - Coins sum """ - - -def count(coins, target_sum): - """ count the ways we can sum coins """ - - ways = [0] * (target_sum + 1) - - ways[0] = 1 - - for value in coins: - for j, _ in enumerate(ways): - if value <= j: - ways[j] += ways[j - value] - - return ways[target_sum] - - -assert count([1, 2, 4], 6) == 6 -assert count([1, 5, 10], 12) == 4 -- cgit