How to resolve the algorithm Department numbers step by step in the Arturo programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Department numbers step by step in the Arturo programming language
Table of Contents
Problem Statement
There is a highly organized city that has decided to assign a number to each of their departments:
Each department can have a number between 1 and 7 (inclusive). The three department numbers are to be unique (different from each other) and must add up to 12. The Chief of the Police doesn't like odd numbers and wants to have an even number for his department.
Write a computer program which outputs all valid combinations.
Possible output (for the 1st and 14th solutions):
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Department numbers step by step in the Arturo programming language
Source code in the arturo programming language
loop 1..7 'x [
loop 1..7 'y [
loop 1..7 'z [
if all? @[
even? x
12 = sum @[x y z]
3 = size unique @[x y z]
] -> print [x y z]
]
]
]
You may also check:How to resolve the algorithm Metaprogramming step by step in the Go programming language
You may also check:How to resolve the algorithm Phrase reversals step by step in the Factor programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the C2 programming language
You may also check:How to resolve the algorithm AVL tree step by step in the Phix programming language
You may also check:How to resolve the algorithm Determine if a string is numeric step by step in the OCaml programming language