[go: up one dir, main page]

login
A321804
Keep only consecutive identical decimal digits of n; write -1 if all digits disappear.
2
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 55, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 66, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 99, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 111, 11, 11, 11, 11, 11, 11, 11, 11, -1, -1, 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 55, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 66, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 99
OFFSET
0,12
COMMENTS
Consecutive identical digits of n are kept. Leading zeros are erased unless the result is 0. If all digits are erased, we write -1 for the result (A321803 is another version, which uses 0 for the empty string).
More than the usual number of terms are shown in order to reach some interesting examples. Agrees with A321800 for n < 121.
EXAMPLE
123321 becomes 33, 1123 becomes 11, 112331 becomes 1133, and 100223 becomes 22 (as we don't accept leading zeros). Note that 12321 disappears immediately and we get -1.
MATHEMATICA
Array[If[# == {}, -1, FromDigits@ #] &@ Apply[Join, Select[Split@ IntegerDigits[#], Length@ # > 1 &]] &, 200] (* Michael De Vlieger, Nov 23 2018 *)
PROG
(Python)
from re import split
def A321804(n):
return (lambda x: int(x) if x != '' else -1)(''.join(d if len(d) != 1 else '' for d in split('(0+)|(1+)|(2+)|(3+)|(4+)|(5+)|(6+)|(7+)|(8+)|(9+)', str(n)) if d != '' and d != None))
CROSSREFS
KEYWORD
sign,base
AUTHOR
Chai Wah Wu, Nov 19 2018
STATUS
approved