How to resolve the algorithm Department numbers step by step in the Transd programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Department numbers step by step in the Transd 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 Transd programming language

Source code in the transd programming language

#lang transd

MainModule : {
    _start: (lambda 
        (lout "Police | Sanit. | Fire")
        (for i in Range(1 8) where (not (mod i 2)) do
            (for j in Range(1 8) where (neq i j) do
                (for k in Range(1 8) where (and (neq i k) (neq j k)) do
           (if (eq (+ i j k) 12) (lout i "        " j "        " k)))))
    )
}


  

You may also check:How to resolve the algorithm Mutual recursion step by step in the Lua programming language
You may also check:How to resolve the algorithm Delete a file step by step in the Erlang programming language
You may also check:How to resolve the algorithm String prepend step by step in the Lasso programming language
You may also check:How to resolve the algorithm Execute a system command step by step in the TUSCRIPT programming language
You may also check:How to resolve the algorithm Function composition step by step in the Bori programming language