Skip to content

Instantly share code, notes, and snippets.

View codingsnap's full-sized avatar
🎯
Focusing

Rahul Singh codingsnap

🎯
Focusing
  • New Delhi, India
View GitHub Profile
@codingsnap
codingsnap / dipeshcode.py
Created March 30, 2020 20:35
Dipesh Financial Crisis @codingsnap.tech
#codingsnap.tech
t = int(input("Enter number of test cases: "))
for i in range(t):
n,m = [int(x) for i in input("Enter the dimensions :").split()]
c = int(input("Enter the cost for each cut made: "))
min_cost = (n-1)*c + (m-1)*c
print("Amount that Dipesh need to pay for the cutting is: ",min_cost)
@codingsnap
codingsnap / Lockers.py
Created March 30, 2020 20:44
Lockers-Daily Coding Problem @codingsnap.tech
t = int(input("Enter the number of the test cases: "))
for i in range(t): #codingsnap.tech
n = int(input("Enter the number of lockers: "))
m = int(input("Enter some random numbers to open the lockers: "))
for i in range(1,n+1):
if (i%m==0):
continue
else:
print(i)
@codingsnap
codingsnap / Candy.py
Created March 30, 2020 20:59
Prateek loves candy problem @codingsnap.tech
def isprime(n):
if (n==1):
return False
elif (n==2):
return True
else:
for i in range(2,n//2+1):
if (n%i==0):
return False
else:
#Numpy Array
a = np.arange(1000)
%timeit a**2
Output: 3.54 µs ± 87.3 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
#Python List
L = range(1000)
%timeit [i**2 for i in L]
import numpy as np
a = np.array([1,2,3,4,5])
print("A :",a)
Output: A : [1 2 3 4 5]
a = np.arange(10)
b = np.arange(2,20,4)
print("Array A =",a)
print("Array B =",b)
Output:
Array A = [0 1 2 3 4 5 6 7 8 9]
Array B = [ 2 6 10 14 18]
a = np.random.rand(5) #5 is the number of elements we want in the array
print(a)
Output:
[0.52759507 0.62328844 0.26818125 0.78392403 0.36929455]
a = np.random.randint(0,20,15)
print(a)
Output:
[10 4 6 13 9 6 1 11 6 11 5 0 11 4 0]
a = np.linspace(1,10,5)
print(a)
Output:
[ 1. 3.25 5.5 7.75 10. ]
a = np.array([[1,2,3,4],[5,6,7,8]])
print(a)
Output:
[[1 2 3 4]
[5 6 7 8]]