Skip to content

Instantly share code, notes, and snippets.

Avatar

Dogac Akyıldız dogac00

  • Trendyol
  • İstanbul
View GitHub Profile
@dogac00
dogac00 / odds
Created Mar 23, 2018
List the Odds (List Just the Odds in an Array)
View odds
def sort_array(arr):
oddarr=[]
for i in arr:
if(i%2!=0):
oddarr.append(i)
oddarr=sorted(oddarr)
j=0
@dogac00
dogac00 / determinant
Created Mar 14, 2018
Finding Determinant in Python
View determinant
import numpy as np
def determinant(matrix):
return round(np.linalg.det(matrix),3)
@dogac00
dogac00 / calculator
Created Mar 14, 2018
Calculator in Python (Nearly One Liner)
View calculator
class Calculator(object):
def evaluate(self, string):
return round(eval(string), 10)
View ip validation
def is_valid_IP(string):
if(string==""):
return False
string=string.split('.')
count = 0
for i in string:
if(i[0]=="0" and len(i)!=1):
return False
elif(i.isdigit()==False):
return False
View palindrome chain length
def check_palindrome(a):
return str(a) == str(a)[::-1]
def palindrome_chain_length(n):
steps=0
while(check_palindrome(n)!=True):
n=n+int(str(n)[::-1])
steps+=1
return steps
@dogac00
dogac00 / friend cheating
Created Mar 13, 2018
Is my friend cheating on @codewars
View friend cheating
def removNb(n):
result=[]
for a in range(1,n+1):
for b in range(1,n+1):
if(a*b==(n*(n+1)/2-a-b)):
result.append((a,b))
return result
@dogac00
dogac00 / trailing zeros
Created Mar 13, 2018
Number of trailing zeros @codewars
View trailing zeros
def zeros(x):
i = 5
count = 0
while x >= i:
count += x // i
i *= 5
return count
View first non-repeating character
def first_non_repeating_letter(string):
for i in string:
if(string.lower().count(i.lower())==1):
return i
return ""
View scramblies
from collections import Counter
def scramble(s1, s2):
letters = Counter(s1)
word = Counter(s2)
diff = word - letters
return len(diff) == 0