From f34778006326c39da8b44b0d471624439a7ef579 Mon Sep 17 00:00:00 2001 From: ph Date: Fri, 13 Sep 2019 23:29:16 +1000 Subject: [PATCH 1/2] command line runner --- frog-2.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frog-2.py b/frog-2.py index c0b0eec..6eca0f0 100644 --- a/frog-2.py +++ b/frog-2.py @@ -1,5 +1,7 @@ +import random + def frog(final_dist=100,max=6): - + # I wrote this quickly in a pub # Don't judge me @@ -7,8 +9,6 @@ def frog(final_dist=100,max=6): while total_dist <= final_dist: - import random - cap = 10**max trials = 0 @@ -33,6 +33,10 @@ def frog(final_dist=100,max=6): total_dist += 1 return "DONE" - + +def main(): + frog() - \ No newline at end of file +if __name__ == '__main__': + main() + From 1506e1ba7b70027852ad976cbd8f652a4ff6f8c3 Mon Sep 17 00:00:00 2001 From: ph Date: Sat, 14 Sep 2019 00:01:59 +1000 Subject: [PATCH 2/2] Added command line runner for convenience. --- frog-2.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/frog-2.py b/frog-2.py index 6eca0f0..525a77d 100644 --- a/frog-2.py +++ b/frog-2.py @@ -1,4 +1,5 @@ import random +import sys def frog(final_dist=100,max=6): @@ -34,9 +35,13 @@ def frog(final_dist=100,max=6): return "DONE" -def main(): - frog() - -if __name__ == '__main__': - main() +def main(args): + """ + Read the first command line as 'final_dist' + Read the second command line as 'max' + """ + frog(*[int(a) for a in args[1:3]]) + +if __name__ == '__main__': + main(sys.argv)