Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add New Questions #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions dawid_and_bags_of_candies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#https://codeforces.com/problemset/problem/1230/A

def brut(s, i):
if(s == (sum(lis)-s)):
return 1
if(i == 4):
return 0

return max(brut(s, i+1), brut(s+lis[i], i+1))


lis = list(map(int, input().split()))

if(brut(0, 0) == 1):
print("YES")
else:
print("NO")
14 changes: 14 additions & 0 deletions from_hero_to_zero.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#https://codeforces.com/problemset/problem/1175/A

a = int(input())
for i in range(a):
b, c = map(int, input().split())
q = 0
while(b != 0):
aux = b//c
q += b-(aux*c)
b = aux
if(aux > 0):
q += 1

print(q)
25 changes: 25 additions & 0 deletions good_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#https://codeforces.com/problemset/problem/1140/B

rep = int(input())

for i in range(rep):
a = int(input())
string = input()

if(string[0] == "<" and string[-1] == ">"):
mc = 0
mf = 0
for i in range(len(string)):
if(string[i] == "<"):
mc += 1
else:
break
for i in range(len(string)-1, -1, -1):
if(string[i] == ">"):
mf += 1
else:
break
print(min(mc, mf))

else:
print(0)
66 changes: 66 additions & 0 deletions plus_from_picture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#https://codeforces.com/problemset/problem/1182/B

a, b = map(int, input().split())

resp = True

grid = []

for i in range(a):
grid.append(input())

if(a < 3 or b < 3):
resp = False
else:
l = [0 for i in range(a)]
c = [0 for i in range(b)]
for i in range(a):
for j in range(b):
if(grid[i][j] == "*"):
l[i] += 1
c[j] += 1

ml = -1
mc = -1
flag = 0
for i in range(a):
if(l[i] == 0):
if(flag == 1):
flag = 2
elif(flag == 2):
resp = False
elif(l[i] != 1 and ml != -1):
resp = False
elif(l[i] != 1):
ml = i
flag = 1
else:
flag = 1

flag = 0
for i in range(b):
if(c[i] == 0):
if(flag == 1):
flag = 2
elif(flag == 2):
resp = False
elif(c[i] != 1 and mc != -1):
resp = False
elif(c[i] != 1):
mc = i
flag = 1
else:
flag = 1

if(grid[ml][mc] != "*"):
resp = False
if(ml == 0 or ml >= a-1 or mc == 0 or mc >= b-1):
resp = False
elif(grid[ml][mc+1] != "*" or grid[ml][mc-1] != "*" or grid[ml+1][mc] != "*" or grid[ml-1][mc] != "*"):
resp = False


if(resp):
print("YES")
else:
print("NO")