From 31d309acc97b6d50776d544108040c53ed4ab17c Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Thu, 20 Aug 2015 23:42:59 -0500 Subject: [PATCH 01/40] Automatic Push --- ...rcises.txt => 100+ Python challenging programming exercises.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 100+ Python challenging programming exercises.txt => 100+ Python challenging programming exercises.md (100%) diff --git a/100+ Python challenging programming exercises.txt b/100+ Python challenging programming exercises.md similarity index 100% rename from 100+ Python challenging programming exercises.txt rename to 100+ Python challenging programming exercises.md From a047c328447ca45eaf7fceeb300ef15f0bc82a95 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Thu, 20 Aug 2015 23:56:14 -0500 Subject: [PATCH 02/40] Automatic Push --- my_solutions/lol.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 my_solutions/lol.txt diff --git a/my_solutions/lol.txt b/my_solutions/lol.txt new file mode 100644 index 00000000..e69de29b From 63e7c5f5cfd7cb98368aae269cfb5c496aefb251 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:26:32 -0500 Subject: [PATCH 03/40] Automatic Push --- README | 0 README.md | 9 +++++++++ markdown-here.wiki | 1 + 3 files changed, 10 insertions(+) delete mode 100644 README create mode 100644 README.md create mode 160000 markdown-here.wiki diff --git a/README b/README deleted file mode 100644 index e69de29b..00000000 diff --git a/README.md b/README.md new file mode 100644 index 00000000..2d3acc34 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Read to 100 Problems + +Today, I am going to + +{% highlight python3%} +for i in you: + print(you are a good boy) + False +{% endhighlight %} \ No newline at end of file diff --git a/markdown-here.wiki b/markdown-here.wiki new file mode 160000 index 00000000..79a523f3 --- /dev/null +++ b/markdown-here.wiki @@ -0,0 +1 @@ +Subproject commit 79a523f39c17215dfe477c8e6126f432f1fd3aff From bacdc9f39c8b4dfa5112e924f4d7cba29b32979d Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:27:42 -0500 Subject: [PATCH 04/40] Automatic Push --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d3acc34..8756fde6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Today, I am going to -{% highlight python3%} +{% highlight python3 %} for i in you: print(you are a good boy) False From 3684e3d6ba4175ee0f0630f9d572ce5af42ddaf3 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:38:04 -0500 Subject: [PATCH 05/40] Automatic Push --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8756fde6..b87734aa 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,18 @@ # Read to 100 Problems -Today, I am going to +Today, 2015 August 21st, I am going to embark on a journey of completing 100 python problems. Ranging from increasing complexities from 1-3. -{% highlight python3 %} -for i in you: - print(you are a good boy) - False -{% endhighlight %} \ No newline at end of file +Easy | Medium | Hard +--- | --- | --- +1 | 2 | 3 + +>“I know it seems hard sometimes but remember one thing. +>Through every dark night, there's a bright day after that. +>So no matter how hard it get, stick your chest out, +>keep ya head up.... and handle it.” +― Tupac Shakur + + +```python +is = 'going to be the language of choice' +``` From 3cdd1506f51e2e5138091c74cf68d7f265aae0bb Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:38:28 -0500 Subject: [PATCH 06/40] Automatic Push --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b87734aa..050c811f 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Easy | Medium | Hard >Through every dark night, there's a bright day after that. >So no matter how hard it get, stick your chest out, >keep ya head up.... and handle it.” + ― Tupac Shakur From ade84e5c8cd93379b7745700be2864fc841729ea Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:38:39 -0500 Subject: [PATCH 07/40] Automatic Push --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 050c811f..4cf5b6f7 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Easy | Medium | Hard --- | --- | --- 1 | 2 | 3 + >“I know it seems hard sometimes but remember one thing. >Through every dark night, there's a bright day after that. >So no matter how hard it get, stick your chest out, From 3f50ebe9416e0e4d29f9709fd9eaf3ed39e64ded Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:38:57 -0500 Subject: [PATCH 08/40] Automatic Push --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4cf5b6f7..02e1144d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ Easy | Medium | Hard --- | --- | --- 1 | 2 | 3 - +
+
>“I know it seems hard sometimes but remember one thing. >Through every dark night, there's a bright day after that. >So no matter how hard it get, stick your chest out, From f163100e276ba5e15f19bb6be5c6a3b746f42a9d Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:39:06 -0500 Subject: [PATCH 09/40] Automatic Push --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 02e1144d..570f26b6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Easy | Medium | Hard --- | --- | --- 1 | 2 | 3 -

>“I know it seems hard sometimes but remember one thing. >Through every dark night, there's a bright day after that. From fe470f7ae44d9369b74f3913518fec54c3be27e5 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:39:28 -0500 Subject: [PATCH 10/40] Automatic Push --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 570f26b6..501a4b73 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ Today, 2015 August 21st, I am going to embark on a journey of completing 100 pyt Easy | Medium | Hard --- | --- | --- 1 | 2 | 3 -
>“I know it seems hard sometimes but remember one thing. >Through every dark night, there's a bright day after that. @@ -13,7 +12,7 @@ Easy | Medium | Hard >keep ya head up.... and handle it.” ― Tupac Shakur - +
```python is = 'going to be the language of choice' From b750908a9298c4da0ad74ca89f82d323d37131b8 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:39:41 -0500 Subject: [PATCH 11/40] Automatic Push --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 501a4b73..78d7e792 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Easy | Medium | Hard >keep ya head up.... and handle it.” ― Tupac Shakur +
```python From c1e798049bba41c357eb87bf72fa6b488c55602c Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:40:00 -0500 Subject: [PATCH 12/40] Automatic Push --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 78d7e792..aba86cc0 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Today, 2015 August 21st, I am going to embark on a journey of completing 100 python problems. Ranging from increasing complexities from 1-3. +## Complexity Scale: + Easy | Medium | Hard --- | --- | --- 1 | 2 | 3 From 80efa44eb3011c845684c83f088d8aa51b73b723 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:40:26 -0500 Subject: [PATCH 13/40] Automatic Push --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aba86cc0..4837017b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Today, 2015 August 21st, I am going to embark on a journey of completing 100 python problems. Ranging from increasing complexities from 1-3. -## Complexity Scale: +### Complexity Scale: Easy | Medium | Hard --- | --- | --- From 9b11ccac0e763046ab83467ddc2d518d87089b18 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:41:30 -0500 Subject: [PATCH 14/40] Automatic Push --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4837017b..ea7ed6f3 100644 --- a/README.md +++ b/README.md @@ -18,5 +18,5 @@ Easy | Medium | Hard
```python -is = 'going to be the language of choice' +python = 'is going to be the language of choice' ``` From 34683b72ba2138c1e349bedc7934064ea66f44b2 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:42:26 -0500 Subject: [PATCH 15/40] Automatic Push --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index ea7ed6f3..12977fbf 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,8 @@ Easy | Medium | Hard ```python python = 'is going to be the language of choice' +def anti_vowel(text): + text = text.lower() + vowels = ['a','e','i','o','u'] + return ''.join([x for x in text if x not in vowels]) ``` From 7451d6945ad9c8678471b997c918c16e659dc60e Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:42:50 -0500 Subject: [PATCH 16/40] Automatic Push --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 12977fbf..1e667fe1 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Easy | Medium | Hard ```python python = 'is going to be the language of choice' + def anti_vowel(text): text = text.lower() vowels = ['a','e','i','o','u'] From 13681fdb92bea1db93a28521c40b094afcac2798 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:44:10 -0500 Subject: [PATCH 17/40] Automatic Push --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 1e667fe1..f7f85ee0 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,7 @@ def anti_vowel(text): text = text.lower() vowels = ['a','e','i','o','u'] return ''.join([x for x in text if x not in vowels]) + +anti_vowel(python) +Output: 's gng t b th lngg f chc' ``` From 1133846696ca0641d55ab0426708af5bbeab7e33 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:44:42 -0500 Subject: [PATCH 18/40] Automatic Push --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f7f85ee0..02f1b396 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,5 @@ def anti_vowel(text): anti_vowel(python) Output: 's gng t b th lngg f chc' ``` + +So, sit back and enjoy the ride ;-). From ce0628ffd9c4d86474495eebe22abf5509f26218 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:47:32 -0500 Subject: [PATCH 19/40] Automatic Push --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 02f1b396..3ea57a4b 100644 --- a/README.md +++ b/README.md @@ -29,4 +29,5 @@ anti_vowel(python) Output: 's gng t b th lngg f chc' ``` -So, sit back and enjoy the ride ;-). +####So, sit back and enjoy the ride... +## Here... We... GO! :facepunch: From d9f844b5d1702b460cef5aaab20e2087f95a3598 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:47:54 -0500 Subject: [PATCH 20/40] Automatic Push --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ea57a4b..e8cc93b1 100644 --- a/README.md +++ b/README.md @@ -30,4 +30,4 @@ Output: 's gng t b th lngg f chc' ``` ####So, sit back and enjoy the ride... -## Here... We... GO! :facepunch: +# Here... We... GO! :facepunch: From 5a63bdb41b26cc97e97af0509d1cdb44e0a644d1 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:48:19 -0500 Subject: [PATCH 21/40] Automatic Push --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e8cc93b1..8f117cd0 100644 --- a/README.md +++ b/README.md @@ -29,5 +29,5 @@ anti_vowel(python) Output: 's gng t b th lngg f chc' ``` -####So, sit back and enjoy the ride... -# Here... We... GO! :facepunch: +So, sit back and enjoy the ride... +- # Here... We... GO! :facepunch: From 67b3c1745ac1fac4425f6c4f3aeabf43c485eeaa Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 06:48:27 -0500 Subject: [PATCH 22/40] Automatic Push --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f117cd0..81f3af4e 100644 --- a/README.md +++ b/README.md @@ -30,4 +30,4 @@ Output: 's gng t b th lngg f chc' ``` So, sit back and enjoy the ride... -- # Here... We... GO! :facepunch: +# Here... We... GO! :facepunch: From a29babd9fde60b0a721e055c255995304ad07a53 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 07:42:24 -0500 Subject: [PATCH 23/40] test ipynb.py --- my_solutions/exercise1.py | 12 ++++++++++++ .../exercise1; List Comprehensions.ipynb.py | 13 +++++++++++++ my_solutions/exercise1; List Comprehensions.py | 12 ++++++++++++ my_solutions/lol.txt | 0 4 files changed, 37 insertions(+) create mode 100644 my_solutions/exercise1.py create mode 100644 my_solutions/exercise1; List Comprehensions.ipynb.py create mode 100644 my_solutions/exercise1; List Comprehensions.py delete mode 100644 my_solutions/lol.txt diff --git a/my_solutions/exercise1.py b/my_solutions/exercise1.py new file mode 100644 index 00000000..04c96c1c --- /dev/null +++ b/my_solutions/exercise1.py @@ -0,0 +1,12 @@ +# coding: utf-8 + + +''' +for i in range(2000,3200): + if i % 7 == 0: + if i % 5 != 0: + print(i) +''' + +print ([i for i in range(2000,3200) if i % 7 == 0 and i % 5 != 0]) + diff --git a/my_solutions/exercise1; List Comprehensions.ipynb.py b/my_solutions/exercise1; List Comprehensions.ipynb.py new file mode 100644 index 00000000..ad4baae4 --- /dev/null +++ b/my_solutions/exercise1; List Comprehensions.ipynb.py @@ -0,0 +1,13 @@ +# coding: utf-8 + + +''' +1st attempt at solution +for i in range(2000,3200): + if i % 7 == 0: + if i % 5 != 0: + print(i) +''' + +print ([i for i in range(2000,3200) if i % 7 == 0 and i % 5 != 0]) + diff --git a/my_solutions/exercise1; List Comprehensions.py b/my_solutions/exercise1; List Comprehensions.py new file mode 100644 index 00000000..04c96c1c --- /dev/null +++ b/my_solutions/exercise1; List Comprehensions.py @@ -0,0 +1,12 @@ +# coding: utf-8 + + +''' +for i in range(2000,3200): + if i % 7 == 0: + if i % 5 != 0: + print(i) +''' + +print ([i for i in range(2000,3200) if i % 7 == 0 and i % 5 != 0]) + diff --git a/my_solutions/lol.txt b/my_solutions/lol.txt deleted file mode 100644 index e69de29b..00000000 From 6c66d0d65f14aaff0164f3c7eba1c174559cb662 Mon Sep 17 00:00:00 2001 From: Rafeh Qazi Date: Fri, 21 Aug 2015 07:43:12 -0500 Subject: [PATCH 24/40] Rename exercise1; List Comprehensions.ipynb.py to exercise1; List Comprehensions.ipynb --- ...mprehensions.ipynb.py => exercise1; List Comprehensions.ipynb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename my_solutions/{exercise1; List Comprehensions.ipynb.py => exercise1; List Comprehensions.ipynb} (100%) diff --git a/my_solutions/exercise1; List Comprehensions.ipynb.py b/my_solutions/exercise1; List Comprehensions.ipynb similarity index 100% rename from my_solutions/exercise1; List Comprehensions.ipynb.py rename to my_solutions/exercise1; List Comprehensions.ipynb From ea17921bcdcd44848167a0dc4ddb16b6edb09075 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 08:49:12 -0500 Subject: [PATCH 25/40] flyintotheair --- t1.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 t1.txt diff --git a/t1.txt b/t1.txt new file mode 100644 index 00000000..e69de29b From 789429b41926e2e56e08f70486b10a6d2e098858 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 08:50:02 -0500 Subject: [PATCH 26/40] bye --- t2.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 t2.txt diff --git a/t2.txt b/t2.txt new file mode 100644 index 00000000..e69de29b From da803212664b61d524f0c1cd50cc23535ca680bc Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 09:28:38 -0500 Subject: [PATCH 27/40] deleting all existing solutions --- my_solutions/exercise1.py | 12 ------------ my_solutions/exercise1; List Comprehensions.ipynb | 13 ------------- my_solutions/exercise1; List Comprehensions.py | 12 ------------ 3 files changed, 37 deletions(-) delete mode 100644 my_solutions/exercise1.py delete mode 100644 my_solutions/exercise1; List Comprehensions.ipynb delete mode 100644 my_solutions/exercise1; List Comprehensions.py diff --git a/my_solutions/exercise1.py b/my_solutions/exercise1.py deleted file mode 100644 index 04c96c1c..00000000 --- a/my_solutions/exercise1.py +++ /dev/null @@ -1,12 +0,0 @@ -# coding: utf-8 - - -''' -for i in range(2000,3200): - if i % 7 == 0: - if i % 5 != 0: - print(i) -''' - -print ([i for i in range(2000,3200) if i % 7 == 0 and i % 5 != 0]) - diff --git a/my_solutions/exercise1; List Comprehensions.ipynb b/my_solutions/exercise1; List Comprehensions.ipynb deleted file mode 100644 index ad4baae4..00000000 --- a/my_solutions/exercise1; List Comprehensions.ipynb +++ /dev/null @@ -1,13 +0,0 @@ -# coding: utf-8 - - -''' -1st attempt at solution -for i in range(2000,3200): - if i % 7 == 0: - if i % 5 != 0: - print(i) -''' - -print ([i for i in range(2000,3200) if i % 7 == 0 and i % 5 != 0]) - diff --git a/my_solutions/exercise1; List Comprehensions.py b/my_solutions/exercise1; List Comprehensions.py deleted file mode 100644 index 04c96c1c..00000000 --- a/my_solutions/exercise1; List Comprehensions.py +++ /dev/null @@ -1,12 +0,0 @@ -# coding: utf-8 - - -''' -for i in range(2000,3200): - if i % 7 == 0: - if i % 5 != 0: - print(i) -''' - -print ([i for i in range(2000,3200) if i % 7 == 0 and i % 5 != 0]) - From 747efc019b597e362e3497e0eee1084b0263bd89 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 09:36:42 -0500 Subject: [PATCH 28/40] need the empty file for folder to exist. --- t1.txt => my_solutions/empty.txt | 0 t2.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename t1.txt => my_solutions/empty.txt (100%) delete mode 100644 t2.txt diff --git a/t1.txt b/my_solutions/empty.txt similarity index 100% rename from t1.txt rename to my_solutions/empty.txt diff --git a/t2.txt b/t2.txt deleted file mode 100644 index e69de29b..00000000 From b15e776a5d0fa0cae3812ab247a7f5dd93f54f2c Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 09:38:55 -0500 Subject: [PATCH 29/40] Updated README headline. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 81f3af4e..9e618d94 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Read to 100 Problems +# 0 - 100 Real Quick (Python Problems) Today, 2015 August 21st, I am going to embark on a journey of completing 100 python problems. Ranging from increasing complexities from 1-3. From a06b84e9210ac7b522da4d9f8c933bd38392872a Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 09:43:09 -0500 Subject: [PATCH 30/40] instructions for fellows to follow me along on this journey of 100 problem solving! --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e618d94..fa8b5a1c 100644 --- a/README.md +++ b/README.md @@ -29,5 +29,7 @@ anti_vowel(python) Output: 's gng t b th lngg f chc' ``` -So, sit back and enjoy the ride... +You are welcome to work on these with me and send request pull your solutions! I promise I won't look at your solutions haha. Only for cross-checking once I complete my solution. Perhaps this repository might be of use to other learners who can see multiple solutions to a problem. + +In any case... # Here... We... GO! :facepunch: From 2f1930cf998ecef0ece862fcdbc9204bae975faa Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 09:43:37 -0500 Subject: [PATCH 31/40] e --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index fa8b5a1c..b914f43a 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,5 @@ Output: 's gng t b th lngg f chc' ``` You are welcome to work on these with me and send request pull your solutions! I promise I won't look at your solutions haha. Only for cross-checking once I complete my solution. Perhaps this repository might be of use to other learners who can see multiple solutions to a problem. - In any case... # Here... We... GO! :facepunch: From 4b6e830752d27ab5279ef6f3c4eff5b70827a71e Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 09:43:59 -0500 Subject: [PATCH 32/40] e --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b914f43a..fa8b5a1c 100644 --- a/README.md +++ b/README.md @@ -30,5 +30,6 @@ Output: 's gng t b th lngg f chc' ``` You are welcome to work on these with me and send request pull your solutions! I promise I won't look at your solutions haha. Only for cross-checking once I complete my solution. Perhaps this repository might be of use to other learners who can see multiple solutions to a problem. + In any case... # Here... We... GO! :facepunch: From a3853de793575146b64a02d25c5b17da6826d32a Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Fri, 21 Aug 2015 20:27:27 -0500 Subject: [PATCH 33/40] HI tenzin --- test1.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test1.txt diff --git a/test1.txt b/test1.txt new file mode 100644 index 00000000..e69de29b From 18d568ff0f65e52fe78dc9f0936b6da3303964d5 Mon Sep 17 00:00:00 2001 From: rafeh01 Date: Sat, 22 Aug 2015 05:47:42 -0500 Subject: [PATCH 34/40] Sublime Environment --- Solutions.sublime-project | 2 + Solutions.sublime-workspace | 527 +++++++++++++++++ my_solutions/Solution2.py | 46 ++ my_solutions/Solution3problem.py | 3 + my_solutions/Solutions.sublime-project | 2 + my_solutions/Solutions.sublime-workspace | 542 ++++++++++++++++++ my_solutions/Sublime Shortcus.md | 5 + .../__pycache__/Solution2.cpython-34.pyc | Bin 0 -> 339 bytes my_solutions/empty.sublime-workspace | 176 ++++++ test1.txt | 0 10 files changed, 1303 insertions(+) create mode 100644 Solutions.sublime-project create mode 100644 Solutions.sublime-workspace create mode 100644 my_solutions/Solution2.py create mode 100644 my_solutions/Solution3problem.py create mode 100644 my_solutions/Solutions.sublime-project create mode 100644 my_solutions/Solutions.sublime-workspace create mode 100644 my_solutions/Sublime Shortcus.md create mode 100644 my_solutions/__pycache__/Solution2.cpython-34.pyc create mode 100644 my_solutions/empty.sublime-workspace delete mode 100644 test1.txt diff --git a/Solutions.sublime-project b/Solutions.sublime-project new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/Solutions.sublime-project @@ -0,0 +1,2 @@ +{ +} diff --git a/Solutions.sublime-workspace b/Solutions.sublime-workspace new file mode 100644 index 00000000..4e20d955 --- /dev/null +++ b/Solutions.sublime-workspace @@ -0,0 +1,527 @@ +{ + "auto_complete": + { + "selected_items": + [ + ] + }, + "buffers": + [ + { + "file": "my_solutions/Solution2.py", + "settings": + { + "buffer_size": 1622, + "line_ending": "Unix", + "name": "Solution2.py" + } + }, + { + "contents": "#SHORTCUTS\n[Key Sublime Shortcuts](http://webdesign.tutsplus.com/tutorials/useful-shortcuts-for-a-faster-workflow-in-sublime-text-3--cms-22185)\n\nctrl+,, s Selection\nctrl+,, f File\nctrl+,, l Lines\nctrl+,, b Block\nctrl+alt+b Run Python Terminal\ncmd+l Select Current Line\ncmd+shift+g Multiple cursor on specifc keyword", + "file": "my_solutions/Sublime Shortcus.md", + "file_size": 78, + "file_write_time": 130847121740000000, + "settings": + { + "buffer_size": 316, + "line_ending": "Unix", + "name": "#SHORTCUTS" + } + }, + { + "contents": "Python 2.7.6 (default, Sep 9 2014, 15:04:36) \n[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> 5+5\n10\n>>> ", + "settings": + { + "buffer_size": 198, + "line_ending": "Unix", + "name": "*REPL* [python]", + "scratch": true + } + }, + { + "contents": "bash: no job control in this shell\nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ ls\nSolution2.py\nSolution3problem.py\nSolutions.sublime-project\nSolutions.sublime-workspace\nSublime Shortcus.md\n__pycache__\nempty.sublime-workspace\nempty.txt\nbash-3.2$ ls\nSolution2.py\nSolution3problem.py\nSolutions.sublime-project\nSolutions.sublime-workspace\nSublime Shortcus.md\n__pycache__\nempty.sublime-workspace\nempty.txt\nbash-3.2$ alias\nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ ls\nSolution2.py\nSolution3problem.py\nSolutions.sublime-project\nSolutions.sublime-workspace\nSublime Shortcus.md\n__pycache__\nempty.sublime-workspace\nempty.txt\nbash-3.2$ cd dropbox\nbash: cd: dropbox: No such file or directory\nbash-3.2$ ls\nSolution2.py\nSolution3problem.py\nSolutions.sublime-project\nSolutions.sublime-workspace\nSublime Shortcus.md\n__pycache__\nempty.sublime-workspace\nempty.txt\nbash-3.2$ cd ..\nbash-3.2$ ls\n100+ Python challenging programming exercises.md\nREADME.md\nSolutions.sublime-project\nSolutions.sublime-workspace\nmarkdown-here.wiki\nmy_solutions\npython contents.docx\npython contents.txt\nbash-3.2$ cd\nbash-3.2$ ls\nAnaconda\nApplications\nDesktop\nDocuments\nDownloads\nDropbox\nGoogle Drive\nLibrary\nMovies\nMusic\nPictures\nPublic\nbash-3.2$ cd dropbox\nbash-3.2$ ls\nApps\nCalculus One\nCamera Uploads\nClosed sicillian attack.pgn\nDROP SYNC\nDad Work\nHive-1BJ4G\nIcon \nLightroom Exports\nMiscellenous\nNew Game.pgn\nPsych Pics\nScreenshots\ndatajoy\ngithub\nipython notebooks\nmohsen1.github.io\nbash-3.2$ ll\nbash: ll: command not found\nbash-3.2$ ll\nbash: ll: command not found\nbash-3.2$ cd github\nbash-3.2$ ls\nCisco\nGalvanize\nGithub_Tips_Tricks\nIPython-notebooks\nPython-programming-exercises\nSublimeProjects\nbootstrap\npython-programs\nrafeh01.github.io\nscript\nbash-3.2$ ", + "settings": + { + "buffer_size": 2060, + "line_ending": "Unix", + "name": "*REPL* [shell]", + "read_only": true, + "scratch": true + } + } + ], + "build_system": "", + "build_system_choices": + [ + ], + "build_varint": "", + "command_palette": + { + "height": 392.0, + "last_filter": "", + "selected_items": + [ + [ + "sublimerepl", + "Build With: sublimerepl_build_system_hack" + ], + [ + "Package Control: Install Package", + "Package Control: Install Package" + ], + [ + "", + "Build With: Python - Syntax Check" + ] + ], + "width": 449.0 + }, + "console": + { + "height": 116.0, + "history": + [ + "stdin(1,2)", + "5+5", + "5_5", + "5+5" + ] + }, + "distraction_free": + { + "menu_visible": true, + "show_minimap": false, + "show_open_files": false, + "show_tabs": false, + "side_bar_visible": false, + "status_bar_visible": false + }, + "file_history": + [ + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/Default (OSX).sublime-keymap", + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/SublimeREPL.sublime-settings", + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/Default/Default (OSX).sublime-keymap", + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/SublimeREPL/SublimeREPL.sublime-settings", + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings", + "/Users/ChessTastic/Dropbox/github/Python-programming-exercises/my_solutions/Solution3problem.py", + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/Default/Preferences.sublime-settings" + ], + "find": + { + "height": 35.0 + }, + "find_in_files": + { + "height": 93.0, + "where_history": + [ + ] + }, + "find_state": + { + "case_sensitive": false, + "find_history": + [ + "enter", + "Input", + "been", + "introductory", + "in1", + "stdin", + "b", + "section", + "c", + "section", + "python", + "github", + "git", + "users", + "chesstastic", + "sta", + "git", + "rafeh" + ], + "highlight": true, + "in_selection": false, + "preserve_case": false, + "regex": false, + "replace_history": + [ + ], + "reverse": false, + "show_context": true, + "use_buffer2": true, + "whole_word": false, + "wrap": true + }, + "groups": + [ + { + "selected": 0, + "sheets": + [ + { + "buffer": 0, + "file": "my_solutions/Solution2.py", + "semi_transient": false, + "settings": + { + "buffer_size": 1622, + "regions": + { + }, + "selection": + [ + [ + 1622, + 1622 + ] + ], + "settings": + { + "auto_name": "Solution2.py", + "syntax": "Packages/Python/Python.tmLanguage" + }, + "translation.x": 0.0, + "translation.y": 0.0, + "zoom_level": 1.0 + }, + "stack_index": 0, + "type": "text" + } + ] + }, + { + "selected": 0, + "sheets": + [ + { + "buffer": 1, + "file": "my_solutions/Sublime Shortcus.md", + "semi_transient": false, + "settings": + { + "buffer_size": 316, + "regions": + { + }, + "selection": + [ + [ + 316, + 316 + ] + ], + "settings": + { + "auto_name": "#SHORTCUTS", + "syntax": "Packages/Markdown/Markdown.tmLanguage" + }, + "translation.x": 0.0, + "translation.y": 57.0, + "zoom_level": 1.0 + }, + "stack_index": 2, + "type": "text" + } + ] + }, + { + "selected": 0, + "sheets": + [ + { + "buffer": 2, + "semi_transient": false, + "settings": + { + "buffer_size": 198, + "regions": + { + }, + "selection": + [ + [ + 198, + 198 + ] + ], + "settings": + { + "auto_complete": true, + "auto_indent": false, + "detect_indentation": false, + "gutter": false, + "history_arrows": true, + "indent_subsequent_lines": false, + "line_numbers": false, + "repl": true, + "repl_external_id": "python", + "repl_id": "c8dc5b7b676f42989a320c214ab28112", + "repl_restart_args": + { + "cmd": + [ + "python", + "-i", + "-u" + ], + "cwd": "$file_path", + "encoding": "utf8", + "extend_env": + { + "PYTHONIOENCODING": "utf-8" + }, + "external_id": "python", + "syntax": "Packages/Python/Python.tmLanguage", + "type": "subprocess" + }, + "repl_sublime2": false, + "smart_indent": false, + "spell_check": false, + "syntax": "Packages/Python/Python.tmLanguage", + "translate_tabs_to_spaces": false + }, + "translation.x": 0.0, + "translation.y": 0.0, + "zoom_level": 1.0 + }, + "stack_index": 3, + "type": "text" + } + ] + }, + { + "selected": 0, + "sheets": + [ + { + "buffer": 3, + "semi_transient": false, + "settings": + { + "buffer_size": 2060, + "regions": + { + }, + "selection": + [ + [ + 1749, + 1749 + ] + ], + "settings": + { + "auto_complete": true, + "auto_indent": false, + "detect_indentation": false, + "gutter": false, + "history_arrows": true, + "indent_subsequent_lines": false, + "line_numbers": false, + "repl": true, + "repl_external_id": "shell", + "repl_id": "44fa0f2297b04464b5d5b154ffe0e1a1", + "repl_restart_args": + { + "cmd": + { + "linux": + [ + "bash", + "-i" + ], + "osx": + [ + "bash", + "-i" + ], + "windows": + [ + "cmd.exe" + ] + }, + "cmd_postfix": "\n", + "cwd": "$file_path", + "encoding": + { + "linux": "utf-8", + "osx": "utf-8", + "windows": "$win_cmd_encoding" + }, + "env": + { + }, + "external_id": "shell", + "suppress_echo": true, + "syntax": "Packages/Text/Plain text.tmLanguage", + "type": "subprocess" + }, + "repl_sublime2": false, + "smart_indent": false, + "spell_check": false, + "syntax": "Packages/Text/Plain text.tmLanguage", + "translate_tabs_to_spaces": false + }, + "translation.x": 0.0, + "translation.y": 2007.0, + "zoom_level": 1.0 + }, + "stack_index": 1, + "type": "text" + } + ] + } + ], + "incremental_find": + { + "height": 25.0 + }, + "input": + { + "height": 0.0 + }, + "layout": + { + "cells": + [ + [ + 0, + 0, + 1, + 3 + ], + [ + 1, + 0, + 2, + 1 + ], + [ + 1, + 1, + 2, + 2 + ], + [ + 1, + 2, + 2, + 3 + ] + ], + "cols": + [ + 0.0, + 0.740640258789, + 1.0 + ], + "rows": + [ + 0.0, + 0.143552311436, + 0.63896080444, + 1.0 + ] + }, + "menu_visible": true, + "output.exec": + { + "height": 28.0 + }, + "output.find_results": + { + "height": 0.0 + }, + "pinned_build_system": "", + "project": "Solutions.sublime-project", + "replace": + { + "height": 46.0 + }, + "save_all_on_build": true, + "select_file": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + [ + "", + "~/Dropbox/github/Python-programming-exercises/my_solutions/Solution3problem.py" + ] + ], + "width": 0.0 + }, + "select_project": + { + "height": 500.0, + "last_filter": "", + "selected_items": + [ + [ + "", + "~/Dropbox/github/Python-programming-exercises/my_solutions/Solutions.sublime-project" + ], + [ + "sol", + "~/Dropbox/github/Python-programming-exercises/Solutions.sublime-project" + ], + [ + "solution", + "~/Dropbox/github/Python-programming-exercises/Solutions.sublime-project" + ] + ], + "width": 380.0 + }, + "select_symbol": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 0.0 + }, + "selected_group": 3, + "settings": + { + "last_automatic_layout": + [ + [ + 0, + 0, + 1, + 3 + ], + [ + 1, + 0, + 2, + 1 + ], + [ + 1, + 1, + 2, + 2 + ], + [ + 1, + 2, + 2, + 3 + ] + ] + }, + "show_minimap": false, + "show_open_files": true, + "show_tabs": true, + "side_bar_visible": false, + "side_bar_width": 120.0, + "status_bar_visible": true, + "template_settings": + { + } +} diff --git a/my_solutions/Solution2.py b/my_solutions/Solution2.py new file mode 100644 index 00000000..d08ab58a --- /dev/null +++ b/my_solutions/Solution2.py @@ -0,0 +1,46 @@ +''' +Working I/O Template + + +Problem Statement +This is an introductory challenge. The purpose of this challenge is to give you a working I/O template in your preferred language. It includes scanning two integers from STDIN, calling a function, +returning a value, and printing it to STDOUT. + +The task is to scan two numbers from STDIN, and print the sum A+B on STDOUT. The code has already been provided for most of the popular languages. This is primarily for you to read +and inspect how the IO is handled. + + +Note: The code has been saved in a template, which you can submit if you want. Or, you may try rewriting it and building it up from scratch. + +Input Format +(This section specifies the Input Format.) +Given A and B on two different lines. + +Output Format +(This section specifies the Output Format.) +An integer that denotes Sum (A+B) +Constraints +(This section tells what input you can expect. You can freely assume that the input will remain within the boundaries specified. +As an example here given below, A and B will never be below 1 or above 1000.) +1≤A,B≤1000 +Sample Input + +2 +3 + + +Sample Output + +5 +The above sample should be taken seriously. The input will be 2 and 3 in two separate lines, and the output should be just one number, 5. You should not print any whitespace at the beginning of output +(e.g. " 5" or "\n5"), unless specifically asked for. Also, printing any extra non-whitespace characters such as "The answer is: 5" will result in a Wrong Answer, as the judging is done using diff checker. +''' + +# STDIN means read input. + +def stdin(in1,in2): + a+b +print (5+5) +print (5+5) + +import seaborn as sns \ No newline at end of file diff --git a/my_solutions/Solution3problem.py b/my_solutions/Solution3problem.py new file mode 100644 index 00000000..bfe49cf7 --- /dev/null +++ b/my_solutions/Solution3problem.py @@ -0,0 +1,3 @@ +Solution3problem.py + +'hi' \ No newline at end of file diff --git a/my_solutions/Solutions.sublime-project b/my_solutions/Solutions.sublime-project new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/my_solutions/Solutions.sublime-project @@ -0,0 +1,2 @@ +{ +} diff --git a/my_solutions/Solutions.sublime-workspace b/my_solutions/Solutions.sublime-workspace new file mode 100644 index 00000000..d399ebf2 --- /dev/null +++ b/my_solutions/Solutions.sublime-workspace @@ -0,0 +1,542 @@ +{ + "auto_complete": + { + "selected_items": + [ + ] + }, + "buffers": + [ + { + "file": "Solution2.py", + "settings": + { + "buffer_size": 1615, + "line_ending": "Unix", + "name": "Solution2.py" + } + }, + { + "contents": "#SHORTCUTS\nctrl+,, s Selection\nctrl+,, f File\nctrl+,, l Lines\nctrl+,, b Block", + "settings": + { + "buffer_size": 77, + "line_ending": "Unix", + "name": "#SHORTCUTS" + } + }, + { + "contents": "Python 2.7.6 (default, Sep 9 2014, 15:04:36) \n[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n(InteractiveConsole)\n>>> 10\n>>> ", + "settings": + { + "buffer_size": 215, + "line_ending": "Unix", + "name": "*REPL* [python]", + "scratch": true + } + }, + { + "contents": "bash: no job control in this shell\nbash-3.2$ \nbash-3.2$ \nbash-3.2$ ls\nSublimeREPL\nUser\nbz2\nbash-3.2$ \nbash-3.2$ \nbash-3.2$ ls\nSublimeREPL\nUser\nbz2\nbash-3.2$ cd\nbash-3.2$ ls\nAnaconda\nApplications\nDesktop\nDocuments\nDownloads\nDropbox\nGoogle Drive\nLibrary\nMovies\nMusic\nPictures\nPublic\nbash-3.2$ cd\nbash-3.2$ ls\nAnaconda\nApplications\nDesktop\nDocuments\nDownloads\nDropbox\nGoogle Drive\nLibrary\nMovies\nMusic\nPictures\nPublic\nbash-3.2$ lcd\nbash: lcd: command not found\nbash-3.2$ \nbash-3.2$ \nbash-3.2$ cd\nbash-3.2$ ls\nAnaconda\nApplications\nDesktop\nDocuments\nDownloads\nDropbox\nGoogle Drive\nLibrary\nMovies\nMusic\nPictures\nPublic\nbash-3.2$ ", + "settings": + { + "buffer_size": 624, + "line_ending": "Unix", + "name": "*REPL* [shell]", + "scratch": true + } + } + ], + "build_system": "", + "build_system_choices": + [ + ], + "build_varint": "", + "command_palette": + { + "height": 392.0, + "last_filter": "", + "selected_items": + [ + [ + "sublimerepl", + "Build With: sublimerepl_build_system_hack" + ], + [ + "Package Control: Install Package", + "Package Control: Install Package" + ], + [ + "", + "Build With: Python - Syntax Check" + ] + ], + "width": 449.0 + }, + "console": + { + "height": 116.0, + "history": + [ + "stdin(1,2)", + "5+5", + "5_5", + "5+5" + ] + }, + "distraction_free": + { + "menu_visible": true, + "show_minimap": false, + "show_open_files": false, + "show_tabs": false, + "side_bar_visible": false, + "status_bar_visible": false + }, + "file_history": + [ + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/SublimeREPL.sublime-settings", + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/Default/Default (OSX).sublime-keymap", + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/SublimeREPL/SublimeREPL.sublime-settings", + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/Default (OSX).sublime-keymap", + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings", + "/Users/ChessTastic/Dropbox/github/Python-programming-exercises/my_solutions/Solution3problem.py", + "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/Default/Preferences.sublime-settings" + ], + "find": + { + "height": 35.0 + }, + "find_in_files": + { + "height": 93.0, + "where_history": + [ + ] + }, + "find_state": + { + "case_sensitive": false, + "find_history": + [ + "enter", + "Input", + "been", + "introductory", + "in1", + "stdin", + "b", + "section", + "c", + "section", + "python", + "github", + "git", + "users", + "chesstastic", + "sta", + "git", + "rafeh" + ], + "highlight": true, + "in_selection": false, + "preserve_case": false, + "regex": false, + "replace_history": + [ + ], + "reverse": false, + "show_context": true, + "use_buffer2": true, + "whole_word": false, + "wrap": true + }, + "groups": + [ + { + "selected": 0, + "sheets": + [ + { + "buffer": 0, + "file": "Solution2.py", + "semi_transient": false, + "settings": + { + "buffer_size": 1615, + "regions": + { + }, + "selection": + [ + [ + 283, + 283 + ] + ], + "settings": + { + "auto_name": "Solution2.py", + "syntax": "Packages/Python/Python.tmLanguage" + }, + "translation.x": 0.0, + "translation.y": 0.0, + "zoom_level": 1.0 + }, + "stack_index": 0, + "type": "text" + } + ] + }, + { + "selected": 0, + "sheets": + [ + { + "buffer": 1, + "semi_transient": false, + "settings": + { + "buffer_size": 77, + "regions": + { + }, + "selection": + [ + [ + 61, + 61 + ] + ], + "settings": + { + "auto_name": "#SHORTCUTS", + "syntax": "Packages/Text/Plain text.tmLanguage" + }, + "translation.x": 0.0, + "translation.y": 0.0, + "zoom_level": 1.0 + }, + "stack_index": 3, + "type": "text" + } + ] + }, + { + "selected": 1, + "sheets": + [ + { + "buffer": 2, + "semi_transient": false, + "settings": + { + "buffer_size": 215, + "regions": + { + }, + "selection": + [ + [ + 215, + 215 + ] + ], + "settings": + { + "auto_complete": true, + "auto_indent": false, + "detect_indentation": false, + "gutter": false, + "history_arrows": true, + "indent_subsequent_lines": false, + "line_numbers": false, + "repl": true, + "repl_external_id": "python", + "repl_id": "4d88d6a0b3bb4acca2ede1546124da94", + "repl_restart_args": + { + "autocomplete_server": true, + "cmd": + { + "linux": + [ + "python", + "-u", + "${packages}/SublimeREPL/config/Python/ipy_repl.py" + ], + "osx": + [ + "python", + "-u", + "${packages}/SublimeREPL/config/Python/ipy_repl.py" + ], + "windows": + [ + "python", + "-u", + "${packages}/SublimeREPL/config/Python/ipy_repl.py" + ] + }, + "cwd": "$file_path", + "encoding": "utf8", + "extend_env": + { + "PYTHONIOENCODING": "utf-8", + "SUBLIMEREPL_EDITOR": "subl -w" + }, + "external_id": "python", + "syntax": "Packages/Python/Python.tmLanguage", + "type": "subprocess" + }, + "repl_sublime2": false, + "smart_indent": false, + "spell_check": false, + "syntax": "Packages/Python/Python.tmLanguage", + "translate_tabs_to_spaces": false + }, + "translation.x": 0.0, + "translation.y": 0.0, + "zoom_level": 1.0 + }, + "stack_index": 2, + "type": "text" + }, + { + "buffer": 3, + "semi_transient": false, + "settings": + { + "buffer_size": 624, + "regions": + { + }, + "selection": + [ + [ + 624, + 624 + ] + ], + "settings": + { + "auto_complete": true, + "auto_indent": false, + "detect_indentation": false, + "gutter": false, + "history_arrows": true, + "indent_subsequent_lines": false, + "line_numbers": false, + "repl": true, + "repl_external_id": "shell", + "repl_id": "ea6bd8f743d4409ab94e14ae7977f5ff", + "repl_restart_args": + { + "cmd": + { + "linux": + [ + "bash", + "-i" + ], + "osx": + [ + "bash", + "-i" + ], + "windows": + [ + "cmd.exe" + ] + }, + "cmd_postfix": "\n", + "cwd": "$file_path", + "encoding": + { + "linux": "utf-8", + "osx": "utf-8", + "windows": "$win_cmd_encoding" + }, + "env": + { + }, + "external_id": "shell", + "suppress_echo": true, + "syntax": "Packages/Text/Plain text.tmLanguage", + "type": "subprocess" + }, + "repl_sublime2": false, + "smart_indent": false, + "spell_check": false, + "syntax": "Packages/Text/Plain text.tmLanguage", + "translate_tabs_to_spaces": false + }, + "translation.x": 0.0, + "translation.y": 0.0, + "zoom_level": 1.0 + }, + "stack_index": 1, + "type": "text" + } + ] + }, + { + "sheets": + [ + ] + } + ], + "incremental_find": + { + "height": 25.0 + }, + "input": + { + "height": 0.0 + }, + "layout": + { + "cells": + [ + [ + 0, + 0, + 1, + 3 + ], + [ + 1, + 0, + 2, + 1 + ], + [ + 1, + 1, + 2, + 2 + ], + [ + 1, + 2, + 2, + 3 + ] + ], + "cols": + [ + 0.0, + 0.713671875, + 1.0 + ], + "rows": + [ + 0.0, + 0.107785888078, + 0.963503649635, + 1.0 + ] + }, + "menu_visible": true, + "output.exec": + { + "height": 28.0 + }, + "output.find_results": + { + "height": 0.0 + }, + "pinned_build_system": "", + "project": "Solutions.sublime-project", + "replace": + { + "height": 46.0 + }, + "save_all_on_build": true, + "select_file": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + [ + "", + "~/Dropbox/github/Python-programming-exercises/my_solutions/Solution3problem.py" + ] + ], + "width": 0.0 + }, + "select_project": + { + "height": 500.0, + "last_filter": "", + "selected_items": + [ + [ + "", + "~/Dropbox/github/Python-programming-exercises/my_solutions/Solutions.sublime-project" + ], + [ + "repl", + "~/Dropbox/github/Python-programming-exercises/Solutions.sublime-project" + ], + [ + "sol", + "~/Dropbox/github/Python-programming-exercises/Solutions.sublime-project" + ], + [ + "solution", + "~/Dropbox/github/Python-programming-exercises/Solutions.sublime-project" + ] + ], + "width": 380.0 + }, + "select_symbol": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 0.0 + }, + "selected_group": 3, + "settings": + { + "last_automatic_layout": + [ + [ + 0, + 0, + 1, + 3 + ], + [ + 1, + 0, + 2, + 1 + ], + [ + 1, + 1, + 2, + 2 + ], + [ + 1, + 2, + 2, + 3 + ] + ] + }, + "show_minimap": true, + "show_open_files": true, + "show_tabs": true, + "side_bar_visible": false, + "side_bar_width": 120.0, + "status_bar_visible": true, + "template_settings": + { + } +} diff --git a/my_solutions/Sublime Shortcus.md b/my_solutions/Sublime Shortcus.md new file mode 100644 index 00000000..dd1de4d3 --- /dev/null +++ b/my_solutions/Sublime Shortcus.md @@ -0,0 +1,5 @@ +#SHORTCUTS +ctrl+,, s Selection +ctrl+,, f File +ctrl+,, l Lines +ctrl+,, b Block diff --git a/my_solutions/__pycache__/Solution2.cpython-34.pyc b/my_solutions/__pycache__/Solution2.cpython-34.pyc new file mode 100644 index 0000000000000000000000000000000000000000..02b044ed2bcbe8d6de9d9f84687eccbc9183a10b GIT binary patch literal 339 zcmYjNO-lnY5S{FYmAali3wl_v2749}>%~hI)`IjR`w?~{-DJt6&^_y)@gJ33J@w)b z@Z@9>>5%v4Wq3m#`A&|<^~H8^cL4AOdliztCEzKM0C;1-Du9Z?2f#7_5keKgyPt-T zrEwXM&zJ8WGXf?=mJWjxzn!IQo(7KPjuq5HsjfUtKf%Q0{CVLE6bAXM5s1$@T3PaY zqq{EsTK01lvx_+>@xHD4OA>SU+cY!;+ZgsU@i5o^YjEF{ON%#wn CSx)Hy literal 0 HcmV?d00001 diff --git a/my_solutions/empty.sublime-workspace b/my_solutions/empty.sublime-workspace new file mode 100644 index 00000000..f0598317 --- /dev/null +++ b/my_solutions/empty.sublime-workspace @@ -0,0 +1,176 @@ +{ + "auto_complete": + { + "selected_items": + [ + ] + }, + "buffers": + [ + ], + "build_system": "", + "build_system_choices": + [ + ], + "build_varint": "", + "command_palette": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 0.0 + }, + "console": + { + "height": 0.0, + "history": + [ + ] + }, + "distraction_free": + { + "menu_visible": true, + "show_minimap": false, + "show_open_files": false, + "show_tabs": false, + "side_bar_visible": false, + "status_bar_visible": false + }, + "file_history": + [ + ], + "find": + { + "height": 23.0 + }, + "find_in_files": + { + "height": 0.0, + "where_history": + [ + ] + }, + "find_state": + { + "case_sensitive": false, + "find_history": + [ + "python", + "github", + "git", + "users", + "chesstastic", + "sta", + "git", + "rafeh" + ], + "highlight": true, + "in_selection": false, + "preserve_case": false, + "regex": false, + "replace_history": + [ + ], + "reverse": false, + "show_context": true, + "use_buffer2": true, + "whole_word": false, + "wrap": true + }, + "groups": + [ + { + "sheets": + [ + ] + } + ], + "incremental_find": + { + "height": 23.0 + }, + "input": + { + "height": 0.0 + }, + "layout": + { + "cells": + [ + [ + 0, + 0, + 1, + 1 + ] + ], + "cols": + [ + 0.0, + 1.0 + ], + "rows": + [ + 0.0, + 1.0 + ] + }, + "menu_visible": true, + "output.find_results": + { + "height": 0.0 + }, + "pinned_build_system": "", + "project": "empty.sublime-project", + "replace": + { + "height": 42.0 + }, + "save_all_on_build": true, + "select_file": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 0.0 + }, + "select_project": + { + "height": 500.0, + "last_filter": "", + "selected_items": + [ + [ + "", + "~/Dropbox/github/SublimeProjects/GitHub.sublime-project" + ] + ], + "width": 380.0 + }, + "select_symbol": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 0.0 + }, + "selected_group": 0, + "settings": + { + }, + "show_minimap": true, + "show_open_files": false, + "show_tabs": true, + "side_bar_visible": true, + "side_bar_width": 120.0, + "status_bar_visible": true, + "template_settings": + { + } +} diff --git a/test1.txt b/test1.txt deleted file mode 100644 index e69de29b..00000000 From c5510b9b6d7aa370a248e414a78073016c1e4b45 Mon Sep 17 00:00:00 2001 From: QaziPython Date: Mon, 27 Jun 2016 05:14:20 -0500 Subject: [PATCH 35/40] Begin work on number guessing game from cse231 and ignore sublime files --- .gitignore | 140 +++++ Solutions.sublime-workspace | 527 ----------------- cse231/number_guessing_game.py | 78 +++ my_solutions/Solution2.py | 11 +- my_solutions/Solutions.sublime-workspace | 542 ------------------ my_solutions/ex3io.py | 46 ++ my_solutions/ex4arraymaps.py | 16 + .../exercise1; List Comprehensions.ipynb.py | 13 + 8 files changed, 299 insertions(+), 1074 deletions(-) create mode 100644 .gitignore delete mode 100644 Solutions.sublime-workspace create mode 100644 cse231/number_guessing_game.py delete mode 100644 my_solutions/Solutions.sublime-workspace create mode 100644 my_solutions/ex3io.py create mode 100644 my_solutions/ex4arraymaps.py create mode 100644 my_solutions/exercise1; List Comprehensions.ipynb.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..05aaa795 --- /dev/null +++ b/.gitignore @@ -0,0 +1,140 @@ +### Python template +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask instance folder +instance/ + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# IPython Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# dotenv +.env + +# virtualenv +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/workspace.xml +.idea/tasks.xml +.idea/dictionaries +.idea/vcs.xml +.idea/jsLibraryMappings.xml + +# Sensitive or high-churn files: +.idea/dataSources.ids +.idea/dataSources.xml +.idea/dataSources.local.xml +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# Gradle: +.idea/gradle.xml +.idea/libraries + +# Mongo Explorer plugin: +.idea/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Created by .ignore support plugin (hsz.mobi) + +# Sublime +*.sublime-project +*.sublime-workspace diff --git a/Solutions.sublime-workspace b/Solutions.sublime-workspace deleted file mode 100644 index 4e20d955..00000000 --- a/Solutions.sublime-workspace +++ /dev/null @@ -1,527 +0,0 @@ -{ - "auto_complete": - { - "selected_items": - [ - ] - }, - "buffers": - [ - { - "file": "my_solutions/Solution2.py", - "settings": - { - "buffer_size": 1622, - "line_ending": "Unix", - "name": "Solution2.py" - } - }, - { - "contents": "#SHORTCUTS\n[Key Sublime Shortcuts](http://webdesign.tutsplus.com/tutorials/useful-shortcuts-for-a-faster-workflow-in-sublime-text-3--cms-22185)\n\nctrl+,, s Selection\nctrl+,, f File\nctrl+,, l Lines\nctrl+,, b Block\nctrl+alt+b Run Python Terminal\ncmd+l Select Current Line\ncmd+shift+g Multiple cursor on specifc keyword", - "file": "my_solutions/Sublime Shortcus.md", - "file_size": 78, - "file_write_time": 130847121740000000, - "settings": - { - "buffer_size": 316, - "line_ending": "Unix", - "name": "#SHORTCUTS" - } - }, - { - "contents": "Python 2.7.6 (default, Sep 9 2014, 15:04:36) \n[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> 5+5\n10\n>>> ", - "settings": - { - "buffer_size": 198, - "line_ending": "Unix", - "name": "*REPL* [python]", - "scratch": true - } - }, - { - "contents": "bash: no job control in this shell\nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ ls\nSolution2.py\nSolution3problem.py\nSolutions.sublime-project\nSolutions.sublime-workspace\nSublime Shortcus.md\n__pycache__\nempty.sublime-workspace\nempty.txt\nbash-3.2$ ls\nSolution2.py\nSolution3problem.py\nSolutions.sublime-project\nSolutions.sublime-workspace\nSublime Shortcus.md\n__pycache__\nempty.sublime-workspace\nempty.txt\nbash-3.2$ alias\nbash-3.2$ \nbash-3.2$ \nbash-3.2$ \nbash-3.2$ ls\nSolution2.py\nSolution3problem.py\nSolutions.sublime-project\nSolutions.sublime-workspace\nSublime Shortcus.md\n__pycache__\nempty.sublime-workspace\nempty.txt\nbash-3.2$ cd dropbox\nbash: cd: dropbox: No such file or directory\nbash-3.2$ ls\nSolution2.py\nSolution3problem.py\nSolutions.sublime-project\nSolutions.sublime-workspace\nSublime Shortcus.md\n__pycache__\nempty.sublime-workspace\nempty.txt\nbash-3.2$ cd ..\nbash-3.2$ ls\n100+ Python challenging programming exercises.md\nREADME.md\nSolutions.sublime-project\nSolutions.sublime-workspace\nmarkdown-here.wiki\nmy_solutions\npython contents.docx\npython contents.txt\nbash-3.2$ cd\nbash-3.2$ ls\nAnaconda\nApplications\nDesktop\nDocuments\nDownloads\nDropbox\nGoogle Drive\nLibrary\nMovies\nMusic\nPictures\nPublic\nbash-3.2$ cd dropbox\nbash-3.2$ ls\nApps\nCalculus One\nCamera Uploads\nClosed sicillian attack.pgn\nDROP SYNC\nDad Work\nHive-1BJ4G\nIcon \nLightroom Exports\nMiscellenous\nNew Game.pgn\nPsych Pics\nScreenshots\ndatajoy\ngithub\nipython notebooks\nmohsen1.github.io\nbash-3.2$ ll\nbash: ll: command not found\nbash-3.2$ ll\nbash: ll: command not found\nbash-3.2$ cd github\nbash-3.2$ ls\nCisco\nGalvanize\nGithub_Tips_Tricks\nIPython-notebooks\nPython-programming-exercises\nSublimeProjects\nbootstrap\npython-programs\nrafeh01.github.io\nscript\nbash-3.2$ ", - "settings": - { - "buffer_size": 2060, - "line_ending": "Unix", - "name": "*REPL* [shell]", - "read_only": true, - "scratch": true - } - } - ], - "build_system": "", - "build_system_choices": - [ - ], - "build_varint": "", - "command_palette": - { - "height": 392.0, - "last_filter": "", - "selected_items": - [ - [ - "sublimerepl", - "Build With: sublimerepl_build_system_hack" - ], - [ - "Package Control: Install Package", - "Package Control: Install Package" - ], - [ - "", - "Build With: Python - Syntax Check" - ] - ], - "width": 449.0 - }, - "console": - { - "height": 116.0, - "history": - [ - "stdin(1,2)", - "5+5", - "5_5", - "5+5" - ] - }, - "distraction_free": - { - "menu_visible": true, - "show_minimap": false, - "show_open_files": false, - "show_tabs": false, - "side_bar_visible": false, - "status_bar_visible": false - }, - "file_history": - [ - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/Default (OSX).sublime-keymap", - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/SublimeREPL.sublime-settings", - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/Default/Default (OSX).sublime-keymap", - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/SublimeREPL/SublimeREPL.sublime-settings", - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings", - "/Users/ChessTastic/Dropbox/github/Python-programming-exercises/my_solutions/Solution3problem.py", - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/Default/Preferences.sublime-settings" - ], - "find": - { - "height": 35.0 - }, - "find_in_files": - { - "height": 93.0, - "where_history": - [ - ] - }, - "find_state": - { - "case_sensitive": false, - "find_history": - [ - "enter", - "Input", - "been", - "introductory", - "in1", - "stdin", - "b", - "section", - "c", - "section", - "python", - "github", - "git", - "users", - "chesstastic", - "sta", - "git", - "rafeh" - ], - "highlight": true, - "in_selection": false, - "preserve_case": false, - "regex": false, - "replace_history": - [ - ], - "reverse": false, - "show_context": true, - "use_buffer2": true, - "whole_word": false, - "wrap": true - }, - "groups": - [ - { - "selected": 0, - "sheets": - [ - { - "buffer": 0, - "file": "my_solutions/Solution2.py", - "semi_transient": false, - "settings": - { - "buffer_size": 1622, - "regions": - { - }, - "selection": - [ - [ - 1622, - 1622 - ] - ], - "settings": - { - "auto_name": "Solution2.py", - "syntax": "Packages/Python/Python.tmLanguage" - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 0, - "type": "text" - } - ] - }, - { - "selected": 0, - "sheets": - [ - { - "buffer": 1, - "file": "my_solutions/Sublime Shortcus.md", - "semi_transient": false, - "settings": - { - "buffer_size": 316, - "regions": - { - }, - "selection": - [ - [ - 316, - 316 - ] - ], - "settings": - { - "auto_name": "#SHORTCUTS", - "syntax": "Packages/Markdown/Markdown.tmLanguage" - }, - "translation.x": 0.0, - "translation.y": 57.0, - "zoom_level": 1.0 - }, - "stack_index": 2, - "type": "text" - } - ] - }, - { - "selected": 0, - "sheets": - [ - { - "buffer": 2, - "semi_transient": false, - "settings": - { - "buffer_size": 198, - "regions": - { - }, - "selection": - [ - [ - 198, - 198 - ] - ], - "settings": - { - "auto_complete": true, - "auto_indent": false, - "detect_indentation": false, - "gutter": false, - "history_arrows": true, - "indent_subsequent_lines": false, - "line_numbers": false, - "repl": true, - "repl_external_id": "python", - "repl_id": "c8dc5b7b676f42989a320c214ab28112", - "repl_restart_args": - { - "cmd": - [ - "python", - "-i", - "-u" - ], - "cwd": "$file_path", - "encoding": "utf8", - "extend_env": - { - "PYTHONIOENCODING": "utf-8" - }, - "external_id": "python", - "syntax": "Packages/Python/Python.tmLanguage", - "type": "subprocess" - }, - "repl_sublime2": false, - "smart_indent": false, - "spell_check": false, - "syntax": "Packages/Python/Python.tmLanguage", - "translate_tabs_to_spaces": false - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 3, - "type": "text" - } - ] - }, - { - "selected": 0, - "sheets": - [ - { - "buffer": 3, - "semi_transient": false, - "settings": - { - "buffer_size": 2060, - "regions": - { - }, - "selection": - [ - [ - 1749, - 1749 - ] - ], - "settings": - { - "auto_complete": true, - "auto_indent": false, - "detect_indentation": false, - "gutter": false, - "history_arrows": true, - "indent_subsequent_lines": false, - "line_numbers": false, - "repl": true, - "repl_external_id": "shell", - "repl_id": "44fa0f2297b04464b5d5b154ffe0e1a1", - "repl_restart_args": - { - "cmd": - { - "linux": - [ - "bash", - "-i" - ], - "osx": - [ - "bash", - "-i" - ], - "windows": - [ - "cmd.exe" - ] - }, - "cmd_postfix": "\n", - "cwd": "$file_path", - "encoding": - { - "linux": "utf-8", - "osx": "utf-8", - "windows": "$win_cmd_encoding" - }, - "env": - { - }, - "external_id": "shell", - "suppress_echo": true, - "syntax": "Packages/Text/Plain text.tmLanguage", - "type": "subprocess" - }, - "repl_sublime2": false, - "smart_indent": false, - "spell_check": false, - "syntax": "Packages/Text/Plain text.tmLanguage", - "translate_tabs_to_spaces": false - }, - "translation.x": 0.0, - "translation.y": 2007.0, - "zoom_level": 1.0 - }, - "stack_index": 1, - "type": "text" - } - ] - } - ], - "incremental_find": - { - "height": 25.0 - }, - "input": - { - "height": 0.0 - }, - "layout": - { - "cells": - [ - [ - 0, - 0, - 1, - 3 - ], - [ - 1, - 0, - 2, - 1 - ], - [ - 1, - 1, - 2, - 2 - ], - [ - 1, - 2, - 2, - 3 - ] - ], - "cols": - [ - 0.0, - 0.740640258789, - 1.0 - ], - "rows": - [ - 0.0, - 0.143552311436, - 0.63896080444, - 1.0 - ] - }, - "menu_visible": true, - "output.exec": - { - "height": 28.0 - }, - "output.find_results": - { - "height": 0.0 - }, - "pinned_build_system": "", - "project": "Solutions.sublime-project", - "replace": - { - "height": 46.0 - }, - "save_all_on_build": true, - "select_file": - { - "height": 0.0, - "last_filter": "", - "selected_items": - [ - [ - "", - "~/Dropbox/github/Python-programming-exercises/my_solutions/Solution3problem.py" - ] - ], - "width": 0.0 - }, - "select_project": - { - "height": 500.0, - "last_filter": "", - "selected_items": - [ - [ - "", - "~/Dropbox/github/Python-programming-exercises/my_solutions/Solutions.sublime-project" - ], - [ - "sol", - "~/Dropbox/github/Python-programming-exercises/Solutions.sublime-project" - ], - [ - "solution", - "~/Dropbox/github/Python-programming-exercises/Solutions.sublime-project" - ] - ], - "width": 380.0 - }, - "select_symbol": - { - "height": 0.0, - "last_filter": "", - "selected_items": - [ - ], - "width": 0.0 - }, - "selected_group": 3, - "settings": - { - "last_automatic_layout": - [ - [ - 0, - 0, - 1, - 3 - ], - [ - 1, - 0, - 2, - 1 - ], - [ - 1, - 1, - 2, - 2 - ], - [ - 1, - 2, - 2, - 3 - ] - ] - }, - "show_minimap": false, - "show_open_files": true, - "show_tabs": true, - "side_bar_visible": false, - "side_bar_width": 120.0, - "status_bar_visible": true, - "template_settings": - { - } -} diff --git a/cse231/number_guessing_game.py b/cse231/number_guessing_game.py new file mode 100644 index 00000000..a6315784 --- /dev/null +++ b/cse231/number_guessing_game.py @@ -0,0 +1,78 @@ +""" +number_guessing_game.py + +Author: Rafeh Qazi + +Modified: June 2016 + +Copyright (C) 2016 Rafeh Qazi +""" + + +def is_good_number(number): + """ + Let's a user know whether a number is properly formed. + Each number should be 5 digits long and should not repeat numbers. + + >>> is_good_number(12345) + True + >>> is_good_number(55432) + False + >>> is_good_number(444) + False + + :param number: int + :return: boolean + """ + if not number: + return False + if len(str(number)) != 5: + return False + for num in str(number): + if str(number).count(num) > 1: + return False + return True + + +def error_message(): + """ + Print an error message based on an ill formed number. + :return: str + """ + pass + + +def blank_lines(): + """ + Print blank lines on a successfully formed number. + :return: str + """ + pass + + +def get_number(): + """ + Ask the user for their number. + :return: str + """ + pass + + +def report_results(user_number, secret_number): + """ + Report how many digits are correct. + Report how many digits are in correct position. + + >>> report_results(54321, 12345) + 'Digits correct: 5' + 'Digits in correct position: 0' + + :return: str + """ + pass + + +if __name__ == '__main__': + import doctest + + doctest.testmod() diff --git a/my_solutions/Solution2.py b/my_solutions/Solution2.py index d08ab58a..c79ce8c8 100644 --- a/my_solutions/Solution2.py +++ b/my_solutions/Solution2.py @@ -38,9 +38,10 @@ # STDIN means read input. -def stdin(in1,in2): - a+b -print (5+5) -print (5+5) +def solveMeFirst(a,b): + return (a+b) -import seaborn as sns \ No newline at end of file +user1 = int(raw_input("Put your number here: ")) +user2 = int(raw_input("Put your number here: ")) + +print(solveMeFirst(user1, user2)) diff --git a/my_solutions/Solutions.sublime-workspace b/my_solutions/Solutions.sublime-workspace deleted file mode 100644 index d399ebf2..00000000 --- a/my_solutions/Solutions.sublime-workspace +++ /dev/null @@ -1,542 +0,0 @@ -{ - "auto_complete": - { - "selected_items": - [ - ] - }, - "buffers": - [ - { - "file": "Solution2.py", - "settings": - { - "buffer_size": 1615, - "line_ending": "Unix", - "name": "Solution2.py" - } - }, - { - "contents": "#SHORTCUTS\nctrl+,, s Selection\nctrl+,, f File\nctrl+,, l Lines\nctrl+,, b Block", - "settings": - { - "buffer_size": 77, - "line_ending": "Unix", - "name": "#SHORTCUTS" - } - }, - { - "contents": "Python 2.7.6 (default, Sep 9 2014, 15:04:36) \n[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n(InteractiveConsole)\n>>> 10\n>>> ", - "settings": - { - "buffer_size": 215, - "line_ending": "Unix", - "name": "*REPL* [python]", - "scratch": true - } - }, - { - "contents": "bash: no job control in this shell\nbash-3.2$ \nbash-3.2$ \nbash-3.2$ ls\nSublimeREPL\nUser\nbz2\nbash-3.2$ \nbash-3.2$ \nbash-3.2$ ls\nSublimeREPL\nUser\nbz2\nbash-3.2$ cd\nbash-3.2$ ls\nAnaconda\nApplications\nDesktop\nDocuments\nDownloads\nDropbox\nGoogle Drive\nLibrary\nMovies\nMusic\nPictures\nPublic\nbash-3.2$ cd\nbash-3.2$ ls\nAnaconda\nApplications\nDesktop\nDocuments\nDownloads\nDropbox\nGoogle Drive\nLibrary\nMovies\nMusic\nPictures\nPublic\nbash-3.2$ lcd\nbash: lcd: command not found\nbash-3.2$ \nbash-3.2$ \nbash-3.2$ cd\nbash-3.2$ ls\nAnaconda\nApplications\nDesktop\nDocuments\nDownloads\nDropbox\nGoogle Drive\nLibrary\nMovies\nMusic\nPictures\nPublic\nbash-3.2$ ", - "settings": - { - "buffer_size": 624, - "line_ending": "Unix", - "name": "*REPL* [shell]", - "scratch": true - } - } - ], - "build_system": "", - "build_system_choices": - [ - ], - "build_varint": "", - "command_palette": - { - "height": 392.0, - "last_filter": "", - "selected_items": - [ - [ - "sublimerepl", - "Build With: sublimerepl_build_system_hack" - ], - [ - "Package Control: Install Package", - "Package Control: Install Package" - ], - [ - "", - "Build With: Python - Syntax Check" - ] - ], - "width": 449.0 - }, - "console": - { - "height": 116.0, - "history": - [ - "stdin(1,2)", - "5+5", - "5_5", - "5+5" - ] - }, - "distraction_free": - { - "menu_visible": true, - "show_minimap": false, - "show_open_files": false, - "show_tabs": false, - "side_bar_visible": false, - "status_bar_visible": false - }, - "file_history": - [ - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/SublimeREPL.sublime-settings", - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/Default/Default (OSX).sublime-keymap", - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/SublimeREPL/SublimeREPL.sublime-settings", - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/Default (OSX).sublime-keymap", - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings", - "/Users/ChessTastic/Dropbox/github/Python-programming-exercises/my_solutions/Solution3problem.py", - "/Users/ChessTastic/Library/Application Support/Sublime Text 3/Packages/Default/Preferences.sublime-settings" - ], - "find": - { - "height": 35.0 - }, - "find_in_files": - { - "height": 93.0, - "where_history": - [ - ] - }, - "find_state": - { - "case_sensitive": false, - "find_history": - [ - "enter", - "Input", - "been", - "introductory", - "in1", - "stdin", - "b", - "section", - "c", - "section", - "python", - "github", - "git", - "users", - "chesstastic", - "sta", - "git", - "rafeh" - ], - "highlight": true, - "in_selection": false, - "preserve_case": false, - "regex": false, - "replace_history": - [ - ], - "reverse": false, - "show_context": true, - "use_buffer2": true, - "whole_word": false, - "wrap": true - }, - "groups": - [ - { - "selected": 0, - "sheets": - [ - { - "buffer": 0, - "file": "Solution2.py", - "semi_transient": false, - "settings": - { - "buffer_size": 1615, - "regions": - { - }, - "selection": - [ - [ - 283, - 283 - ] - ], - "settings": - { - "auto_name": "Solution2.py", - "syntax": "Packages/Python/Python.tmLanguage" - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 0, - "type": "text" - } - ] - }, - { - "selected": 0, - "sheets": - [ - { - "buffer": 1, - "semi_transient": false, - "settings": - { - "buffer_size": 77, - "regions": - { - }, - "selection": - [ - [ - 61, - 61 - ] - ], - "settings": - { - "auto_name": "#SHORTCUTS", - "syntax": "Packages/Text/Plain text.tmLanguage" - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 3, - "type": "text" - } - ] - }, - { - "selected": 1, - "sheets": - [ - { - "buffer": 2, - "semi_transient": false, - "settings": - { - "buffer_size": 215, - "regions": - { - }, - "selection": - [ - [ - 215, - 215 - ] - ], - "settings": - { - "auto_complete": true, - "auto_indent": false, - "detect_indentation": false, - "gutter": false, - "history_arrows": true, - "indent_subsequent_lines": false, - "line_numbers": false, - "repl": true, - "repl_external_id": "python", - "repl_id": "4d88d6a0b3bb4acca2ede1546124da94", - "repl_restart_args": - { - "autocomplete_server": true, - "cmd": - { - "linux": - [ - "python", - "-u", - "${packages}/SublimeREPL/config/Python/ipy_repl.py" - ], - "osx": - [ - "python", - "-u", - "${packages}/SublimeREPL/config/Python/ipy_repl.py" - ], - "windows": - [ - "python", - "-u", - "${packages}/SublimeREPL/config/Python/ipy_repl.py" - ] - }, - "cwd": "$file_path", - "encoding": "utf8", - "extend_env": - { - "PYTHONIOENCODING": "utf-8", - "SUBLIMEREPL_EDITOR": "subl -w" - }, - "external_id": "python", - "syntax": "Packages/Python/Python.tmLanguage", - "type": "subprocess" - }, - "repl_sublime2": false, - "smart_indent": false, - "spell_check": false, - "syntax": "Packages/Python/Python.tmLanguage", - "translate_tabs_to_spaces": false - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 2, - "type": "text" - }, - { - "buffer": 3, - "semi_transient": false, - "settings": - { - "buffer_size": 624, - "regions": - { - }, - "selection": - [ - [ - 624, - 624 - ] - ], - "settings": - { - "auto_complete": true, - "auto_indent": false, - "detect_indentation": false, - "gutter": false, - "history_arrows": true, - "indent_subsequent_lines": false, - "line_numbers": false, - "repl": true, - "repl_external_id": "shell", - "repl_id": "ea6bd8f743d4409ab94e14ae7977f5ff", - "repl_restart_args": - { - "cmd": - { - "linux": - [ - "bash", - "-i" - ], - "osx": - [ - "bash", - "-i" - ], - "windows": - [ - "cmd.exe" - ] - }, - "cmd_postfix": "\n", - "cwd": "$file_path", - "encoding": - { - "linux": "utf-8", - "osx": "utf-8", - "windows": "$win_cmd_encoding" - }, - "env": - { - }, - "external_id": "shell", - "suppress_echo": true, - "syntax": "Packages/Text/Plain text.tmLanguage", - "type": "subprocess" - }, - "repl_sublime2": false, - "smart_indent": false, - "spell_check": false, - "syntax": "Packages/Text/Plain text.tmLanguage", - "translate_tabs_to_spaces": false - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 1, - "type": "text" - } - ] - }, - { - "sheets": - [ - ] - } - ], - "incremental_find": - { - "height": 25.0 - }, - "input": - { - "height": 0.0 - }, - "layout": - { - "cells": - [ - [ - 0, - 0, - 1, - 3 - ], - [ - 1, - 0, - 2, - 1 - ], - [ - 1, - 1, - 2, - 2 - ], - [ - 1, - 2, - 2, - 3 - ] - ], - "cols": - [ - 0.0, - 0.713671875, - 1.0 - ], - "rows": - [ - 0.0, - 0.107785888078, - 0.963503649635, - 1.0 - ] - }, - "menu_visible": true, - "output.exec": - { - "height": 28.0 - }, - "output.find_results": - { - "height": 0.0 - }, - "pinned_build_system": "", - "project": "Solutions.sublime-project", - "replace": - { - "height": 46.0 - }, - "save_all_on_build": true, - "select_file": - { - "height": 0.0, - "last_filter": "", - "selected_items": - [ - [ - "", - "~/Dropbox/github/Python-programming-exercises/my_solutions/Solution3problem.py" - ] - ], - "width": 0.0 - }, - "select_project": - { - "height": 500.0, - "last_filter": "", - "selected_items": - [ - [ - "", - "~/Dropbox/github/Python-programming-exercises/my_solutions/Solutions.sublime-project" - ], - [ - "repl", - "~/Dropbox/github/Python-programming-exercises/Solutions.sublime-project" - ], - [ - "sol", - "~/Dropbox/github/Python-programming-exercises/Solutions.sublime-project" - ], - [ - "solution", - "~/Dropbox/github/Python-programming-exercises/Solutions.sublime-project" - ] - ], - "width": 380.0 - }, - "select_symbol": - { - "height": 0.0, - "last_filter": "", - "selected_items": - [ - ], - "width": 0.0 - }, - "selected_group": 3, - "settings": - { - "last_automatic_layout": - [ - [ - 0, - 0, - 1, - 3 - ], - [ - 1, - 0, - 2, - 1 - ], - [ - 1, - 1, - 2, - 2 - ], - [ - 1, - 2, - 2, - 3 - ] - ] - }, - "show_minimap": true, - "show_open_files": true, - "show_tabs": true, - "side_bar_visible": false, - "side_bar_width": 120.0, - "status_bar_visible": true, - "template_settings": - { - } -} diff --git a/my_solutions/ex3io.py b/my_solutions/ex3io.py new file mode 100644 index 00000000..c40ad312 --- /dev/null +++ b/my_solutions/ex3io.py @@ -0,0 +1,46 @@ +ex3io.py + +Problem Statement + +You learnt about STDIN and STDOUT in Solve me first. + +This is the second challenge in the introduction series. The purpose of this challenge is to give you a working I/O template in your preferred language. It includes scanning two space-separated integers from STDIN in a loop over T lines, calling a function, returning a value, and printing it to STDOUT. + +A pseudo code looks like the following: + +read T +loop from 1 to T + read A and B + compute the sum + print value in a newline +end loop +The task is to scan two numbers from STDIN, and print the sum A+B on STDOUT. The code has already been provided for most of the popular languages. This is primarily for you to read and inspect how the IO is handled. + +Note: The code has been saved in a template, which you can submit if you want. Or, you may try rewriting it and building it up from scratch. + +Input Format +(This section specifies the Input Format.) +The first line contains T (number of test cases) followed by T lines +Each line contains A and B, separated by a space. + +As you can see that we have provided in advance the number of lines, we discourage the use of scanning till EOF as not every language has an easy way to handle that. In fact, every HackerRank challenge is designed in such a way that multitests begin with a T line to indicate the number of lines. + +Output Format +(This section specifies the Output Format.) +An integer that denotes Sum (A+B) printed on new line for every testcase. + +Constraints +(This section tells what input you can expect. You can freely assume that the input will remain within the boundaries specified.) +1≤T,A,B≤1000 + +Sample Input + +2 +2 3 +3 7 +Sample Output + +5 +10 +The above sample should be taken seriously. 2 in the first line describes how many lines will follow, and your test cases are 2, 3 and 3, 7 in two separate lines. Your output should be 5 and 10 printed on two separate lines. If you print extra lines or "The answer is: 5", any such extra characters in output will result in a Wrong Answer, as the judging is done using diff checker. + diff --git a/my_solutions/ex4arraymaps.py b/my_solutions/ex4arraymaps.py new file mode 100644 index 00000000..7575d4ab --- /dev/null +++ b/my_solutions/ex4arraymaps.py @@ -0,0 +1,16 @@ +''' + +ex4arraymapping.py + +Turn single-spaced numbers from strings to arrays of integers and then compute the sum. + +''' + +# [in] 6 +# [in] 1 2 3 4 5 6 +# [out] 21 + +n = input() +arr = map(int,raw_input().split()) #map integers to the strings. +print arr +print sum(arr) diff --git a/my_solutions/exercise1; List Comprehensions.ipynb.py b/my_solutions/exercise1; List Comprehensions.ipynb.py new file mode 100644 index 00000000..ad4baae4 --- /dev/null +++ b/my_solutions/exercise1; List Comprehensions.ipynb.py @@ -0,0 +1,13 @@ +# coding: utf-8 + + +''' +1st attempt at solution +for i in range(2000,3200): + if i % 7 == 0: + if i % 5 != 0: + print(i) +''' + +print ([i for i in range(2000,3200) if i % 7 == 0 and i % 5 != 0]) + From 0e61ffc031b1265cfb108038ca7ae65130f5daa6 Mon Sep 17 00:00:00 2001 From: QaziPython Date: Mon, 27 Jun 2016 05:30:15 -0500 Subject: [PATCH 36/40] Add doctest for player progress --- cse231/number_guessing_game.py | 41 +++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/cse231/number_guessing_game.py b/cse231/number_guessing_game.py index a6315784..ba7261c6 100644 --- a/cse231/number_guessing_game.py +++ b/cse231/number_guessing_game.py @@ -14,15 +14,15 @@ def is_good_number(number): Let's a user know whether a number is properly formed. Each number should be 5 digits long and should not repeat numbers. + :param number: int + :return: boolean + >>> is_good_number(12345) True >>> is_good_number(55432) False >>> is_good_number(444) False - - :param number: int - :return: boolean """ if not number: return False @@ -63,12 +63,43 @@ def report_results(user_number, secret_number): Report how many digits are correct. Report how many digits are in correct position. + :return: tuple + >>> report_results(54321, 12345) - 'Digits correct: 5' - 'Digits in correct position: 0' + (5, 0) + """ + return 5, 0 + pass + + +def player_progress(num_of_guesses, user_guess, correct_digits, correct_pos_digits): + """ + Report the player's current progress. + Nums of guesses, their guess, num of correct digits, + and num of digits in the correct position. + + :param num_of_guesses: int + :param user_guess: str + :param correct_digits: int + :param correct_pos_digits: int :return: str + + >>> player_progress(5, '12345', 4, 3) + ------------------------------ + Used guesses: 5 + User guess: 12345 + Digits correct: 4 + Digits in correct position: 3 + ------------------------------ """ + + print('------------------------------') + print('Used guesses: {}'.format(5)) + print('User guess: {}'.format('12345')) + print('Digits correct: {}'.format(4)) + print('Digits in correct position: {}'.format(3)) + print('------------------------------') pass From 91c5e1f1dfd1ecaae80800aa707be3b210216c57 Mon Sep 17 00:00:00 2001 From: QaziPython Date: Mon, 27 Jun 2016 05:35:45 -0500 Subject: [PATCH 37/40] Add signature and doctest for success_message function --- cse231/number_guessing_game.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/cse231/number_guessing_game.py b/cse231/number_guessing_game.py index ba7261c6..6cb53e04 100644 --- a/cse231/number_guessing_game.py +++ b/cse231/number_guessing_game.py @@ -37,7 +37,6 @@ def is_good_number(number): def error_message(): """ Print an error message based on an ill formed number. - :return: str """ pass @@ -45,7 +44,6 @@ def error_message(): def blank_lines(): """ Print blank lines on a successfully formed number. - :return: str """ pass @@ -83,7 +81,6 @@ def player_progress(num_of_guesses, user_guess, correct_digits, correct_pos_digi :param user_guess: str :param correct_digits: int :param correct_pos_digits: int - :return: str >>> player_progress(5, '12345', 4, 3) ------------------------------ @@ -95,12 +92,25 @@ def player_progress(num_of_guesses, user_guess, correct_digits, correct_pos_digi """ print('------------------------------') - print('Used guesses: {}'.format(5)) - print('User guess: {}'.format('12345')) - print('Digits correct: {}'.format(4)) - print('Digits in correct position: {}'.format(3)) + print('Used guesses: {}'.format(num_of_guesses)) + print('User guess: {}'.format(user_guess)) + print('Digits correct: {}'.format(correct_digits)) + print('Digits in correct position: {}'.format(correct_pos_digits)) print('------------------------------') - pass + + +def success_message(num_of_guesses): + """ + If user guesses number successfully, print how many guesses were used. + + :param num_of_guesses: int + + >>> success_message(5) + Congratulations! You have successfully guessed the secret number! + It took you 5 guesses to get it right! + """ + print('Congratulations! You have successfully guessed the secret number!') + print('It took you {} guesses to get it right!'.format(num_of_guesses)) if __name__ == '__main__': From 28690cee0fe6233323bf7c9e0ac4e17f1b27f69d Mon Sep 17 00:00:00 2001 From: QaziPython Date: Mon, 27 Jun 2016 05:41:03 -0500 Subject: [PATCH 38/40] Add signature for guesses_exceeded and doctest --- cse231/number_guessing_game.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cse231/number_guessing_game.py b/cse231/number_guessing_game.py index 6cb53e04..3ceb3930 100644 --- a/cse231/number_guessing_game.py +++ b/cse231/number_guessing_game.py @@ -101,7 +101,8 @@ def player_progress(num_of_guesses, user_guess, correct_digits, correct_pos_digi def success_message(num_of_guesses): """ - If user guesses number successfully, print how many guesses were used. + If user guesses the secret number successfully, + show how many guesses were used. :param num_of_guesses: int @@ -109,10 +110,30 @@ def success_message(num_of_guesses): Congratulations! You have successfully guessed the secret number! It took you 5 guesses to get it right! """ + print('Congratulations! You have successfully guessed the secret number!') print('It took you {} guesses to get it right!'.format(num_of_guesses)) +def guesses_exceeded(allowed_guesses, num_of_guesses): + """ + Set the maximum number of guesses and notify the user + that they lost when they exceed the limit. + + :param allowed_guesses: int + :param num_of_guesses: int + + >>> guesses_exceeded(5, 6) + Allowed guesses: 5 + Used guesses: 6 + You have exceeded your limit of guesses, you lose! + """ + + print('Allowed guesses: {}'.format(allowed_guesses)) + print('Used guesses: {}'.format(num_of_guesses)) + print('You have exceeded your limit of guesses, you lose!') + + if __name__ == '__main__': import doctest From 3cab87c6427c786265aaf63eb38d3e6c195f37ec Mon Sep 17 00:00:00 2001 From: QaziPython Date: Mon, 27 Jun 2016 06:28:56 -0500 Subject: [PATCH 39/40] Number guessing game complete --- cse231/number_guessing_game.py | 92 +++++++++++++++++++++++++++------- 1 file changed, 74 insertions(+), 18 deletions(-) diff --git a/cse231/number_guessing_game.py b/cse231/number_guessing_game.py index 3ceb3930..1d95cecb 100644 --- a/cse231/number_guessing_game.py +++ b/cse231/number_guessing_game.py @@ -14,23 +14,31 @@ def is_good_number(number): Let's a user know whether a number is properly formed. Each number should be 5 digits long and should not repeat numbers. - :param number: int + :param number: str :return: boolean - >>> is_good_number(12345) + >>> is_good_number('12345') True - >>> is_good_number(55432) + >>> is_good_number('55432') False - >>> is_good_number(444) + >>> is_good_number('444') False """ - if not number: + try: + int(number) + except ValueError: + error_message() + + if not int(number): return False - if len(str(number)) != 5: + + elif len(number) != 5: return False - for num in str(number): - if str(number).count(num) > 1: + + for num in number: + if number.count(num) > 1: return False + return True @@ -38,22 +46,30 @@ def error_message(): """ Print an error message based on an ill formed number. """ - pass + print('The number must be 5 digits long and should not repeat numbers.') + print('Please fix your number!\n\n') + return get_number() def blank_lines(): """ Print blank lines on a successfully formed number. """ - pass + print('--------------------------------------') + for _ in range(20): + print() def get_number(): """ - Ask the user for their number. + Ask the user for their number and retrieve that number. + :return: str """ - pass + user_input = input('Please enter your 5 digit number here:\n\n') + if is_good_number(user_input): + return user_input + return error_message() def report_results(user_number, secret_number): @@ -61,13 +77,27 @@ def report_results(user_number, secret_number): Report how many digits are correct. Report how many digits are in correct position. + :param user_number: str + :param secret_number: str :return: tuple - >>> report_results(54321, 12345) - (5, 0) + >>> report_results('54321', '12345') + (5, 1) + >>> report_results('25314', '23514') + (5, 3) """ - return 5, 0 - pass + correct_digits = 0 + correct_pos_digits = 0 + + for digit in user_number: + if digit in secret_number: + correct_digits += 1 + + for i in range(len(user_number)): + if user_number[i] == secret_number[i]: + correct_pos_digits += 1 + + return correct_digits, correct_pos_digits def player_progress(num_of_guesses, user_guess, correct_digits, correct_pos_digits): @@ -126,15 +156,41 @@ def guesses_exceeded(allowed_guesses, num_of_guesses): >>> guesses_exceeded(5, 6) Allowed guesses: 5 Used guesses: 6 - You have exceeded your limit of guesses, you lose! + You have exceeded your limit of guesses and you still did not get it correct, you lose! """ print('Allowed guesses: {}'.format(allowed_guesses)) print('Used guesses: {}'.format(num_of_guesses)) - print('You have exceeded your limit of guesses, you lose!') + print('You have exceeded your limit of guesses and you still did not get it correct, you lose!') + + +def win(user_number, secret_number): + return report_results(user_number, secret_number)[1] == len(secret_number) + + +def main(): + """ + Number guessing game logic + """ + max_guesses = int(input('Enter the max number of allowed guesses: ')) + secret_number = get_number() + num_of_guesses = 0 + blank_lines() + while (input('Press Q or q to quit, anything else to continue playing: ').lower()) != 'q': + guess = get_number() + num_of_guesses += 1 + correct_digits, correct_pos_digits = report_results(guess, secret_number) + player_progress(num_of_guesses, guess, correct_digits, correct_pos_digits) + + if win(guess, secret_number): + return success_message(num_of_guesses) + + if num_of_guesses > max_guesses: + return guesses_exceeded(max_guesses, num_of_guesses) if __name__ == '__main__': import doctest doctest.testmod() + main() From 1d525b54cca34ee38247891817c34747c1fb7508 Mon Sep 17 00:00:00 2001 From: QaziPython Date: Wed, 29 Jun 2016 02:53:55 -0500 Subject: [PATCH 40/40] Inefficient anagram solution needs to be replaced --- cse231/anagrams/anagrams.py | 38 +++++++++++++++++++++++++++++++ cse231/anagrams/shortWordList.txt | 19 ++++++++++++++++ cse231/number_guessing_game.py | 1 + 3 files changed, 58 insertions(+) create mode 100644 cse231/anagrams/anagrams.py create mode 100644 cse231/anagrams/shortWordList.txt diff --git a/cse231/anagrams/anagrams.py b/cse231/anagrams/anagrams.py new file mode 100644 index 00000000..ba7b840e --- /dev/null +++ b/cse231/anagrams/anagrams.py @@ -0,0 +1,38 @@ +""" +anagrams.py + +Author: Rafeh Qazi + +Modified: June 2016 + +Copyright (C) 2016 Rafeh Qazi +""" + +from collections import Counter + + +def read_file(file): + with open(file, 'r') as f: + return [word[:-1] for word in f] + + +file_data = read_file('shortWordList.txt') + +# print(file_data) +# +# for _ in range(5): +# print('\n') +# +# anagrams = [] +# for word_1 in file_data: +# file_data.pop(0) +# word_1_anagrams = [] +# for word_2 in file_data: +# if Counter(word_1) == Counter(word_2): +# if word_2 not in anagrams: +# word_1_anagrams.append(word_2) +# anagrams.append(word_2) +# if word_1_anagrams: +# print(word_1_anagrams) + +# print(anagrams) diff --git a/cse231/anagrams/shortWordList.txt b/cse231/anagrams/shortWordList.txt new file mode 100644 index 00000000..110db744 --- /dev/null +++ b/cse231/anagrams/shortWordList.txt @@ -0,0 +1,19 @@ +able +acre +bale +beyond +binary +boat +brainy +care +cat +cater +crate +lawn +list +race +react +sheet +silt +slit +trace diff --git a/cse231/number_guessing_game.py b/cse231/number_guessing_game.py index 1d95cecb..e6c9bc2f 100644 --- a/cse231/number_guessing_game.py +++ b/cse231/number_guessing_game.py @@ -100,6 +100,7 @@ def report_results(user_number, secret_number): return correct_digits, correct_pos_digits + def player_progress(num_of_guesses, user_guess, correct_digits, correct_pos_digits): """ Report the player's current progress.