Chapter 3 Daily 05 RG

Reading questions to make sure you actually understand the details of the Daily 5 assignment.

These reading guide questions should be read along side the Chapter 3 Daily 5 assignment.

  1. Decode the binary number [1,1,0,1] written in form used in the problem set.

  2. A variation on the bcount function, called bcountTen, works with base ten numbers. What should be the result of running bcountTen 33 44 ?

  3. Another variation, bcountTenBin is like bcountTen but the results are output in the binary format used in the assignment. Give the result of bcountTenbin 51 89.

  4. Fill in potential missing values in the table.

len xs ensureLen len xs
4 [1,1] a
b [0,1] [0,1,0,0,0,0,0]
5 [1,1,1,1,1,1] c
6 d [0,1,1,1,0,0]
  1. What is and' 0 0? What about and' 15 15?

  2. What do you think or' would do? Explain briefly, possibly giving examples.

  3. Computer bitwiseAnd [0,1,0,0,1,0,0,0,1] [1,0,1,1,1,0,0,1,1].

  4. Can you use the function f x y = y * length x in the bitwise function? Explain.

  5. Can you use the function g a b = a^2 - b^2 in the bitwise function? Explain.

  6. A classmate is working on the txtToBin function. While explaining their work, they to online to the ASCII table and look up 'P' is 80, which is 0b1010000 according to a quick search, which causes them to write [1,0,1,0,0,0,0]. Respond to this work in the context of the problem set.

  7. Compute by hand: txtToBin "ACE".

  8. Compute by hand: binToMsg [[0,1],[1,0,1],[1],[1,1,0,0,1],[0,0,1,0,1]].

  9. Translate by hand with a group, possibly with a table of letter values.

    msgDecode [1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,0]
    
  10. Encrypt the message “HELP” using the key “me”.

Common Errors

  • Question 5: It would be surprising if and' 15 15 == 15.
  • Question 9: Compute bitwise g [1,0,1] [1,1,0] and make sure you are OK with the result before commenting on it.
  • Question 10. Writing the binary number in reverse order does not fix all of the problems with this method!

Encoding/Decoding Table


    0 []
A   1 [1]
B   2 [0, 1]
C   3 [1, 1]
D   4 [0, 0, 1]
E   5 [1, 0, 1]
F   6 [0, 1, 1]
G   7 [1, 1, 1]
H   8 [0, 0, 0, 1]
I   9 [1, 0, 0, 1]
J  10 [0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