Last active
December 18, 2015 04:39
-
-
Save ashleygwilliams/5726653 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i have [["a", "b", "c"],["a", "b", "z"],["d", "e", "f"],["d", "e", "p"]] | |
ok i need to buil {a=>??,d=>??} | |
THEN i need to build {a=>b, d=>e} | |
THEN i need to build {a=>{b=>??},d=>{e=>??}} | |
THEN i need to build {a=>{b=>[]]},d=>{e=>[]]}} | |
** maybe make [c,z] and [f,p] | |
THEN i need to build {a=>{b=>[c]]},d=>{e=>[f]]}} | |
THEN i need to build {a=>{b=>[c,z]]},d=>{e=>[f,p]]}} | |
i want {a=>{b=>[c,z]}, d=>{e=>[f,p]}} | |
i have {a=>{b=>[c,z,f,p]]},d=>{e=>[c,z,f,p]]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
songs = [ | |
"The Magnetic Fields - 69 Love Songs - Parades Go By", | |
"The Magnetic Fields - Get Lost - Smoke and Mirrors", | |
"The Magnetic Fields - Get Lost - You, Me, and the Moon", | |
"The Magnetic Fields - 69 Love Songs - The Book of Love", | |
"Neutral Milk Hotel - In An Aeroplane Over the Sea - Holland 1945", | |
"Neutral Milk Hotel - In An Aeroplane Over the Sea - The King of Carrot Flowers" | |
] | |
song_chunks = [] | |
songs.each do |song_info| | |
song_chunks.push(song_info.split(' - ')) | |
end | |
#song_info = song[0] = "The Magnetic Fields - 69 Love Songs - Parades Go By" | |
#song_info.split('-') = ["The Magnetic Fields ", " 69 Love Songs ", " Parades Go By"] | |
albums = [] | |
artists = [] | |
songs_titles = [] | |
playlist = {} | |
#playlist = {key:artist => {key:album=>[songs], key:album=>[songs]}} | |
song_chunks.each do |chunk| | |
playlist[chunk[0]] = {} | |
if x===y | |
x[artst]=song | |
elsif x=zip(enums | |
z[artist] = song | |
albums.push(chunk[1]) #in hash playlist find the key that equal the value of chunk[0]"artist" and set that key's value to an array wher ewe push album names(chunk[1]) | |
songs_titles.push(chunk[2]) | |
end | |
# {artist => {album => [songs]}} | |
puts playlist | |
puts songs | |
#{"neutral milk hotel => ["album1", "album2"]} | |
#ok so i am going to creat a new key with an artist name | |
#if the artist name is the same then add a key tot he hash that the key poitns to | |
# | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
students = | |
["Julian - Brooklyn - Bushwick", | |
"Alex - Long Island - Great Neck"] | |
#create a hash with this format: | |
#{"student_name => ["location=>more_specific_location"]"} | |
new_students = [] | |
students.each do |student| | |
new_students.push(student.split(' - ')) | |
end | |
location = [] | |
# thisismyhash = {key=>{key2=>value}} | |
# thisismyhash[key] = {key2=>value} | |
# thisismyhash[key][key2] = value | |
# thisismyhash = {key=>{}} | |
# thisismyhash[key][key2] = value | |
# thisismyhash[key][key3] = value | |
#=> thisismyhash={key=>{key2=>value, key3=>value}} | |
student_hash = {} | |
new_students.each do |student| | |
student_hash[student[0]] = {student[1]=>student[2]} | |
end | |
puts student_hash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yo so i've just been looking at this... and reading some articles on stackoverflow... and i still can't figure it out. i know it's supposed to be simple. alas, i can't do it.