Back

Challenge Set 7

Unlocks after Activity 1.16. Three code challenges and the Part 2 review set.

divider

What This Set Is For

All three of these produce a different answer every time you run them. Nothing before Activity 1.16 did that, and it changes what testing means: you can no longer run a program once, see the right answer, and be finished.

Magic 8 Ball and Dice Duel both hide the same bug, and it is the reason this set is worth doing. A random range with the wrong upper number quietly drops one outcome — a die that never rolls a 6, an answer the toy can never give. It compiles, it runs, and it looks completely normal. Coin Flip does not have this trap — two outcomes from Next(0, 2) leaves no upper number to get wrong, which is exactly why it is the easier one to start on.


The Second Number Is Where It Stops

Random.Shared.Next(1, 7) gives you a whole number from 1 to 6. The 7 is not a value you can get — it is where the range ends.

The exam sheet writes the same die as RANDOM(1, 6), with both ends included, which you met in Activity 1.6. The two notations describe the same six faces and do not use the same second number. That is the single most likely thing to go wrong in this set.


Both Are Briefs

Nobody lists the steps on either page. You get a result somebody wants, and you write the requirements list first — input, calculate, output, and every decision you had to make yourself.

If that is unfamiliar, read it once here: How to Read a Brief, in Challenge Set 1.


The Challenges

Coin Flip is one random call and two outcomes — start here if Random.Shared.Next is brand new. Magic 8 Ball is the next step up and is a six-branch chain on top of a random number. Dice Duel has two rolls instead of one and three outcomes instead of two, and the tie is the one you will not hit by accident.

These are options, not a checklist. Pick whichever combination gets you to what the dropbox asks for — Coin Flip is the easiest way in if a random result feels unfamiliar.


The Review Set

Three pages, one drop, and none of them need a computer. All three are reading somebody else's code — do them on paper in one sitting, which is how the exam will ask for them.

Question Set 3 is timed at 12 minutes. Start the timer before you read the first question, not after.


Which Homework These Feed

This page feeds both drops. The three code challenges finish Part 2's pool of five, together with anything you did not use from Challenge Set 4, Challenge Set 5, or Challenge Set 6. The review set is its own drop.

The dropbox says how many. This page only says what is available.

Commence Challenges