RosettaCodeData/Task/Find-the-missing-permutation/11l/find-the-missing-permutation.11l
2026-02-01 16:33:20 -08:00

15 lines
559 B
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

V perms = [ABCD, CABD, ACDB, DACB, BCDA, ACBD, ADCB, CDAB,
DABC, BCAD, CADB, CDBA, CBAD, ABDC, ADBC, BDCA,
DCBA, BACD, BADC, BDAC, CBDA, DBCA, DCAB]
V missing =
L(i) 0.<4
V cnt = [0] * 4
L(j) 0 .< perms.len
cnt[perms[j][i].code - A.code]++
L(j) 0.<4
I cnt[j] != factorial(4-1)
missing = Char(code' A.code + j)
L.break
print(missing)