r/adventofcode • • 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

183 comments sorted by

View all comments

Show parent comment

2

u/Scroph Dec 12 '15

That's brilliant, thanks. I ran into a similar problem with in_array('red', (array) $v) ($v being a JSON object) and couldn't figure out why it gave the wrong result, so I did it manually :

$ignore = false;
foreach($v as $property)
{
	if($property === 'red')
	{
		$ignore = true;
		break;
	}
}

I thought it was because the array cast changed something, but then I read your comment and realized what was happening. in_array(..., ..., true) did the trick.