From 9d1b14ab039aba2300b015bf89ac9b99cf6a41c2 Mon Sep 17 00:00:00 2001 From: Zeheng Li Date: Mon, 25 Nov 2024 03:17:13 -0700 Subject: [PATCH] add examples --- src/aldur.py | 2 ++ src/busassignment.lua | 8 ++++++++ src/busassignment.py | 7 +++++++ src/generalizedfizzbuzz.lua | 12 ++++++++++++ src/generalizedfizzbuzz.py | 10 ++++++++++ src/hairofthedog.py | 8 ++++++++ src/heysata.py | 3 +++ src/hornrett.py | 2 ++ src/intuitiveelements.py | 7 +++++++ src/mork.py | 6 ++++++ src/ruffians.py | 8 ++++++++ src/snowfall.lua | 10 ++++++++++ src/snowfall.py | 5 +++++ src/starwars2.py | 3 +++ src/telja.lua | 4 ++++ src/telja.py | 1 + src/welcomesign.py | 13 +++++++++++++ 17 files changed, 109 insertions(+) create mode 100644 src/aldur.py create mode 100644 src/busassignment.lua create mode 100644 src/busassignment.py create mode 100644 src/generalizedfizzbuzz.lua create mode 100644 src/generalizedfizzbuzz.py create mode 100644 src/hairofthedog.py create mode 100644 src/heysata.py create mode 100644 src/hornrett.py create mode 100644 src/intuitiveelements.py create mode 100644 src/mork.py create mode 100644 src/ruffians.py create mode 100644 src/snowfall.lua create mode 100644 src/snowfall.py create mode 100644 src/starwars2.py create mode 100644 src/telja.lua create mode 100644 src/telja.py create mode 100644 src/welcomesign.py diff --git a/src/aldur.py b/src/aldur.py new file mode 100644 index 00000000..1a1a3962 --- /dev/null +++ b/src/aldur.py @@ -0,0 +1,2 @@ +n = int(input()) +print(min(int(input()) for _ in range(n))) diff --git a/src/busassignment.lua b/src/busassignment.lua new file mode 100644 index 00000000..3bf2d6ea --- /dev/null +++ b/src/busassignment.lua @@ -0,0 +1,8 @@ +n = io.read("*n") +c, m = 0, 0 +for _ = 1, n do + a, b = io.read("*n", "*n") + c = c + b - a + m = math.max(m, c) +end +print(m) diff --git a/src/busassignment.py b/src/busassignment.py new file mode 100644 index 00000000..210daf74 --- /dev/null +++ b/src/busassignment.py @@ -0,0 +1,7 @@ +n = int(input()) +c, m = 0, 0 +for _ in range(n): + a, b = [int(d) for d in input().split()] + c += b - a + m = max(m, c) +print(m) diff --git a/src/generalizedfizzbuzz.lua b/src/generalizedfizzbuzz.lua new file mode 100644 index 00000000..968ed01c --- /dev/null +++ b/src/generalizedfizzbuzz.lua @@ -0,0 +1,12 @@ +n, a, b = io.read("*n", "*n", "*n") +fizzbuzz, fizz, buzz = 0, 0, 0 +for i = 1, n do + if i % a == 0 and i % b == 0 then + fizzbuzz = fizzbuzz + 1 + elseif i % a == 0 then + fizz = fizz + 1 + elseif i % b == 0 then + buzz = buzz + 1 + end +end +print(fizz, buzz, fizzbuzz) diff --git a/src/generalizedfizzbuzz.py b/src/generalizedfizzbuzz.py new file mode 100644 index 00000000..fafddd92 --- /dev/null +++ b/src/generalizedfizzbuzz.py @@ -0,0 +1,10 @@ +n, a, b = [int(d) for d in input().split()] +fizzbuzz, fizz, buzz = 0, 0, 0 +for i in range(1, n + 1): + if not i % a and not i % b: + fizzbuzz += 1 + elif not i % a: + fizz += 1 + elif not i % b: + buzz += 1 +print(fizz, buzz, fizzbuzz) diff --git a/src/hairofthedog.py b/src/hairofthedog.py new file mode 100644 index 00000000..e32ce3ee --- /dev/null +++ b/src/hairofthedog.py @@ -0,0 +1,8 @@ +n = int(input()) +s, d = "sober", 0 +for _ in range(n): + v = input() + if v == "drunk" and s != "drunk": + d += 1 + s = v +print(d) diff --git a/src/heysata.py b/src/heysata.py new file mode 100644 index 00000000..cfe98f8f --- /dev/null +++ b/src/heysata.py @@ -0,0 +1,3 @@ +input() +c = input() +print("Unnar fann hana!" if c in input() else "Unnar fann hana ekki!") diff --git a/src/hornrett.py b/src/hornrett.py new file mode 100644 index 00000000..95e776c0 --- /dev/null +++ b/src/hornrett.py @@ -0,0 +1,2 @@ +a, b, c = [int(d) for d in input().split()] +print(a * b // 2 if a * a + b * b == c * c else -1) diff --git a/src/intuitiveelements.py b/src/intuitiveelements.py new file mode 100644 index 00000000..3be7402f --- /dev/null +++ b/src/intuitiveelements.py @@ -0,0 +1,7 @@ +t = int(input()) +for _ in range(t): + a, b = input(), input() + if not set(b) - set(a): + print("YES") + else: + print("NO") diff --git a/src/mork.py b/src/mork.py new file mode 100644 index 00000000..f2c76b95 --- /dev/null +++ b/src/mork.py @@ -0,0 +1,6 @@ +n = int(input()) +m = int(input()) +if m == 0 or (m == 2 and n == 2): + print("Jebb") +else: + print("Neibb") diff --git a/src/ruffians.py b/src/ruffians.py new file mode 100644 index 00000000..0110a843 --- /dev/null +++ b/src/ruffians.py @@ -0,0 +1,8 @@ +t = int(input()) +for _ in range(t): + a, b, f = input().split(), input().split(), False + for i in range(5): + if a[i] in [b[j] for j in range(5) if i != j]: + f = True + break + print("YES" if f else "NO") diff --git a/src/snowfall.lua b/src/snowfall.lua new file mode 100644 index 00000000..0c7bff11 --- /dev/null +++ b/src/snowfall.lua @@ -0,0 +1,10 @@ +n, h = io.read("*n"), 0 +for _ = 1, n do + t, a = io.read("*n", "*n") + if t == 1 then + h = math.max(h - a, 0) + else + h = h + a + end +end +print(h) diff --git a/src/snowfall.py b/src/snowfall.py new file mode 100644 index 00000000..df55b661 --- /dev/null +++ b/src/snowfall.py @@ -0,0 +1,5 @@ +n, h = int(input()), 0 +for _ in range(n): + t, a = [int(d) for d in input().split()] + h = max(h - a, 0) if t else h + a +print(h) diff --git a/src/starwars2.py b/src/starwars2.py new file mode 100644 index 00000000..bbf2a71a --- /dev/null +++ b/src/starwars2.py @@ -0,0 +1,3 @@ +n = int(input()) +x = sorted(int(d) for d in input().split()) +print(*(x[n // 3 : -n // 3] + x[: n // 3] + x[-n // 3 :])) diff --git a/src/telja.lua b/src/telja.lua new file mode 100644 index 00000000..682a6e65 --- /dev/null +++ b/src/telja.lua @@ -0,0 +1,4 @@ +n = io.read("*n") +for i = 1, n do + print(i) +end diff --git a/src/telja.py b/src/telja.py new file mode 100644 index 00000000..d605ae44 --- /dev/null +++ b/src/telja.py @@ -0,0 +1 @@ +print(*range(1, int(input()) + 1)) diff --git a/src/welcomesign.py b/src/welcomesign.py new file mode 100644 index 00000000..b9ee5bec --- /dev/null +++ b/src/welcomesign.py @@ -0,0 +1,13 @@ +r, c = [int(d) for d in input().split()] +t = 0 +for i in range(r): + s = input() + p = (c - len(s)) // 2 + d = (c - len(s)) % 2 + if t % 2: + left, right = (p + d) * ".", p * "." + else: + right, left = (p + d) * ".", p * "." + if d: + t += 1 + print(left + s + right)