How to resolve the algorithm Department numbers step by step in the MAD programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Department numbers step by step in the MAD 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 MAD programming language
Source code in the mad programming language
NORMAL MODE IS INTEGER
PRINT COMMENT $ POLICE SANITATION FIRE$
THROUGH LOOP, FOR P=2, 2, P.G.7
THROUGH LOOP, FOR S=1, 1, S.G.7
THROUGH LOOP, FOR F=1, 1, F.G.7
WHENEVER P.E.S .OR. P.E.F .OR. S.E.F, TRANSFER TO LOOP
WHENEVER P+S+F .E. 12, PRINT FORMAT OCC, P, S, F
LOOP CONTINUE
VECTOR VALUES OCC = $I6,S2,I10,S2,I4*$
END OF PROGRAM
You may also check:How to resolve the algorithm Periodic table step by step in the BASIC programming language
You may also check:How to resolve the algorithm CSV data manipulation step by step in the Phix programming language
You may also check:How to resolve the algorithm 100 prisoners step by step in the F# programming language
You may also check:How to resolve the algorithm Assertions step by step in the PL/I programming language
You may also check:How to resolve the algorithm XML/DOM serialization step by step in the ABAP programming language