How to resolve the algorithm Dinesman's multiple-dwelling problem step by step in the 11l programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Dinesman's multiple-dwelling problem step by step in the 11l programming language

Table of Contents

Problem Statement

Solve Dinesman's multiple dwelling problem but in a way that most naturally follows the problem statement given below. Solutions are allowed (but not required) to parse and interpret the problem text, but should remain flexible and should state what changes to the problem text are allowed. Flexibility and ease of expression are valued. Examples may be be split into "setup", "problem statement", and "output" sections where the ease and naturalness of stating the problem and getting an answer, as well as the ease and flexibility of modifying the problem are the primary concerns. Example output should be shown here, as well as any comments on the examples flexibility.

Baker, Cooper, Fletcher, Miller, and Smith live on different floors of an apartment house that contains only five floors.

Where does everyone live?

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Dinesman's multiple-dwelling problem step by step in the 11l programming language

Source code in the 11l programming language

-V
   BAKER    = 0
   COOPER   = 1
   FLETCHER = 2
   MILLER   = 3
   SMITH    = 4
   names = [‘Baker’, ‘Cooper’, ‘Fletcher’, ‘Miller’, ‘Smith’]

V floors = Array(1..5)

L
   I floors[BAKER] != 5 &
     floors[COOPER] != 1 &
     floors[FLETCHER] !C (1, 5) &
     floors[MILLER] > floors[COOPER] &
     abs(floors[SMITH] - floors[FLETCHER]) != 1 &
     abs(floors[FLETCHER] - floors[COOPER]) != 1
      L(floor) floors
         print(names[L.index]‘ lives on floor ’floor)
      L.break

   I !floors.next_permutation()
      print(‘No solution found.’)
      L.break

  

You may also check:How to resolve the algorithm Dot product step by step in the Maxima programming language
You may also check:How to resolve the algorithm A+B step by step in the Ela programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the Java programming language
You may also check:How to resolve the algorithm Read entire file step by step in the E programming language
You may also check:How to resolve the algorithm Balanced brackets step by step in the Picat programming language