How to resolve the algorithm Find the missing permutation step by step in the Run BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Find the missing permutation step by step in the Run BASIC programming language

Table of Contents

Problem Statement

Listed above are   all-but-one   of the permutations of the symbols   A,   B,   C,   and   D,   except   for one permutation that's   not   listed.

Find that missing permutation.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Find the missing permutation step by step in the Run BASIC programming language

Source code in the run programming language

list$ = "ABCD CABD ACDB DACB BCDA ACBD ADCB CDAB DABC BCAD CADB CDBA CBAD ABDC ADBC BDCA DCBA BACD BADC BDAC CBDA DBCA DCAB"

for a = asc("A") to asc("D")
  for b = asc("A") to asc("D")
    for c = asc("A") to asc("D")
      for d = asc("A") to asc("D")
        x$ = chr$(a) + chr$(b) + chr$(c)+ chr$(d)
        for i = 1 to 4                                            ' make sure each letter is unique
          j = instr(x$,mid$(x$,i,1))
          if instr(x$,mid$(x$,i,1),j + 1) <> 0 then goto [nxt]
        next i
       if instr(list$,x$) = 0 then print x$;" missing"            ' found missing permutation
[nxt] next d
    next c
  next b
next a

  

You may also check:How to resolve the algorithm Write entire file step by step in the Factor programming language
You may also check:How to resolve the algorithm Disarium numbers step by step in the Java programming language
You may also check:How to resolve the algorithm Map range step by step in the Wren programming language
You may also check:How to resolve the algorithm Mastermind step by step in the Prolog programming language
You may also check:How to resolve the algorithm FizzBuzz step by step in the OOC programming language