Graded out of 30. Median was 25. 1. More Numbers In The Social Atom (2007), author Mark Buchanan says "Take a piece of whisper-thin paper, say 0.1 mm thick. Now suppose you fold it in half twenty-five times in a row, doubling its thickness each time. How thick will it be? Almost everyone asked such a question will grossly underestimate the result." Right now, make your own estimate, which you should be able to do in your head on the basis of what we've done in class. When you do the rest of this exercise you can assess whether you are better than "almost everyone". (a) If Buchanan is correct about the thickness of a piece of paper, how thick will the folded paper be? 3 points .1mm * 2^25, or about 3 million mm, or 3 km or equivalent. you will lose a bit if you gave too much precision. (b) Is Buchanan's estimate of 0.1 mm much too high, much too low, or about right, and why? (You can make your own estimate by observation near printers.) 3 points only 1 point if they don't give a plausible reason? very close to right. if you measure a standard ream of paper like those found near printers, 500 sheets is about 5+ cm or 50 mm, so 10 sheets is 1 mm. (c) "... just 33 genes, each coming in just two varieties (such as on or off), would be enough to make every human being in the world unique. There are more than 10 billion ways of flipping a coin 33 times." (Nature via Nurture, Matt Ridley, 2003). Are these two statements consistent, and if not which one is wrong? Explain your answer quantitatively. (This is a question about numbers, not genomics.) 2 points not consistent: 2^33 ~ 8.6B < 10^10 (d) The standard RGB representation of colors uses 8 bits for the red component, 8 bits for green, and 8 bits for blue (24 bits in all), and thus 6 hexadecimal digits can express any given color. Suppose instead that a representation uses 9 bits for red, 8 bits for green and 7 bits for blue. Assuming that the bits are stored left to right in RGB order, what are the hexadecimal representations of red, green and blue? 1 point each? FF8000 007F80 00007F in each case, write out the 24 bits in binary, then convert back to hex. for example, red is 1111 1111 1000 0000 0000 0000 0000 2. Bloody Instructions (a) The toy machine was described in class (and its instruction repertoire is described below). Which toy machine instruction provides this "conditional transfer order"? IFPOS 2 points (b) The toy simulator (toysim.html) is a Javascript program that runs in a web page. Identify the lines in the simulator program that implement this instruction. else if (opcode[pc] == "ifpos") {if (accumulator >= 0) pc = findlab(adr[pc])-1} 2 points? (c) Modify the simulator by adding an IFNEG instruction that tests whether the accumulator holds a negative value. Give the code you write and say where in the existing program you added it. should be something like else if (opcode[pc] == "ifneg") {if (accumulator < 0) pc = findlab(adr[pc])-1} the test has to be < 0. otherwise your ifneg operator treats zero at a negative number. this is a critical error. 3. Get With the Program (a) Write a program that reads one number from the keyboard and prints twice its value (e.g., if the number is 10, the program prints 20). This should be about 6 lines long. Hint: Think about the class example that adds two numbers. Copy and paste the code from the Toy simulator screen where you ran it. 4 points? GET STORE X ADD X PRINT STOP X the label doesn't matter. don't worry about formatting. the simulator is pretty stupid, so if you don't use a label at all, the program still "works". i will try to remember to fix the program for the future. (b) Modify the program of (a) so it gets one number, prints twice its value, then loops to get another number. It stops when the input number is negative. 6 points? Top GET IFNEG Bot STORE X ADD X PRINT GOTO Top Bot STOP X again, should be pretty much like this, though you don't need to have used IFNEG.