aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x2125/main.py26
-rwxr-xr-x2620/main.js18
-rwxr-xr-x2667/main.js14
3 files changed, 58 insertions, 0 deletions
diff --git a/2125/main.py b/2125/main.py
new file mode 100755
index 0000000..da45c29
--- /dev/null
+++ b/2125/main.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+
+import typing
+
+
+class Solution:
+ def numberOfBeams(self, bank: typing.List[str]) -> int:
+ row_count = 0
+ result = 0
+ for row in bank:
+ count = row.count("1")
+ if count != 0:
+ result += row_count * count
+ row_count = row.count("1")
+
+ return result
+
+
+def main():
+ solution = Solution()
+ print(solution.numberOfBeams(["011001", "000000", "010100", "00100"]))
+ print(solution.numberOfBeams(["000", "111", "000"]))
+
+
+if __name__ == "__main__":
+ main()
diff --git a/2620/main.js b/2620/main.js
new file mode 100755
index 0000000..da3ecbe
--- /dev/null
+++ b/2620/main.js
@@ -0,0 +1,18 @@
+#!/usr/bin/env node
+"use strict";
+
+/**
+ * @param {number} n
+ * @return {Function} counter
+ */
+var createCounter = function (n) {
+ var count = n;
+ return function () {
+ return count++;
+ };
+};
+
+const counter = createCounter(10);
+console.log(counter()); // 10
+console.log(counter()); // 11
+console.log(counter()); // 12
diff --git a/2667/main.js b/2667/main.js
new file mode 100755
index 0000000..d1a5a00
--- /dev/null
+++ b/2667/main.js
@@ -0,0 +1,14 @@
+#!/usr/bin/env node
+"strict mode";
+
+/**
+ * @return {Function}
+ */
+var createHelloWorld = function () {
+ return function (...args) {
+ return "Hello World";
+ };
+};
+
+const f = createHelloWorld([]);
+f(); // "Hello World"