OFFSET
0,3
COMMENTS
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
EXAMPLE
n = 11: digits 0 and 1 occur twice in {a(k): k=0..10}, all other digits exactly once, where 2 is the smallest; therefore a(11) must contain digit 2, and 12 is the smallest unused number containing 2, hence a(11) = 12.
n = 55: digits 0..9 occur exactly 10 times in {a(k): k=0..54}; therefore a(55) must contain digit 0, the smallest digit; a(55) = 100, as 100 is the smallest unused number containing 0;
n = 56: least occurring digits in {a(k): k=0..10} are 2..9 and 2 is the smallest; therefore a(56) must contain digit 2, and 21 is the smallest unused number containing 2, hence a(56) = 21.
PROG
(Haskell)
import Data.List (delete, group, sortBy); import Data.Function (on)
a249626 n = a249626_list !! n
a249626_list = f (zip [0, 0..] [0..9]) a031298_tabf where
f acds@((_, dig):_) zss = g zss where
g (ys:yss) = if dig `elem` ys
then y : f acds' (delete ys zss) else g yss
where y = foldr (\d v -> 10 * v + d) 0 ys
acds' = sortBy (compare `on` fst) $
addd (sortBy (compare `on` snd) acds)
(sortBy (compare `on` snd) $
zip (map length gss) (map head gss))
addd cds [] = cds
addd [] _ = []
addd ((c, d) : cds) yys'@((cy, dy) : yys)
| d == dy = (c + cy, d) : addd cds yys
| otherwise = (c, d) : addd cds yys'
gss = sortBy compare $ group ys
CROSSREFS
KEYWORD
AUTHOR
Reinhard Zumkeller, Nov 03 2014
STATUS
approved