How to resolve the algorithm Number reversal game step by step in the 11l programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Number reversal game step by step in the 11l programming language
Table of Contents
Problem Statement
Given a jumbled list of the numbers 1 to 9 that are definitely not in ascending order. Show the list, and then ask the player how many digits from the left to reverse. Reverse those digits, then ask again, until all the digits end up in ascending order.
The score is the count of the reversals needed to attain the ascending order.
Note: Assume the player's input does not need extra validation.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Number reversal game step by step in the 11l programming language
Source code in the 11l programming language
V data = Array(‘139275486’)
V trials = 0
L data != sorted(data)
trials++
V flip = Int(input(‘###2: LIST: '#.' Flip how many?: ’.format(trials, data.join(‘ ’))))
data.reverse_range(0 .< flip)
print("\nYou took #. attempts to put the digits in order!".format(trials))
You may also check:How to resolve the algorithm Elliptic curve arithmetic step by step in the Go programming language
You may also check:How to resolve the algorithm Greyscale bars/Display step by step in the BASIC programming language
You may also check:How to resolve the algorithm Filter step by step in the SQL programming language
You may also check:How to resolve the algorithm 100 doors step by step in the Xojo programming language
You may also check:How to resolve the algorithm Table creation/Postal addresses step by step in the FunL programming language