0% found this document useful (0 votes)
20 views

Python

Uploaded by

paniyanandhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Python

Uploaded by

paniyanandhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Author: Dishang Mehta

Q1

def checkRepetitive(start: int, end: int) -> list:


count = 0
for i in range(start, end+1):
if len(list(set(str(i)))) == len(str(i)):
count += 1

return count

print(checkRepetitive(int(input()), int(input())))

Te l e g r a m : @ d m e h t a 6 2 4 Page 1
Author: Dishang Mehta

Q2

def rotate(arr: list, k: int) -> list:


for i in range(k):
arr.insert(0, arr.pop())

return arr

print(rotate(list(map(int, input().split())), int(input())))

Te l e g r a m : @ d m e h t a 6 2 4 Page 2
Author: Dishang Mehta

Q3

def pushMultiples(arr: list) -> list:


final = []
multiples = []
for ele in arr:
if ele % 10 == 0:
multiples.append(ele)
else:
final.append(ele)

final.extend(multiples)
return final

if __name__ == '__main__':
print(pushMultiples(list(map(int, input().split()))))

Te l e g r a m : @ d m e h t a 6 2 4 Page 3
Author: Dishang Mehta

Q4

def pushAtEnd(arr: list, k: int) -> list:


return arr[k:] + arr[:k]

if __name__ == '__main__':
print(pushAtEnd(list(map(int, input().split())), int(input())))

Te l e g r a m : @ d m e h t a 6 2 4 Page 4
Author: Dishang Mehta

Q5

Te l e g r a m : @ d m e h t a 6 2 4 Page 5
Author: Dishang Mehta

import math

def calculateCost(r1: int, n: int, r2: int, x: int) -> int:


x = math.ceil(x / 60)
if x>=n:
cost = n * r1
x -= n
cost += x * r2
else:
cost = x * r1
return cost

if __name__ == '__main__':
print(calculateCost(int(input()), int(input()), int(input()),
int(input())))

Te l e g r a m : @ d m e h t a 6 2 4 Page 6
Author: Dishang Mehta

Q6

def gemstoneArrangement(R: int, G: int, T: int, last='') -> int:


if R == 0 and G == 0 and T == 0:
return 1

count = 0

if last != 'R' and R>0:


count += gemstoneArrangement(R-1, G, T, 'R')

if last != 'G' and G > 0:


count += gemstoneArrangement(R, G-1, T, 'G')

if last != 'T' and T > 0:


count += gemstoneArrangement(R, G, T-1, 'T')

return count

if __name__ == '__main__':
print(gemstoneArrangement(int(input()), int(input()), int(input())))

Te l e g r a m : @ d m e h t a 6 2 4 Page 7

You might also like