A022481
Describe previous term from the right (method B - initial term is 1).
Original entry on oeis.org
1, 11, 12, 2111, 1321, 11213111, 1331112112, 211221133211, 12213212221221, 11221123112131112211, 122213311121123121122212, 211123122111312112211332112311
Offset: 1
E.g. the term after 1321 is obtained by saying "1 once, 2 once, 3 once, 1 once", which gives 11213111.
-
import Data.List (group, transpose)
a022481 n = a022481_list !! (n-1)
a022481_list = 1 : f [1] :: [Integer] where
f xs = (read $ concatMap show ys) : f ys where
ys = concat $ transpose [map head zss, map length zss]
zss = reverse $ group xs
-- Reinhard Zumkeller, Jan 26 2014
-
A022481[1]:=1;A022481[n_]:=A022481[n]=FromDigits[Flatten[{First[#],Length[#]}&/@Split[Reverse[IntegerDigits[A022481[n-1]]]]]];Map[A022481,Range[15]] (* Peter J. C. Moses, Apr 22 2013 *)
a[1]=1;a[n_]:=a[n]=FromDigits[Flatten[Replace[ Replace[ Replace[ Split[ Reverse[IntegerDigits[a[n-1]]]],{x_,y_}->{x,Length[{x,y}]},{1}],{x_,y_,z_}->{x,Length[{x,y,z}]},{1}],{x_}->{x,Length[{x}]},{1}]]];Array[a,15] (* Ivan N. Ianakiev, Jun 22 2017 *)
NestList[FromDigits@ Flatten@ Reverse@ Map[{First@ #, Length@ #} &, Split@ IntegerDigits@ #] &, 1, 11] (* Michael De Vlieger, Jun 26 2017 *)
A022488
Describe previous term from the right (method B - initial term is 2).
Original entry on oeis.org
2, 21, 1121, 112112, 21122112, 2112221221, 112211231221, 1122113121122212, 21112312211131122212, 211123123113221131211321, 112131122111311222311231211131211321, 112131122111311321113121123123123113221231112112
Offset: 1
E.g., the term after 1121 is obtained by saying "1 once, 2 once, 1 twice", which gives 112112.
-
import Data.List (group, transpose)
a022488 n = a022488_list !! (n-1)
a022488_list = 2 : f [2] :: [Integer] where
f xs = (read $ concatMap show ys) : f ys where
ys = concat $ transpose [map head zss, map length zss]
zss = reverse $ group xs
-- Reinhard Zumkeller, Apr 14 2014
-
A022488[1]:=2;A022488[n_]:=A022488[n]=FromDigits[Flatten[{First[#],Length[#]}&/@Split[Reverse[IntegerDigits[A022488[n-1]]]]]];Map[A022488,Range[15]] (* Peter J. C. Moses, Apr 22 2013 *)
-
from re import split
A022488_list, l = [2], '2'
for _ in range(10):
l = ''.join(d[0]+str(len(d)) for d in split('(0+|1+|2+|3+|4+|5+|6+|7+|8+|9+)',l[::-1]) if d != '')
A022488_list.append(int(l)) # Chai Wah Wu, Jan 07 2015
-
from itertools import accumulate, groupby, repeat
def summarize(n, _):
return int("".join(k+str(len(list(g))) for k, g in groupby(str(n)[::-1])))
def aupton(nn): return list(accumulate(repeat(2, nn), summarize))
print(aupton(12)) # Michael S. Branicky, Feb 21 2021
A022520
Describe previous term from the right (method B - initial term is 9).
Original entry on oeis.org
9, 91, 1191, 119112, 21129112, 211291211221, 112212211191211221, 1122122111911322112212, 21112212223112911322112212, 21112212223112912112312311221321
Offset: 0
The term after 1191 is obtained by saying "1 once, 9 once, 1 twice", which gives 119112.
-
import Data.List (group, transpose)
a022520 n = a022520_list !! n
a022520_list = 9 : f [9] :: [Integer] where
f xs = (read $ concatMap show ys) : f ys where
ys = concat $ transpose [map head zss, map length zss]
zss = reverse $ group xs
-- Reinhard Zumkeller, Jan 26 2014
A022518
Describe previous term from the right (method B - initial term is 7).
Original entry on oeis.org
7, 71, 1171, 117112, 21127112, 211271211221, 112212211171211221, 1122122111711322112212, 21112212223112711322112212, 21112212223112712112312311221321
Offset: 0
The term after 1171 is obtained by saying "1 once, 7 once, 1 twice", which gives 117112.
-
import Data.List (group, transpose)
a022518 n = a022518_list !! n
a022518_list = 7 : f [7] :: [Integer] where
f xs = (read $ concatMap show ys) : f ys where
ys = concat $ transpose [map head zss, map length zss]
zss = reverse $ group xs
-- Reinhard Zumkeller, Jan 26 2014
-
split[n_]:=Split[Reverse[IntegerDigits[n]]];
list1[n_]:=List/@Length/@split[n];riffle1[n_]:=Riffle[split[n],list1[n]];
tab[n_]:=Table[i,{i,1,2*Length[list1[n]],2}];
list2[n_]:=Append[riffle1[n][[#]],riffle1[n][[#+1]]]&/@tab[n];
flat[n_]:=Flatten/@list2[n];riffle2[n_]:=Riffle[First/@flat[n],Last/@flat[n]];
a[1]=7;a[n_]:=FromDigits[riffle2[a[n-1]]];Array[a,10] (* or *)
a[1]=7;a[n_]:=FromDigits[Flatten[Replace[Replace[Replace[Split[Reverse[IntegerDigits[
a[n-1]]]],{x_,y_}-> {x,Length[{x,y}]},{1}],{x_,y_,z_}-> {x,Length[{x,y,z}]},{1}],{x_}-> {x,Length[{x}]},{1}]]];Array[a,10] (* Ivan N. Ianakiev, Oct 07 2016 *)
Showing 1-4 of 4 results.
Comments