Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zehengl committed Nov 25, 2024
1 parent d8b5009 commit 9d1b14a
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/aldur.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
n = int(input())
print(min(int(input()) for _ in range(n)))
8 changes: 8 additions & 0 deletions src/busassignment.lua
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions src/busassignment.py
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 12 additions & 0 deletions src/generalizedfizzbuzz.lua
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 10 additions & 0 deletions src/generalizedfizzbuzz.py
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 8 additions & 0 deletions src/hairofthedog.py
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions src/heysata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
input()
c = input()
print("Unnar fann hana!" if c in input() else "Unnar fann hana ekki!")
2 changes: 2 additions & 0 deletions src/hornrett.py
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions src/intuitiveelements.py
Original file line number Diff line number Diff line change
@@ -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")
6 changes: 6 additions & 0 deletions src/mork.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
n = int(input())
m = int(input())
if m == 0 or (m == 2 and n == 2):
print("Jebb")
else:
print("Neibb")
8 changes: 8 additions & 0 deletions src/ruffians.py
Original file line number Diff line number Diff line change
@@ -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")
10 changes: 10 additions & 0 deletions src/snowfall.lua
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions src/snowfall.py
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions src/starwars2.py
Original file line number Diff line number Diff line change
@@ -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 :]))
4 changes: 4 additions & 0 deletions src/telja.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
n = io.read("*n")
for i = 1, n do
print(i)
end
1 change: 1 addition & 0 deletions src/telja.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print(*range(1, int(input()) + 1))
13 changes: 13 additions & 0 deletions src/welcomesign.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 9d1b14a

Please sign in to comment.