RosettaCodeData/Task/Find-the-missing-permutation/EasyLang/find-the-missing-permutation.easy

19 lines
525 B
Text
Raw Permalink Normal View History

2025-06-11 20:16:52 -04:00
func$ missing perms$[] .
n = len perms$[1]
len cnt[] n
nn = 1
for i = 2 to n - 1 : nn *= i
for i to n
for j to n : cnt[j] = 0
for s$ in perms$[]
cod = strcode substr s$ i 1 - 64
cnt[cod] += 1
.
for j to n
if cnt[j] <> nn : miss$ &= strchar (j + 64)
2024-03-06 22:25:12 -08:00
.
.
2025-06-11 20:16:52 -04:00
return miss$
2024-03-06 22:25:12 -08:00
.
2025-06-11 20:16:52 -04:00
print missing [ "ABCD" "CABD" "ACDB" "DACB" "BCDA" "ACBD" "ADCB" "CDAB" "DABC" "BCAD" "CADB" "CDBA" "CBAD" "ABDC" "ADBC" "BDCA" "DCBA" "BACD" "BADC" "BDAC" "CBDA" "DBCA" "DCAB" ]