login
I is the first, second, eighth, ... letter in this sentence not counting spaces or commas.
5

%I #15 Apr 02 2022 10:53:59

%S 1,2,8,19,25,41,51,56,61,66,71,76,81,86,91,103,115,120,126,131,137,

%T 142,148,164,178,201,222,238,243,259,307,323,351,367,405,410,432,446,

%U 451,494,510,515,532,555,588,615,631,636,652,664,680,691,700,712,723,734

%N I is the first, second, eighth, ... letter in this sentence not counting spaces or commas.

%e The sentence begins:

%e 1234567890 1234567890 1234567890 1234567890 1234567890

%e Iisthefirs tsecondeig hthninetee nthtwentyf ifthfortyf

%e irstfiftyf irstfiftys ixthsixtyf irstsixtys ixthsevent

%e yfirstseve ntysixthei ghtyfirste ightysixth ninetyfirs

%e tonehundre dthirdoneh undredfift eenthonehu ndredtwent

%e iethonehun dredtwenty sixthonehu ndredthirt yfirstoneh

%e undredthir tyseventho nehundredf ortysecond onehundred ...

%t seed="iisthe";s[1]=1;s[2]=2; name[n_]:=

%t StringReplace[IntegerName[n,{"English","Ordinal"}],{"-"->""," "->""}];

%t s[n_]:=seed=StringJoin[seed<>name[StringPosition[seed,"i"][[n-2,1]]]];

%t l=s/@Range[56]; Table[StringPosition[Last[l],"i"][[k,1]],{k,1,Length[l]}]

%t (* _Ivan N. Ianakiev_, Apr 02 2022 *)

%o (Python)

%o from num2words import num2words

%o from itertools import islice

%o def n2w(n):

%o os = num2words(n, ordinal=True).replace(" and", "")

%o return os.replace(" ", "").replace("-", "").replace(", ", "")

%o def agen(): # generator of terms

%o s, idx = "iisthe", 0

%o while True:

%o idx_rel = 1 + s.index("i")

%o idx += idx_rel

%o yield idx

%o s = s[idx_rel:] + n2w(idx)

%o print(list(islice(agen(), 56))) # _Michael S. Branicky_, Apr 02 2022

%Y Cf. A005224, A055508.

%K nonn,word,easy,nice

%O 1,2

%A _J. Lowell_

%E More terms from _Robert G. Wilson v_, Jul 18 2000

%E Corrected and extended by Larry Reeves (larryr(AT)acm.org), Nov 02 2000