option.
Then evaluate the expression
<#3605#>(repl<#3605#> <#3606#>check-guess)<#3606#>
after <#60907#><#3610#>check-guess<#3610#><#60907#> has been thoroughly tested.~ Solution<#60908#><#60908#>
<#3616#>Exercise 5.1.3<#3616#>
Develop the function <#60909#><#3619#>check-guess3<#3619#><#60909#>. It implements a larger portion of
the number guessing game of exercise~#exguess1#3620> than the function
<#60910#><#3621#>check-guess<#3621#><#60910#>. Now the teachpack hands over the <#60911#><#3622#>digits<#3622#><#60911#> that
the user guesses, not the number that they form.
To simplify the problem a little bit, the game works with only three
numbers. Thus, <#60912#><#3623#>check-guess3<#3623#><#60912#> consumes three digits and a number. The
first digit is the least significant, the third one is the most significant. The
number is called <#60913#><#3624#>target<#3624#><#60913#> and represents the randomly chosen number.
Depending on how <#60914#><#3625#>guess<#3625#><#60914#>, the number determined by the three digits,
relates to <#60915#><#3626#>target<#3626#><#60915#>, <#60916#><#3627#>check-guess3<#3627#><#60916#> produces one of the following
three answers: <#60917#><#3628#>'<#3628#><#3629#>TooSmall<#3629#><#60917#>, <#60918#><#3630#>'<#3630#><#3631#>Perfect<#3631#><#60918#>, or <#60919#><#3632#>'<#3632#><#3633#>TooLarge<#3633#><#60919#>.
The rest of the game is still implemented by <#3634#>guess.ss<#3634#>. To play
the game with <#60920#><#3635#>check-guess3<#3635#><#60920#>, evaluate
<#3640#>(repl3<#3640#> <#3641#>check-guess3)<#3641#>
after the function has been thoroughly tested.
<#3645#>Hint:<#3645#> Remember to develop an auxiliary function per concept.~ Solution<#60921#><#60921#>
<#3651#>Exercise 5.1.4<#3651#>
Develop <#60922#><#3653#>what-kind<#3653#><#60922#>. The function consumes the coefficients <#60923#><#3654#>a<#3654#><#60923#>,
<#60924#><#3655#>b<#3655#><#60924#>, and <#60925#><#3656#>c<#3656#><#60925#> of a quadratic equation. It then determines whether
the equation is degenerate and, if not, how many solutions the equation has. The
function produces one of four symbols: <#60926#><#3657#>'<#3657#><#3658#>degenerate<#3658#><#60926#>, <#60927#><#3659#>'<#3659#><#3660#>two<#3660#><#60927#>,
<#60928#><#3661#>'<#3661#><#3662#>one<#3662#><#60928#>, or <#60929#><#3663#>'<#3663#><#3664#>none<#3664#><#60929#>.
<#3665#>Hint:<#3665#> \ Compare with exercise~#exquad1#3666>.~ Solution<#60930#><#60930#>
<#3672#>Exercise 5.1.5<#3672#>
#drnexcheckguess#3675>
Develop the function <#60932#><#3676#>check-color<#3676#><#60932#>. It implements a key portion of a color
guessing game. One player picks two colors for two squares; we call those
``targets''. The other one tries to guess which color is assigned to which
square; they are guesses. The first player's response to a guess is check the
colors and to produce one of the following answers:
- <#60933#><#3678#>'<#3678#><#3679#>Perfect<#3679#><#60933#>, if the first target is equal to the first
guess and the second target is equal to the second guess;
- <#60934#><#3680#>'<#3680#><#3681#>OneColorAtCorrectPosition<#3681#><#60934#>, if the first guess is equal to
the first target or the second guess is equal to the second target;
- <#60935#><#3682#>'<#3682#><#3683#>OneColorOccurs<#3683#><#60935#>, if either of the guesses is one of the two
targets;
- and <#60936#><#3684#>'<#3684#><#3685#>NothingCorrect<#3685#><#60936#>, otherwise.
These four answers are the only answers that the first player gives. The
second player is to guess the two chosen target colors with as few guesses
as possible.
The function <#60937#><#3687#>check-color<#3687#><#60937#> simulates the first player's checking action. It
consumes four colors; for simplicity, we assume that a color is a symbol, say,
<#60938#><#3688#>'<#3688#><#3689#>red<#3689#><#60938#>. The first two arguments to <#60939#><#3690#>check-color<#3690#><#60939#> are ``targets,''
the latter two are ``guesses.'' The function produces one of the four answers.
When the function is tested, use the teachpack to <#3691#>master.ss<#3691#> to play
the color-guessing game. The teachpack
provides the function <#60940#><#3693#>master<#3693#><#60940#>. Evaluate <#60941#><#3694#>(master<#3694#>\ <#3695#>check-color)<#3695#><#60941#>
and choose colors with the mouse.~ Solution<#60942#><#60942#>