Now that we learnt how to convert numbers into binary, you can imagine everything are turned into 1's and 0's inside a CPU(Central Processing Unit). What are "everything"? Well, actually there are only two types of information: data and instructions of what to do with the data. You understand how binary numbers work, you can add, subtract, multiply them etc. How do instructions work? We will introduce a new topic today.
1) Bit-strings: well, they are just strings of bits, like 10101 or 111000111000. Keep in mind that these 1's and 0's are not numbers, they are encoded instructions or controls. In this case, bit-wise operations are more useful than numeric operations. The bit-wise operations include shifting and circulating, plus the following:
AND &
1 & 1 = 1
1 & 0 = 0
0 & 1 = 0
0 & 0 = 0, for example, 1011 & 0010 = 0010. Notice x & 0 = 0, only 1 & 1 = 1.
OR |
1 | 1 = 1
1 | 0 = 1
0 | 1 = 1
0 | 0 = 0, for example, 1011 | 0010 = 1011. Notice x | 1 = 1, only 0 | 0 = 0.
NOT ~
~1 = 0
~0 = 1, for example, !10101 = 01010. Like a negative sign negates a number, NOT flips a bit.
XOR
0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0, for example, 1011 ^ 0010 = 1001. Notice x ^ x = 0, x ^ (~x) = 1.
Learn how they work in Kahoot!.
2) Coding task: DraftPick or ACSL Search
The first step to program anything is always to understand the problem "thoroughly". Sometimes it requires knowledge of a special industry or profession. For this problem, you will have to read carefully and figure out what are 16-game average and 18-game average.
Your Challenge this week:
1) #3#4 in 2010-2011c2 and #3#4 in 2012-2013c2. Submit your answers by replying to this post. Clearly mark question numbers and years please.
2) Complete DraftPick, be prepared to show and tell your code in our next meeting.
2010-2011:
3)00001
4)01110
2012-2013:
3)00000
4)11000
You all got a big part of the correct answers :) Here they are:
2010-2011: #3 00001, #4 01110; 2012-2013: #3 00000, #4 11000
2012-2013
#3 00000 #4 11000 2010-2011 #3 00001 #4 01110
2010_2011 3)00000 4)11000 2012_2013 3)00000 4)01001
2012-2013 3)00000 4)11000
2010-2011 3)10000 4)01110
2010-11
3.00011
4.11110
2012-13
3.11101
4.11000
2012-2013: 2010-2011
3. 00000 3. 00010
4. 11000 4. 00110