# [plt-scheme] Combining digits to form numbers

 From: aditya shukla (adityashukla1983 at gmail.com) Date: Mon Feb 16 14:59:03 EST 2009 Previous message: [plt-scheme] HtDP in Python! Next message: [plt-scheme] Combining digits to form numbers Messages sorted by: [date] [thread] [subject] [author]

```I am trying to solve this exercise from htdp

http://www.htdp.org/2003-09-26/Book/curriculum-Z-H-8.html

*Exercise 5.1.3.*   Develop the function check-guess3. It implements a
larger portion of the number guessing game of exercise
5.1.2<http://www.htdp.org/2003-09-26/Book/curriculum-Z-H-8.html#node_thm_5.1.2>than
the function
check-guess. Now the teachpack hands over the digits 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, check-guess3 consumes three digits and a number. The first
digit is the least significant, the third one is the most significant. The
number is called target and represents the randomly chosen number. Depending
on how guess, the number determined by the three digits, relates to target,
check-guess3 produces one of the following three answers: 'TooSmall, '
Perfect, or 'TooLarge.

The rest of the game is still implemented by *guess.ss*. To play the game
with check-guess3, evaluate

(guess-with-gui-3 check-guess3)

after the function has been thoroughly tested.

My solution is like this
contract for check-guess3

;; check-guess3 :: number * number * number  * number > symbol

(define check-3 (lambda(lsb csb msb number)....)

body

(define check-guess3 (lambda(lsb csb msb number)
(cond
[(< guess(lsb csb msb) number) 'Toosmall]
[(= guess(lsb csb msb) number) 'Perfect]
[else 'Toolarge])))

contract for guess

;;guess :: number * number *number -> number

(define guess (lambda(lsb csb msb)...)

body

(define guess (lambda(lsb csb msb)
This is the part which i was not able to do , how can i combine lsb
, csb and msb so the number is of the form (msbcsblsb) .Is there any
function in scheme which can do this

))

Any help is appreciated.