Picks illegal number of sticks

Assignment Help Basic Computer Science
Reference no: EM131544602

The game of "23" is a two-player game that begins with a pile of 23 toothpicks. Players take turns, withdrawing either 1,2, or 3 toothpicks at a time. The player to withdraw the last toothpick loses the game. Write a human vs. computer program that plays "23". The human should always move first. When it is the computer's turn, it should play according the following rules:

a. If there are more than 4 toothpicks left, the computer should withdraw 4 - X toothpicks, where X is the number of toothpicks the human withdrew on the previous turn.

b. If there are 2 to 4 toothpicks left, the computer should withdraw enough toothpicks to lave 1.

c. If there is 1 toothpick left, the computer has to take it and loses.

When the human player enters the number of toothpicks to withdraw, the program should perform input validation. Make sure the entered number is between 1 and 3 and that the player is not trying to withdraw more toothpicks than exist in the pile.

1. If the user picks illegal number of sticks, the program will prompt the user to repick.

2. At the end of each game, the program will prompt user to choose if the user wants another game.

Reference no: EM131544602

Questions Cloud

Company rate of return on this investment : What was the company's rate of return (in dollars) on this investment?
How will you train and educate others about the code : Create an original code of ethics for your family by thinking about your family as an organization. How will you train and educate others about the code?
Signature generation process results : DSA specifies that if the signature generation process results in a value of s=0, a new value of k should be generated and the signature should be recalculated
Application lifecycle management tool : Your team has decided to recommend that Sifers-Grayson invest in an Application Lifecycle Management tool.
Picks illegal number of sticks : If the user picks illegal number of sticks, the program will prompt the user to repick. At the end of each game, the program will prompt user to choose.
Draw the payoff diagrams : Draw the payoff diagrams (at maturity) for the following combinations of ABC stock and its options.
Expalin the competitive advantage of your selected company : Expalin the competitive advantage of your selected company. Evaluate the strategies your selected company uses to create value and gain competitive advantage.
Market rate of interest associated with this perpetuity : What is the market rate of interest associated with this perpetuity?
What are the most important elements of a business plan : What other elements should be added to the Business Plan to encourage potential investors? What are the most important elements of a Business Plan?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd