Skip to content

Instantly share code, notes, and snippets.

View dogac00's full-sized avatar

Dogac Akyıldız dogac00

  • Trendyol
  • İstanbul
View GitHub Profile
@dogac00
dogac00 / odds
Created March 23, 2018 02:17
List the Odds (List Just the Odds in an Array)
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 March 14, 2018 01:40
Finding Determinant in Python
import numpy as np
def determinant(matrix):
return round(np.linalg.det(matrix),3)
@dogac00
dogac00 / calculator
Created March 14, 2018 01:36
Calculator in Python (Nearly One Liner)
class Calculator(object):
def evaluate(self, string):
return round(eval(string), 10)
@dogac00
dogac00 / ip validation
Created March 14, 2018 00:07
IP Validation @codewars
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
@dogac00
dogac00 / palindrome chain length
Created March 13, 2018 23:33
Palindrome chain length @codewars
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 March 13, 2018 23:22
Is my friend cheating on @codewars
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 March 13, 2018 23:06
Number of trailing zeros @codewars
def zeros(x):
i = 5
count = 0
while x >= i:
count += x // i
i *= 5
return count
@dogac00
dogac00 / first non-repeating character
Created March 13, 2018 22:31
First non-repeating character @codewars
def first_non_repeating_letter(string):
for i in string:
if(string.lower().count(i.lower())==1):
return i
return ""
from collections import Counter
def scramble(s1, s2):
letters = Counter(s1)
word = Counter(s2)
diff = word - letters
return len(diff) == 0