Œ!QŒḂ€S%“µɲ€’
Çevrimiçi deneyin!
Nasıl?
Kaba bir zorlama.
Œ!QŒḂ€S%“µɲ€’ - Main link: string
Œ! - all permutations
Q - unique
€ - for each
ŒḂ - isPalindromic? (yep a built-in!)
S - sum
% - mod
“µɲ€’ - base 250 compressed number 666013
Ben inanıyorum bu bu daha verimli yapacak, ama bu 30 byte (düzenleme: Bu pdf onaylamak gibi görünüyor, nezaket SML cevabı ):
ÑHḞµS!÷!P$ - Link 1, palindrome count: string a e.g. 'abcabcd'
Ñ - call the next link (2) as a monad(a) e.g. [2, 2, 2, 1]
H - halve e.g. [1, 1, 1, 0.5]
Ḟ - floor (get pair counts) e.g. [1, 1, 1, 0]
µ - start a new monadic chain - call that p
S - sum(p) e.g. 3
! - factorial e.g. 6
$ - last 2 links as a monad:
! - factorial(p) (vectorises) e.g. [1, 1, 1, 1]
P - product e.g. 1
: - integer division e.g. 6
ĠL€ - Link 2, count characters: string a e.g. 'abcabcd'
Ġ - group indexes e.g. [[1, 4], [2, 5], [3, 6], 7]
L€ - length of €ach e.g. [2, 2, 2, 1]
ÇḂS⁼LḂ$aÑ%“µɲ€’ - Main link: string a e.g. 'abcabcd'
- first check to see if any palindromes will be possible:
Ç - last link (2) as a monad e.g. [2, 2, 2, 1]
Ḃ - mod 2 e.g. [0, 0, 0, 1]
S - sum e.g. 1
$ - last two links as a monad:
L - length(a string) e.g. 7
Ḃ - mod 2 e.g. 1
⁼ - equal? e.g. 1 (1 when palindromes are possible)
a - and
Ñ - next link as a monad e.g. 6
%“µɲ€’ - mod 666013, as in the brute force version.