Last active
August 29, 2015 14:01
-
-
Save markedmondson/75ace94346e7daf88d60 to your computer and use it in GitHub Desktop.
Level++
This file contains hidden or 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
state_counts = [ | |
OpenStruct.new(name: "BC", country: "Canada", count: 5), | |
OpenStruct.new(name: "Ontario", country: "CA", count: 15), | |
OpenStruct.new(name: "QC", country: nil, count: 25), | |
OpenStruct.new(name: "Oregon", country: "USA", count: 35), | |
OpenStruct.new(name: "WA", country: "United States", count: 45), | |
OpenStruct.new(name: "CA", country: nil, count: 55), | |
OpenStruct.new(name: "WA", country: "Australia", count: 65) | |
] | |
canada = OpenStruct.new(name: "Canada", iso: "CA", iso3: "CAN") | |
usa = OpenStruct.new(name: "United States", iso: "US", iso3: "USA") | |
australia = OpenStruct.new(name: "Australia", iso: "AU", iso3: "AUS") | |
# => {bc => 5, on => 15, qc => 25, or => 35, wa => 45, ca => 55, wtf=> 65} |
never mind previous comment, I was using string as key, instead of objects...
Yeah it was more to ensure that "WA" wasn't being used as a state matcher for Washington.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This currently doesn't change anything to the solution as it is not based on the country...
Let's add :
to the countries
and
to the state counts
so the output would have to be something like :
# => {ca.bc => 5, ca.on => 15, ca.qc => 25, us.or => 35, us.wa => 45, us.ca => 55, au.wa => 65}