login
Flip 6,9 numbers: if number k contains decimal digit '6' or '9', then flip all occurrences of '6' to '9' and vice versa.
0

%I #13 Sep 07 2021 09:29:18

%S 9,6,19,16,29,26,39,36,49,46,59,56,90,91,92,93,94,95,99,97,98,96,79,

%T 76,89,86,60,61,62,63,64,65,69,67,68,66,109,106,119,116,129,126,139,

%U 136,149,146,159,156,190,191,192,193,194,195,199,197,198,196,179,176,189

%N Flip 6,9 numbers: if number k contains decimal digit '6' or '9', then flip all occurrences of '6' to '9' and vice versa.

%C For digits d of n if d = 6 make it 9 else if d = 9 make it 6.

%C However, numbers containing neither digit 6 nor 9 are not terms (cf. A222251).

%o (PARI) flip69(n) = { for(x=1,n, y=x; v=0; f=0; ln =length(Str(x)); a = vector(ln); forstep(j=ln,1,-1, r = y%10; a[j]=r; if(r==6,a[j] = 9; f=1); if(r==9,a[j] = 6; f=1); y = floor(y/10); ); forstep(j=ln,1,-1, v=v+a[j]*10^(ln-j) ); if(f,print1(v",")); ) }

%o (Python)

%o def has69(s): return '6' in s or '9' in s

%o def flp69(s): return s.replace("6", "-").replace("9", "6").replace("-", "9")

%o def aupto(lim):

%o return [int(flp69(s)) for s in map(str, range(lim+1)) if has69(s)]

%o print(aupto(186)) # _Michael S. Branicky_, Sep 06 2021

%Y Cf. A171055, A222251.

%K nonn,base

%O 1,1

%A _Cino Hilliard_, Nov 02 2003