Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zehengl committed Mar 28, 2024
1 parent bdeae92 commit 4bcdf72
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/conteststruggles.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
n, k, d, s = io.read("*n", "*n", "*n", "*n")
ans = (n * d - k * s) / (n - k)
if ans < 0 or ans > 100 then
print("impossible")
else
print(ans)
end
7 changes: 7 additions & 0 deletions src/conteststruggles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
n, k = [int(c) for c in input().split()]
d, s = [int(c) for c in input().split()]
ans = (n * d - k * s) / (n - k)
if ans < 0 or ans > 100:
print("impossible")
else:
print(f"{ans:.7f}")
60 changes: 60 additions & 0 deletions src/hnappasetningaskipti.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
table = """
qwerty dvorak bjarki
~ ~ 0
1 1 2
2 2 4
3 3 8
4 4 6
5 5 1
6 6 3
7 7 5
8 8 7
9 9 9
0 0 =
- [ -
= ] /
q ' b
w , j
e . a
r p r
t y k
y f i
u g g
i c u
o r s
p l t
[ / .
] = ,
a a l
s o o
d e e
f u m
g i p
h d d
j h c
k t n
l n v
; s q
' - ;
z ; [
x q ]
c j y
v k z
b x h
n b w
m m f
, w x
. v '
/ z ~
""".strip()

m = {
"qwerty": [row.split("\t")[0] for row in table.split("\n")[1:]],
"dvorak": [row.split("\t")[1] for row in table.split("\n")[1:]],
"bjarki": [row.split("\t")[2] for row in table.split("\n")[1:]],
}
k, _, v = input().split()
mapping = dict(zip(m[k], m[v]))

s = input()
print("".join(mapping.get(c, c) for c in s))
22 changes: 22 additions & 0 deletions src/notamused.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from collections import Counter

d = 1
while True:
try:
s = input().split()

if "OPEN" in s:
book = {}
t = Counter()
elif "ENTER" in s:
book[s[1]] = int(s[2])
elif "EXIT" in s:
t[s[1]] += int(s[2]) - book.pop(s[1])
elif "CLOSE" in s:
print(f"Day {d}")
for k in sorted(t):
print(f"{k} ${t[k]/10:.2f}")
print()
d += 1
except:
break

0 comments on commit 4bcdf72

Please sign in to comment.