Liste tous les titres possibles pour les jeux Anno

37

Dans la série de jeux vidéo Anno, il y a 6 jeux dont un septième annoncé pour début 2019. Leurs titres figurent toujours une année dans un modèle spécifique:

Anno 1602, Anno 1503, Anno 1701, Anno 1404, Anno 2070, Anno 2205, Anno 1800

  • La somme numérique est toujours 9.
  • Les années ont quatre chiffres.
  • Ils contiennent au moins un zéro.

Parmi ces contraintes, il existe 109 titres possibles:

[1008,1017,1026,1035,1044,1053,1062,1071,1080,1107,1170,1206,1260,1305,1350,1404,1440,1503,1530,1602,1620,1701,1710,1800,2007,2016,2025,2034,2043,2052,2061,2070,2106,2160,2205,2250,2304,2340,2403,2430,2502,2520,2601,2610,2700,3006,3015,3024,3033,3042,3051,3060,3105,3150,3204,3240,3303,3330,3402,3420,3501,3510,3600,4005,4014,4023,4032,4041,4050,4104,4140,4203,4230,4302,4320,4401,4410,4500,5004,5013,5022,5031,5040,5103,5130,5202,5220,5301,5310,5400,6003,6012,6021,6030,6102,6120,6201,6210,6300,7002,7011,7020,7101,7110,7200,8001,8010,8100,9000]

Votre objectif est de les lister sous une forme raisonnable dans le plus petit nombre d’octets.

Laikoni
la source
Quelle est la flexibilité du format de sortie? Est- ce acceptable?
Luis Mendo
1
@ LuisMendo Oui, ça me va.
Laikoni
Les listes de chiffres sont-elles autorisées?
Erik l'Outgolfer
1
@aslum Je suppose que vous entendez beaucoup d'espaces, pas seulement un, non? Le démarquage des commentaires ne permet pas une bonne représentation de cela. Et je suppose que c'est autorisé, étant donné que le format de Luis ci-dessus est autorisé. ;-)
Erik the Outgolfer
1
@EriktheOutgolfer Je dirais non aux listes de chiffres car ils ne ressemblent plus vraiment à des années.
Laikoni

Réponses:

20

R , 59 51 octets

Affiche les numéros valides sous forme de noms d'une liste de 201. Pourquoi 201? Parce que ASCII 0 est 48, et 4 * 48 + 9 est ... oui. Enregistré 6 octets par aliasing ^à Mapet un autre 2 en utilisant 1:9e3comme plage.

"^"=Map;x=sum^utf8ToInt^grep(0,1:9e3,,,T);x[x==201]

Essayez-le en ligne!

Explication

# Create list of sums of ASCII char values of numbers,
# with the original numbers as the names of the list
x <- Map(sum,
  # Create a list from the strings where each element is the string split 
  # into ASCII char values
  Map(utf8ToInt,
      # Find all numbers between 1 and 9e3 that contain a zero
      # Return the matched values as a vector of strings (6th T arg)
      grep(pattern=0,x=1:9000,value=TRUE)
  )
)
# Pick out elements with value 201 (i.e. 4-digits that sum to 9)
# This implicitly only picks out elements with 4 digits, since 3-digit 
# sums to 9 won't have this ASCII sum, letting us use the 1:9e3 range
x[x==201] 
J.Doe
la source
3
ah, greppourquoi ne me souviens-je jamais qu'il jette character...
Giuseppe
17

Perl 6 , 35 33 octets

-2 octets grâce à Jo King

{grep {.ords.sum==201&&/0/},^1e4}

Essayez-le en ligne!

Nwellnhof
la source
9

Python 2 , 67 66 64 octets

print[y for y in range(9001)if('0'in`y`)*sum(map(ord,`y`))==201]

Essayez-le en ligne!


Enregistré:

  • -1 octet, merci à Luis felipe De jesus Munoz
  • -2 octets, merci à Kevin Cruijssen
TFeld
la source
64 octets en utilisant le ord sum == 201truc d'autres réponses.
Kevin Cruijssen
9

Gelée , 11 octets

9ȷṢ€æ.ẹ9ṫ19

Essayez-le en ligne!

Comment ça marche

9ȷṢ€æ.ẹ9ṫ19  Main link. No arguments.

9ȷ           Set the left argument and the return value to 9000.
  Ṣ€         Sort the digits of each integer in [1, ..., 9000].
    æ.       Perform the dot product of each digit list and the left argument,
             which gets promoted from 9000 to [9000].
             Overflowing digits get summed without multiplying, so we essentially
             map the digit list [a, b, c, d] to (9000a + b + c + d).
      ẹ9     Find all 1-based indices of 9.
             Note that 9000a + b + c + d == 9 iff a == 0 and b + c + d == 9.
        ṫ19  Tail 19; discard the first 18 indices.
Dennis
la source
7

PowerShell , 50 49 octets

999..1e4-match0|?{([char[]]"$_"-join'+'|iex)-eq9}

Essayez-le en ligne!

Construit une plage allant de 999à 10000, puis utilise inline -matchcomme filtre pour extraire les entrées avec lesquelles la regex correspond 0. Cela nous laisse avec 1000, 1001, 1002, etc.Nous canalisons ensuite cela dans une Where-Objectclause où nous prenons le nombre actuel comme une chaîne "$_", le chartransposons comme un tableau, -joinces caractères avec +et Invoke- Ex(similaire à eval) pour arriver à leur somme. Nous vérifions que ce soit -equel à 9, et s'il est passé sur le pipeline. À la fin du programme, ces chiffres sont extraits du pipeline et sortent implicitement.

AdmBorkBork
la source
5

JavaScript (ES6), 78 73 octets

2 octets sauvés grâce à @KevinCruijssen

Retourne une chaîne séparée par des espaces.

f=(n=9e3)=>n>999?f(n-9)+(eval([...n+''].join`+`)&/0/.test(n)?n+' ':''):''

Essayez-le en ligne!

Comment?

Nous parcourons l'intervalle [1008..9000] avec un incrément de 9 , en ignorant les nombres qui n'ont pas de 0 .

Tous ces nombres sont des multiples de 9 , la somme de leurs chiffres est donc également un multiple de 9 .

Comme les nombres valides ont au moins un 0 , ils n’ont pas plus de deux 9 , ce qui signifie que la somme des chiffres restants est au maximum de 18 . Par conséquent, il suffit de vérifier si la somme des chiffres est impair.

D'où le test:

(eval([...n + ''].join`+`) & /0/.test(n)
Arnauld
la source
Vous pouvez enregistrer un octet changer l' 1008à 999, car il ne contient pas de 0 de toute façon, et 999+9 = 1008.
Kevin Cruijssen
Ou même 2 octets en le changeant en f=(n=9e3)=>n<1e3?'':(eval([...n+''].join`+`)<10&/0/.test(n)?[n,,]:'')+f(n-9)(contient une virgule de fin, cependant, f=(n=9e3)=>n<1e3?'':(eval([...n+''].join`+`)<10&/0/.test(n)?n+' ':'')+f(n-9)avec un délimiteur d'espace incluant l'espace de fin peut paraître plus joli)
Kevin Cruijssen
@KevinCruijssen Merci! J'essaie en fait de mettre à jour cela pendant un moment, mais j'ai environ 500 Go de bande passante Internet, là où je suis ce soir. : /
Arnauld
Je connais le sentiment. Dernièrement, notre connexion Internet à la maison est de la merde pour une raison quelconque. Impossible de télécharger quoi que ce soit au-dessus de 10 Mo, et il faut parfois rafraîchir des vidéos ou des pages contenant plus de 10 images plusieurs fois avant qu’il ne se charge complètement .. Vraiment ennuyeux Quand je travaille à la maison les lundis / mardis ...>.> Demain, quelqu'un vient le réparer (et je ne le quitterai pas avant que cela soit réglé xD)
Kevin Cruijssen
5

JavaScript (Node.js) , 89 octets

[...Array(9e3)].map(_=>i++,i=1e3).filter(a=>(s=[...a+""]).sort()[0]<1&eval(s.join`+`)==9)

Essayez-le en ligne!

  • -4 octets grâce à @ETHproductions

JavaScript (Node.js) 129 127 126 124 115 114 111 110 105 97 93 92 90 octets

[...Array(9e3)].map(f=(_,i)=>eval(s=[...(i+=1e3)+""].sort().join`+`)-9|s[0]?0:i).filter(f)

Essayez-le en ligne!

Explication

[...Array(9e3)].map(f=(_,i)=>eval(s=[...(i+=1e3)+""].sort().join`+`)-9|s[0]?0:i).filter(f)
[...Array(9e3)].map(f=(_,i)=>                                                  )           // Create a 9000-length array and loop over it; store the loop body
                                    [...(i+=1e3)+""]                                       // Add 1000 to the index and split it into an array of characters (17 -> ["1", "0", "1", "7"])
                                                    .sort()                                // Sort the array of characters in ascending order by their code points ("0" will always be first) (["1", "0", "1", "7"] -> ["0", "1", "1", "7"])
                                  s=                       .join`+`                        // Join them together with "+" as the separator (["0", "1", "1", "7"] -> "0+0+2+9"); store the result
                             eval(                                 )-9                     // Evaluate and test if it's different than 9
                                                                       s[0]                // Take the first character of the string and implicitly test if it's different than "0"
                                                                      |    ?0              // If either of those tests succeeded, then the number doesn't meet challenge criteria - return a falsey value
                                                                             :i            // Otherwise, return the index
                                                                                .filter(f) // Filter out falsey values by reusing the loop body

First time doing code golf in JavaScript. I don't think I need to say it, but if I'm doing something wrong, please notify me in the comments below.

  • -3 bytes thanks to @Luis felipe De jesus Munoz

  • -6 bytes thanks to @Kevin Cruijssen

Alion
la source
1
[...Array(9e3)] instead Array(9e3).fill() saves 2 bytes
Luis felipe De jesus Munoz
1
.map(a=>+a) instead .map(Number) saves another byte
Luis felipe De jesus Munoz
1
You can remove the space at (_, i) to save a byte, and s[0]+s[1]+s[2]+s[3] can be eval(s.join`+`) to save an additional 4 bytes.
Kevin Cruijssen
1
Also, I'm pretty sure the || can be | in your answer.
Kevin Cruijssen
1
If you use .map() only to generate the range, and keep the filtering separate, you can save 8 bytes: Try it online!
ETHproductions
5

Python 2, 57 bytes

n=999
exec"n+=9\nif'0'in`n`>int(`n`,11)%10>8:print n\n"*n

Try it online!

2 bytes thanks to Dennis

Uses an exec loop to counts up n in steps of 9 as 1008, 1017, ..., 9981, 9990, printing those that meet the condition.

Only multiples of 9 can have digit sum 9, but multiples of 9 in this range can also have digits sum of 18 and 27. We rule these out with the condition int(`n`,11)%10>8. Interpreting n in base 11, its digit sum is equal to the number modulo 10, just like in base 10 a number equals its digit sum modulo 9. The digits sum of (9, 18, 27) correspond to (9, 8, 7) modulo 10, so taking those>8 works to filter out nines.

The number containing a zero is check with string membership. '0'in`n`. This condition is joined with the other one with a chained inequality, using that Python 2 treats strings as greater than numbers.

xnor
la source
I like how heavily golfed Python seems to often have enormously long autogenerated executables...
J.Doe
4

sed and grep (and seq), 72 64 63 bytes

seq 9e3|sed s/\\B/+/g|bc|grep -wn 9|sed s/:9//|grep 0|grep ....
Thor
la source
Some of these aren't four digits long (but I'm not sure what the final grep is, so maybe I'm running it wrong?)
Sparhawk
@Sparhawk: The last grep ensures that the number is 4 digits long
Thor
@Thor Ah right. For some reason I parsed that as an ellipsis.
Sparhawk
4

Haskell, 55 bytes

[i|i<-show<$>[1..5^6],201==sum(fromEnum<$>i),elem '0'i]

Thanks to @Laikoni, see the comments.

Readable:

import Data.Char (digitToInt)

[i | i <- show <$> [1000..9999]
   , sum (digitToInt <$> i) == 9
   , '0' `elem` i
   ]
mb21
la source
2
Welcome to PPCG and Haskell golfing in particular! You can save a few bytes by dropping (-48+) and comparing the sum against 201 instead of 9. Incidentally this also allows you to use 1 instead of 1000 for the range.
Laikoni
Also your previous version without main=print was fine as per this consensus on Meta.
Laikoni
9999 can be 5^6 instead.
Laikoni
1
Ha, there's always another byte to shave! Thanks :-)
mb21
3

R, 82 bytes

write((x=t(expand.grid(1:9,0:9,0:9,0:9)))[,colSums(x)==9&!apply(x,2,all)],1,4,,"")

Try it online!

Generates a matrix x of all possible 4-digit numbers, excluding leading zeros, going down columns. Then filters for column (digital) sums of 9 and containing zero, i.e., not all are nonzero. write prints down the columns, so we write to stdout with a width of 4 and a separator of "".

Outgolfed by J.Doe

Giuseppe
la source
Nice answer! I came up with a different route...
J.Doe
3

Japt, 20 18 bytes.

-2 bytes thanks to @Shaggy and @ETHproductions

A³òL² f_=ì)x ¥9«Z×

A³òL² f_=ì)x ¥9«Z×  Full program
A³òL²               Range [1000, 10000]
      f_            Filter by : 
        =ì)         Convert to array 
           x ¥9     Sum equal to 9?
               «    And 
                Z×  Product not 0

Try it online!

Luis felipe De jesus Munoz
la source
This is actually 28 bytes. Using a literal integer instead is 22 bytes but A³ò9000 f_ìx ¥9©ZsøT gets you back down to 20.
Shaggy
1
You can save 1 byte by using ì instead of s and ¬, which has to be done in the filter: f_=ì)x ¥9.... Then you can save another by checking if the product of Z is zero with «Z×: Try it online!
ETHproductions
3

Java 8, 128 117 115 bytes

v->{int i=109,r[]=new int[i],n=i;for(;i>0;n++)if((n+"").chars().sum()==201&(n+"").contains("0"))r[--i]=n;return r;}

-11 bytes thanks to @nwellnhof.

Try it online.

Explanation:

v->{                              // Method with empty unused parameter & int-array return
  int i=109,                      //  Index-integer, starting at 109
      r[]=new int[i],             //  Result-array of size 109
      n=i;                        //  Number integer, starting at 109
   for(;i>0;                      //  Loop as long as `i` is not 0 yet:
       n++)                       //    After every iteration, increase `n` by 1
     if((n+"").chars().sum()==201 //   If the sum of the unicode values of `n` is 201,
                                  //   this means there are four digits, with digit-sum = 9
        &(n+"").contains("0"))    //   and `n` contains a 0:
       r[--i                      //    Decrease `i` by 1 first
            ]=n;                  //    And put `n` in the array at index `i`
  return r;}                      //  Return the array as result
Kevin Cruijssen
la source
1
What about chars().sum()==201?
nwellnhof
@nwellnhof Ah, of course. Thanks!
Kevin Cruijssen
3

R, 85 bytes

(just competing for the best abuse of R square brackets ... :P )

`[`=`for`;i[a<-0:9,j[a,k[a,w[a,if(sum(s<-c(i,j,k,w))==9&any(!s)&i)write(s,1,s='')]]]]

Try it online!

digEmAll
la source
1
Holy for loops, Batman!
BLT
3

05AB1E, 15 13 12 10 bytes

₄4°ŸεW°ö9Q

-2 bytes thanks to @Emigna
-3 bytes thanks to @Grimy

Try it online.

Explanation:

4°Ÿ        # Create a list in the range [1000,10000]
    ʒ       # Filter this list by:
     W      #  Get the smallest digit in the number (without popping the number itself)
      °     #  Take 10 to the power this digit
       ö    #  Convert the number from this base to an integer (in base-10)
        9Q  #  Check if it's equal to 9
  • If the smallest digit is d=0 it will become 1 with the 10d (°). And the number in base-1 converted to an integer in base-10 (ö) would act like a sum of digits.
  • If the smallest digit is d=1 it will become 10 with the 10d (°). And the number in base-10 converted to an integer in base-10 (ö) will of course remain the same.
  • If the smallest digit is d=2 it will become 100 with the 10d (°). And the number in base-100 convert to an integer in base-10 (ö) would act like a join with 0 in this case (i.e. 2345 becomes 2030405).
  • If the smallest digit is d=3 it will become 1000 with the 10d (°). And the number in base-100 convert to an integer in base-10 (ö) would act like a join with 00 in this case (i.e. 3456 becomes 3004005006).
  • ... etc. Smallest digits d=[4,9] would act the same as d=2 and d=3 above, with d1 amount of 0s in the 'join'.

If the smallest digit is >0 with the given range [1000,10000], the resulting number after °ö would then be within the range [1111,9000000009000000009000000009], so can never be equal to 9. If the result is equal to 9 (9Q) it would mean the smallest digit is d=0, resulting in a base-1 with °ö; and the sum of the digits was 9.

Kevin Cruijssen
la source
1
₄4°Ÿʒ0å}ʒSO9Q. Splitting filters are usually shorter
Emigna
@Emigna Ah, I was looking for a shorter way for the range, but completely forgot about . Thanks. And you're indeed right that multiple loose filters (at the end) are shorter. Will also add it to one of my tip answers. Thanks for both bytes!
Kevin Cruijssen
1
And my other 13-byter (inspired by the ord sum == 201 trick) is 4°Lʒ0å}ʒÇOт·-. Leaving this here, maybe someone can golf it further
Mr. Xcoder
1
₄4°ŸʒD0åôO9Q. Using a single filter is usually shorter.
Grimmy
1
Nevermind, here's a 10: ₄4°ŸʒW°ö9Q
Grimmy
2

Pip, 18 bytes

{0Na&$+a=9}FIm,t*m

Use an ouput-format flag such as -p to get readable output. Try it online!

{0Na&$+a=9}FIm,t*m
             m,t*m  Range from 1000 to 10*1000
{         }FI       Filter on this function:
 0Na                 There is at least one 0 in the argument
    &                and
     $+a             The sum of the argument
        =9           equals 9
DLosc
la source
2

Wolfram Language (Mathematica), 56 55 bytes

Select[9!!~Range~9999,Tr@#==Times@@#+9&@*IntegerDigits]

Try it online!

We test the range from 9!! = 945 to 9999, since there are no results between 945 and 999. Maybe there's a shorter way to write a number between 9000 and 10007, as well.

Tr@#==Times@@#+9& applied to {a,b,c,d} tests if a+b+c+d == a*b*c*d+9, which ends up being equivalent to The Anno Condition.

Misha Lavrov
la source
In retrospect, 9!! isn't any shorter than 999 or something, but it beats 1000.
Misha Lavrov
What is 9!! ? In guessing it isnt related to factorials.
Robert Fraser
@RobertFraser Double factorial: 9*7*5*3*1.
Misha Lavrov
2

Ruby, 46 42 41 bytes

?9.upto(?9*4){|x|x.sum==201&&x[?0]&&p(x)}

Try it online!

How it works:

  • Iterate on strings ranging from '9' to '9999'
  • Check that sum of ASCII values is 201
  • Check if string contains a zero (without regex, a regex would be 1 byte longer)

(Thanks Laikoni for -2 bytes)

G B
la source
1
9*3 can be just 9, because checking against 201 already requires 4 digit numbers.
Laikoni
2

Octave, 49 bytes

6 bytes saved using a more convenient output format as suggested by J.Doe.

Thanks to @Laikoni for a correction.

y=dec2base(x=1e3:9999,10)'-48;x(sum(y)==9>all(y))

Try it online!

Luis Mendo
la source
I don't know anything about Octave, but it looks like you can leave the disp off...
J.Doe
@J.Doe OP has confirmed that that output format is acceptable. Thanks for the suggestion!
Luis Mendo
2

Dart,  103 100  96 bytes

f()=>List.generate(9001,(i)=>'$i').where((i)=>i.contains('0')&&i.runes.fold(0,(p,e)=>p+e)==201);

  • -3 bytes by setting the value in the array to string, making the conversion once and not twice
  • -4 bytes by using runes instead of codeUnits
  • Pretty self-explanatory. generates a list of 9001 (0-9000) cells with the cell's index as value, filters the ones containing a 0 then the one having an ASCII sum of 201 (The result if all the ASCII characters sum to 9). These conditions implictly include that the year is 4 digits long because using 2 ASCII numbers (and the 0), you cannot reach 201.

    Try it on Dartpad!

    Elcan
    la source
    Welcome to PPCG. :)
    Laikoni
    1
    Thanks ! Been lurking for a while, can finally participate
    Elcan
    2

    Bash (with seq, grep), 39 bytes

    seq 0 9 1e4|egrep '([0-4].*){3}'|grep 0

    Try it online!

    tsh
    la source
    @xobzoo suggested seq 0 9 1e4|awk '/([0-4].*){3}/&&/0/' to save two bytes.
    Timtech
    2

    K (ngn/k), 22 bytes

    55_&(|/~a)&9=+/a:!4#10
    

    Try it online!

    ngn
    la source
    Nice! 55_&9=+/y*|/'~y:!4#10 for 21?
    streetster
    1
    @streetster thanks :) the ' in |/' looks wrong. the result includes 1116, 1125, 1134, etc which are not supposed to be there
    ngn
    2

    APL (Dyalog Unicode), 23 bytes

    55↓⍸(×⌿<9=+⌿)10⊥⍣¯19e3

    Try it online!

    FrownyFrog
    la source
    that use of < is clever. you can make it even shorter with ⎕io←0 and ( )10⊥⍣¯1⍳9e3 -> ( )¨,⍳4⍴10
    ngn
    2

    PHP, 69, 87 bytes 74 bytes

    for($i=999;$i<9001;$i++){echo((array_sum(str_split($i))==9&strpos($i,"0")!=0)?$i:" ");} for($i=999;$i++<1e4;)echo!strpos($i,48)|array_sum(str_split($i))-9?" ":$i;

    Note this puts a space for every "failed" number, leading to some kind of funky spacing. This can be changed to comma separation, but will add another 4 characters: ?$i.",":""

    Got bigger because I wasn't checking for 0. Derp. Shortened by 13 by Titus!

    aslum
    la source
    2
    I don't really know PHP, but does this code ensure that each year contains a zero?
    Laikoni
    This code does not check for zero in the number.
    krzysiej
    1
    13 bytes shorter: for($i=999;$i++<1e4;)echo!strpos($i,48)|array_sum(str_split($i))-9?" ":$i;
    Titus
    Here´s another byte: ?"$i,":"" er ... now the other way round: ?"":"$i,"
    Titus
    Actually @Titus that adds a couple bytes. We don't need quotes around $i unless we're including a string w/ it.
    aslum
    2

    Scala (76 63 61 56 bytes)

    for(n<-0 to 9000;t=n+""if t.sum==201&t.min<49)println(t)
    

    Try it online

    • Thanks to Laikoni for the suggestions
    • Two more bytes shed after applying Jo King's comment
    jrook
    la source
    1
    Welcome to PPCG! Do you have an idea what needs to be added to the header or footer section to get this code to run on TIO? Try it online!
    Laikoni
    @Laikoni, didn't know I could run Scala in TIO. Fixed it. Thanks for the comment.
    jrook
    1
    It looks like t.sum==201 works instead of t.map(_.asDigit).sum==9.
    Laikoni
    You may find our tips for golfing in Scala interesting. E.g. it looks like s"$n" can be n+"" and s"$t " can be t+" ".
    Laikoni
    1
    Since you're using the sum is 201 trick, the range doesn't need to start at 999
    Jo King
    1

    Japt, 16 bytes

    Returns an array of digit arrays.

    L²õì l4 k_ת9aZx
    

    Test it


    Explanation

    L                    :100
     ²                   :Squared
      õ                  :Range [1,L²]
       ì                 :Convert each to a digit array
         l4              :Filter elements of length 4
            k_           :Remove each Z that returns truthy (not 0)
              ×          :  When reduced by multiplication
               ª         :  OR
                  Zx     :  When reduced by addition
                9a       :   And subtracted from 9
    
    Shaggy
    la source
    1
    OP has ruled that digit arrays aren't valid output unfortunately :o(
    Sok
    1

    APL(NARS), 45 chars, 90 bytes

    f←{⍵×⍳(0∊x)∧9=+/x←⍎¨⍕⍵}⋄f¨1e3..5e3⋄f¨5e3..9e3
    

    test afther some formatting:

    1008  1017  1026  1035  1044  1053  1062  1071  1080  1107  1170  1206  1260  
      1305  1350  1404  1440  1503  1530  1602  1620  1701  1710  1800  2007  2016  
      2025  2034  2043  2052  2061  2070  2106  2160  2205  2250  2304  2340  
      2403  2430  2502  2520  2601  2610  2700  3006  3015  3024  3033  3042  3051  
      3060  3105  3150  3204  3240  3303  3330  3402  3420  3501  3510  3600  
      4005  4014  4023  4032  4041  4050  4104  4140  4203  4230  4302  4320  4401  
      4410  4500 
    5004  5013  5022  5031  5040  5103  5130  5202  5220  5301  5310  5400  6003  
      6012  6021  6030  6102  6120  6201  6210  6300  7002  7011  7020  7101  7110  
      7200  8001  8010  8100  9000 
    

    possible alternative

    r←f;i;x
       r←⍬⋄i←1e3⋄→B
    A: r←r,i
    B: i+←1⋄→A×⍳(0∊x)∧9=+/x←⍎¨⍕i⋄→B×⍳i≤9e3
    
    RosLuP
    la source
    1

    Jelly, 13 bytes

    ȷ4µṢÄm3Ḍ)ẹ9ṫ4
    

    Try it online!

    How?

    ȷ4µṢÄm3Ḍ)ẹ9ṫ4 - Link: no arguments
    ȷ4            - literal 10^4 = 10000
      µ     )     - for each in range (1,2,3,...,10000): e.g. 3042       or  5211
       Ṣ          -   sort (given an integer makes digits)    [0,2,3,4]      [1,1,2,5]
        Ä         -   cumulative addition                     [0,2,5,9]      [1,2,4,9]
         m3       -   modulo 3 slice (1st,4th,7th...)         [0,9]          [1,9]
           Ḍ      -   convert from decimal digits             9              19
             ẹ9   - 1-based indices equal to nine             [9,99,999,1008,1017,...,8100,9000]
               ṫ4 - tail from the 4th index                   [1008,1017,...,8100,9000]
    
    Jonathan Allan
    la source