Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zehengl committed Dec 4, 2023
1 parent 07c956d commit f297364
Show file tree
Hide file tree
Showing 21 changed files with 104 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/3dprinter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
n = io.read("*n")
d = 1
while 2 ^ (d - 1) < n do
d = d + 1
end
print(d)
2 changes: 2 additions & 0 deletions src/addtwonumbers.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a, b = io.read("*n", "*n")
print(a + b)
7 changes: 7 additions & 0 deletions src/alexandbarb.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
k, m, n = io.read("*n", "*n", "*n")

if k % (m + n) < m then
print("Barb")
else
print("Alex")
end
2 changes: 2 additions & 0 deletions src/areal.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
s = io.read("*n")
print(4 * math.sqrt(s))
3 changes: 3 additions & 0 deletions src/betting.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a = io.read("*n")
print(string.format("%.10f", 100 / a))
print(string.format("%.10f", 100 / (100 - a)))
6 changes: 6 additions & 0 deletions src/bossbattle.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
n = io.read("*n")
if n // 4 > 0 then
print(n - 2)
else
print(1)
end
4 changes: 4 additions & 0 deletions src/crne.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
n = io.read("*n")
a = n // 2
b = n - a
print((a + 1) * (b + 1))
1 change: 1 addition & 0 deletions src/discdistrict.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print(1, io.read())
6 changes: 6 additions & 0 deletions src/gcd.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
a, b = io.read("*n", "*n")
function gcd(a, b)
return b == 0 and a or gcd(b, a % b)
end

print(gcd(a, b))
5 changes: 5 additions & 0 deletions src/hradgreining.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if string.find(io.read(), "COV") then
print("Veikur!")
else
print("Ekki veikur!")
end
6 changes: 6 additions & 0 deletions src/laptopsticker.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
wc, hc, ws, hs = io.read("*n", "*n", "*n", "*n")
if wc - 2 >= ws and hc - 2 >= hs then
print(1)
else
print(0)
end
2 changes: 2 additions & 0 deletions src/makingameowth.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
n, p, x, y = io.read("*n", "*n", "*n", "*n")
print(p * x + p // (n - 1) * y)
10 changes: 10 additions & 0 deletions src/nastyhacks.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
for _ = 1, io.read("*n") do
r, e, c = io.read("*n", "*n", "*n")
if e > r + c then
print("advertise")
elseif e < r + c then
print("do not advertise")
else
print("does not matter")
end
end
15 changes: 15 additions & 0 deletions src/overdraft.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
n = io.read("*n")
s = 0
b = 0
for _ = 1, n do
t = io.read("*n")
if t > 0 then
b = b + t
elseif b + t < 0 then
s = s - (b + t)
b = 0
else
b = b + t
end
end
print(s)
2 changes: 2 additions & 0 deletions src/pieceofcake2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
n, h, v = io.read("*n", "*n", "*n")
print(4 * math.max(h * v, (n - h) * (n - v), h * (n - v), v * (n - h)))
2 changes: 2 additions & 0 deletions src/pizza2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
r, c = io.read("*n", "*n")
print(string.format("%.6f", (r - c) ^ 2 / r ^ 2 * 100))
9 changes: 9 additions & 0 deletions src/thanos.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
for _ = 1, io.read("*n") do
p, r, f = io.read("*n", "*n", "*n")
y = 0
while p <= f do
p = p * r
y = y + 1
end
print(y)
end
3 changes: 3 additions & 0 deletions src/timeloop.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
for i = 1, io.read("*n") do
print(string.format("%d Abracadabra", i))
end
5 changes: 5 additions & 0 deletions src/twostones.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if io.read("*n") % 2 > 0 then
print("Alice")
else
print("Bob")
end
2 changes: 2 additions & 0 deletions src/twosum.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a, b = io.read("*n", "*n")
print(a + b)
6 changes: 6 additions & 0 deletions src/whichisgreater.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
a, b = io.read("*n", "*n")
if a > b then
print(1)
else
print(0)
end

0 comments on commit f297364

Please sign in to comment.