Binary Math - Part I Answers
Thank you to everyone who participated... It was my first time running a little contest on the blog, and I'm sorry to say it didn't quite work as I expected! The comments were not supposed to be seen until a day later, but I think I forgot to share that with the other folks here! My bad!
Anyway, there are a variety of answers that we received in the commentary, and remember that I said all three must be correct. That was the catchy part, as even the first few people were almost there. Almost, but not quite! It's a good learning curve though!
Andrew Dempsey was the first person to actually get all three of them correct! Congratulations! Andrew, pop me an e-mail and we'll figure out how to get the tokens to you.
To everyone else, I promise to have all the kinks worked out by tomorrow when I post Part II with a much more exciting set of things to think about!
Answers...
1. Start picking a few and finding similarities again...
0 00000000
4 00000100
8 00001000
12 00001100
16 00010000
20 00010100
etc.
Just like with our even/odd example, we look at the constants. The last two bits will ALWAYS be "00". So a mask of 11111100 would fit.
access-list 16 permit 131.102.0.0 0.0.252.255
2. Our differences here are in the third octet.
128 10000000
130 10000010
132 10000100
134 10000110
136 10001000
138 10001010
There are three bits of difference between the six values there. The 2-bit, 4-bit and 8-bit positions. But 2^3 would yield eight matches.
140 and 142 are missing there. So we have two ways of looking at this.
Method 1:
access-list 17 permit 200.100.128.0 0.0.6.0
access-list 17 permit 200.100.136.0 0.0.2.0
Method 2:
access-list 17 deny 200.100.140.0 0.0.2.0
access-list 17 permit 200.100.128.0 0.0.14.0
Either way, two lines is our best bet!
3. This is a little more complicated than it looks! Namely because there's a gap in the middle and we aren't allowed to use any "deny" statements! Go figure!
This exercise is just like creating subnets though. How well did you know your bit boundaries? :)
So let's make as many major blocks as we can.
access-list 18 permit 158.1.100.0 0.0.0.63
access-list 18 permit 158.1.100.64 0.0.0.15
access-list 18 permit 158.1.100.80 0.0.0.7
access-list 18 permit 158.1.100.88 0.0.0.3
access-list 18 permit 158.1.100.92 0.0.0.0
access-list 18 permit 158.1.100.107 0.0.0.0
access-list 18 permit 158.1.100.108 0.0.0.3
access-list 18 permit 158.1.100.112 0.0.0.15
access-list 18 permit 158.1.100.128 0.0.0.127
After a while you have to think about all the different bit boundaries. On the bright side, Windows Calculator available to help if necessary!
Back in a day'ish!