aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2021-05-10 06:23:50 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2021-05-10 06:23:50 +0100
commitd262806c01dd2da390a1206452bd792715013c7b (patch)
treefda86f62df2f65b0be0520434e3b1f788b547b68
parent8d7193899988fae55b12ebaa1bf605a1f3c65b19 (diff)
downloadperlweeklychallenge-club-d262806c01dd2da390a1206452bd792715013c7b.tar.gz
perlweeklychallenge-club-d262806c01dd2da390a1206452bd792715013c7b.tar.bz2
perlweeklychallenge-club-d262806c01dd2da390a1206452bd792715013c7b.zip
- Added Python and Scala solutions by Laurent Rosenfeld.
-rw-r--r--challenge-111/laurent-rosenfeld/python/ch-1.py17
-rw-r--r--challenge-111/laurent-rosenfeld/scala/ch-1.scala24
2 files changed, 41 insertions, 0 deletions
diff --git a/challenge-111/laurent-rosenfeld/python/ch-1.py b/challenge-111/laurent-rosenfeld/python/ch-1.py
new file mode 100644
index 0000000000..5b7c24b282
--- /dev/null
+++ b/challenge-111/laurent-rosenfeld/python/ch-1.py
@@ -0,0 +1,17 @@
+matrix = ( [ 1, 2, 3, 5, 7 ],
+ [ 9, 11, 15, 19, 20 ],
+ [ 23, 24, 25, 29, 31 ],
+ [ 32, 33, 39, 40, 42 ],
+ [ 45, 47, 48, 49, 50 ]
+ );
+
+hash = {}
+for row in matrix:
+ for item in row:
+ hash[item] = 1
+
+for i in range(55):
+ if i in hash:
+ print(i, " => 1")
+ else:
+ print(i, " => 0")
diff --git a/challenge-111/laurent-rosenfeld/scala/ch-1.scala b/challenge-111/laurent-rosenfeld/scala/ch-1.scala
new file mode 100644
index 0000000000..ed29305a26
--- /dev/null
+++ b/challenge-111/laurent-rosenfeld/scala/ch-1.scala
@@ -0,0 +1,24 @@
+object SearchItem extends App {
+ val matrix = Array(
+ Array(1, 2, 3, 5, 7),
+ Array(9, 11, 15, 19, 20),
+ Array(23, 24, 25, 29, 31),
+ Array(32, 33, 39, 40, 42),
+ Array(45, 47, 48, 49, 50)
+ )
+
+ var hash = scala.collection.mutable.Map[Int, Int]()
+ for (row <- matrix) {
+ for (item <- row) {
+ hash(item) = 1
+ }
+ }
+
+ for (i <- 0 to 54) {
+ if (hash.contains(i)) {
+ println(s"$i => 1")
+ } else {
+ println(s"$i => 0")
+ }
+ }
+}