• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Erlang otp Task problem

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everyone i try to learn Erlang otp programing and i have such a problem how to solve this task i try but i'm new and i don't have a good background on programing any suggestion!!


Implement a function that generates a random integer between 1 and 100. Then it reads an integer number from the standard input and checks whether the user given number is equal to the generated number. If not than it provides some hints to the user (similar to: "The number is lesser than ... ", "The number is greater than ...") and asks for a new number. The function asks numbers recursively until the user hits the generated one. To avoid infinite recursion a limit is provided as an initial argument, that is the maximum numbers of attempts. Please read the examples carefully to see what is the required information to provide for the user.

Example 1:

1> generate:num(20)

#########

Guess a number between 1 and 100!

--> 22.

22 is not my number. It is lesser than 22.

#########

Guess a number between 1 and 21!

--> 2.

2 is not my number. It is greater than 2.

#########

Guess a number between 3 and 21!

--> 5.

#########

Oh, yeah! 5 is my number! You've won the game!



Example 2:

1> generate:num(2)

#########

Guess a number between 1 and 100!

--> 55.

55 is not my number. It is lesser than 55.

#########

Guess a number between 1 and 54!

--> 21.

21 is not my number. It is lesser than 21.

#########

Game is over, sorry you've lost the game!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic