Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created February 25, 2017 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmcw/e87f3c789c49e76f65156d7d7f3ecbef to your computer and use it in GitHub Desktop.
Save tmcw/e87f3c789c49e76f65156d7d7f3ecbef to your computer and use it in GitHub Desktop.
require 'json'
artists = {}
Dir.glob('charts/*').select do |f|
contents = File.read(f)
chart = JSON.load(contents)
chart.each.with_index do |song, i|
unless artists.has_key?(song['artist'])
artists[song['artist']] = {}
end
unless artists[song['artist']].has_key?(song['title'])
reduced = {
:title => song['title'],
:artist => song['artist'],
:positions => []
}
artists[song['artist']]['title'] = reduced
end
artists[song['artist']]['title'][:positions] << [f.split('/')[1], i]
end
end
JSON.dump(artists, File.open("./reduced.json", "w"))
@tmcw
Copy link
Author

tmcw commented Feb 25, 2017

Haskell implementation ~2hrs in, no luck so far. Starting on rust implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment