Descrizione
Consideriamo un numero intero con almeno 3 cifre triplicate se, quando divise in tre parti, le cifre in ogni parte si sommano allo stesso numero. Dividiamo i numeri come segue:
abcdefghi - Standard case: the number of digits is divisable through 3:
abc def ghi
abcdefgh - Number % 3 == 2: The outer groups are both assigned another digit
abc de fgh (the inner group will have one digit less than both outer groups)
abcdefghij - Number % 3 == 1: The inner group is assigned the extra digit
abc defg hij (the inner group will have one digit more than the outer groups)
Sfida
Il tuo compito è quello di scrivere un programma che, dato un numero intero con almeno 3 cifre, determina se il numero dato è triplo bilanciato e genera un valore di verità o falsa in base al suo risultato.
Casi test
333 -> True
343 -> False
3123 -> True
34725 -> True
456456 -> False
123222321 -> True
Si tratta di code-golf , quindi si applicano scappatoie standard e può vincere la risposta più breve in byte!
when split in three parts,