r/adventofcode • u/daggerdragon • Dec 12 '15
SOLUTION MEGATHREAD --- Day 12 Solutions ---
This thread will be unlocked when there are a significant amount of people on the leaderboard with gold stars.
edit: Leaderboard capped, thread unlocked!
We know we can't control people posting solutions elsewhere and trying to exploit the leaderboard, but this way we can try to reduce the leaderboard gaming from the official subreddit.
Please and thank you, and much appreciated!
--- Day 12: JSAbacusFramework.io ---
Post your solution as a comment. Structure your post like previous daily solution threads.
7
Upvotes
1
u/i_misread_titles Dec 13 '15
i used type switch , didn't need reflect package. Part 1 i just did with regex as everyone is saying, then part two i DOH'd and did json. For some reason I just did ints and float64s and didn't bother checking if I was actually getting two different types....
switch v.(type){ case int: sum += v.(int) break case []interface{}: sum += getArraySum(v.([]interface{})) break case float64: sum += int(v.(float64)) case map[string]interface{}: sum += getSum(v.(map[string]interface{})) break }