Skip to content

Commit

Permalink
Python programs for Codeforces questions were added
Browse files Browse the repository at this point in the history
  • Loading branch information
sadock123 committed Oct 29, 2022
1 parent 74022ae commit 9f17de1
Show file tree
Hide file tree
Showing 17 changed files with 215 additions and 0 deletions.
21 changes: 21 additions & 0 deletions AntonandPolyhedrons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

n=int(input())
count=0
while (n):

cat=str(input())
if (cat=="Tetrahedron"):
count=count+4
elif (cat=="Cube"):
count=count+6
elif (cat=="Octahedron"):
count=count+8
elif (cat=="Dodecahedron"):
count=count+12
elif (cat=="Icosahedron"):
count=count+20
n=n-1
print(count)



2 changes: 2 additions & 0 deletions Antonandtheletters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
n=input()
print(len(set(n))-4)
27 changes: 27 additions & 0 deletions Best_Permutation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
test=int(input())
while(test>0):
n=int(input())
arr=[]
if n%2==0:
for i in range(n-2,1,-1):
arr.append(i)
arr.append(1)
arr.append(n-1)
arr.append(n)
for i in range(len(arr)):
print(arr[i],end=" ")
else:
for i in range(n-2,1,-1):
arr.append(i)
for i in range(len(arr)-1):
temp=arr[i]
arr[i]=arr[i+1]
arr[i+1]=temp
arr.append(1)
arr.append(n-1)
arr.append(n)
for i in range(len(arr)):
print(arr[i],end=" ")

test=test-1
print("")
8 changes: 8 additions & 0 deletions Colored_Balls_Revisited.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test=int(input())
while(test>0):
m=int(input())
k=list(map(int,input().split()))
l=max(k)
print(k.index(l)+1)

test=test-1
14 changes: 14 additions & 0 deletions DecodeString.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
t=int(input())
while (t>0):
n=int(input())
code=input()
res=""
while code:
if code[-1] != '0':
res = chr(96 + int(code[-1])) + res
code = code[:-1]
else:
res = chr(96 + int(code[-3:-1])) + res
code = code[:-3]
print(res)
t-=1
6 changes: 6 additions & 0 deletions Drinks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
n=int(input())
list1=list(map(int,input().split()))
k=0.0
for i in range(n):
k=k+float(list1[i]/n)
print(k)
8 changes: 8 additions & 0 deletions Expression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
l=[]
for i in range(3):
l.append(int(input()))

a=l[0]
b=l[1]
c=l[2]
print(max((a*b*c),(a+b+c),((a+b)*c), a*(b+c)))
14 changes: 14 additions & 0 deletions IwannabeTheGuy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
n=int(input())
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
flag=0
for i in (l1):
if i==n:
flag=1
for j in (l2):
if j==n:
flag=1
if (flag==1):
print("I become the guy.")
else:
print("Oh, my keyboard!")
4 changes: 4 additions & 0 deletions MadokaandStrangeThoughts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import math
for i in range(int(input())):
k=int(input())
f
7 changes: 7 additions & 0 deletions Present.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
n=int(input())
x=list(map(int,input().split()))
l=[]
for i in range(1,n+1):
l.append(x.index(i)+1)

print (*l)
17 changes: 17 additions & 0 deletions Wonderfulpermutation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

test=int(input())


while (test>0):
count=0
n,k=map(int,input().split())
l1=list(map(int,input().split()))
for i in range(k):
if l1[i]> k:
count=count+1


print(count)

test=test-1

23 changes: 23 additions & 0 deletions YoungPhysicist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
n=int(input())
k=[]
for i in range(n):
x=list(map(int,input().split()))
k.append(x)
sum1=0
sum2=0
sum3=0
for j in range(len(k)):
m=0
sum1=sum1+ k[j][m]

for j in range(len(k)):
m=1
sum2=sum2+k[j][m]
for j in range(len(k)):
m=2
sum3=sum3+k[j][m]
if sum1==0 and sum2==0 and sum3==0:
print("YES")
else:
print("NO")

13 changes: 13 additions & 0 deletions boyorgirl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
st=''
count=0
name=str(input())
for i in name:
if i not in st:
count=count+1
st=st+i
else:
continue
if (count%2==0):
print("CHAT WITH HER!")
else:
print("IGNORE HIM!")
19 changes: 19 additions & 0 deletions counzero.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
test=int(input())
while (test>0):
count=0
n=int(input())
l1=list(map(int,input().split()))
l2=[]
for i in range(n-1):
for j in range(n):
if l1[j] in l2:
l1[j]=0
continue
elif l1[i]>= l1[j] and l1[i]!=0:
l2.append(l1[i])
l1[i]=0
count=count+1


test=test-1
print(count)
13 changes: 13 additions & 0 deletions elephant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
n=str(input())
sum=0
max_sum=0
for i in range(len(n)-1):
if (n[i]==n[i+1]):
sum=sum+1
else:
sum=0
max_sum=max(max_sum,sum+1)
if max_sum>=7:
print("YES")
else:
print("NO")
12 changes: 12 additions & 0 deletions football.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from collections import Counter
n=int(input())

arr=[]
for i in range(n):
k=str(input())
arr.append(k)
l=Counter(arr)
k1=1

m=max(l, key=l.get)
print(m)
7 changes: 7 additions & 0 deletions stringtask.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
st=str(input())
vowel=["a","e","i","o","u","A","E","I","O","U","y","Y"]
s=''
for i in st:
if i not in vowel:
s=s+"."+i.lower()
print(s)

0 comments on commit 9f17de1

Please sign in to comment.