diff options
Diffstat (limited to 'challenge-140/sgreen/python/ch-2.py')
| -rwxr-xr-x | challenge-140/sgreen/python/ch-2.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-140/sgreen/python/ch-2.py b/challenge-140/sgreen/python/ch-2.py new file mode 100755 index 0000000000..d27ce9f168 --- /dev/null +++ b/challenge-140/sgreen/python/ch-2.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +import sys + + +def main(inputs): + i = int(inputs[0]) + j = int(inputs[1]) + k = int(inputs[2]) + numbers = [] + + # Ensure we don't do something stupid + if (k > i * j): + raise Exception('Not enough elements') + + for m in range(1, i+1): + for n in range(1, j+1): + numbers.append(m*n) + + numbers.sort() + print(numbers[k - 1]) + + +if __name__ == '__main__': + main(sys.argv[1:]) |
