A088999 Flip 6,9 numbers: if number k contains decimal digit '6' or '9', then flip all occurrences of '6' to '9' and vice versa.
9, 6, 19, 16, 29, 26, 39, 36, 49, 46, 59, 56, 90, 91, 92, 93, 94, 95, 99, 97, 98, 96, 79, 76, 89, 86, 60, 61, 62, 63, 64, 65, 69, 67, 68, 66, 109, 106, 119, 116, 129, 126, 139, 136, 149, 146, 159, 156, 190, 191, 192, 193, 194, 195, 199, 197, 198, 196, 179, 176, 189
Offset: 1
Programs
-
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",")); ) }
-
Python
def has69(s): return '6' in s or '9' in s def flp69(s): return s.replace("6", "-").replace("9", "6").replace("-", "9") def aupto(lim): return [int(flp69(s)) for s in map(str, range(lim+1)) if has69(s)] print(aupto(186)) # Michael S. Branicky, Sep 06 2021
Comments