Skip to content

Instantly share code, notes, and snippets.

View kharioki's full-sized avatar
🤘
I'm burdened with glorious purpose

Tony Kharioki kharioki

🤘
I'm burdened with glorious purpose
View GitHub Profile
#sort playlist
def sort_music_asc(a):
i = 0
m = a[i][1]
for m in range(len(a)-1,0,-1):
for i in range(m):
if a[i][1]>a[i+1][1]:
temp = a[i]
a[i] = a[i+1]
a[i+1] = temp
def camel_snake(input):
output = [input[0].lower()]
for c in input[1:]:
if c in ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
output.append('_')
output.append(c.lower())
else:
output.append(c)
return str.join('', output)
def sort_mylist_asc(a):
for my_number in range(len(a)-1,0,-1):
for i in range(my_number):
if a[i]>a[i+1]:
temp = a[i]
a[i] = a[i+1]
a[i+1] = temp
return a
def second_places(a):
def sort_mylist_asc(a):
for my_number in range(len(a)-1,0,-1):
for i in range(my_number):
if a[i]>a[i+1]:
temp = a[i]
a[i] = a[i+1]
a[i+1] = temp
return a
def sort_mylist_desc(a):
def product_except?(d)
e = []
startvalue = 0
endvalue = d.length
product = d.inject(1){|first,n| first * n}
result = []
while startvalue < endvalue
result.push(product/ d[startvalue])
startvalue = startvalue + 1
end
def mid_point(x,y)
(x+y)/2.0
end
def square_root(x,e)
if x == 1
guess = 1
else
lowest = 0
highest = x
guess = mid_point(lowest,highest)
def mid_point(x,y)
(x+y)/2.0
end
def square_root(x,e)
if x==1;
guess=1
else
lowest = 0
highest = x
guess = mid_point(lowest,highest)