aboutsummaryrefslogtreecommitdiff
path: root/challenge-046/user-person/python
diff options
context:
space:
mode:
authoruser-person <60802990+user-person@users.noreply.github.com>2020-02-09 02:47:33 -0500
committerGitHub <noreply@github.com>2020-02-09 02:47:33 -0500
commitb33db2590e7cee71bf44e66f6e3039c8a50d41e4 (patch)
tree0c8781233aa1908247296d9f93fe39dc01202e12 /challenge-046/user-person/python
parentf331ee909862825fb9c4d5d043723860d45dc4f2 (diff)
downloadperlweeklychallenge-club-b33db2590e7cee71bf44e66f6e3039c8a50d41e4.tar.gz
perlweeklychallenge-club-b33db2590e7cee71bf44e66f6e3039c8a50d41e4.tar.bz2
perlweeklychallenge-club-b33db2590e7cee71bf44e66f6e3039c8a50d41e4.zip
Create ch-2.py
Diffstat (limited to 'challenge-046/user-person/python')
-rw-r--r--challenge-046/user-person/python/ch-2.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-046/user-person/python/ch-2.py b/challenge-046/user-person/python/ch-2.py
new file mode 100644
index 0000000000..6032cf4b47
--- /dev/null
+++ b/challenge-046/user-person/python/ch-2.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+###########################################################################
+# script name: ch-2.py #
+# #
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-046/ #
+# #
+###########################################################################
+
+MAX = 500
+doors = ["CLOSED" for i in range(MAX+1)]
+
+def change (doorStatus):
+ returnString = "OPENED"
+ if doorStatus == "OPENED":
+ returnString = "CLOSED"
+ return returnString
+
+for i in range(1,MAX):
+ if i > MAX/2:
+ doors[i] = change(doors[i])
+ continue
+
+ for j in range(1,MAX):
+ if j % i == 0:
+ doors[j] = change(doors[j])
+
+for k in range(1,MAX):
+ if doors[k] == "OPENED":
+ print(k,end=" ")
+
+print()
+
+# ch-2.py output:
+# 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 441 484