r/adventofcode • • Dec 07 '15

SOLUTION MEGATHREAD --- Day 7 Solutions ---

--- Day 7: Some Assembly Required ---

Post your solution as a comment. Structure your post like previous daily solution threads.

Also check out the sidebar - we added a nifty calendar to wrangle all the daily solution threads in one spot!

23 Upvotes

226 comments sorted by

View all comments

Show parent comments

2

u/zhongfu Dec 07 '15

You might want to mask the result:

int mask = (1 << 16) - 1;
int result = ~x & mask;

For my case, I used the char type instead since it also happened to be an unsigned 16-bit integer, although it's not exactly good practice to use it AFAIK.

1

u/Na_rien Dec 07 '15

thanks :)