Skip to content

Commit

Permalink
Did my part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Stathis committed Oct 16, 2021
1 parent 569ab40 commit c9ea6b7
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Mosaic_Decoration_III/Mosaic_Decoration_III.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import math
inp = list(map(int,input().split()))
N_rows = inp[0]
M_col = inp[1]
R_rows = inp[2]
C_col = inp[3]
costs = []
for i in range(R_rows):
costs.append(input().split())
# print(costs)'
a = math.ceil(N_rows/R_rows)
b = math.ceil(M_col/C_col)
if (a*R_rows)%N_rows != 0:
pass
if (b*C_col)%M_col !=0:
pass
R_C_cost = 0
tiles = a*b
for i in costs:
for j in i:
R_C_cost+=int(j)
print(a*b*R_C_cost)
Binary file added Mosaic_Decoration_III/task_statement.pdf
Binary file not shown.
62 changes: 62 additions & 0 deletions Poker_Game/Poker_Game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
N, K = input().split()

cards = ["2","3","4","5","6","7","8","9","X","J","Q","K","A"]
commun = {}
mine = {}
impossible = False
total = 0

for i in cards:
commun[i] = -1
mine[i] = 0

deck = input()
moves = input()

for i in range(int(N)):
if moves[i] == "n":
if commun[deck[i]] == 0:
impossible = True
break
else:
commun[deck[i]] = 0
elif commun[deck[i]] == -1:
commun[deck[i]] = 1
mine[deck[i]] = 1
total += 1
elif commun[deck[i]] >= 1:
commun[deck[i]] += 1

if total > int(K) or impossible:
print("impossible")
else:
left = int(K) - total
step = 0
hand = ""

while left:
commun_sort = sorted(commun.items(), reverse=True, key=lambda x: x[1])

if commun_sort[step][1] == 0:
step += 1
elif commun_sort[step][1] > 0 and commun_sort[step][1] + mine[commun_sort[step][0]] < 4:
mine[commun_sort[step][0]] += 1
left -= 1
elif mine[commun_sort[step][0]] < 4:
mine[commun_sort[step][0]] += 1
left -= 1
else:
step += 1

if step > 12:
impossible = True
break

for i in mine:
for j in range(mine[i]):
hand += i

if impossible:
print("impossible")
else:
print(hand)
Binary file added Poker_Game/task_statement.pdf
Binary file not shown.
19 changes: 19 additions & 0 deletions Rescue_Mission/Rescue Mission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Nof_hideouts = int(input())
hides = input().split()

soldiers = 0

for i in hides:
soldiers += int(i)

days = int(input())
rescue = 0

for i in range(days):
vals = input().split()
rescue += int(vals[2])

if soldiers < rescue:
print(soldiers)
else:
print(rescue)
Binary file added Rescue_Mission/task_statement.pdf
Binary file not shown.

0 comments on commit c9ea6b7

Please sign in to comment.