diff options
Diffstat (limited to 'challenge-284/zapwai/python/ch-1.py')
| -rw-r--r-- | challenge-284/zapwai/python/ch-1.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-284/zapwai/python/ch-1.py b/challenge-284/zapwai/python/ch-1.py new file mode 100644 index 0000000000..16187e6da5 --- /dev/null +++ b/challenge-284/zapwai/python/ch-1.py @@ -0,0 +1,20 @@ +def proc(ints): + print("Input: ints =", ints) + lucky = -1 + freq = [] + for j in range(1 + max(ints)): + freq.append(0) + for item in ints: + freq[item] += 1 + + for i in range(1, len(freq)): + if i == freq[i]: + lucky = i + print("Output:", lucky) + +ints = [2, 2, 3, 4] +proc(ints) +ints = [1, 2, 2, 3, 3, 3] +proc(ints) +ints = [1, 1, 1, 3] +proc(ints) |
