How to resolve the algorithm Guess the number/With feedback step by step in the 11l programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Guess the number/With feedback step by step in the 11l programming language

Table of Contents

Problem Statement

Write a game (computer program) that follows the following rules:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Guess the number/With feedback step by step in the 11l programming language

Source code in the 11l programming language

V (target_min, target_max) = (1, 100)

print("Guess my target number that is between #. and #. (inclusive).\n".format(target_min, target_max))
V target = random:(target_min..target_max)
V (answer, i) = (target_min - 1, 0)
L answer != target
   i++
   V txt = input(‘Your guess(#.): ’.format(i))
   X.try
      answer = Int(txt)
   X.catch ValueError
      print(‘  I don't understand your input of '#.' ?’.format(txt))
      L.continue
   I answer < target_min | answer > target_max
      print(‘  Out of range!’)
      L.continue
   I answer == target
      print(‘  Ye-Haw!!’)
      L.break
   I answer < target {print(‘  Too low.’)}
   I answer > target {print(‘  Too high.’)}

print("\nThanks for playing.")

  

You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the Fortran programming language
You may also check:How to resolve the algorithm Tonelli-Shanks algorithm step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Sort three variables step by step in the RPL programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the Axe programming language
You may also check:How to resolve the algorithm Nonogram solver step by step in the C# programming language