How to resolve the algorithm 21 game step by step in the Phix programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm 21 game step by step in the Phix programming language

Table of Contents

Problem Statement

21 is a two player game, the game is played by choosing a number (1, 2, or 3) to be added to the running total. The game is won by the player whose chosen number causes the running total to reach exactly 21. The running total starts at zero. One player will be the computer. Players alternate supplying a number to be added to the running total.

Write a computer program that will:

Let's start with the solution: