Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Higher or Lower

By: a guest on Feb 10th, 2012  |  syntax: Prolog  |  size: 0.46 KB  |  views: 602  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. numguess:-numGuess(100,1).
  2. numGuess(Top,Bottom):-write('Is your number less than '),Middle is truncate((Top + Bottom) / 2),write(Middle),write('? [y/n]'),read(y), numGuess(Middle - 1,Bottom).
  3. numGuess(Top,Bottom):-write('Is your number greater than '),Middle is truncate((Top + Bottom) / 2),write(Middle),write('? [y/n]'),read(y), numGuess(Top,Middle + 1).
  4. numGuess(Top,Bottom):-write('Your number is '),Middle is truncate((Top + Bottom) / 2),write(Middle),write('.').