Skip to content
{{ message }}

Instantly share code, notes, and snippets.

🏠
Working from home

# Prince Agrawalprkagrawal

🏠
Working from home
Created Jul 5, 2020
#dailyCoding
View magicalSticks.py
 t = int(input()) while(t>0): t = t - 1 n = int(input()) if(n==1) : print(1) continue if(n%2==0): print(int(n/2)) continue
Last active Jun 21, 2020
#dailyCoding
View AcodeAlphacode.py
 # This is a "dynamic programming" (aka dp) question and the solution is "recursive" # Using loop to make the code run until provided non-acceptable input while True: n = str(input()) # check if given no is zero if n == "0": break dp = [] # Make an array with a length len(n)+1 with each element as zero # We will use this array
Last active Jun 20, 2020
#dailyCoding #python
View soldierAndBananas.py
 k,n,w = str(input()).split() k = int(k) n = int(n) w = int(w) mn = 0 for i in range(w): mn = mn + (i+1)*k if n
Last active Jun 20, 2020
View birthdayPresent.py #dailyCoding
 n = int(input()) # Part 1 for i in range(n): s = [] for j in range(n): if i+j-n >= 0: s.append(str(i+j-n)) else: s.append(" ") t = s[::-1]
Last active Jun 20, 2020
View stringPatternSearch.py #dailyCoding
 def stringPatternSearch(text,pattern): n = len(text) m = len(pattern) count = 0 for i in range(n - m + 1): for j in range(m): if pattern[j] != text[i+j]: break if j == m-1 : count = count + 1
Last active Jun 20, 2020
View cowsAndBullsGame.py #dailyCoding
 import random t = str(random.randint(1000,9999)) def check(): k = str(input("Enter a four digit number : ")) if k == t: print("Correct : Game Over") return elif k != t:
Last active Jun 20, 2020
View dailyCoding15June.py #dailyCoding
 n,t = map(int,input().split()) s = str(input()) l = list(s) z = len(s) - 1 for i in range(t): for a in range(z): if l[a]=='B' and l[a+1]=='G': l[a] = 'G' l[a+1] = 'B'
Last active Jun 20, 2020
Calculating no of trailing zeroes in factorial of given number
View factorialTrailingZeroes.py #dailyCoding
 def trailing_zeroes(n): # 0s are produced when 2 and 5 are multiplied # so you'll need to count how many 2s and 5s are there # 2s are always more than 5s so count just 5s res = 0 k = 5 # find all powers of 5 # 25 has 2 5s, 125 has 3 5s, etc while k <= n:
You can’t perform that action at this time.