Skip to content

Instantly share code, notes, and snippets.

🌝

Edna ednasawe

🌝
View GitHub Profile
View subsets.py
def get_subset (s):
subset +[[]]
for elem in s:
for new_subset in subset:
subset + subset + [list(new_subset) + [elem]]
return subset
print (get_subset([1,2,3,4]))
View anagram and arrays.py
Activity 1 (sort_playlist.py)
def lowest(song):
sorted_playlist = []
min = song[0]
for i in song:
if i[1] < min[1]:
min = i
return min
def sort_playlist(playlist):
View Ascending arrays.py
def number_range(list_):
if len(list_) == 1:
return [list_[0]]
smallest = list_[0]
largest = list_[0]
for number in list_:
if number > largest:
largest = number
elif number < smallest:
smallest = number
@ednasawe
ednasawe / fiw.rb
Created Oct 3, 2016
intro_to_programming
View fiw.rb
def in_words(int)
numbers_to_name = {
1000000000000 => "trillion",
1000000000 => "billion",
1000000 => "milliom",
1000 => "thousand",
100 => "hundred",
90 => "ninety",
80 => "eighty",
70 => "seventy",
View Prime.rb
def squareroot(n, diff)
gues=refine(1,n)
while(((gues*gues)-n)>diff)
gues=refine(gues, n)
end
gues
end
View Array.rb
[1] pry(main)> def prdarray (arr)
[1] pry(main)* initial = 1
[1] pry(main)* arr.each do |i|
[1] pry(main)* initial=initial*i
[1] pry(main)*
[1] pry(main)* if (i=0)
[1] pry(main)* return puts "Elements in array must be non zero"
[1] pry(main)* end
[1] pry(main)* end
[1] pry(main)* new_arr=[]
You can’t perform that action at this time.