home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / misc / mouse.lbr / ODD.MZE / ODD.MSE
Encoding:
Text File  |  1988-07-12  |  1.5 KB  |  73 lines

  1.  
  2. "!
  3. ODD.MSE, 7/24/86, Lee R. Bradley
  4. !"
  5.  
  6. "!Want some background? " ?' r: 
  7. r. 'y = r. 'Y = + 
  8. [
  9. "!
  10. A man lives on a long street in Hartford.  The house numbers
  11. are odd on his side.  If the sum of the house numbers on one 
  12. side of his house equals the sum of the numbers on the other 
  13. side of his house, how many houses are there and what is his 
  14. house number ?  Here's a picture.  x represents the position
  15. of the man's house.  His house number would be 2*x -1.  y 
  16. represents the position of the last house on the street.
  17. "
  18. ]
  19. "!                             
  20.           1 .....  x-1   x   x+1 .....  y
  21.  
  22. "
  23.  
  24. ~ It can be shown that (x-1)*(x-1) + x*x = y*y .  
  25. ~ As they say, the proof is left as an exercise 
  26. ~ for the reader.
  27.  
  28. 1 s :
  29.  
  30. (
  31. s. ^
  32. "
  33. Enter a value greater than 50 and less than 500.  This will 
  34. be used as the first value of x, which represents the position
  35. of the man's house.  The program will try it and continue to 
  36. increment it until a solution is found.  
  37. Your number please.  "
  38. ? x :
  39. x. 50 > x. 501 < * [0 s :]
  40. s. ["!Try again."]
  41. )
  42.  
  43. "!!Calculating..."
  44. 1 s :
  45. (
  46. 500 x. - s. * ^
  47. x. 1 - x. 1 - * x. x. * + w :
  48. 1 t :
  49. x. 1 + y :
  50. (
  51. 500 y. - t. * ^
  52. y. y. * z :
  53. z. w. < [ 1 y. + y : ]
  54. z. w. > [ 0 t : ]
  55. z. w. = [ 0 t : 0 s : ]
  56. )
  57. s.
  58. [1 x. + x : ]
  59. )
  60. s. 0 = 
  61. [
  62. "!!
  63. The man lives in the " x. ! "th house.
  64. His house number is " x. 2 * 1 - !".
  65. There are " y. !" houses.
  66. "
  67. ]
  68. s.  
  69. ["!!Try a smaller x."]
  70. $
  71. the " x. ! "th house.
  72. His house number is " x. 2 * 1 - !".
  73. The