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
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)
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 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 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 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)
#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
a = [[1,2,4,5],[6,7,8,9],[10,11,12,13],[14,15,16,17]]
number = 17
def box_arr_num(a, number)
length = a.length-1
number = number
(0..a.length).each do |i|
if a[i][a.length-1] >= number
(0..a.length).each do |j|
if a[i][j] == number
return i, j
def time_sort(time):
i = 0
music = time[i][1]
for music in range(len(time)-1,0,-1):
for i in range(music):
if time[i][1]>time[i+1][1]:
clock = time[i]
time[i] = time[i+1]
time[i+1] = clock
return time
def simultaneous_eqn(eqns):
a = eqns[0]
b = eqns[1]
c = eqns[2]
x = float((-b - c) / a)
return x
def two_unknown(eqns):