Print all lexicographically increasing numbers under 10000











up vote
30
down vote

favorite
4












A lexicographically increasing number is an integer whose digits are in strictly increasing order. Print all lexicographically increasing numbers under 10000.



Here are lines of the expected output:



0
1
2
3
4
5
6
7
8
9
12
13
14
15
16
17
18
19
23
24
25
26
27
28
29
34
35
36
37
38
39
45
46
47
48
49
56
57
58
59
67
68
69
78
79
89
123
124
125
126
127
128
129
134
135
136
137
138
139
145
146
147
148
149
156
157
158
159
167
168
169
178
179
189
234
235
236
237
238
239
245
246
247
248
249
256
257
258
259
267
268
269
278
279
289
345
346
347
348
349
356
357
358
359
367
368
369
378
379
389
456
457
458
459
467
468
469
478
479
489
567
568
569
578
579
589
678
679
689
789
1234
1235
1236
1237
1238
1239
1245
1246
1247
1248
1249
1256
1257
1258
1259
1267
1268
1269
1278
1279
1289
1345
1346
1347
1348
1349
1356
1357
1358
1359
1367
1368
1369
1378
1379
1389
1456
1457
1458
1459
1467
1468
1469
1478
1479
1489
1567
1568
1569
1578
1579
1589
1678
1679
1689
1789
2345
2346
2347
2348
2349
2356
2357
2358
2359
2367
2368
2369
2378
2379
2389
2456
2457
2458
2459
2467
2468
2469
2478
2479
2489
2567
2568
2569
2578
2579
2589
2678
2679
2689
2789
3456
3457
3458
3459
3467
3468
3469
3478
3479
3489
3567
3568
3569
3578
3579
3589
3678
3679
3689
3789
4567
4568
4569
4578
4579
4589
4678
4679
4689
4789
5678
5679
5689
5789
6789


This is a code golf challenge! Shortest answer wins!



(P.S. looking for a python solution)










share|improve this question









New contributor




Varun Patro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 3




    do we need to print them on separate lines or is space-separated OK?
    – Giuseppe
    Nov 16 at 19:29






  • 3




    Welcome to PPCG! Nice first challenge. For future challenges, I can recommend using the Sandbox to refine a challenge and get meaningful feedback before posting it to main.
    – AdmBorkBork
    Nov 16 at 19:38






  • 4




    To expand on @Giuseppe's question, can we output separated by commas, spaces, in array format [0,1,...], etc. or must we output each number on a separate line?
    – ETHproductions
    Nov 16 at 19:42






  • 10




    Do the numbers need to be in a specific order, or do they just need to all exist?
    – Kamil Drakari
    Nov 16 at 19:56






  • 13




    @VarunPatro, please update the challenge to explicitly state that each number by on a separate line (although I'd recommend against that requirement) and make sure to inform any existing solutions that don't do so.
    – Shaggy
    Nov 16 at 20:32















up vote
30
down vote

favorite
4












A lexicographically increasing number is an integer whose digits are in strictly increasing order. Print all lexicographically increasing numbers under 10000.



Here are lines of the expected output:



0
1
2
3
4
5
6
7
8
9
12
13
14
15
16
17
18
19
23
24
25
26
27
28
29
34
35
36
37
38
39
45
46
47
48
49
56
57
58
59
67
68
69
78
79
89
123
124
125
126
127
128
129
134
135
136
137
138
139
145
146
147
148
149
156
157
158
159
167
168
169
178
179
189
234
235
236
237
238
239
245
246
247
248
249
256
257
258
259
267
268
269
278
279
289
345
346
347
348
349
356
357
358
359
367
368
369
378
379
389
456
457
458
459
467
468
469
478
479
489
567
568
569
578
579
589
678
679
689
789
1234
1235
1236
1237
1238
1239
1245
1246
1247
1248
1249
1256
1257
1258
1259
1267
1268
1269
1278
1279
1289
1345
1346
1347
1348
1349
1356
1357
1358
1359
1367
1368
1369
1378
1379
1389
1456
1457
1458
1459
1467
1468
1469
1478
1479
1489
1567
1568
1569
1578
1579
1589
1678
1679
1689
1789
2345
2346
2347
2348
2349
2356
2357
2358
2359
2367
2368
2369
2378
2379
2389
2456
2457
2458
2459
2467
2468
2469
2478
2479
2489
2567
2568
2569
2578
2579
2589
2678
2679
2689
2789
3456
3457
3458
3459
3467
3468
3469
3478
3479
3489
3567
3568
3569
3578
3579
3589
3678
3679
3689
3789
4567
4568
4569
4578
4579
4589
4678
4679
4689
4789
5678
5679
5689
5789
6789


This is a code golf challenge! Shortest answer wins!



(P.S. looking for a python solution)










share|improve this question









New contributor




Varun Patro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 3




    do we need to print them on separate lines or is space-separated OK?
    – Giuseppe
    Nov 16 at 19:29






  • 3




    Welcome to PPCG! Nice first challenge. For future challenges, I can recommend using the Sandbox to refine a challenge and get meaningful feedback before posting it to main.
    – AdmBorkBork
    Nov 16 at 19:38






  • 4




    To expand on @Giuseppe's question, can we output separated by commas, spaces, in array format [0,1,...], etc. or must we output each number on a separate line?
    – ETHproductions
    Nov 16 at 19:42






  • 10




    Do the numbers need to be in a specific order, or do they just need to all exist?
    – Kamil Drakari
    Nov 16 at 19:56






  • 13




    @VarunPatro, please update the challenge to explicitly state that each number by on a separate line (although I'd recommend against that requirement) and make sure to inform any existing solutions that don't do so.
    – Shaggy
    Nov 16 at 20:32













up vote
30
down vote

favorite
4









up vote
30
down vote

favorite
4






4





A lexicographically increasing number is an integer whose digits are in strictly increasing order. Print all lexicographically increasing numbers under 10000.



Here are lines of the expected output:



0
1
2
3
4
5
6
7
8
9
12
13
14
15
16
17
18
19
23
24
25
26
27
28
29
34
35
36
37
38
39
45
46
47
48
49
56
57
58
59
67
68
69
78
79
89
123
124
125
126
127
128
129
134
135
136
137
138
139
145
146
147
148
149
156
157
158
159
167
168
169
178
179
189
234
235
236
237
238
239
245
246
247
248
249
256
257
258
259
267
268
269
278
279
289
345
346
347
348
349
356
357
358
359
367
368
369
378
379
389
456
457
458
459
467
468
469
478
479
489
567
568
569
578
579
589
678
679
689
789
1234
1235
1236
1237
1238
1239
1245
1246
1247
1248
1249
1256
1257
1258
1259
1267
1268
1269
1278
1279
1289
1345
1346
1347
1348
1349
1356
1357
1358
1359
1367
1368
1369
1378
1379
1389
1456
1457
1458
1459
1467
1468
1469
1478
1479
1489
1567
1568
1569
1578
1579
1589
1678
1679
1689
1789
2345
2346
2347
2348
2349
2356
2357
2358
2359
2367
2368
2369
2378
2379
2389
2456
2457
2458
2459
2467
2468
2469
2478
2479
2489
2567
2568
2569
2578
2579
2589
2678
2679
2689
2789
3456
3457
3458
3459
3467
3468
3469
3478
3479
3489
3567
3568
3569
3578
3579
3589
3678
3679
3689
3789
4567
4568
4569
4578
4579
4589
4678
4679
4689
4789
5678
5679
5689
5789
6789


This is a code golf challenge! Shortest answer wins!



(P.S. looking for a python solution)










share|improve this question









New contributor




Varun Patro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











A lexicographically increasing number is an integer whose digits are in strictly increasing order. Print all lexicographically increasing numbers under 10000.



Here are lines of the expected output:



0
1
2
3
4
5
6
7
8
9
12
13
14
15
16
17
18
19
23
24
25
26
27
28
29
34
35
36
37
38
39
45
46
47
48
49
56
57
58
59
67
68
69
78
79
89
123
124
125
126
127
128
129
134
135
136
137
138
139
145
146
147
148
149
156
157
158
159
167
168
169
178
179
189
234
235
236
237
238
239
245
246
247
248
249
256
257
258
259
267
268
269
278
279
289
345
346
347
348
349
356
357
358
359
367
368
369
378
379
389
456
457
458
459
467
468
469
478
479
489
567
568
569
578
579
589
678
679
689
789
1234
1235
1236
1237
1238
1239
1245
1246
1247
1248
1249
1256
1257
1258
1259
1267
1268
1269
1278
1279
1289
1345
1346
1347
1348
1349
1356
1357
1358
1359
1367
1368
1369
1378
1379
1389
1456
1457
1458
1459
1467
1468
1469
1478
1479
1489
1567
1568
1569
1578
1579
1589
1678
1679
1689
1789
2345
2346
2347
2348
2349
2356
2357
2358
2359
2367
2368
2369
2378
2379
2389
2456
2457
2458
2459
2467
2468
2469
2478
2479
2489
2567
2568
2569
2578
2579
2589
2678
2679
2689
2789
3456
3457
3458
3459
3467
3468
3469
3478
3479
3489
3567
3568
3569
3578
3579
3589
3678
3679
3689
3789
4567
4568
4569
4578
4579
4589
4678
4679
4689
4789
5678
5679
5689
5789
6789


This is a code golf challenge! Shortest answer wins!



(P.S. looking for a python solution)







code-golf number sequence kolmogorov-complexity






share|improve this question









New contributor




Varun Patro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Varun Patro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 16 at 19:36









Shaggy

18.2k21663




18.2k21663






New contributor




Varun Patro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 16 at 19:08









Varun Patro

15426




15426




New contributor




Varun Patro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Varun Patro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Varun Patro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 3




    do we need to print them on separate lines or is space-separated OK?
    – Giuseppe
    Nov 16 at 19:29






  • 3




    Welcome to PPCG! Nice first challenge. For future challenges, I can recommend using the Sandbox to refine a challenge and get meaningful feedback before posting it to main.
    – AdmBorkBork
    Nov 16 at 19:38






  • 4




    To expand on @Giuseppe's question, can we output separated by commas, spaces, in array format [0,1,...], etc. or must we output each number on a separate line?
    – ETHproductions
    Nov 16 at 19:42






  • 10




    Do the numbers need to be in a specific order, or do they just need to all exist?
    – Kamil Drakari
    Nov 16 at 19:56






  • 13




    @VarunPatro, please update the challenge to explicitly state that each number by on a separate line (although I'd recommend against that requirement) and make sure to inform any existing solutions that don't do so.
    – Shaggy
    Nov 16 at 20:32














  • 3




    do we need to print them on separate lines or is space-separated OK?
    – Giuseppe
    Nov 16 at 19:29






  • 3




    Welcome to PPCG! Nice first challenge. For future challenges, I can recommend using the Sandbox to refine a challenge and get meaningful feedback before posting it to main.
    – AdmBorkBork
    Nov 16 at 19:38






  • 4




    To expand on @Giuseppe's question, can we output separated by commas, spaces, in array format [0,1,...], etc. or must we output each number on a separate line?
    – ETHproductions
    Nov 16 at 19:42






  • 10




    Do the numbers need to be in a specific order, or do they just need to all exist?
    – Kamil Drakari
    Nov 16 at 19:56






  • 13




    @VarunPatro, please update the challenge to explicitly state that each number by on a separate line (although I'd recommend against that requirement) and make sure to inform any existing solutions that don't do so.
    – Shaggy
    Nov 16 at 20:32








3




3




do we need to print them on separate lines or is space-separated OK?
– Giuseppe
Nov 16 at 19:29




do we need to print them on separate lines or is space-separated OK?
– Giuseppe
Nov 16 at 19:29




3




3




Welcome to PPCG! Nice first challenge. For future challenges, I can recommend using the Sandbox to refine a challenge and get meaningful feedback before posting it to main.
– AdmBorkBork
Nov 16 at 19:38




Welcome to PPCG! Nice first challenge. For future challenges, I can recommend using the Sandbox to refine a challenge and get meaningful feedback before posting it to main.
– AdmBorkBork
Nov 16 at 19:38




4




4




To expand on @Giuseppe's question, can we output separated by commas, spaces, in array format [0,1,...], etc. or must we output each number on a separate line?
– ETHproductions
Nov 16 at 19:42




To expand on @Giuseppe's question, can we output separated by commas, spaces, in array format [0,1,...], etc. or must we output each number on a separate line?
– ETHproductions
Nov 16 at 19:42




10




10




Do the numbers need to be in a specific order, or do they just need to all exist?
– Kamil Drakari
Nov 16 at 19:56




Do the numbers need to be in a specific order, or do they just need to all exist?
– Kamil Drakari
Nov 16 at 19:56




13




13




@VarunPatro, please update the challenge to explicitly state that each number by on a separate line (although I'd recommend against that requirement) and make sure to inform any existing solutions that don't do so.
– Shaggy
Nov 16 at 20:32




@VarunPatro, please update the challenge to explicitly state that each number by on a separate line (although I'd recommend against that requirement) and make sure to inform any existing solutions that don't do so.
– Shaggy
Nov 16 at 20:32










38 Answers
38






active

oldest

votes













1 2
next











up vote
25
down vote














Python 2, 56 bytes





for n in range(9999):
if eval('<'.join(`n`))**n:print n


Try it online!



Converts each number like 124 to an expression 1<2<4 and evaluates it to check if the digits are sorted,



A hiccup happens for one-digit numbers giving an expression that just is the number itself. This causes 0 to evaluate to a Falsey value even though it should be printed. This is fixed by a trick suggested by Erik the Outgolfer of doing **n, which gives truthy value 0**0 for n=0 and doesn't affect the truth value otherwise.






share|improve this answer























  • What does the ` do in `n`?
    – BruceWayne
    Nov 16 at 21:58








  • 1




    @BruceWayne It takes the string representation. This was removed in Python 3.
    – xnor
    Nov 16 at 22:00






  • 4




    @BruceWayne Note that it's the same as the repr() function, not the str() function. They aren't always the same. Here's an example.
    – mbomb007
    Nov 16 at 22:39












  • @mbomb007 thanks for that comment! I would have thought it was str() equivalent.
    – BruceWayne
    Nov 16 at 22:48






  • 1




    We can handle the 0 case with a bit of trickery.
    – xsot
    Nov 17 at 16:04


















up vote
10
down vote














Haskell, 50 bytes





unlines[s|s<-show<$>[0..6^5],s==scanl1(max.succ)s]


Try it online!



Outputs a multiline string. We check that the number s increasing using s==scanl1(max.succ)s, a variant of the usual sortedness check s==scanl1 max s that ensures strict sortedness by incrementing each digit character before taking the maximum of it and the next digit.



Ourous saved a byte by using 6^5 as the upper bound in place of a 4-digit number.






share|improve this answer






























    up vote
    8
    down vote














    Python 2, 55 bytes





    i=0
    exec"print ini+=1nif eval('<'.join(`i`)):1;"*7000


    Try it online!






    share|improve this answer




























      up vote
      7
      down vote













      Japt -R, 12 11 8 bytes



      L²Ç¶ìüÃð


      Test it



      L            :100
      ² :Squared
      Ç :Map the range [0,L²)
      ì : Split to a digit array
      ü : For the sake if simplicity*, let's say: Sort & deduplicate
      : Implicitly rejoin to an integer
      ¶ : Test for equality with original number
      Ã :End map
      ð :Get 0-based indices of truthy elements
      :Implicitly join with newlines and output


      *Or, to offer a better explanation: the ü method sorts an array and splits it into equal elements (e.g., [8,4,8,4].ü() -> [[4,4],[8,8]]) and then, in what seems to be a strange quirk and hopefully not a bug, the ì method, when converting the array back to a number, takes the first element of each nested array, rather than first flattening the array, which is what I expected when I tried this trick (e.g., [[4,4],[8,8]].ì() -> 48).






      share|improve this answer



















      • 1




        Nice. Similar to what I had: L²Ç¥ì ü ¬Ãð
        – Oliver
        Nov 16 at 19:39






      • 2




        I have to say, that ü trick you guys used is genius :-) @Oliver
        – ETHproductions
        Nov 16 at 19:45






      • 1




        @Oliver, you must have posted that as I was updating; great minds ... :)
        – Shaggy
        Nov 16 at 19:48










      • @ETHproductions, like most things, I tried it on a whim - amazed it works.
        – Shaggy
        Nov 16 at 19:48


















      up vote
      7
      down vote














      Jelly, 7 bytes



      9ŒPḌḣ⁹Y


      Try it online!



      How it works



      9ŒPḌḣ⁹Y  Main link. No arguments.

      9 Set the return value to 9.
      ŒP Powerset; promote 9 to [1, ..., 9] and generate all subsets.
      Ḍ Undecimal; map the subsets of digits to the integers they represent.
      ⁹ Yield 256.
      ḣ Dyadic head; take the first 256 elements of the integer list.
      Y Separate the result by linefeeds.





      share|improve this answer



















      • 2




        I'm trying to figure out how 0 gets included here but I don't know Jelly. Am I correct that Jelly's powerset includes the empty array which then gets converted to 0 when "undecimaled"?
        – Shaggy
        Nov 17 at 0:21






      • 1




        Yes, that's exactly what happens.
        – Dennis
        Nov 17 at 0:37


















      up vote
      6
      down vote














      R, 62 49 bytes





      `[`=write;0[1];for(i in 1:4)combn(1:9,i)[1,i,,""]


      Try it online!



      Because combn iterates through its input in the order given, it's easy to create all the lexicographically increasing integers, printing them out in order. write prints them each i-digit number in lines of width i, neatly fulfilling the newline requirement as well.






      share|improve this answer























      • great idea exploiting combn !
        – digEmAll
        Nov 17 at 14:36










      • Extremely clever aliasing!
        – J.Doe
        Nov 18 at 12:15


















      up vote
      5
      down vote













      Haskell, 56 55 bytes



      Edit: -1 byte thanks to @Ourous



      mapM print$filter(and.(zipWith(<)<*>tail).show)[0..6^5]


      Try it online!






      share|improve this answer






























        up vote
        4
        down vote














        PowerShell, 42 40 bytes





        0..1e4|?{-join("$_"|% t*y|sort -u)-eq$_}


        Try it online!



        Loop from 0 to 1e4 (i.e., 10000). Pull out those objects where |?{...} the number as a string $_ is -equal to the number cast toCharArray and then sorted with the -unique flag. In other words, only numbers that are the same as their sorted and deduplicated strings. Each of those are left on the pipeline and output is implicit.






        share|improve this answer






























          up vote
          3
          down vote














          Perl 6, 26 bytes



          .say if [<] .comb for ^1e4


          Try it online!



          .comb produces a list of the digits of each number, and [<] does a less-than reduction on that list, equivalent to: digit1 < digit2 < ... < digitN.






          share|improve this answer

















          • 2




            [<](.comb)&&.say saves a byte.
            – nwellnhof
            Nov 17 at 9:56










          • This is surprisingly readable. (I already know a little Perl 6, but still...)
            – J-L
            Nov 19 at 20:38


















          up vote
          3
          down vote













          J, 26 bytes



          ,.(#~(-:/:~@~.)@":"0)i.1e4


          Try it online!



          explanation



          ,. (#~ (-: /:~@~.)@":"0) i.1e4
          i.1e4 NB. list 0 to 9999
          "0 NB. for each number in the input list
          @":"0 NB. convert it to a string and
          (#~ ( ) NB. remove any not passing this test:
          -: NB. the string of digits matches
          @~. NB. the nub of the digits (dups removed)
          /:~ NB. sorted
          ,. NB. ravel items: take the result of all that
          NB. and turn it into a big column





          share|improve this answer






























            up vote
            3
            down vote














            Common Lisp, 74 72 bytes



            (dotimes(i 7e3)(format(apply'char<(coerce(format()"~d"i)'list))"~d~%"i))


            Try it online!



            -2 bytes thank to @Shaggy!






            share|improve this answer






























              up vote
              3
              down vote














              Pyth, 10 bytes



              jiRThc2yS9


              Try it online!



              How it works



              jiRThc2yS9
              S9 Yield [1, 2, 3, 4, 5, 6, 7, 8, 9].
              y Take all 512 subsets.
              c2 Split the array of subsets into 2 pieces (256 subsets each).
              h Head; take the first piece.
              iRT Convert each subset from base 10 to integer.
              j Separate by newlines.





              share|improve this answer




























                up vote
                2
                down vote














                V, 41 bytes



                7000ïÎaÛ
                Îy$úúP
                Ç^¨ä*©±$/d
                ÎãlD
                爱/d
                HO0


                Try it online!



                Hexdump:



                00000000: 3730 3030 efce 61db 0ace 7924 fafa 500a  7000..a...y$..P.
                00000010: c75e a8e4 2aa9 b124 2f64 0ace e36c 440a .^..*..$/d...lD.
                00000020: e788 b12f 640a 484f 30 .../d.HO0





                share|improve this answer




























                  up vote
                  2
                  down vote














                  Perl 5, 55 bytes





                  $"=$,;map"@{[sort{$a-$b}/./g]}"-$_||/(.)1/||say,0..1E4


                  Try it online!






                  share|improve this answer




























                    up vote
                    2
                    down vote














                    Charcoal, 19 bytes



                    ΦEXχ⁴Iι¬Φι∧쬋§ι⊖μλ


                    Try it online! Link is to verbose version of code. Explanation:



                       χ                Predefined variable 10
                    X To the power
                    ⁴ Literal 4
                    E Map over implicit range
                    ι Current value
                    I Cast to string
                    Φ Filter over strings where
                    ι Current string
                    Φ Filtered over characters
                    μ Character index (is nonzero)
                    ∧ And
                    μ Character index
                    ⊖ Decremented
                    § Indexed into
                    ι Current string
                    ¬ Is not
                    ‹ Less than
                    λ Current character
                    ¬ Results in an empty string
                    Implicitly print matches on separate lines





                    share|improve this answer




























                      up vote
                      2
                      down vote














                      05AB1E (legacy), 8 bytes



                      4°ÝD€êû


                      Try it online!



                      Works in the new version of 05AB1E as well but is painfully slow for some reason.



                      How?




                      4°ÝD€êû – Full program.
                      4°Ý – Push [0 ... 10000].
                      D€ê – Push each integer in [0 ... 10000] sorted and deduplicated at the same time.
                      û – And join the interection of the two lists by newlines.





                      share|improve this answer





















                      • Nice answer. Better than the 9 byter I had (which only works in the legacy).
                        – Kevin Cruijssen
                        Nov 19 at 13:54










                      • 4°Ýʒ¥P.± is my alternate 8-byter in the rewrite.
                        – Magic Octopus Urn
                        Nov 19 at 15:03


















                      up vote
                      2
                      down vote














                      Jelly, 13 9 8 bytes



                      Saved 5 bytes thanks to @Dennis



                      9œcⱮ4ẎŻY


                      Try it online!



                      Explanation



                      Generates all lexicographically increasing numbers below 10000 by taking the digits [1...9] and finding all combinations of length ≤ 4.



                      9œcⱮ4ẎŻY    Main link. Arguments: none
                      9 Yield 9.
                      Ɱ4 For each n in [1...4]:
                      œc Yield the combinations of the range [1...9] of length n.
                      Ẏ Tighten; dump each of the 4 lists generated into the main list.
                      Ż Prepend a 0 to the list.
                      Y Join on newlines.





                      Jelly, 11 10 9 bytes



                      Saved a byte thanks to @EriktheOutgolfer



                      ȷ4Ḷ<ƝẠ$ƇY


                      Try it online!



                      Explanation



                      Filters through the range, keeping the numbers that are lexicographically increasing.



                      ȷ4Ḷ<ƝẠ$ƇY    Main link. Arguments: none
                      ȷ4 Yield 10^4 (10000).
                      Ḷ Generate the range [0...10000).
                      Ƈ Filter; yield only the numbers where this link return a truthy value.
                      $ Run these two links and yield the result.
                      Ɲ For each pair of items (digits) in the number:
                      < Check whether the left digit is less than the right digit.
                      Ạ All; check that every comparison yielded true.
                      This yields whether the digits are strictly increasing.
                      Y Join the filtered list on newlines.





                      share|improve this answer






























                        up vote
                        2
                        down vote













                        JavaScript, 64 bytes



                        A bit of pub golf so probably far from optimal.



                        (f=n=>n&&f(n-1)+([...n+``].every(x=>y<(y=x),y=0)?`
                        `+n:``))(7e3)


                        Try it online



                        Yes, doing it without an IIFE would be a few bytes shorter but that throws an overflow error when called, which would normally be fine as we can assume infinite memory for the purposes of code golf but, to me, doesn't seem to be in the spirit of KC challenges.






                        share|improve this answer























                        • I don't get an overflow error without an IIFE.
                          – Spitemaster
                          Nov 17 at 4:32










                        • Is this a function submission or a full program? If not, you should either count the console.log or relabel your submission as JavaScript REPL.
                          – Dennis
                          yesterday


















                        up vote
                        2
                        down vote














                        Wolfram Language (Mathematica), 36 bytes



                        After I wrote this, it was clarified that each number must be on a new line, so +7 bytes for the Print/@.



                        This method takes advantage of the fact that the Subsets function 1) doesn't replicate any digits and 2) sorts the output by set size and set contents. FromDigits assembles each list of digits.



                        -1 byte thanks to @Mr.Xcoder



                        Print/@FromDigits/@Range@9~Subsets~4


                        Try it online!






                        share|improve this answer



















                        • 1




                          Print/@FromDigits/@Range@9~Subsets~4 for 36 bytes.
                          – Mr. Xcoder
                          Nov 17 at 14:32










                        • Funny, I thought of that and just didn't do it because I thought ~ had higher precedence than @
                          – Kelly Lowder
                          Nov 19 at 2:55


















                        up vote
                        2
                        down vote














                        K (ngn/k) / K (oK), 32 30 26 bytes



                        Solution:



                        `0:$&&/'1_'>':'" ",'$!9999


                        Try it online!



                        Explanation:



                        `0:$&&/'1_'>':'" ",'$!9999 / the solution
                        !9999 / range 0..9998 (could use !6890)
                        $ / string
                        " ",' / prepend " " to each (lower than "0" in ascii)
                        >:' / greater-than each-previous?
                        1_' / drop first result from each
                        &/' / max (&) over (/)
                        & / indices where true
                        $ / convert to string
                        `0: / print to stdout





                        share|improve this answer






























                          up vote
                          1
                          down vote














                          Python 2, 63 bytes





                          for i in range(6790):
                          if`i`=="".join(sorted(set(`i`))):print i


                          Try it online!






                          share|improve this answer




























                            up vote
                            1
                            down vote














                            Python 2, 61 bytes





                            for i in range(9999):
                            if list(`i`)==sorted(set(`i`)):print i


                            Try it online!






                            share|improve this answer




























                              up vote
                              1
                              down vote














                              Python 2, 64 61 bytes





                              lambda:[x for x in range(9999)if sorted(set(`x`))==list(`x`)]


                              Try it online!



                              Gets the unique characters of the integer's string representation, sorts them, and compares the result to the original number.






                              share|improve this answer























                              • You can save a byte by using range(9999) or any other number between 6790 and 9999. Our solutions are almost identical BTW :)
                                – DJMcMayhem
                                Nov 16 at 19:47










                              • @DJMcMayhem But then it wouldn't check ALL numbers under 10,000....:P Thanks! Sometimes I get too literal with these challenges.
                                – Triggernometry
                                Nov 16 at 19:50


















                              up vote
                              1
                              down vote













                              T-SQL, 188 bytes



                              WITH a AS(SELECT 0n UNION ALL SELECT n+1FROM a WHERE n<9)
                              SELECT ABS(CONCAT(a.n,b.n,c.n,d.n))
                              FROM a,a b,a c,a d
                              WHERE(a.n<b.n OR a.n+b.n=0)
                              AND(b.n<c.n OR b.n+c.n=0)
                              AND(c.n<d.n OR c.n+d.n=0)


                              Line breaks are for readability only.



                              I'm certain there must be more efficient ways to do this in SQL, but this was the first thing I thought of. Explanation:




                              1. Declare an in-memory table with values 0 to 9

                              2. Cross-join 4 copies of this table for all possible values from 0000 to 9999

                              3. Messy WHERE clause to ensure the digits are strictly increasing (or both 0)

                              4. Smash the digits together (CONCAT) and convert to integer (ABS)

                              5. The resulting rows may or may not be sorted, but the challenge doesn't appear to require that.






                              share|improve this answer




























                                up vote
                                1
                                down vote














                                Stax, 8 bytes



                                ¬ ▬A♥¶N∙


                                Run and debug it






                                share|improve this answer




























                                  up vote
                                  1
                                  down vote














                                  Clean, 90 bytes



                                  import StdEnv
                                  Start=(0,[('
                                  ',n)\n<-[1..6^5]|(l=removeDup l==sort l)[c\c<-:toString n]])


                                  Try it online!






                                  share|improve this answer






























                                    up vote
                                    1
                                    down vote














                                    Red, 59 bytes



                                    repeat n 9999[if(d: n - 1)= do sort unique form d[print d]]


                                    Try it online!






                                    share|improve this answer




























                                      up vote
                                      1
                                      down vote














                                      Jelly, 7 bytes



                                      <ƝẠ$⁹#Y


                                      Try it online!



                                      How?



                                      <ƝẠ$⁹#Y - Main Link: no arguments (implicit z=0)
                                      ⁹ - literal 256
                                      # - count up from n=z (0) finding the first 256 for which this is truthy:
                                      $ - last two links as a monad:
                                      Ɲ - neighbours (implicitly gets digits of n):
                                      < - less than?
                                      Ạ - all truthy? (N.B. yields 1 for an empty list)
                                      Y - join with newlines





                                      share|improve this answer




























                                        up vote
                                        1
                                        down vote














                                        C (gcc), 97 bytes





                                        g(n,l,r){for(r=l=10;n;n/=10)r*=n%10<l,l=n%10;n=r;}f(i){for(i=0;i<1e4;i++)g(i)&&printf("%dn",i);}


                                        Try it online!






                                        share|improve this answer




























                                          up vote
                                          1
                                          down vote














                                          C# (Visual C# Interactive Compiler), 102 101 ... 73 bytes



                                          -12 and -4 thanks @Dennis!





                                          for(var i=0;i<7e3;i++)if((i+"").Aggregate((a,b)=>a<b?b:':')<':')Print(i);


                                          Try it online!



                                          Each integer from 0 to 7k tested by first converting it into a string. Leveraging the fact that C# treats strings as character enumerables and LINQ, an aggregate is calculated for each character enumerable as follows:




                                          • compare the accumulated value with the current character

                                          • if the current character is greater than the accumulation, return the current character

                                          • otherwise return : which is greater than 9


                                          If the result of this is less than :, then the number has lexicographically increasing digits.






                                          share|improve this answer



























                                            1 2
                                            next



                                            Your Answer





                                            StackExchange.ifUsing("editor", function () {
                                            return StackExchange.using("mathjaxEditing", function () {
                                            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                                            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                                            });
                                            });
                                            }, "mathjax-editing");

                                            StackExchange.ifUsing("editor", function () {
                                            StackExchange.using("externalEditor", function () {
                                            StackExchange.using("snippets", function () {
                                            StackExchange.snippets.init();
                                            });
                                            });
                                            }, "code-snippets");

                                            StackExchange.ready(function() {
                                            var channelOptions = {
                                            tags: "".split(" "),
                                            id: "200"
                                            };
                                            initTagRenderer("".split(" "), "".split(" "), channelOptions);

                                            StackExchange.using("externalEditor", function() {
                                            // Have to fire editor after snippets, if snippets enabled
                                            if (StackExchange.settings.snippets.snippetsEnabled) {
                                            StackExchange.using("snippets", function() {
                                            createEditor();
                                            });
                                            }
                                            else {
                                            createEditor();
                                            }
                                            });

                                            function createEditor() {
                                            StackExchange.prepareEditor({
                                            heartbeatType: 'answer',
                                            convertImagesToLinks: false,
                                            noModals: true,
                                            showLowRepImageUploadWarning: true,
                                            reputationToPostImages: null,
                                            bindNavPrevention: true,
                                            postfix: "",
                                            imageUploader: {
                                            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                                            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                                            allowUrls: true
                                            },
                                            onDemand: true,
                                            discardSelector: ".discard-answer"
                                            ,immediatelyShowMarkdownHelp:true
                                            });


                                            }
                                            });






                                            Varun Patro is a new contributor. Be nice, and check out our Code of Conduct.










                                             

                                            draft saved


                                            draft discarded


















                                            StackExchange.ready(
                                            function () {
                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f176095%2fprint-all-lexicographically-increasing-numbers-under-10000%23new-answer', 'question_page');
                                            }
                                            );

                                            Post as a guest















                                            Required, but never shown

























                                            38 Answers
                                            38






                                            active

                                            oldest

                                            votes








                                            38 Answers
                                            38






                                            active

                                            oldest

                                            votes









                                            active

                                            oldest

                                            votes






                                            active

                                            oldest

                                            votes








                                            1 2
                                            next









                                            up vote
                                            25
                                            down vote














                                            Python 2, 56 bytes





                                            for n in range(9999):
                                            if eval('<'.join(`n`))**n:print n


                                            Try it online!



                                            Converts each number like 124 to an expression 1<2<4 and evaluates it to check if the digits are sorted,



                                            A hiccup happens for one-digit numbers giving an expression that just is the number itself. This causes 0 to evaluate to a Falsey value even though it should be printed. This is fixed by a trick suggested by Erik the Outgolfer of doing **n, which gives truthy value 0**0 for n=0 and doesn't affect the truth value otherwise.






                                            share|improve this answer























                                            • What does the ` do in `n`?
                                              – BruceWayne
                                              Nov 16 at 21:58








                                            • 1




                                              @BruceWayne It takes the string representation. This was removed in Python 3.
                                              – xnor
                                              Nov 16 at 22:00






                                            • 4




                                              @BruceWayne Note that it's the same as the repr() function, not the str() function. They aren't always the same. Here's an example.
                                              – mbomb007
                                              Nov 16 at 22:39












                                            • @mbomb007 thanks for that comment! I would have thought it was str() equivalent.
                                              – BruceWayne
                                              Nov 16 at 22:48






                                            • 1




                                              We can handle the 0 case with a bit of trickery.
                                              – xsot
                                              Nov 17 at 16:04















                                            up vote
                                            25
                                            down vote














                                            Python 2, 56 bytes





                                            for n in range(9999):
                                            if eval('<'.join(`n`))**n:print n


                                            Try it online!



                                            Converts each number like 124 to an expression 1<2<4 and evaluates it to check if the digits are sorted,



                                            A hiccup happens for one-digit numbers giving an expression that just is the number itself. This causes 0 to evaluate to a Falsey value even though it should be printed. This is fixed by a trick suggested by Erik the Outgolfer of doing **n, which gives truthy value 0**0 for n=0 and doesn't affect the truth value otherwise.






                                            share|improve this answer























                                            • What does the ` do in `n`?
                                              – BruceWayne
                                              Nov 16 at 21:58








                                            • 1




                                              @BruceWayne It takes the string representation. This was removed in Python 3.
                                              – xnor
                                              Nov 16 at 22:00






                                            • 4




                                              @BruceWayne Note that it's the same as the repr() function, not the str() function. They aren't always the same. Here's an example.
                                              – mbomb007
                                              Nov 16 at 22:39












                                            • @mbomb007 thanks for that comment! I would have thought it was str() equivalent.
                                              – BruceWayne
                                              Nov 16 at 22:48






                                            • 1




                                              We can handle the 0 case with a bit of trickery.
                                              – xsot
                                              Nov 17 at 16:04













                                            up vote
                                            25
                                            down vote










                                            up vote
                                            25
                                            down vote










                                            Python 2, 56 bytes





                                            for n in range(9999):
                                            if eval('<'.join(`n`))**n:print n


                                            Try it online!



                                            Converts each number like 124 to an expression 1<2<4 and evaluates it to check if the digits are sorted,



                                            A hiccup happens for one-digit numbers giving an expression that just is the number itself. This causes 0 to evaluate to a Falsey value even though it should be printed. This is fixed by a trick suggested by Erik the Outgolfer of doing **n, which gives truthy value 0**0 for n=0 and doesn't affect the truth value otherwise.






                                            share|improve this answer















                                            Python 2, 56 bytes





                                            for n in range(9999):
                                            if eval('<'.join(`n`))**n:print n


                                            Try it online!



                                            Converts each number like 124 to an expression 1<2<4 and evaluates it to check if the digits are sorted,



                                            A hiccup happens for one-digit numbers giving an expression that just is the number itself. This causes 0 to evaluate to a Falsey value even though it should be printed. This is fixed by a trick suggested by Erik the Outgolfer of doing **n, which gives truthy value 0**0 for n=0 and doesn't affect the truth value otherwise.







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Nov 16 at 20:42

























                                            answered Nov 16 at 20:01









                                            xnor

                                            88.9k18184437




                                            88.9k18184437












                                            • What does the ` do in `n`?
                                              – BruceWayne
                                              Nov 16 at 21:58








                                            • 1




                                              @BruceWayne It takes the string representation. This was removed in Python 3.
                                              – xnor
                                              Nov 16 at 22:00






                                            • 4




                                              @BruceWayne Note that it's the same as the repr() function, not the str() function. They aren't always the same. Here's an example.
                                              – mbomb007
                                              Nov 16 at 22:39












                                            • @mbomb007 thanks for that comment! I would have thought it was str() equivalent.
                                              – BruceWayne
                                              Nov 16 at 22:48






                                            • 1




                                              We can handle the 0 case with a bit of trickery.
                                              – xsot
                                              Nov 17 at 16:04


















                                            • What does the ` do in `n`?
                                              – BruceWayne
                                              Nov 16 at 21:58








                                            • 1




                                              @BruceWayne It takes the string representation. This was removed in Python 3.
                                              – xnor
                                              Nov 16 at 22:00






                                            • 4




                                              @BruceWayne Note that it's the same as the repr() function, not the str() function. They aren't always the same. Here's an example.
                                              – mbomb007
                                              Nov 16 at 22:39












                                            • @mbomb007 thanks for that comment! I would have thought it was str() equivalent.
                                              – BruceWayne
                                              Nov 16 at 22:48






                                            • 1




                                              We can handle the 0 case with a bit of trickery.
                                              – xsot
                                              Nov 17 at 16:04
















                                            What does the ` do in `n`?
                                            – BruceWayne
                                            Nov 16 at 21:58






                                            What does the ` do in `n`?
                                            – BruceWayne
                                            Nov 16 at 21:58






                                            1




                                            1




                                            @BruceWayne It takes the string representation. This was removed in Python 3.
                                            – xnor
                                            Nov 16 at 22:00




                                            @BruceWayne It takes the string representation. This was removed in Python 3.
                                            – xnor
                                            Nov 16 at 22:00




                                            4




                                            4




                                            @BruceWayne Note that it's the same as the repr() function, not the str() function. They aren't always the same. Here's an example.
                                            – mbomb007
                                            Nov 16 at 22:39






                                            @BruceWayne Note that it's the same as the repr() function, not the str() function. They aren't always the same. Here's an example.
                                            – mbomb007
                                            Nov 16 at 22:39














                                            @mbomb007 thanks for that comment! I would have thought it was str() equivalent.
                                            – BruceWayne
                                            Nov 16 at 22:48




                                            @mbomb007 thanks for that comment! I would have thought it was str() equivalent.
                                            – BruceWayne
                                            Nov 16 at 22:48




                                            1




                                            1




                                            We can handle the 0 case with a bit of trickery.
                                            – xsot
                                            Nov 17 at 16:04




                                            We can handle the 0 case with a bit of trickery.
                                            – xsot
                                            Nov 17 at 16:04










                                            up vote
                                            10
                                            down vote














                                            Haskell, 50 bytes





                                            unlines[s|s<-show<$>[0..6^5],s==scanl1(max.succ)s]


                                            Try it online!



                                            Outputs a multiline string. We check that the number s increasing using s==scanl1(max.succ)s, a variant of the usual sortedness check s==scanl1 max s that ensures strict sortedness by incrementing each digit character before taking the maximum of it and the next digit.



                                            Ourous saved a byte by using 6^5 as the upper bound in place of a 4-digit number.






                                            share|improve this answer



























                                              up vote
                                              10
                                              down vote














                                              Haskell, 50 bytes





                                              unlines[s|s<-show<$>[0..6^5],s==scanl1(max.succ)s]


                                              Try it online!



                                              Outputs a multiline string. We check that the number s increasing using s==scanl1(max.succ)s, a variant of the usual sortedness check s==scanl1 max s that ensures strict sortedness by incrementing each digit character before taking the maximum of it and the next digit.



                                              Ourous saved a byte by using 6^5 as the upper bound in place of a 4-digit number.






                                              share|improve this answer

























                                                up vote
                                                10
                                                down vote










                                                up vote
                                                10
                                                down vote










                                                Haskell, 50 bytes





                                                unlines[s|s<-show<$>[0..6^5],s==scanl1(max.succ)s]


                                                Try it online!



                                                Outputs a multiline string. We check that the number s increasing using s==scanl1(max.succ)s, a variant of the usual sortedness check s==scanl1 max s that ensures strict sortedness by incrementing each digit character before taking the maximum of it and the next digit.



                                                Ourous saved a byte by using 6^5 as the upper bound in place of a 4-digit number.






                                                share|improve this answer















                                                Haskell, 50 bytes





                                                unlines[s|s<-show<$>[0..6^5],s==scanl1(max.succ)s]


                                                Try it online!



                                                Outputs a multiline string. We check that the number s increasing using s==scanl1(max.succ)s, a variant of the usual sortedness check s==scanl1 max s that ensures strict sortedness by incrementing each digit character before taking the maximum of it and the next digit.



                                                Ourous saved a byte by using 6^5 as the upper bound in place of a 4-digit number.







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Nov 17 at 1:57

























                                                answered Nov 16 at 20:37









                                                xnor

                                                88.9k18184437




                                                88.9k18184437






















                                                    up vote
                                                    8
                                                    down vote














                                                    Python 2, 55 bytes





                                                    i=0
                                                    exec"print ini+=1nif eval('<'.join(`i`)):1;"*7000


                                                    Try it online!






                                                    share|improve this answer

























                                                      up vote
                                                      8
                                                      down vote














                                                      Python 2, 55 bytes





                                                      i=0
                                                      exec"print ini+=1nif eval('<'.join(`i`)):1;"*7000


                                                      Try it online!






                                                      share|improve this answer























                                                        up vote
                                                        8
                                                        down vote










                                                        up vote
                                                        8
                                                        down vote










                                                        Python 2, 55 bytes





                                                        i=0
                                                        exec"print ini+=1nif eval('<'.join(`i`)):1;"*7000


                                                        Try it online!






                                                        share|improve this answer













                                                        Python 2, 55 bytes





                                                        i=0
                                                        exec"print ini+=1nif eval('<'.join(`i`)):1;"*7000


                                                        Try it online!







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Nov 17 at 15:59









                                                        xsot

                                                        4,7791921




                                                        4,7791921






















                                                            up vote
                                                            7
                                                            down vote













                                                            Japt -R, 12 11 8 bytes



                                                            L²Ç¶ìüÃð


                                                            Test it



                                                            L            :100
                                                            ² :Squared
                                                            Ç :Map the range [0,L²)
                                                            ì : Split to a digit array
                                                            ü : For the sake if simplicity*, let's say: Sort & deduplicate
                                                            : Implicitly rejoin to an integer
                                                            ¶ : Test for equality with original number
                                                            Ã :End map
                                                            ð :Get 0-based indices of truthy elements
                                                            :Implicitly join with newlines and output


                                                            *Or, to offer a better explanation: the ü method sorts an array and splits it into equal elements (e.g., [8,4,8,4].ü() -> [[4,4],[8,8]]) and then, in what seems to be a strange quirk and hopefully not a bug, the ì method, when converting the array back to a number, takes the first element of each nested array, rather than first flattening the array, which is what I expected when I tried this trick (e.g., [[4,4],[8,8]].ì() -> 48).






                                                            share|improve this answer



















                                                            • 1




                                                              Nice. Similar to what I had: L²Ç¥ì ü ¬Ãð
                                                              – Oliver
                                                              Nov 16 at 19:39






                                                            • 2




                                                              I have to say, that ü trick you guys used is genius :-) @Oliver
                                                              – ETHproductions
                                                              Nov 16 at 19:45






                                                            • 1




                                                              @Oliver, you must have posted that as I was updating; great minds ... :)
                                                              – Shaggy
                                                              Nov 16 at 19:48










                                                            • @ETHproductions, like most things, I tried it on a whim - amazed it works.
                                                              – Shaggy
                                                              Nov 16 at 19:48















                                                            up vote
                                                            7
                                                            down vote













                                                            Japt -R, 12 11 8 bytes



                                                            L²Ç¶ìüÃð


                                                            Test it



                                                            L            :100
                                                            ² :Squared
                                                            Ç :Map the range [0,L²)
                                                            ì : Split to a digit array
                                                            ü : For the sake if simplicity*, let's say: Sort & deduplicate
                                                            : Implicitly rejoin to an integer
                                                            ¶ : Test for equality with original number
                                                            Ã :End map
                                                            ð :Get 0-based indices of truthy elements
                                                            :Implicitly join with newlines and output


                                                            *Or, to offer a better explanation: the ü method sorts an array and splits it into equal elements (e.g., [8,4,8,4].ü() -> [[4,4],[8,8]]) and then, in what seems to be a strange quirk and hopefully not a bug, the ì method, when converting the array back to a number, takes the first element of each nested array, rather than first flattening the array, which is what I expected when I tried this trick (e.g., [[4,4],[8,8]].ì() -> 48).






                                                            share|improve this answer



















                                                            • 1




                                                              Nice. Similar to what I had: L²Ç¥ì ü ¬Ãð
                                                              – Oliver
                                                              Nov 16 at 19:39






                                                            • 2




                                                              I have to say, that ü trick you guys used is genius :-) @Oliver
                                                              – ETHproductions
                                                              Nov 16 at 19:45






                                                            • 1




                                                              @Oliver, you must have posted that as I was updating; great minds ... :)
                                                              – Shaggy
                                                              Nov 16 at 19:48










                                                            • @ETHproductions, like most things, I tried it on a whim - amazed it works.
                                                              – Shaggy
                                                              Nov 16 at 19:48













                                                            up vote
                                                            7
                                                            down vote










                                                            up vote
                                                            7
                                                            down vote









                                                            Japt -R, 12 11 8 bytes



                                                            L²Ç¶ìüÃð


                                                            Test it



                                                            L            :100
                                                            ² :Squared
                                                            Ç :Map the range [0,L²)
                                                            ì : Split to a digit array
                                                            ü : For the sake if simplicity*, let's say: Sort & deduplicate
                                                            : Implicitly rejoin to an integer
                                                            ¶ : Test for equality with original number
                                                            Ã :End map
                                                            ð :Get 0-based indices of truthy elements
                                                            :Implicitly join with newlines and output


                                                            *Or, to offer a better explanation: the ü method sorts an array and splits it into equal elements (e.g., [8,4,8,4].ü() -> [[4,4],[8,8]]) and then, in what seems to be a strange quirk and hopefully not a bug, the ì method, when converting the array back to a number, takes the first element of each nested array, rather than first flattening the array, which is what I expected when I tried this trick (e.g., [[4,4],[8,8]].ì() -> 48).






                                                            share|improve this answer














                                                            Japt -R, 12 11 8 bytes



                                                            L²Ç¶ìüÃð


                                                            Test it



                                                            L            :100
                                                            ² :Squared
                                                            Ç :Map the range [0,L²)
                                                            ì : Split to a digit array
                                                            ü : For the sake if simplicity*, let's say: Sort & deduplicate
                                                            : Implicitly rejoin to an integer
                                                            ¶ : Test for equality with original number
                                                            Ã :End map
                                                            ð :Get 0-based indices of truthy elements
                                                            :Implicitly join with newlines and output


                                                            *Or, to offer a better explanation: the ü method sorts an array and splits it into equal elements (e.g., [8,4,8,4].ü() -> [[4,4],[8,8]]) and then, in what seems to be a strange quirk and hopefully not a bug, the ì method, when converting the array back to a number, takes the first element of each nested array, rather than first flattening the array, which is what I expected when I tried this trick (e.g., [[4,4],[8,8]].ì() -> 48).







                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited Nov 16 at 22:22

























                                                            answered Nov 16 at 19:33









                                                            Shaggy

                                                            18.2k21663




                                                            18.2k21663








                                                            • 1




                                                              Nice. Similar to what I had: L²Ç¥ì ü ¬Ãð
                                                              – Oliver
                                                              Nov 16 at 19:39






                                                            • 2




                                                              I have to say, that ü trick you guys used is genius :-) @Oliver
                                                              – ETHproductions
                                                              Nov 16 at 19:45






                                                            • 1




                                                              @Oliver, you must have posted that as I was updating; great minds ... :)
                                                              – Shaggy
                                                              Nov 16 at 19:48










                                                            • @ETHproductions, like most things, I tried it on a whim - amazed it works.
                                                              – Shaggy
                                                              Nov 16 at 19:48














                                                            • 1




                                                              Nice. Similar to what I had: L²Ç¥ì ü ¬Ãð
                                                              – Oliver
                                                              Nov 16 at 19:39






                                                            • 2




                                                              I have to say, that ü trick you guys used is genius :-) @Oliver
                                                              – ETHproductions
                                                              Nov 16 at 19:45






                                                            • 1




                                                              @Oliver, you must have posted that as I was updating; great minds ... :)
                                                              – Shaggy
                                                              Nov 16 at 19:48










                                                            • @ETHproductions, like most things, I tried it on a whim - amazed it works.
                                                              – Shaggy
                                                              Nov 16 at 19:48








                                                            1




                                                            1




                                                            Nice. Similar to what I had: L²Ç¥ì ü ¬Ãð
                                                            – Oliver
                                                            Nov 16 at 19:39




                                                            Nice. Similar to what I had: L²Ç¥ì ü ¬Ãð
                                                            – Oliver
                                                            Nov 16 at 19:39




                                                            2




                                                            2




                                                            I have to say, that ü trick you guys used is genius :-) @Oliver
                                                            – ETHproductions
                                                            Nov 16 at 19:45




                                                            I have to say, that ü trick you guys used is genius :-) @Oliver
                                                            – ETHproductions
                                                            Nov 16 at 19:45




                                                            1




                                                            1




                                                            @Oliver, you must have posted that as I was updating; great minds ... :)
                                                            – Shaggy
                                                            Nov 16 at 19:48




                                                            @Oliver, you must have posted that as I was updating; great minds ... :)
                                                            – Shaggy
                                                            Nov 16 at 19:48












                                                            @ETHproductions, like most things, I tried it on a whim - amazed it works.
                                                            – Shaggy
                                                            Nov 16 at 19:48




                                                            @ETHproductions, like most things, I tried it on a whim - amazed it works.
                                                            – Shaggy
                                                            Nov 16 at 19:48










                                                            up vote
                                                            7
                                                            down vote














                                                            Jelly, 7 bytes



                                                            9ŒPḌḣ⁹Y


                                                            Try it online!



                                                            How it works



                                                            9ŒPḌḣ⁹Y  Main link. No arguments.

                                                            9 Set the return value to 9.
                                                            ŒP Powerset; promote 9 to [1, ..., 9] and generate all subsets.
                                                            Ḍ Undecimal; map the subsets of digits to the integers they represent.
                                                            ⁹ Yield 256.
                                                            ḣ Dyadic head; take the first 256 elements of the integer list.
                                                            Y Separate the result by linefeeds.





                                                            share|improve this answer



















                                                            • 2




                                                              I'm trying to figure out how 0 gets included here but I don't know Jelly. Am I correct that Jelly's powerset includes the empty array which then gets converted to 0 when "undecimaled"?
                                                              – Shaggy
                                                              Nov 17 at 0:21






                                                            • 1




                                                              Yes, that's exactly what happens.
                                                              – Dennis
                                                              Nov 17 at 0:37















                                                            up vote
                                                            7
                                                            down vote














                                                            Jelly, 7 bytes



                                                            9ŒPḌḣ⁹Y


                                                            Try it online!



                                                            How it works



                                                            9ŒPḌḣ⁹Y  Main link. No arguments.

                                                            9 Set the return value to 9.
                                                            ŒP Powerset; promote 9 to [1, ..., 9] and generate all subsets.
                                                            Ḍ Undecimal; map the subsets of digits to the integers they represent.
                                                            ⁹ Yield 256.
                                                            ḣ Dyadic head; take the first 256 elements of the integer list.
                                                            Y Separate the result by linefeeds.





                                                            share|improve this answer



















                                                            • 2




                                                              I'm trying to figure out how 0 gets included here but I don't know Jelly. Am I correct that Jelly's powerset includes the empty array which then gets converted to 0 when "undecimaled"?
                                                              – Shaggy
                                                              Nov 17 at 0:21






                                                            • 1




                                                              Yes, that's exactly what happens.
                                                              – Dennis
                                                              Nov 17 at 0:37













                                                            up vote
                                                            7
                                                            down vote










                                                            up vote
                                                            7
                                                            down vote










                                                            Jelly, 7 bytes



                                                            9ŒPḌḣ⁹Y


                                                            Try it online!



                                                            How it works



                                                            9ŒPḌḣ⁹Y  Main link. No arguments.

                                                            9 Set the return value to 9.
                                                            ŒP Powerset; promote 9 to [1, ..., 9] and generate all subsets.
                                                            Ḍ Undecimal; map the subsets of digits to the integers they represent.
                                                            ⁹ Yield 256.
                                                            ḣ Dyadic head; take the first 256 elements of the integer list.
                                                            Y Separate the result by linefeeds.





                                                            share|improve this answer















                                                            Jelly, 7 bytes



                                                            9ŒPḌḣ⁹Y


                                                            Try it online!



                                                            How it works



                                                            9ŒPḌḣ⁹Y  Main link. No arguments.

                                                            9 Set the return value to 9.
                                                            ŒP Powerset; promote 9 to [1, ..., 9] and generate all subsets.
                                                            Ḍ Undecimal; map the subsets of digits to the integers they represent.
                                                            ⁹ Yield 256.
                                                            ḣ Dyadic head; take the first 256 elements of the integer list.
                                                            Y Separate the result by linefeeds.






                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited Nov 16 at 22:22

























                                                            answered Nov 16 at 22:15









                                                            Dennis

                                                            184k32294730




                                                            184k32294730








                                                            • 2




                                                              I'm trying to figure out how 0 gets included here but I don't know Jelly. Am I correct that Jelly's powerset includes the empty array which then gets converted to 0 when "undecimaled"?
                                                              – Shaggy
                                                              Nov 17 at 0:21






                                                            • 1




                                                              Yes, that's exactly what happens.
                                                              – Dennis
                                                              Nov 17 at 0:37














                                                            • 2




                                                              I'm trying to figure out how 0 gets included here but I don't know Jelly. Am I correct that Jelly's powerset includes the empty array which then gets converted to 0 when "undecimaled"?
                                                              – Shaggy
                                                              Nov 17 at 0:21






                                                            • 1




                                                              Yes, that's exactly what happens.
                                                              – Dennis
                                                              Nov 17 at 0:37








                                                            2




                                                            2




                                                            I'm trying to figure out how 0 gets included here but I don't know Jelly. Am I correct that Jelly's powerset includes the empty array which then gets converted to 0 when "undecimaled"?
                                                            – Shaggy
                                                            Nov 17 at 0:21




                                                            I'm trying to figure out how 0 gets included here but I don't know Jelly. Am I correct that Jelly's powerset includes the empty array which then gets converted to 0 when "undecimaled"?
                                                            – Shaggy
                                                            Nov 17 at 0:21




                                                            1




                                                            1




                                                            Yes, that's exactly what happens.
                                                            – Dennis
                                                            Nov 17 at 0:37




                                                            Yes, that's exactly what happens.
                                                            – Dennis
                                                            Nov 17 at 0:37










                                                            up vote
                                                            6
                                                            down vote














                                                            R, 62 49 bytes





                                                            `[`=write;0[1];for(i in 1:4)combn(1:9,i)[1,i,,""]


                                                            Try it online!



                                                            Because combn iterates through its input in the order given, it's easy to create all the lexicographically increasing integers, printing them out in order. write prints them each i-digit number in lines of width i, neatly fulfilling the newline requirement as well.






                                                            share|improve this answer























                                                            • great idea exploiting combn !
                                                              – digEmAll
                                                              Nov 17 at 14:36










                                                            • Extremely clever aliasing!
                                                              – J.Doe
                                                              Nov 18 at 12:15















                                                            up vote
                                                            6
                                                            down vote














                                                            R, 62 49 bytes





                                                            `[`=write;0[1];for(i in 1:4)combn(1:9,i)[1,i,,""]


                                                            Try it online!



                                                            Because combn iterates through its input in the order given, it's easy to create all the lexicographically increasing integers, printing them out in order. write prints them each i-digit number in lines of width i, neatly fulfilling the newline requirement as well.






                                                            share|improve this answer























                                                            • great idea exploiting combn !
                                                              – digEmAll
                                                              Nov 17 at 14:36










                                                            • Extremely clever aliasing!
                                                              – J.Doe
                                                              Nov 18 at 12:15













                                                            up vote
                                                            6
                                                            down vote










                                                            up vote
                                                            6
                                                            down vote










                                                            R, 62 49 bytes





                                                            `[`=write;0[1];for(i in 1:4)combn(1:9,i)[1,i,,""]


                                                            Try it online!



                                                            Because combn iterates through its input in the order given, it's easy to create all the lexicographically increasing integers, printing them out in order. write prints them each i-digit number in lines of width i, neatly fulfilling the newline requirement as well.






                                                            share|improve this answer















                                                            R, 62 49 bytes





                                                            `[`=write;0[1];for(i in 1:4)combn(1:9,i)[1,i,,""]


                                                            Try it online!



                                                            Because combn iterates through its input in the order given, it's easy to create all the lexicographically increasing integers, printing them out in order. write prints them each i-digit number in lines of width i, neatly fulfilling the newline requirement as well.







                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited Nov 16 at 21:20

























                                                            answered Nov 16 at 19:28









                                                            Giuseppe

                                                            16k31052




                                                            16k31052












                                                            • great idea exploiting combn !
                                                              – digEmAll
                                                              Nov 17 at 14:36










                                                            • Extremely clever aliasing!
                                                              – J.Doe
                                                              Nov 18 at 12:15


















                                                            • great idea exploiting combn !
                                                              – digEmAll
                                                              Nov 17 at 14:36










                                                            • Extremely clever aliasing!
                                                              – J.Doe
                                                              Nov 18 at 12:15
















                                                            great idea exploiting combn !
                                                            – digEmAll
                                                            Nov 17 at 14:36




                                                            great idea exploiting combn !
                                                            – digEmAll
                                                            Nov 17 at 14:36












                                                            Extremely clever aliasing!
                                                            – J.Doe
                                                            Nov 18 at 12:15




                                                            Extremely clever aliasing!
                                                            – J.Doe
                                                            Nov 18 at 12:15










                                                            up vote
                                                            5
                                                            down vote













                                                            Haskell, 56 55 bytes



                                                            Edit: -1 byte thanks to @Ourous



                                                            mapM print$filter(and.(zipWith(<)<*>tail).show)[0..6^5]


                                                            Try it online!






                                                            share|improve this answer



























                                                              up vote
                                                              5
                                                              down vote













                                                              Haskell, 56 55 bytes



                                                              Edit: -1 byte thanks to @Ourous



                                                              mapM print$filter(and.(zipWith(<)<*>tail).show)[0..6^5]


                                                              Try it online!






                                                              share|improve this answer

























                                                                up vote
                                                                5
                                                                down vote










                                                                up vote
                                                                5
                                                                down vote









                                                                Haskell, 56 55 bytes



                                                                Edit: -1 byte thanks to @Ourous



                                                                mapM print$filter(and.(zipWith(<)<*>tail).show)[0..6^5]


                                                                Try it online!






                                                                share|improve this answer














                                                                Haskell, 56 55 bytes



                                                                Edit: -1 byte thanks to @Ourous



                                                                mapM print$filter(and.(zipWith(<)<*>tail).show)[0..6^5]


                                                                Try it online!







                                                                share|improve this answer














                                                                share|improve this answer



                                                                share|improve this answer








                                                                edited Nov 17 at 2:31

























                                                                answered Nov 16 at 19:38









                                                                nimi

                                                                30.8k31985




                                                                30.8k31985






















                                                                    up vote
                                                                    4
                                                                    down vote














                                                                    PowerShell, 42 40 bytes





                                                                    0..1e4|?{-join("$_"|% t*y|sort -u)-eq$_}


                                                                    Try it online!



                                                                    Loop from 0 to 1e4 (i.e., 10000). Pull out those objects where |?{...} the number as a string $_ is -equal to the number cast toCharArray and then sorted with the -unique flag. In other words, only numbers that are the same as their sorted and deduplicated strings. Each of those are left on the pipeline and output is implicit.






                                                                    share|improve this answer



























                                                                      up vote
                                                                      4
                                                                      down vote














                                                                      PowerShell, 42 40 bytes





                                                                      0..1e4|?{-join("$_"|% t*y|sort -u)-eq$_}


                                                                      Try it online!



                                                                      Loop from 0 to 1e4 (i.e., 10000). Pull out those objects where |?{...} the number as a string $_ is -equal to the number cast toCharArray and then sorted with the -unique flag. In other words, only numbers that are the same as their sorted and deduplicated strings. Each of those are left on the pipeline and output is implicit.






                                                                      share|improve this answer

























                                                                        up vote
                                                                        4
                                                                        down vote










                                                                        up vote
                                                                        4
                                                                        down vote










                                                                        PowerShell, 42 40 bytes





                                                                        0..1e4|?{-join("$_"|% t*y|sort -u)-eq$_}


                                                                        Try it online!



                                                                        Loop from 0 to 1e4 (i.e., 10000). Pull out those objects where |?{...} the number as a string $_ is -equal to the number cast toCharArray and then sorted with the -unique flag. In other words, only numbers that are the same as their sorted and deduplicated strings. Each of those are left on the pipeline and output is implicit.






                                                                        share|improve this answer















                                                                        PowerShell, 42 40 bytes





                                                                        0..1e4|?{-join("$_"|% t*y|sort -u)-eq$_}


                                                                        Try it online!



                                                                        Loop from 0 to 1e4 (i.e., 10000). Pull out those objects where |?{...} the number as a string $_ is -equal to the number cast toCharArray and then sorted with the -unique flag. In other words, only numbers that are the same as their sorted and deduplicated strings. Each of those are left on the pipeline and output is implicit.







                                                                        share|improve this answer














                                                                        share|improve this answer



                                                                        share|improve this answer








                                                                        edited Nov 19 at 13:24

























                                                                        answered Nov 16 at 19:38









                                                                        AdmBorkBork

                                                                        25.6k363224




                                                                        25.6k363224






















                                                                            up vote
                                                                            3
                                                                            down vote














                                                                            Perl 6, 26 bytes



                                                                            .say if [<] .comb for ^1e4


                                                                            Try it online!



                                                                            .comb produces a list of the digits of each number, and [<] does a less-than reduction on that list, equivalent to: digit1 < digit2 < ... < digitN.






                                                                            share|improve this answer

















                                                                            • 2




                                                                              [<](.comb)&&.say saves a byte.
                                                                              – nwellnhof
                                                                              Nov 17 at 9:56










                                                                            • This is surprisingly readable. (I already know a little Perl 6, but still...)
                                                                              – J-L
                                                                              Nov 19 at 20:38















                                                                            up vote
                                                                            3
                                                                            down vote














                                                                            Perl 6, 26 bytes



                                                                            .say if [<] .comb for ^1e4


                                                                            Try it online!



                                                                            .comb produces a list of the digits of each number, and [<] does a less-than reduction on that list, equivalent to: digit1 < digit2 < ... < digitN.






                                                                            share|improve this answer

















                                                                            • 2




                                                                              [<](.comb)&&.say saves a byte.
                                                                              – nwellnhof
                                                                              Nov 17 at 9:56










                                                                            • This is surprisingly readable. (I already know a little Perl 6, but still...)
                                                                              – J-L
                                                                              Nov 19 at 20:38













                                                                            up vote
                                                                            3
                                                                            down vote










                                                                            up vote
                                                                            3
                                                                            down vote










                                                                            Perl 6, 26 bytes



                                                                            .say if [<] .comb for ^1e4


                                                                            Try it online!



                                                                            .comb produces a list of the digits of each number, and [<] does a less-than reduction on that list, equivalent to: digit1 < digit2 < ... < digitN.






                                                                            share|improve this answer













                                                                            Perl 6, 26 bytes



                                                                            .say if [<] .comb for ^1e4


                                                                            Try it online!



                                                                            .comb produces a list of the digits of each number, and [<] does a less-than reduction on that list, equivalent to: digit1 < digit2 < ... < digitN.







                                                                            share|improve this answer












                                                                            share|improve this answer



                                                                            share|improve this answer










                                                                            answered Nov 16 at 19:54









                                                                            Sean

                                                                            3,13636




                                                                            3,13636








                                                                            • 2




                                                                              [<](.comb)&&.say saves a byte.
                                                                              – nwellnhof
                                                                              Nov 17 at 9:56










                                                                            • This is surprisingly readable. (I already know a little Perl 6, but still...)
                                                                              – J-L
                                                                              Nov 19 at 20:38














                                                                            • 2




                                                                              [<](.comb)&&.say saves a byte.
                                                                              – nwellnhof
                                                                              Nov 17 at 9:56










                                                                            • This is surprisingly readable. (I already know a little Perl 6, but still...)
                                                                              – J-L
                                                                              Nov 19 at 20:38








                                                                            2




                                                                            2




                                                                            [<](.comb)&&.say saves a byte.
                                                                            – nwellnhof
                                                                            Nov 17 at 9:56




                                                                            [<](.comb)&&.say saves a byte.
                                                                            – nwellnhof
                                                                            Nov 17 at 9:56












                                                                            This is surprisingly readable. (I already know a little Perl 6, but still...)
                                                                            – J-L
                                                                            Nov 19 at 20:38




                                                                            This is surprisingly readable. (I already know a little Perl 6, but still...)
                                                                            – J-L
                                                                            Nov 19 at 20:38










                                                                            up vote
                                                                            3
                                                                            down vote













                                                                            J, 26 bytes



                                                                            ,.(#~(-:/:~@~.)@":"0)i.1e4


                                                                            Try it online!



                                                                            explanation



                                                                            ,. (#~ (-: /:~@~.)@":"0) i.1e4
                                                                            i.1e4 NB. list 0 to 9999
                                                                            "0 NB. for each number in the input list
                                                                            @":"0 NB. convert it to a string and
                                                                            (#~ ( ) NB. remove any not passing this test:
                                                                            -: NB. the string of digits matches
                                                                            @~. NB. the nub of the digits (dups removed)
                                                                            /:~ NB. sorted
                                                                            ,. NB. ravel items: take the result of all that
                                                                            NB. and turn it into a big column





                                                                            share|improve this answer



























                                                                              up vote
                                                                              3
                                                                              down vote













                                                                              J, 26 bytes



                                                                              ,.(#~(-:/:~@~.)@":"0)i.1e4


                                                                              Try it online!



                                                                              explanation



                                                                              ,. (#~ (-: /:~@~.)@":"0) i.1e4
                                                                              i.1e4 NB. list 0 to 9999
                                                                              "0 NB. for each number in the input list
                                                                              @":"0 NB. convert it to a string and
                                                                              (#~ ( ) NB. remove any not passing this test:
                                                                              -: NB. the string of digits matches
                                                                              @~. NB. the nub of the digits (dups removed)
                                                                              /:~ NB. sorted
                                                                              ,. NB. ravel items: take the result of all that
                                                                              NB. and turn it into a big column





                                                                              share|improve this answer

























                                                                                up vote
                                                                                3
                                                                                down vote










                                                                                up vote
                                                                                3
                                                                                down vote









                                                                                J, 26 bytes



                                                                                ,.(#~(-:/:~@~.)@":"0)i.1e4


                                                                                Try it online!



                                                                                explanation



                                                                                ,. (#~ (-: /:~@~.)@":"0) i.1e4
                                                                                i.1e4 NB. list 0 to 9999
                                                                                "0 NB. for each number in the input list
                                                                                @":"0 NB. convert it to a string and
                                                                                (#~ ( ) NB. remove any not passing this test:
                                                                                -: NB. the string of digits matches
                                                                                @~. NB. the nub of the digits (dups removed)
                                                                                /:~ NB. sorted
                                                                                ,. NB. ravel items: take the result of all that
                                                                                NB. and turn it into a big column





                                                                                share|improve this answer














                                                                                J, 26 bytes



                                                                                ,.(#~(-:/:~@~.)@":"0)i.1e4


                                                                                Try it online!



                                                                                explanation



                                                                                ,. (#~ (-: /:~@~.)@":"0) i.1e4
                                                                                i.1e4 NB. list 0 to 9999
                                                                                "0 NB. for each number in the input list
                                                                                @":"0 NB. convert it to a string and
                                                                                (#~ ( ) NB. remove any not passing this test:
                                                                                -: NB. the string of digits matches
                                                                                @~. NB. the nub of the digits (dups removed)
                                                                                /:~ NB. sorted
                                                                                ,. NB. ravel items: take the result of all that
                                                                                NB. and turn it into a big column






                                                                                share|improve this answer














                                                                                share|improve this answer



                                                                                share|improve this answer








                                                                                edited Nov 16 at 22:46

























                                                                                answered Nov 16 at 20:05









                                                                                Jonah

                                                                                1,971816




                                                                                1,971816






















                                                                                    up vote
                                                                                    3
                                                                                    down vote














                                                                                    Common Lisp, 74 72 bytes



                                                                                    (dotimes(i 7e3)(format(apply'char<(coerce(format()"~d"i)'list))"~d~%"i))


                                                                                    Try it online!



                                                                                    -2 bytes thank to @Shaggy!






                                                                                    share|improve this answer



























                                                                                      up vote
                                                                                      3
                                                                                      down vote














                                                                                      Common Lisp, 74 72 bytes



                                                                                      (dotimes(i 7e3)(format(apply'char<(coerce(format()"~d"i)'list))"~d~%"i))


                                                                                      Try it online!



                                                                                      -2 bytes thank to @Shaggy!






                                                                                      share|improve this answer

























                                                                                        up vote
                                                                                        3
                                                                                        down vote










                                                                                        up vote
                                                                                        3
                                                                                        down vote










                                                                                        Common Lisp, 74 72 bytes



                                                                                        (dotimes(i 7e3)(format(apply'char<(coerce(format()"~d"i)'list))"~d~%"i))


                                                                                        Try it online!



                                                                                        -2 bytes thank to @Shaggy!






                                                                                        share|improve this answer















                                                                                        Common Lisp, 74 72 bytes



                                                                                        (dotimes(i 7e3)(format(apply'char<(coerce(format()"~d"i)'list))"~d~%"i))


                                                                                        Try it online!



                                                                                        -2 bytes thank to @Shaggy!







                                                                                        share|improve this answer














                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited Nov 17 at 10:08

























                                                                                        answered Nov 16 at 19:59









                                                                                        Renzo

                                                                                        1,590516




                                                                                        1,590516






















                                                                                            up vote
                                                                                            3
                                                                                            down vote














                                                                                            Pyth, 10 bytes



                                                                                            jiRThc2yS9


                                                                                            Try it online!



                                                                                            How it works



                                                                                            jiRThc2yS9
                                                                                            S9 Yield [1, 2, 3, 4, 5, 6, 7, 8, 9].
                                                                                            y Take all 512 subsets.
                                                                                            c2 Split the array of subsets into 2 pieces (256 subsets each).
                                                                                            h Head; take the first piece.
                                                                                            iRT Convert each subset from base 10 to integer.
                                                                                            j Separate by newlines.





                                                                                            share|improve this answer

























                                                                                              up vote
                                                                                              3
                                                                                              down vote














                                                                                              Pyth, 10 bytes



                                                                                              jiRThc2yS9


                                                                                              Try it online!



                                                                                              How it works



                                                                                              jiRThc2yS9
                                                                                              S9 Yield [1, 2, 3, 4, 5, 6, 7, 8, 9].
                                                                                              y Take all 512 subsets.
                                                                                              c2 Split the array of subsets into 2 pieces (256 subsets each).
                                                                                              h Head; take the first piece.
                                                                                              iRT Convert each subset from base 10 to integer.
                                                                                              j Separate by newlines.





                                                                                              share|improve this answer























                                                                                                up vote
                                                                                                3
                                                                                                down vote










                                                                                                up vote
                                                                                                3
                                                                                                down vote










                                                                                                Pyth, 10 bytes



                                                                                                jiRThc2yS9


                                                                                                Try it online!



                                                                                                How it works



                                                                                                jiRThc2yS9
                                                                                                S9 Yield [1, 2, 3, 4, 5, 6, 7, 8, 9].
                                                                                                y Take all 512 subsets.
                                                                                                c2 Split the array of subsets into 2 pieces (256 subsets each).
                                                                                                h Head; take the first piece.
                                                                                                iRT Convert each subset from base 10 to integer.
                                                                                                j Separate by newlines.





                                                                                                share|improve this answer













                                                                                                Pyth, 10 bytes



                                                                                                jiRThc2yS9


                                                                                                Try it online!



                                                                                                How it works



                                                                                                jiRThc2yS9
                                                                                                S9 Yield [1, 2, 3, 4, 5, 6, 7, 8, 9].
                                                                                                y Take all 512 subsets.
                                                                                                c2 Split the array of subsets into 2 pieces (256 subsets each).
                                                                                                h Head; take the first piece.
                                                                                                iRT Convert each subset from base 10 to integer.
                                                                                                j Separate by newlines.






                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered Nov 17 at 14:13









                                                                                                Dennis

                                                                                                184k32294730




                                                                                                184k32294730






















                                                                                                    up vote
                                                                                                    2
                                                                                                    down vote














                                                                                                    V, 41 bytes



                                                                                                    7000ïÎaÛ
                                                                                                    Îy$úúP
                                                                                                    Ç^¨ä*©±$/d
                                                                                                    ÎãlD
                                                                                                    爱/d
                                                                                                    HO0


                                                                                                    Try it online!



                                                                                                    Hexdump:



                                                                                                    00000000: 3730 3030 efce 61db 0ace 7924 fafa 500a  7000..a...y$..P.
                                                                                                    00000010: c75e a8e4 2aa9 b124 2f64 0ace e36c 440a .^..*..$/d...lD.
                                                                                                    00000020: e788 b12f 640a 484f 30 .../d.HO0





                                                                                                    share|improve this answer

























                                                                                                      up vote
                                                                                                      2
                                                                                                      down vote














                                                                                                      V, 41 bytes



                                                                                                      7000ïÎaÛ
                                                                                                      Îy$úúP
                                                                                                      Ç^¨ä*©±$/d
                                                                                                      ÎãlD
                                                                                                      爱/d
                                                                                                      HO0


                                                                                                      Try it online!



                                                                                                      Hexdump:



                                                                                                      00000000: 3730 3030 efce 61db 0ace 7924 fafa 500a  7000..a...y$..P.
                                                                                                      00000010: c75e a8e4 2aa9 b124 2f64 0ace e36c 440a .^..*..$/d...lD.
                                                                                                      00000020: e788 b12f 640a 484f 30 .../d.HO0





                                                                                                      share|improve this answer























                                                                                                        up vote
                                                                                                        2
                                                                                                        down vote










                                                                                                        up vote
                                                                                                        2
                                                                                                        down vote










                                                                                                        V, 41 bytes



                                                                                                        7000ïÎaÛ
                                                                                                        Îy$úúP
                                                                                                        Ç^¨ä*©±$/d
                                                                                                        ÎãlD
                                                                                                        爱/d
                                                                                                        HO0


                                                                                                        Try it online!



                                                                                                        Hexdump:



                                                                                                        00000000: 3730 3030 efce 61db 0ace 7924 fafa 500a  7000..a...y$..P.
                                                                                                        00000010: c75e a8e4 2aa9 b124 2f64 0ace e36c 440a .^..*..$/d...lD.
                                                                                                        00000020: e788 b12f 640a 484f 30 .../d.HO0





                                                                                                        share|improve this answer













                                                                                                        V, 41 bytes



                                                                                                        7000ïÎaÛ
                                                                                                        Îy$úúP
                                                                                                        Ç^¨ä*©±$/d
                                                                                                        ÎãlD
                                                                                                        爱/d
                                                                                                        HO0


                                                                                                        Try it online!



                                                                                                        Hexdump:



                                                                                                        00000000: 3730 3030 efce 61db 0ace 7924 fafa 500a  7000..a...y$..P.
                                                                                                        00000010: c75e a8e4 2aa9 b124 2f64 0ace e36c 440a .^..*..$/d...lD.
                                                                                                        00000020: e788 b12f 640a 484f 30 .../d.HO0






                                                                                                        share|improve this answer












                                                                                                        share|improve this answer



                                                                                                        share|improve this answer










                                                                                                        answered Nov 16 at 20:21









                                                                                                        DJMcMayhem

                                                                                                        40.6k11145307




                                                                                                        40.6k11145307






















                                                                                                            up vote
                                                                                                            2
                                                                                                            down vote














                                                                                                            Perl 5, 55 bytes





                                                                                                            $"=$,;map"@{[sort{$a-$b}/./g]}"-$_||/(.)1/||say,0..1E4


                                                                                                            Try it online!






                                                                                                            share|improve this answer

























                                                                                                              up vote
                                                                                                              2
                                                                                                              down vote














                                                                                                              Perl 5, 55 bytes





                                                                                                              $"=$,;map"@{[sort{$a-$b}/./g]}"-$_||/(.)1/||say,0..1E4


                                                                                                              Try it online!






                                                                                                              share|improve this answer























                                                                                                                up vote
                                                                                                                2
                                                                                                                down vote










                                                                                                                up vote
                                                                                                                2
                                                                                                                down vote










                                                                                                                Perl 5, 55 bytes





                                                                                                                $"=$,;map"@{[sort{$a-$b}/./g]}"-$_||/(.)1/||say,0..1E4


                                                                                                                Try it online!






                                                                                                                share|improve this answer













                                                                                                                Perl 5, 55 bytes





                                                                                                                $"=$,;map"@{[sort{$a-$b}/./g]}"-$_||/(.)1/||say,0..1E4


                                                                                                                Try it online!







                                                                                                                share|improve this answer












                                                                                                                share|improve this answer



                                                                                                                share|improve this answer










                                                                                                                answered Nov 16 at 20:24









                                                                                                                Xcali

                                                                                                                4,990520




                                                                                                                4,990520






















                                                                                                                    up vote
                                                                                                                    2
                                                                                                                    down vote














                                                                                                                    Charcoal, 19 bytes



                                                                                                                    ΦEXχ⁴Iι¬Φι∧쬋§ι⊖μλ


                                                                                                                    Try it online! Link is to verbose version of code. Explanation:



                                                                                                                       χ                Predefined variable 10
                                                                                                                    X To the power
                                                                                                                    ⁴ Literal 4
                                                                                                                    E Map over implicit range
                                                                                                                    ι Current value
                                                                                                                    I Cast to string
                                                                                                                    Φ Filter over strings where
                                                                                                                    ι Current string
                                                                                                                    Φ Filtered over characters
                                                                                                                    μ Character index (is nonzero)
                                                                                                                    ∧ And
                                                                                                                    μ Character index
                                                                                                                    ⊖ Decremented
                                                                                                                    § Indexed into
                                                                                                                    ι Current string
                                                                                                                    ¬ Is not
                                                                                                                    ‹ Less than
                                                                                                                    λ Current character
                                                                                                                    ¬ Results in an empty string
                                                                                                                    Implicitly print matches on separate lines





                                                                                                                    share|improve this answer

























                                                                                                                      up vote
                                                                                                                      2
                                                                                                                      down vote














                                                                                                                      Charcoal, 19 bytes



                                                                                                                      ΦEXχ⁴Iι¬Φι∧쬋§ι⊖μλ


                                                                                                                      Try it online! Link is to verbose version of code. Explanation:



                                                                                                                         χ                Predefined variable 10
                                                                                                                      X To the power
                                                                                                                      ⁴ Literal 4
                                                                                                                      E Map over implicit range
                                                                                                                      ι Current value
                                                                                                                      I Cast to string
                                                                                                                      Φ Filter over strings where
                                                                                                                      ι Current string
                                                                                                                      Φ Filtered over characters
                                                                                                                      μ Character index (is nonzero)
                                                                                                                      ∧ And
                                                                                                                      μ Character index
                                                                                                                      ⊖ Decremented
                                                                                                                      § Indexed into
                                                                                                                      ι Current string
                                                                                                                      ¬ Is not
                                                                                                                      ‹ Less than
                                                                                                                      λ Current character
                                                                                                                      ¬ Results in an empty string
                                                                                                                      Implicitly print matches on separate lines





                                                                                                                      share|improve this answer























                                                                                                                        up vote
                                                                                                                        2
                                                                                                                        down vote










                                                                                                                        up vote
                                                                                                                        2
                                                                                                                        down vote










                                                                                                                        Charcoal, 19 bytes



                                                                                                                        ΦEXχ⁴Iι¬Φι∧쬋§ι⊖μλ


                                                                                                                        Try it online! Link is to verbose version of code. Explanation:



                                                                                                                           χ                Predefined variable 10
                                                                                                                        X To the power
                                                                                                                        ⁴ Literal 4
                                                                                                                        E Map over implicit range
                                                                                                                        ι Current value
                                                                                                                        I Cast to string
                                                                                                                        Φ Filter over strings where
                                                                                                                        ι Current string
                                                                                                                        Φ Filtered over characters
                                                                                                                        μ Character index (is nonzero)
                                                                                                                        ∧ And
                                                                                                                        μ Character index
                                                                                                                        ⊖ Decremented
                                                                                                                        § Indexed into
                                                                                                                        ι Current string
                                                                                                                        ¬ Is not
                                                                                                                        ‹ Less than
                                                                                                                        λ Current character
                                                                                                                        ¬ Results in an empty string
                                                                                                                        Implicitly print matches on separate lines





                                                                                                                        share|improve this answer













                                                                                                                        Charcoal, 19 bytes



                                                                                                                        ΦEXχ⁴Iι¬Φι∧쬋§ι⊖μλ


                                                                                                                        Try it online! Link is to verbose version of code. Explanation:



                                                                                                                           χ                Predefined variable 10
                                                                                                                        X To the power
                                                                                                                        ⁴ Literal 4
                                                                                                                        E Map over implicit range
                                                                                                                        ι Current value
                                                                                                                        I Cast to string
                                                                                                                        Φ Filter over strings where
                                                                                                                        ι Current string
                                                                                                                        Φ Filtered over characters
                                                                                                                        μ Character index (is nonzero)
                                                                                                                        ∧ And
                                                                                                                        μ Character index
                                                                                                                        ⊖ Decremented
                                                                                                                        § Indexed into
                                                                                                                        ι Current string
                                                                                                                        ¬ Is not
                                                                                                                        ‹ Less than
                                                                                                                        λ Current character
                                                                                                                        ¬ Results in an empty string
                                                                                                                        Implicitly print matches on separate lines






                                                                                                                        share|improve this answer












                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer










                                                                                                                        answered Nov 16 at 20:59









                                                                                                                        Neil

                                                                                                                        78.1k744175




                                                                                                                        78.1k744175






















                                                                                                                            up vote
                                                                                                                            2
                                                                                                                            down vote














                                                                                                                            05AB1E (legacy), 8 bytes



                                                                                                                            4°ÝD€êû


                                                                                                                            Try it online!



                                                                                                                            Works in the new version of 05AB1E as well but is painfully slow for some reason.



                                                                                                                            How?




                                                                                                                            4°ÝD€êû – Full program.
                                                                                                                            4°Ý – Push [0 ... 10000].
                                                                                                                            D€ê – Push each integer in [0 ... 10000] sorted and deduplicated at the same time.
                                                                                                                            û – And join the interection of the two lists by newlines.





                                                                                                                            share|improve this answer





















                                                                                                                            • Nice answer. Better than the 9 byter I had (which only works in the legacy).
                                                                                                                              – Kevin Cruijssen
                                                                                                                              Nov 19 at 13:54










                                                                                                                            • 4°Ýʒ¥P.± is my alternate 8-byter in the rewrite.
                                                                                                                              – Magic Octopus Urn
                                                                                                                              Nov 19 at 15:03















                                                                                                                            up vote
                                                                                                                            2
                                                                                                                            down vote














                                                                                                                            05AB1E (legacy), 8 bytes



                                                                                                                            4°ÝD€êû


                                                                                                                            Try it online!



                                                                                                                            Works in the new version of 05AB1E as well but is painfully slow for some reason.



                                                                                                                            How?




                                                                                                                            4°ÝD€êû – Full program.
                                                                                                                            4°Ý – Push [0 ... 10000].
                                                                                                                            D€ê – Push each integer in [0 ... 10000] sorted and deduplicated at the same time.
                                                                                                                            û – And join the interection of the two lists by newlines.





                                                                                                                            share|improve this answer





















                                                                                                                            • Nice answer. Better than the 9 byter I had (which only works in the legacy).
                                                                                                                              – Kevin Cruijssen
                                                                                                                              Nov 19 at 13:54










                                                                                                                            • 4°Ýʒ¥P.± is my alternate 8-byter in the rewrite.
                                                                                                                              – Magic Octopus Urn
                                                                                                                              Nov 19 at 15:03













                                                                                                                            up vote
                                                                                                                            2
                                                                                                                            down vote










                                                                                                                            up vote
                                                                                                                            2
                                                                                                                            down vote










                                                                                                                            05AB1E (legacy), 8 bytes



                                                                                                                            4°ÝD€êû


                                                                                                                            Try it online!



                                                                                                                            Works in the new version of 05AB1E as well but is painfully slow for some reason.



                                                                                                                            How?




                                                                                                                            4°ÝD€êû – Full program.
                                                                                                                            4°Ý – Push [0 ... 10000].
                                                                                                                            D€ê – Push each integer in [0 ... 10000] sorted and deduplicated at the same time.
                                                                                                                            û – And join the interection of the two lists by newlines.





                                                                                                                            share|improve this answer













                                                                                                                            05AB1E (legacy), 8 bytes



                                                                                                                            4°ÝD€êû


                                                                                                                            Try it online!



                                                                                                                            Works in the new version of 05AB1E as well but is painfully slow for some reason.



                                                                                                                            How?




                                                                                                                            4°ÝD€êû – Full program.
                                                                                                                            4°Ý – Push [0 ... 10000].
                                                                                                                            D€ê – Push each integer in [0 ... 10000] sorted and deduplicated at the same time.
                                                                                                                            û – And join the interection of the two lists by newlines.






                                                                                                                            share|improve this answer












                                                                                                                            share|improve this answer



                                                                                                                            share|improve this answer










                                                                                                                            answered Nov 17 at 14:41









                                                                                                                            Mr. Xcoder

                                                                                                                            31.2k758197




                                                                                                                            31.2k758197












                                                                                                                            • Nice answer. Better than the 9 byter I had (which only works in the legacy).
                                                                                                                              – Kevin Cruijssen
                                                                                                                              Nov 19 at 13:54










                                                                                                                            • 4°Ýʒ¥P.± is my alternate 8-byter in the rewrite.
                                                                                                                              – Magic Octopus Urn
                                                                                                                              Nov 19 at 15:03


















                                                                                                                            • Nice answer. Better than the 9 byter I had (which only works in the legacy).
                                                                                                                              – Kevin Cruijssen
                                                                                                                              Nov 19 at 13:54










                                                                                                                            • 4°Ýʒ¥P.± is my alternate 8-byter in the rewrite.
                                                                                                                              – Magic Octopus Urn
                                                                                                                              Nov 19 at 15:03
















                                                                                                                            Nice answer. Better than the 9 byter I had (which only works in the legacy).
                                                                                                                            – Kevin Cruijssen
                                                                                                                            Nov 19 at 13:54




                                                                                                                            Nice answer. Better than the 9 byter I had (which only works in the legacy).
                                                                                                                            – Kevin Cruijssen
                                                                                                                            Nov 19 at 13:54












                                                                                                                            4°Ýʒ¥P.± is my alternate 8-byter in the rewrite.
                                                                                                                            – Magic Octopus Urn
                                                                                                                            Nov 19 at 15:03




                                                                                                                            4°Ýʒ¥P.± is my alternate 8-byter in the rewrite.
                                                                                                                            – Magic Octopus Urn
                                                                                                                            Nov 19 at 15:03










                                                                                                                            up vote
                                                                                                                            2
                                                                                                                            down vote














                                                                                                                            Jelly, 13 9 8 bytes



                                                                                                                            Saved 5 bytes thanks to @Dennis



                                                                                                                            9œcⱮ4ẎŻY


                                                                                                                            Try it online!



                                                                                                                            Explanation



                                                                                                                            Generates all lexicographically increasing numbers below 10000 by taking the digits [1...9] and finding all combinations of length ≤ 4.



                                                                                                                            9œcⱮ4ẎŻY    Main link. Arguments: none
                                                                                                                            9 Yield 9.
                                                                                                                            Ɱ4 For each n in [1...4]:
                                                                                                                            œc Yield the combinations of the range [1...9] of length n.
                                                                                                                            Ẏ Tighten; dump each of the 4 lists generated into the main list.
                                                                                                                            Ż Prepend a 0 to the list.
                                                                                                                            Y Join on newlines.





                                                                                                                            Jelly, 11 10 9 bytes



                                                                                                                            Saved a byte thanks to @EriktheOutgolfer



                                                                                                                            ȷ4Ḷ<ƝẠ$ƇY


                                                                                                                            Try it online!



                                                                                                                            Explanation



                                                                                                                            Filters through the range, keeping the numbers that are lexicographically increasing.



                                                                                                                            ȷ4Ḷ<ƝẠ$ƇY    Main link. Arguments: none
                                                                                                                            ȷ4 Yield 10^4 (10000).
                                                                                                                            Ḷ Generate the range [0...10000).
                                                                                                                            Ƈ Filter; yield only the numbers where this link return a truthy value.
                                                                                                                            $ Run these two links and yield the result.
                                                                                                                            Ɲ For each pair of items (digits) in the number:
                                                                                                                            < Check whether the left digit is less than the right digit.
                                                                                                                            Ạ All; check that every comparison yielded true.
                                                                                                                            This yields whether the digits are strictly increasing.
                                                                                                                            Y Join the filtered list on newlines.





                                                                                                                            share|improve this answer



























                                                                                                                              up vote
                                                                                                                              2
                                                                                                                              down vote














                                                                                                                              Jelly, 13 9 8 bytes



                                                                                                                              Saved 5 bytes thanks to @Dennis



                                                                                                                              9œcⱮ4ẎŻY


                                                                                                                              Try it online!



                                                                                                                              Explanation



                                                                                                                              Generates all lexicographically increasing numbers below 10000 by taking the digits [1...9] and finding all combinations of length ≤ 4.



                                                                                                                              9œcⱮ4ẎŻY    Main link. Arguments: none
                                                                                                                              9 Yield 9.
                                                                                                                              Ɱ4 For each n in [1...4]:
                                                                                                                              œc Yield the combinations of the range [1...9] of length n.
                                                                                                                              Ẏ Tighten; dump each of the 4 lists generated into the main list.
                                                                                                                              Ż Prepend a 0 to the list.
                                                                                                                              Y Join on newlines.





                                                                                                                              Jelly, 11 10 9 bytes



                                                                                                                              Saved a byte thanks to @EriktheOutgolfer



                                                                                                                              ȷ4Ḷ<ƝẠ$ƇY


                                                                                                                              Try it online!



                                                                                                                              Explanation



                                                                                                                              Filters through the range, keeping the numbers that are lexicographically increasing.



                                                                                                                              ȷ4Ḷ<ƝẠ$ƇY    Main link. Arguments: none
                                                                                                                              ȷ4 Yield 10^4 (10000).
                                                                                                                              Ḷ Generate the range [0...10000).
                                                                                                                              Ƈ Filter; yield only the numbers where this link return a truthy value.
                                                                                                                              $ Run these two links and yield the result.
                                                                                                                              Ɲ For each pair of items (digits) in the number:
                                                                                                                              < Check whether the left digit is less than the right digit.
                                                                                                                              Ạ All; check that every comparison yielded true.
                                                                                                                              This yields whether the digits are strictly increasing.
                                                                                                                              Y Join the filtered list on newlines.





                                                                                                                              share|improve this answer

























                                                                                                                                up vote
                                                                                                                                2
                                                                                                                                down vote










                                                                                                                                up vote
                                                                                                                                2
                                                                                                                                down vote










                                                                                                                                Jelly, 13 9 8 bytes



                                                                                                                                Saved 5 bytes thanks to @Dennis



                                                                                                                                9œcⱮ4ẎŻY


                                                                                                                                Try it online!



                                                                                                                                Explanation



                                                                                                                                Generates all lexicographically increasing numbers below 10000 by taking the digits [1...9] and finding all combinations of length ≤ 4.



                                                                                                                                9œcⱮ4ẎŻY    Main link. Arguments: none
                                                                                                                                9 Yield 9.
                                                                                                                                Ɱ4 For each n in [1...4]:
                                                                                                                                œc Yield the combinations of the range [1...9] of length n.
                                                                                                                                Ẏ Tighten; dump each of the 4 lists generated into the main list.
                                                                                                                                Ż Prepend a 0 to the list.
                                                                                                                                Y Join on newlines.





                                                                                                                                Jelly, 11 10 9 bytes



                                                                                                                                Saved a byte thanks to @EriktheOutgolfer



                                                                                                                                ȷ4Ḷ<ƝẠ$ƇY


                                                                                                                                Try it online!



                                                                                                                                Explanation



                                                                                                                                Filters through the range, keeping the numbers that are lexicographically increasing.



                                                                                                                                ȷ4Ḷ<ƝẠ$ƇY    Main link. Arguments: none
                                                                                                                                ȷ4 Yield 10^4 (10000).
                                                                                                                                Ḷ Generate the range [0...10000).
                                                                                                                                Ƈ Filter; yield only the numbers where this link return a truthy value.
                                                                                                                                $ Run these two links and yield the result.
                                                                                                                                Ɲ For each pair of items (digits) in the number:
                                                                                                                                < Check whether the left digit is less than the right digit.
                                                                                                                                Ạ All; check that every comparison yielded true.
                                                                                                                                This yields whether the digits are strictly increasing.
                                                                                                                                Y Join the filtered list on newlines.





                                                                                                                                share|improve this answer















                                                                                                                                Jelly, 13 9 8 bytes



                                                                                                                                Saved 5 bytes thanks to @Dennis



                                                                                                                                9œcⱮ4ẎŻY


                                                                                                                                Try it online!



                                                                                                                                Explanation



                                                                                                                                Generates all lexicographically increasing numbers below 10000 by taking the digits [1...9] and finding all combinations of length ≤ 4.



                                                                                                                                9œcⱮ4ẎŻY    Main link. Arguments: none
                                                                                                                                9 Yield 9.
                                                                                                                                Ɱ4 For each n in [1...4]:
                                                                                                                                œc Yield the combinations of the range [1...9] of length n.
                                                                                                                                Ẏ Tighten; dump each of the 4 lists generated into the main list.
                                                                                                                                Ż Prepend a 0 to the list.
                                                                                                                                Y Join on newlines.





                                                                                                                                Jelly, 11 10 9 bytes



                                                                                                                                Saved a byte thanks to @EriktheOutgolfer



                                                                                                                                ȷ4Ḷ<ƝẠ$ƇY


                                                                                                                                Try it online!



                                                                                                                                Explanation



                                                                                                                                Filters through the range, keeping the numbers that are lexicographically increasing.



                                                                                                                                ȷ4Ḷ<ƝẠ$ƇY    Main link. Arguments: none
                                                                                                                                ȷ4 Yield 10^4 (10000).
                                                                                                                                Ḷ Generate the range [0...10000).
                                                                                                                                Ƈ Filter; yield only the numbers where this link return a truthy value.
                                                                                                                                $ Run these two links and yield the result.
                                                                                                                                Ɲ For each pair of items (digits) in the number:
                                                                                                                                < Check whether the left digit is less than the right digit.
                                                                                                                                Ạ All; check that every comparison yielded true.
                                                                                                                                This yields whether the digits are strictly increasing.
                                                                                                                                Y Join the filtered list on newlines.






                                                                                                                                share|improve this answer














                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer








                                                                                                                                edited Nov 17 at 17:24

























                                                                                                                                answered Nov 16 at 19:31









                                                                                                                                ETHproductions

                                                                                                                                44.1k573219




                                                                                                                                44.1k573219






















                                                                                                                                    up vote
                                                                                                                                    2
                                                                                                                                    down vote













                                                                                                                                    JavaScript, 64 bytes



                                                                                                                                    A bit of pub golf so probably far from optimal.



                                                                                                                                    (f=n=>n&&f(n-1)+([...n+``].every(x=>y<(y=x),y=0)?`
                                                                                                                                    `+n:``))(7e3)


                                                                                                                                    Try it online



                                                                                                                                    Yes, doing it without an IIFE would be a few bytes shorter but that throws an overflow error when called, which would normally be fine as we can assume infinite memory for the purposes of code golf but, to me, doesn't seem to be in the spirit of KC challenges.






                                                                                                                                    share|improve this answer























                                                                                                                                    • I don't get an overflow error without an IIFE.
                                                                                                                                      – Spitemaster
                                                                                                                                      Nov 17 at 4:32










                                                                                                                                    • Is this a function submission or a full program? If not, you should either count the console.log or relabel your submission as JavaScript REPL.
                                                                                                                                      – Dennis
                                                                                                                                      yesterday















                                                                                                                                    up vote
                                                                                                                                    2
                                                                                                                                    down vote













                                                                                                                                    JavaScript, 64 bytes



                                                                                                                                    A bit of pub golf so probably far from optimal.



                                                                                                                                    (f=n=>n&&f(n-1)+([...n+``].every(x=>y<(y=x),y=0)?`
                                                                                                                                    `+n:``))(7e3)


                                                                                                                                    Try it online



                                                                                                                                    Yes, doing it without an IIFE would be a few bytes shorter but that throws an overflow error when called, which would normally be fine as we can assume infinite memory for the purposes of code golf but, to me, doesn't seem to be in the spirit of KC challenges.






                                                                                                                                    share|improve this answer























                                                                                                                                    • I don't get an overflow error without an IIFE.
                                                                                                                                      – Spitemaster
                                                                                                                                      Nov 17 at 4:32










                                                                                                                                    • Is this a function submission or a full program? If not, you should either count the console.log or relabel your submission as JavaScript REPL.
                                                                                                                                      – Dennis
                                                                                                                                      yesterday













                                                                                                                                    up vote
                                                                                                                                    2
                                                                                                                                    down vote










                                                                                                                                    up vote
                                                                                                                                    2
                                                                                                                                    down vote









                                                                                                                                    JavaScript, 64 bytes



                                                                                                                                    A bit of pub golf so probably far from optimal.



                                                                                                                                    (f=n=>n&&f(n-1)+([...n+``].every(x=>y<(y=x),y=0)?`
                                                                                                                                    `+n:``))(7e3)


                                                                                                                                    Try it online



                                                                                                                                    Yes, doing it without an IIFE would be a few bytes shorter but that throws an overflow error when called, which would normally be fine as we can assume infinite memory for the purposes of code golf but, to me, doesn't seem to be in the spirit of KC challenges.






                                                                                                                                    share|improve this answer














                                                                                                                                    JavaScript, 64 bytes



                                                                                                                                    A bit of pub golf so probably far from optimal.



                                                                                                                                    (f=n=>n&&f(n-1)+([...n+``].every(x=>y<(y=x),y=0)?`
                                                                                                                                    `+n:``))(7e3)


                                                                                                                                    Try it online



                                                                                                                                    Yes, doing it without an IIFE would be a few bytes shorter but that throws an overflow error when called, which would normally be fine as we can assume infinite memory for the purposes of code golf but, to me, doesn't seem to be in the spirit of KC challenges.







                                                                                                                                    share|improve this answer














                                                                                                                                    share|improve this answer



                                                                                                                                    share|improve this answer








                                                                                                                                    edited Nov 18 at 15:48

























                                                                                                                                    answered Nov 16 at 23:06









                                                                                                                                    Shaggy

                                                                                                                                    18.2k21663




                                                                                                                                    18.2k21663












                                                                                                                                    • I don't get an overflow error without an IIFE.
                                                                                                                                      – Spitemaster
                                                                                                                                      Nov 17 at 4:32










                                                                                                                                    • Is this a function submission or a full program? If not, you should either count the console.log or relabel your submission as JavaScript REPL.
                                                                                                                                      – Dennis
                                                                                                                                      yesterday


















                                                                                                                                    • I don't get an overflow error without an IIFE.
                                                                                                                                      – Spitemaster
                                                                                                                                      Nov 17 at 4:32










                                                                                                                                    • Is this a function submission or a full program? If not, you should either count the console.log or relabel your submission as JavaScript REPL.
                                                                                                                                      – Dennis
                                                                                                                                      yesterday
















                                                                                                                                    I don't get an overflow error without an IIFE.
                                                                                                                                    – Spitemaster
                                                                                                                                    Nov 17 at 4:32




                                                                                                                                    I don't get an overflow error without an IIFE.
                                                                                                                                    – Spitemaster
                                                                                                                                    Nov 17 at 4:32












                                                                                                                                    Is this a function submission or a full program? If not, you should either count the console.log or relabel your submission as JavaScript REPL.
                                                                                                                                    – Dennis
                                                                                                                                    yesterday




                                                                                                                                    Is this a function submission or a full program? If not, you should either count the console.log or relabel your submission as JavaScript REPL.
                                                                                                                                    – Dennis
                                                                                                                                    yesterday










                                                                                                                                    up vote
                                                                                                                                    2
                                                                                                                                    down vote














                                                                                                                                    Wolfram Language (Mathematica), 36 bytes



                                                                                                                                    After I wrote this, it was clarified that each number must be on a new line, so +7 bytes for the Print/@.



                                                                                                                                    This method takes advantage of the fact that the Subsets function 1) doesn't replicate any digits and 2) sorts the output by set size and set contents. FromDigits assembles each list of digits.



                                                                                                                                    -1 byte thanks to @Mr.Xcoder



                                                                                                                                    Print/@FromDigits/@Range@9~Subsets~4


                                                                                                                                    Try it online!






                                                                                                                                    share|improve this answer



















                                                                                                                                    • 1




                                                                                                                                      Print/@FromDigits/@Range@9~Subsets~4 for 36 bytes.
                                                                                                                                      – Mr. Xcoder
                                                                                                                                      Nov 17 at 14:32










                                                                                                                                    • Funny, I thought of that and just didn't do it because I thought ~ had higher precedence than @
                                                                                                                                      – Kelly Lowder
                                                                                                                                      Nov 19 at 2:55















                                                                                                                                    up vote
                                                                                                                                    2
                                                                                                                                    down vote














                                                                                                                                    Wolfram Language (Mathematica), 36 bytes



                                                                                                                                    After I wrote this, it was clarified that each number must be on a new line, so +7 bytes for the Print/@.



                                                                                                                                    This method takes advantage of the fact that the Subsets function 1) doesn't replicate any digits and 2) sorts the output by set size and set contents. FromDigits assembles each list of digits.



                                                                                                                                    -1 byte thanks to @Mr.Xcoder



                                                                                                                                    Print/@FromDigits/@Range@9~Subsets~4


                                                                                                                                    Try it online!






                                                                                                                                    share|improve this answer



















                                                                                                                                    • 1




                                                                                                                                      Print/@FromDigits/@Range@9~Subsets~4 for 36 bytes.
                                                                                                                                      – Mr. Xcoder
                                                                                                                                      Nov 17 at 14:32










                                                                                                                                    • Funny, I thought of that and just didn't do it because I thought ~ had higher precedence than @
                                                                                                                                      – Kelly Lowder
                                                                                                                                      Nov 19 at 2:55













                                                                                                                                    up vote
                                                                                                                                    2
                                                                                                                                    down vote










                                                                                                                                    up vote
                                                                                                                                    2
                                                                                                                                    down vote










                                                                                                                                    Wolfram Language (Mathematica), 36 bytes



                                                                                                                                    After I wrote this, it was clarified that each number must be on a new line, so +7 bytes for the Print/@.



                                                                                                                                    This method takes advantage of the fact that the Subsets function 1) doesn't replicate any digits and 2) sorts the output by set size and set contents. FromDigits assembles each list of digits.



                                                                                                                                    -1 byte thanks to @Mr.Xcoder



                                                                                                                                    Print/@FromDigits/@Range@9~Subsets~4


                                                                                                                                    Try it online!






                                                                                                                                    share|improve this answer















                                                                                                                                    Wolfram Language (Mathematica), 36 bytes



                                                                                                                                    After I wrote this, it was clarified that each number must be on a new line, so +7 bytes for the Print/@.



                                                                                                                                    This method takes advantage of the fact that the Subsets function 1) doesn't replicate any digits and 2) sorts the output by set size and set contents. FromDigits assembles each list of digits.



                                                                                                                                    -1 byte thanks to @Mr.Xcoder



                                                                                                                                    Print/@FromDigits/@Range@9~Subsets~4


                                                                                                                                    Try it online!







                                                                                                                                    share|improve this answer














                                                                                                                                    share|improve this answer



                                                                                                                                    share|improve this answer








                                                                                                                                    edited Nov 19 at 2:58

























                                                                                                                                    answered Nov 16 at 19:55









                                                                                                                                    Kelly Lowder

                                                                                                                                    2,968416




                                                                                                                                    2,968416








                                                                                                                                    • 1




                                                                                                                                      Print/@FromDigits/@Range@9~Subsets~4 for 36 bytes.
                                                                                                                                      – Mr. Xcoder
                                                                                                                                      Nov 17 at 14:32










                                                                                                                                    • Funny, I thought of that and just didn't do it because I thought ~ had higher precedence than @
                                                                                                                                      – Kelly Lowder
                                                                                                                                      Nov 19 at 2:55














                                                                                                                                    • 1




                                                                                                                                      Print/@FromDigits/@Range@9~Subsets~4 for 36 bytes.
                                                                                                                                      – Mr. Xcoder
                                                                                                                                      Nov 17 at 14:32










                                                                                                                                    • Funny, I thought of that and just didn't do it because I thought ~ had higher precedence than @
                                                                                                                                      – Kelly Lowder
                                                                                                                                      Nov 19 at 2:55








                                                                                                                                    1




                                                                                                                                    1




                                                                                                                                    Print/@FromDigits/@Range@9~Subsets~4 for 36 bytes.
                                                                                                                                    – Mr. Xcoder
                                                                                                                                    Nov 17 at 14:32




                                                                                                                                    Print/@FromDigits/@Range@9~Subsets~4 for 36 bytes.
                                                                                                                                    – Mr. Xcoder
                                                                                                                                    Nov 17 at 14:32












                                                                                                                                    Funny, I thought of that and just didn't do it because I thought ~ had higher precedence than @
                                                                                                                                    – Kelly Lowder
                                                                                                                                    Nov 19 at 2:55




                                                                                                                                    Funny, I thought of that and just didn't do it because I thought ~ had higher precedence than @
                                                                                                                                    – Kelly Lowder
                                                                                                                                    Nov 19 at 2:55










                                                                                                                                    up vote
                                                                                                                                    2
                                                                                                                                    down vote














                                                                                                                                    K (ngn/k) / K (oK), 32 30 26 bytes



                                                                                                                                    Solution:



                                                                                                                                    `0:$&&/'1_'>':'" ",'$!9999


                                                                                                                                    Try it online!



                                                                                                                                    Explanation:



                                                                                                                                    `0:$&&/'1_'>':'" ",'$!9999 / the solution
                                                                                                                                    !9999 / range 0..9998 (could use !6890)
                                                                                                                                    $ / string
                                                                                                                                    " ",' / prepend " " to each (lower than "0" in ascii)
                                                                                                                                    >:' / greater-than each-previous?
                                                                                                                                    1_' / drop first result from each
                                                                                                                                    &/' / max (&) over (/)
                                                                                                                                    & / indices where true
                                                                                                                                    $ / convert to string
                                                                                                                                    `0: / print to stdout





                                                                                                                                    share|improve this answer



























                                                                                                                                      up vote
                                                                                                                                      2
                                                                                                                                      down vote














                                                                                                                                      K (ngn/k) / K (oK), 32 30 26 bytes



                                                                                                                                      Solution:



                                                                                                                                      `0:$&&/'1_'>':'" ",'$!9999


                                                                                                                                      Try it online!



                                                                                                                                      Explanation:



                                                                                                                                      `0:$&&/'1_'>':'" ",'$!9999 / the solution
                                                                                                                                      !9999 / range 0..9998 (could use !6890)
                                                                                                                                      $ / string
                                                                                                                                      " ",' / prepend " " to each (lower than "0" in ascii)
                                                                                                                                      >:' / greater-than each-previous?
                                                                                                                                      1_' / drop first result from each
                                                                                                                                      &/' / max (&) over (/)
                                                                                                                                      & / indices where true
                                                                                                                                      $ / convert to string
                                                                                                                                      `0: / print to stdout





                                                                                                                                      share|improve this answer

























                                                                                                                                        up vote
                                                                                                                                        2
                                                                                                                                        down vote










                                                                                                                                        up vote
                                                                                                                                        2
                                                                                                                                        down vote










                                                                                                                                        K (ngn/k) / K (oK), 32 30 26 bytes



                                                                                                                                        Solution:



                                                                                                                                        `0:$&&/'1_'>':'" ",'$!9999


                                                                                                                                        Try it online!



                                                                                                                                        Explanation:



                                                                                                                                        `0:$&&/'1_'>':'" ",'$!9999 / the solution
                                                                                                                                        !9999 / range 0..9998 (could use !6890)
                                                                                                                                        $ / string
                                                                                                                                        " ",' / prepend " " to each (lower than "0" in ascii)
                                                                                                                                        >:' / greater-than each-previous?
                                                                                                                                        1_' / drop first result from each
                                                                                                                                        &/' / max (&) over (/)
                                                                                                                                        & / indices where true
                                                                                                                                        $ / convert to string
                                                                                                                                        `0: / print to stdout





                                                                                                                                        share|improve this answer















                                                                                                                                        K (ngn/k) / K (oK), 32 30 26 bytes



                                                                                                                                        Solution:



                                                                                                                                        `0:$&&/'1_'>':'" ",'$!9999


                                                                                                                                        Try it online!



                                                                                                                                        Explanation:



                                                                                                                                        `0:$&&/'1_'>':'" ",'$!9999 / the solution
                                                                                                                                        !9999 / range 0..9998 (could use !6890)
                                                                                                                                        $ / string
                                                                                                                                        " ",' / prepend " " to each (lower than "0" in ascii)
                                                                                                                                        >:' / greater-than each-previous?
                                                                                                                                        1_' / drop first result from each
                                                                                                                                        &/' / max (&) over (/)
                                                                                                                                        & / indices where true
                                                                                                                                        $ / convert to string
                                                                                                                                        `0: / print to stdout






                                                                                                                                        share|improve this answer














                                                                                                                                        share|improve this answer



                                                                                                                                        share|improve this answer








                                                                                                                                        edited 2 days ago

























                                                                                                                                        answered Nov 17 at 9:31









                                                                                                                                        streetster

                                                                                                                                        2,414515




                                                                                                                                        2,414515






















                                                                                                                                            up vote
                                                                                                                                            1
                                                                                                                                            down vote














                                                                                                                                            Python 2, 63 bytes





                                                                                                                                            for i in range(6790):
                                                                                                                                            if`i`=="".join(sorted(set(`i`))):print i


                                                                                                                                            Try it online!






                                                                                                                                            share|improve this answer

























                                                                                                                                              up vote
                                                                                                                                              1
                                                                                                                                              down vote














                                                                                                                                              Python 2, 63 bytes





                                                                                                                                              for i in range(6790):
                                                                                                                                              if`i`=="".join(sorted(set(`i`))):print i


                                                                                                                                              Try it online!






                                                                                                                                              share|improve this answer























                                                                                                                                                up vote
                                                                                                                                                1
                                                                                                                                                down vote










                                                                                                                                                up vote
                                                                                                                                                1
                                                                                                                                                down vote










                                                                                                                                                Python 2, 63 bytes





                                                                                                                                                for i in range(6790):
                                                                                                                                                if`i`=="".join(sorted(set(`i`))):print i


                                                                                                                                                Try it online!






                                                                                                                                                share|improve this answer













                                                                                                                                                Python 2, 63 bytes





                                                                                                                                                for i in range(6790):
                                                                                                                                                if`i`=="".join(sorted(set(`i`))):print i


                                                                                                                                                Try it online!







                                                                                                                                                share|improve this answer












                                                                                                                                                share|improve this answer



                                                                                                                                                share|improve this answer










                                                                                                                                                answered Nov 16 at 19:45









                                                                                                                                                DJMcMayhem

                                                                                                                                                40.6k11145307




                                                                                                                                                40.6k11145307






















                                                                                                                                                    up vote
                                                                                                                                                    1
                                                                                                                                                    down vote














                                                                                                                                                    Python 2, 61 bytes





                                                                                                                                                    for i in range(9999):
                                                                                                                                                    if list(`i`)==sorted(set(`i`)):print i


                                                                                                                                                    Try it online!






                                                                                                                                                    share|improve this answer

























                                                                                                                                                      up vote
                                                                                                                                                      1
                                                                                                                                                      down vote














                                                                                                                                                      Python 2, 61 bytes





                                                                                                                                                      for i in range(9999):
                                                                                                                                                      if list(`i`)==sorted(set(`i`)):print i


                                                                                                                                                      Try it online!






                                                                                                                                                      share|improve this answer























                                                                                                                                                        up vote
                                                                                                                                                        1
                                                                                                                                                        down vote










                                                                                                                                                        up vote
                                                                                                                                                        1
                                                                                                                                                        down vote










                                                                                                                                                        Python 2, 61 bytes





                                                                                                                                                        for i in range(9999):
                                                                                                                                                        if list(`i`)==sorted(set(`i`)):print i


                                                                                                                                                        Try it online!






                                                                                                                                                        share|improve this answer













                                                                                                                                                        Python 2, 61 bytes





                                                                                                                                                        for i in range(9999):
                                                                                                                                                        if list(`i`)==sorted(set(`i`)):print i


                                                                                                                                                        Try it online!







                                                                                                                                                        share|improve this answer












                                                                                                                                                        share|improve this answer



                                                                                                                                                        share|improve this answer










                                                                                                                                                        answered Nov 16 at 20:04









                                                                                                                                                        Chas Brown

                                                                                                                                                        4,6541519




                                                                                                                                                        4,6541519






















                                                                                                                                                            up vote
                                                                                                                                                            1
                                                                                                                                                            down vote














                                                                                                                                                            Python 2, 64 61 bytes





                                                                                                                                                            lambda:[x for x in range(9999)if sorted(set(`x`))==list(`x`)]


                                                                                                                                                            Try it online!



                                                                                                                                                            Gets the unique characters of the integer's string representation, sorts them, and compares the result to the original number.






                                                                                                                                                            share|improve this answer























                                                                                                                                                            • You can save a byte by using range(9999) or any other number between 6790 and 9999. Our solutions are almost identical BTW :)
                                                                                                                                                              – DJMcMayhem
                                                                                                                                                              Nov 16 at 19:47










                                                                                                                                                            • @DJMcMayhem But then it wouldn't check ALL numbers under 10,000....:P Thanks! Sometimes I get too literal with these challenges.
                                                                                                                                                              – Triggernometry
                                                                                                                                                              Nov 16 at 19:50















                                                                                                                                                            up vote
                                                                                                                                                            1
                                                                                                                                                            down vote














                                                                                                                                                            Python 2, 64 61 bytes





                                                                                                                                                            lambda:[x for x in range(9999)if sorted(set(`x`))==list(`x`)]


                                                                                                                                                            Try it online!



                                                                                                                                                            Gets the unique characters of the integer's string representation, sorts them, and compares the result to the original number.






                                                                                                                                                            share|improve this answer























                                                                                                                                                            • You can save a byte by using range(9999) or any other number between 6790 and 9999. Our solutions are almost identical BTW :)
                                                                                                                                                              – DJMcMayhem
                                                                                                                                                              Nov 16 at 19:47










                                                                                                                                                            • @DJMcMayhem But then it wouldn't check ALL numbers under 10,000....:P Thanks! Sometimes I get too literal with these challenges.
                                                                                                                                                              – Triggernometry
                                                                                                                                                              Nov 16 at 19:50













                                                                                                                                                            up vote
                                                                                                                                                            1
                                                                                                                                                            down vote










                                                                                                                                                            up vote
                                                                                                                                                            1
                                                                                                                                                            down vote










                                                                                                                                                            Python 2, 64 61 bytes





                                                                                                                                                            lambda:[x for x in range(9999)if sorted(set(`x`))==list(`x`)]


                                                                                                                                                            Try it online!



                                                                                                                                                            Gets the unique characters of the integer's string representation, sorts them, and compares the result to the original number.






                                                                                                                                                            share|improve this answer















                                                                                                                                                            Python 2, 64 61 bytes





                                                                                                                                                            lambda:[x for x in range(9999)if sorted(set(`x`))==list(`x`)]


                                                                                                                                                            Try it online!



                                                                                                                                                            Gets the unique characters of the integer's string representation, sorts them, and compares the result to the original number.







                                                                                                                                                            share|improve this answer














                                                                                                                                                            share|improve this answer



                                                                                                                                                            share|improve this answer








                                                                                                                                                            edited Nov 16 at 20:14

























                                                                                                                                                            answered Nov 16 at 19:44









                                                                                                                                                            Triggernometry

                                                                                                                                                            44617




                                                                                                                                                            44617












                                                                                                                                                            • You can save a byte by using range(9999) or any other number between 6790 and 9999. Our solutions are almost identical BTW :)
                                                                                                                                                              – DJMcMayhem
                                                                                                                                                              Nov 16 at 19:47










                                                                                                                                                            • @DJMcMayhem But then it wouldn't check ALL numbers under 10,000....:P Thanks! Sometimes I get too literal with these challenges.
                                                                                                                                                              – Triggernometry
                                                                                                                                                              Nov 16 at 19:50


















                                                                                                                                                            • You can save a byte by using range(9999) or any other number between 6790 and 9999. Our solutions are almost identical BTW :)
                                                                                                                                                              – DJMcMayhem
                                                                                                                                                              Nov 16 at 19:47










                                                                                                                                                            • @DJMcMayhem But then it wouldn't check ALL numbers under 10,000....:P Thanks! Sometimes I get too literal with these challenges.
                                                                                                                                                              – Triggernometry
                                                                                                                                                              Nov 16 at 19:50
















                                                                                                                                                            You can save a byte by using range(9999) or any other number between 6790 and 9999. Our solutions are almost identical BTW :)
                                                                                                                                                            – DJMcMayhem
                                                                                                                                                            Nov 16 at 19:47




                                                                                                                                                            You can save a byte by using range(9999) or any other number between 6790 and 9999. Our solutions are almost identical BTW :)
                                                                                                                                                            – DJMcMayhem
                                                                                                                                                            Nov 16 at 19:47












                                                                                                                                                            @DJMcMayhem But then it wouldn't check ALL numbers under 10,000....:P Thanks! Sometimes I get too literal with these challenges.
                                                                                                                                                            – Triggernometry
                                                                                                                                                            Nov 16 at 19:50




                                                                                                                                                            @DJMcMayhem But then it wouldn't check ALL numbers under 10,000....:P Thanks! Sometimes I get too literal with these challenges.
                                                                                                                                                            – Triggernometry
                                                                                                                                                            Nov 16 at 19:50










                                                                                                                                                            up vote
                                                                                                                                                            1
                                                                                                                                                            down vote













                                                                                                                                                            T-SQL, 188 bytes



                                                                                                                                                            WITH a AS(SELECT 0n UNION ALL SELECT n+1FROM a WHERE n<9)
                                                                                                                                                            SELECT ABS(CONCAT(a.n,b.n,c.n,d.n))
                                                                                                                                                            FROM a,a b,a c,a d
                                                                                                                                                            WHERE(a.n<b.n OR a.n+b.n=0)
                                                                                                                                                            AND(b.n<c.n OR b.n+c.n=0)
                                                                                                                                                            AND(c.n<d.n OR c.n+d.n=0)


                                                                                                                                                            Line breaks are for readability only.



                                                                                                                                                            I'm certain there must be more efficient ways to do this in SQL, but this was the first thing I thought of. Explanation:




                                                                                                                                                            1. Declare an in-memory table with values 0 to 9

                                                                                                                                                            2. Cross-join 4 copies of this table for all possible values from 0000 to 9999

                                                                                                                                                            3. Messy WHERE clause to ensure the digits are strictly increasing (or both 0)

                                                                                                                                                            4. Smash the digits together (CONCAT) and convert to integer (ABS)

                                                                                                                                                            5. The resulting rows may or may not be sorted, but the challenge doesn't appear to require that.






                                                                                                                                                            share|improve this answer

























                                                                                                                                                              up vote
                                                                                                                                                              1
                                                                                                                                                              down vote













                                                                                                                                                              T-SQL, 188 bytes



                                                                                                                                                              WITH a AS(SELECT 0n UNION ALL SELECT n+1FROM a WHERE n<9)
                                                                                                                                                              SELECT ABS(CONCAT(a.n,b.n,c.n,d.n))
                                                                                                                                                              FROM a,a b,a c,a d
                                                                                                                                                              WHERE(a.n<b.n OR a.n+b.n=0)
                                                                                                                                                              AND(b.n<c.n OR b.n+c.n=0)
                                                                                                                                                              AND(c.n<d.n OR c.n+d.n=0)


                                                                                                                                                              Line breaks are for readability only.



                                                                                                                                                              I'm certain there must be more efficient ways to do this in SQL, but this was the first thing I thought of. Explanation:




                                                                                                                                                              1. Declare an in-memory table with values 0 to 9

                                                                                                                                                              2. Cross-join 4 copies of this table for all possible values from 0000 to 9999

                                                                                                                                                              3. Messy WHERE clause to ensure the digits are strictly increasing (or both 0)

                                                                                                                                                              4. Smash the digits together (CONCAT) and convert to integer (ABS)

                                                                                                                                                              5. The resulting rows may or may not be sorted, but the challenge doesn't appear to require that.






                                                                                                                                                              share|improve this answer























                                                                                                                                                                up vote
                                                                                                                                                                1
                                                                                                                                                                down vote










                                                                                                                                                                up vote
                                                                                                                                                                1
                                                                                                                                                                down vote









                                                                                                                                                                T-SQL, 188 bytes



                                                                                                                                                                WITH a AS(SELECT 0n UNION ALL SELECT n+1FROM a WHERE n<9)
                                                                                                                                                                SELECT ABS(CONCAT(a.n,b.n,c.n,d.n))
                                                                                                                                                                FROM a,a b,a c,a d
                                                                                                                                                                WHERE(a.n<b.n OR a.n+b.n=0)
                                                                                                                                                                AND(b.n<c.n OR b.n+c.n=0)
                                                                                                                                                                AND(c.n<d.n OR c.n+d.n=0)


                                                                                                                                                                Line breaks are for readability only.



                                                                                                                                                                I'm certain there must be more efficient ways to do this in SQL, but this was the first thing I thought of. Explanation:




                                                                                                                                                                1. Declare an in-memory table with values 0 to 9

                                                                                                                                                                2. Cross-join 4 copies of this table for all possible values from 0000 to 9999

                                                                                                                                                                3. Messy WHERE clause to ensure the digits are strictly increasing (or both 0)

                                                                                                                                                                4. Smash the digits together (CONCAT) and convert to integer (ABS)

                                                                                                                                                                5. The resulting rows may or may not be sorted, but the challenge doesn't appear to require that.






                                                                                                                                                                share|improve this answer












                                                                                                                                                                T-SQL, 188 bytes



                                                                                                                                                                WITH a AS(SELECT 0n UNION ALL SELECT n+1FROM a WHERE n<9)
                                                                                                                                                                SELECT ABS(CONCAT(a.n,b.n,c.n,d.n))
                                                                                                                                                                FROM a,a b,a c,a d
                                                                                                                                                                WHERE(a.n<b.n OR a.n+b.n=0)
                                                                                                                                                                AND(b.n<c.n OR b.n+c.n=0)
                                                                                                                                                                AND(c.n<d.n OR c.n+d.n=0)


                                                                                                                                                                Line breaks are for readability only.



                                                                                                                                                                I'm certain there must be more efficient ways to do this in SQL, but this was the first thing I thought of. Explanation:




                                                                                                                                                                1. Declare an in-memory table with values 0 to 9

                                                                                                                                                                2. Cross-join 4 copies of this table for all possible values from 0000 to 9999

                                                                                                                                                                3. Messy WHERE clause to ensure the digits are strictly increasing (or both 0)

                                                                                                                                                                4. Smash the digits together (CONCAT) and convert to integer (ABS)

                                                                                                                                                                5. The resulting rows may or may not be sorted, but the challenge doesn't appear to require that.







                                                                                                                                                                share|improve this answer












                                                                                                                                                                share|improve this answer



                                                                                                                                                                share|improve this answer










                                                                                                                                                                answered Nov 16 at 20:53









                                                                                                                                                                BradC

                                                                                                                                                                3,579522




                                                                                                                                                                3,579522






















                                                                                                                                                                    up vote
                                                                                                                                                                    1
                                                                                                                                                                    down vote














                                                                                                                                                                    Stax, 8 bytes



                                                                                                                                                                    ¬ ▬A♥¶N∙


                                                                                                                                                                    Run and debug it






                                                                                                                                                                    share|improve this answer

























                                                                                                                                                                      up vote
                                                                                                                                                                      1
                                                                                                                                                                      down vote














                                                                                                                                                                      Stax, 8 bytes



                                                                                                                                                                      ¬ ▬A♥¶N∙


                                                                                                                                                                      Run and debug it






                                                                                                                                                                      share|improve this answer























                                                                                                                                                                        up vote
                                                                                                                                                                        1
                                                                                                                                                                        down vote










                                                                                                                                                                        up vote
                                                                                                                                                                        1
                                                                                                                                                                        down vote










                                                                                                                                                                        Stax, 8 bytes



                                                                                                                                                                        ¬ ▬A♥¶N∙


                                                                                                                                                                        Run and debug it






                                                                                                                                                                        share|improve this answer













                                                                                                                                                                        Stax, 8 bytes



                                                                                                                                                                        ¬ ▬A♥¶N∙


                                                                                                                                                                        Run and debug it







                                                                                                                                                                        share|improve this answer












                                                                                                                                                                        share|improve this answer



                                                                                                                                                                        share|improve this answer










                                                                                                                                                                        answered Nov 16 at 21:21









                                                                                                                                                                        recursive

                                                                                                                                                                        4,9941221




                                                                                                                                                                        4,9941221






















                                                                                                                                                                            up vote
                                                                                                                                                                            1
                                                                                                                                                                            down vote














                                                                                                                                                                            Clean, 90 bytes



                                                                                                                                                                            import StdEnv
                                                                                                                                                                            Start=(0,[('
                                                                                                                                                                            ',n)\n<-[1..6^5]|(l=removeDup l==sort l)[c\c<-:toString n]])


                                                                                                                                                                            Try it online!






                                                                                                                                                                            share|improve this answer



























                                                                                                                                                                              up vote
                                                                                                                                                                              1
                                                                                                                                                                              down vote














                                                                                                                                                                              Clean, 90 bytes



                                                                                                                                                                              import StdEnv
                                                                                                                                                                              Start=(0,[('
                                                                                                                                                                              ',n)\n<-[1..6^5]|(l=removeDup l==sort l)[c\c<-:toString n]])


                                                                                                                                                                              Try it online!






                                                                                                                                                                              share|improve this answer

























                                                                                                                                                                                up vote
                                                                                                                                                                                1
                                                                                                                                                                                down vote










                                                                                                                                                                                up vote
                                                                                                                                                                                1
                                                                                                                                                                                down vote










                                                                                                                                                                                Clean, 90 bytes



                                                                                                                                                                                import StdEnv
                                                                                                                                                                                Start=(0,[('
                                                                                                                                                                                ',n)\n<-[1..6^5]|(l=removeDup l==sort l)[c\c<-:toString n]])


                                                                                                                                                                                Try it online!






                                                                                                                                                                                share|improve this answer















                                                                                                                                                                                Clean, 90 bytes



                                                                                                                                                                                import StdEnv
                                                                                                                                                                                Start=(0,[('
                                                                                                                                                                                ',n)\n<-[1..6^5]|(l=removeDup l==sort l)[c\c<-:toString n]])


                                                                                                                                                                                Try it online!







                                                                                                                                                                                share|improve this answer














                                                                                                                                                                                share|improve this answer



                                                                                                                                                                                share|improve this answer








                                                                                                                                                                                edited Nov 17 at 1:36

























                                                                                                                                                                                answered Nov 17 at 1:31









                                                                                                                                                                                Οurous

                                                                                                                                                                                5,78311031




                                                                                                                                                                                5,78311031






















                                                                                                                                                                                    up vote
                                                                                                                                                                                    1
                                                                                                                                                                                    down vote














                                                                                                                                                                                    Red, 59 bytes



                                                                                                                                                                                    repeat n 9999[if(d: n - 1)= do sort unique form d[print d]]


                                                                                                                                                                                    Try it online!






                                                                                                                                                                                    share|improve this answer

























                                                                                                                                                                                      up vote
                                                                                                                                                                                      1
                                                                                                                                                                                      down vote














                                                                                                                                                                                      Red, 59 bytes



                                                                                                                                                                                      repeat n 9999[if(d: n - 1)= do sort unique form d[print d]]


                                                                                                                                                                                      Try it online!






                                                                                                                                                                                      share|improve this answer























                                                                                                                                                                                        up vote
                                                                                                                                                                                        1
                                                                                                                                                                                        down vote










                                                                                                                                                                                        up vote
                                                                                                                                                                                        1
                                                                                                                                                                                        down vote










                                                                                                                                                                                        Red, 59 bytes



                                                                                                                                                                                        repeat n 9999[if(d: n - 1)= do sort unique form d[print d]]


                                                                                                                                                                                        Try it online!






                                                                                                                                                                                        share|improve this answer













                                                                                                                                                                                        Red, 59 bytes



                                                                                                                                                                                        repeat n 9999[if(d: n - 1)= do sort unique form d[print d]]


                                                                                                                                                                                        Try it online!







                                                                                                                                                                                        share|improve this answer












                                                                                                                                                                                        share|improve this answer



                                                                                                                                                                                        share|improve this answer










                                                                                                                                                                                        answered Nov 17 at 4:32









                                                                                                                                                                                        Galen Ivanov

                                                                                                                                                                                        5,93711032




                                                                                                                                                                                        5,93711032






















                                                                                                                                                                                            up vote
                                                                                                                                                                                            1
                                                                                                                                                                                            down vote














                                                                                                                                                                                            Jelly, 7 bytes



                                                                                                                                                                                            <ƝẠ$⁹#Y


                                                                                                                                                                                            Try it online!



                                                                                                                                                                                            How?



                                                                                                                                                                                            <ƝẠ$⁹#Y - Main Link: no arguments (implicit z=0)
                                                                                                                                                                                            ⁹ - literal 256
                                                                                                                                                                                            # - count up from n=z (0) finding the first 256 for which this is truthy:
                                                                                                                                                                                            $ - last two links as a monad:
                                                                                                                                                                                            Ɲ - neighbours (implicitly gets digits of n):
                                                                                                                                                                                            < - less than?
                                                                                                                                                                                            Ạ - all truthy? (N.B. yields 1 for an empty list)
                                                                                                                                                                                            Y - join with newlines





                                                                                                                                                                                            share|improve this answer

























                                                                                                                                                                                              up vote
                                                                                                                                                                                              1
                                                                                                                                                                                              down vote














                                                                                                                                                                                              Jelly, 7 bytes



                                                                                                                                                                                              <ƝẠ$⁹#Y


                                                                                                                                                                                              Try it online!



                                                                                                                                                                                              How?



                                                                                                                                                                                              <ƝẠ$⁹#Y - Main Link: no arguments (implicit z=0)
                                                                                                                                                                                              ⁹ - literal 256
                                                                                                                                                                                              # - count up from n=z (0) finding the first 256 for which this is truthy:
                                                                                                                                                                                              $ - last two links as a monad:
                                                                                                                                                                                              Ɲ - neighbours (implicitly gets digits of n):
                                                                                                                                                                                              < - less than?
                                                                                                                                                                                              Ạ - all truthy? (N.B. yields 1 for an empty list)
                                                                                                                                                                                              Y - join with newlines





                                                                                                                                                                                              share|improve this answer























                                                                                                                                                                                                up vote
                                                                                                                                                                                                1
                                                                                                                                                                                                down vote










                                                                                                                                                                                                up vote
                                                                                                                                                                                                1
                                                                                                                                                                                                down vote










                                                                                                                                                                                                Jelly, 7 bytes



                                                                                                                                                                                                <ƝẠ$⁹#Y


                                                                                                                                                                                                Try it online!



                                                                                                                                                                                                How?



                                                                                                                                                                                                <ƝẠ$⁹#Y - Main Link: no arguments (implicit z=0)
                                                                                                                                                                                                ⁹ - literal 256
                                                                                                                                                                                                # - count up from n=z (0) finding the first 256 for which this is truthy:
                                                                                                                                                                                                $ - last two links as a monad:
                                                                                                                                                                                                Ɲ - neighbours (implicitly gets digits of n):
                                                                                                                                                                                                < - less than?
                                                                                                                                                                                                Ạ - all truthy? (N.B. yields 1 for an empty list)
                                                                                                                                                                                                Y - join with newlines





                                                                                                                                                                                                share|improve this answer













                                                                                                                                                                                                Jelly, 7 bytes



                                                                                                                                                                                                <ƝẠ$⁹#Y


                                                                                                                                                                                                Try it online!



                                                                                                                                                                                                How?



                                                                                                                                                                                                <ƝẠ$⁹#Y - Main Link: no arguments (implicit z=0)
                                                                                                                                                                                                ⁹ - literal 256
                                                                                                                                                                                                # - count up from n=z (0) finding the first 256 for which this is truthy:
                                                                                                                                                                                                $ - last two links as a monad:
                                                                                                                                                                                                Ɲ - neighbours (implicitly gets digits of n):
                                                                                                                                                                                                < - less than?
                                                                                                                                                                                                Ạ - all truthy? (N.B. yields 1 for an empty list)
                                                                                                                                                                                                Y - join with newlines






                                                                                                                                                                                                share|improve this answer












                                                                                                                                                                                                share|improve this answer



                                                                                                                                                                                                share|improve this answer










                                                                                                                                                                                                answered Nov 17 at 17:07









                                                                                                                                                                                                Jonathan Allan

                                                                                                                                                                                                50.1k534165




                                                                                                                                                                                                50.1k534165






















                                                                                                                                                                                                    up vote
                                                                                                                                                                                                    1
                                                                                                                                                                                                    down vote














                                                                                                                                                                                                    C (gcc), 97 bytes





                                                                                                                                                                                                    g(n,l,r){for(r=l=10;n;n/=10)r*=n%10<l,l=n%10;n=r;}f(i){for(i=0;i<1e4;i++)g(i)&&printf("%dn",i);}


                                                                                                                                                                                                    Try it online!






                                                                                                                                                                                                    share|improve this answer

























                                                                                                                                                                                                      up vote
                                                                                                                                                                                                      1
                                                                                                                                                                                                      down vote














                                                                                                                                                                                                      C (gcc), 97 bytes





                                                                                                                                                                                                      g(n,l,r){for(r=l=10;n;n/=10)r*=n%10<l,l=n%10;n=r;}f(i){for(i=0;i<1e4;i++)g(i)&&printf("%dn",i);}


                                                                                                                                                                                                      Try it online!






                                                                                                                                                                                                      share|improve this answer























                                                                                                                                                                                                        up vote
                                                                                                                                                                                                        1
                                                                                                                                                                                                        down vote










                                                                                                                                                                                                        up vote
                                                                                                                                                                                                        1
                                                                                                                                                                                                        down vote










                                                                                                                                                                                                        C (gcc), 97 bytes





                                                                                                                                                                                                        g(n,l,r){for(r=l=10;n;n/=10)r*=n%10<l,l=n%10;n=r;}f(i){for(i=0;i<1e4;i++)g(i)&&printf("%dn",i);}


                                                                                                                                                                                                        Try it online!






                                                                                                                                                                                                        share|improve this answer













                                                                                                                                                                                                        C (gcc), 97 bytes





                                                                                                                                                                                                        g(n,l,r){for(r=l=10;n;n/=10)r*=n%10<l,l=n%10;n=r;}f(i){for(i=0;i<1e4;i++)g(i)&&printf("%dn",i);}


                                                                                                                                                                                                        Try it online!







                                                                                                                                                                                                        share|improve this answer












                                                                                                                                                                                                        share|improve this answer



                                                                                                                                                                                                        share|improve this answer










                                                                                                                                                                                                        answered Nov 17 at 23:38









                                                                                                                                                                                                        gastropner

                                                                                                                                                                                                        1,8301410




                                                                                                                                                                                                        1,8301410






















                                                                                                                                                                                                            up vote
                                                                                                                                                                                                            1
                                                                                                                                                                                                            down vote














                                                                                                                                                                                                            C# (Visual C# Interactive Compiler), 102 101 ... 73 bytes



                                                                                                                                                                                                            -12 and -4 thanks @Dennis!





                                                                                                                                                                                                            for(var i=0;i<7e3;i++)if((i+"").Aggregate((a,b)=>a<b?b:':')<':')Print(i);


                                                                                                                                                                                                            Try it online!



                                                                                                                                                                                                            Each integer from 0 to 7k tested by first converting it into a string. Leveraging the fact that C# treats strings as character enumerables and LINQ, an aggregate is calculated for each character enumerable as follows:




                                                                                                                                                                                                            • compare the accumulated value with the current character

                                                                                                                                                                                                            • if the current character is greater than the accumulation, return the current character

                                                                                                                                                                                                            • otherwise return : which is greater than 9


                                                                                                                                                                                                            If the result of this is less than :, then the number has lexicographically increasing digits.






                                                                                                                                                                                                            share|improve this answer



























                                                                                                                                                                                                              up vote
                                                                                                                                                                                                              1
                                                                                                                                                                                                              down vote














                                                                                                                                                                                                              C# (Visual C# Interactive Compiler), 102 101 ... 73 bytes



                                                                                                                                                                                                              -12 and -4 thanks @Dennis!





                                                                                                                                                                                                              for(var i=0;i<7e3;i++)if((i+"").Aggregate((a,b)=>a<b?b:':')<':')Print(i);


                                                                                                                                                                                                              Try it online!



                                                                                                                                                                                                              Each integer from 0 to 7k tested by first converting it into a string. Leveraging the fact that C# treats strings as character enumerables and LINQ, an aggregate is calculated for each character enumerable as follows:




                                                                                                                                                                                                              • compare the accumulated value with the current character

                                                                                                                                                                                                              • if the current character is greater than the accumulation, return the current character

                                                                                                                                                                                                              • otherwise return : which is greater than 9


                                                                                                                                                                                                              If the result of this is less than :, then the number has lexicographically increasing digits.






                                                                                                                                                                                                              share|improve this answer

























                                                                                                                                                                                                                up vote
                                                                                                                                                                                                                1
                                                                                                                                                                                                                down vote










                                                                                                                                                                                                                up vote
                                                                                                                                                                                                                1
                                                                                                                                                                                                                down vote










                                                                                                                                                                                                                C# (Visual C# Interactive Compiler), 102 101 ... 73 bytes



                                                                                                                                                                                                                -12 and -4 thanks @Dennis!





                                                                                                                                                                                                                for(var i=0;i<7e3;i++)if((i+"").Aggregate((a,b)=>a<b?b:':')<':')Print(i);


                                                                                                                                                                                                                Try it online!



                                                                                                                                                                                                                Each integer from 0 to 7k tested by first converting it into a string. Leveraging the fact that C# treats strings as character enumerables and LINQ, an aggregate is calculated for each character enumerable as follows:




                                                                                                                                                                                                                • compare the accumulated value with the current character

                                                                                                                                                                                                                • if the current character is greater than the accumulation, return the current character

                                                                                                                                                                                                                • otherwise return : which is greater than 9


                                                                                                                                                                                                                If the result of this is less than :, then the number has lexicographically increasing digits.






                                                                                                                                                                                                                share|improve this answer















                                                                                                                                                                                                                C# (Visual C# Interactive Compiler), 102 101 ... 73 bytes



                                                                                                                                                                                                                -12 and -4 thanks @Dennis!





                                                                                                                                                                                                                for(var i=0;i<7e3;i++)if((i+"").Aggregate((a,b)=>a<b?b:':')<':')Print(i);


                                                                                                                                                                                                                Try it online!



                                                                                                                                                                                                                Each integer from 0 to 7k tested by first converting it into a string. Leveraging the fact that C# treats strings as character enumerables and LINQ, an aggregate is calculated for each character enumerable as follows:




                                                                                                                                                                                                                • compare the accumulated value with the current character

                                                                                                                                                                                                                • if the current character is greater than the accumulation, return the current character

                                                                                                                                                                                                                • otherwise return : which is greater than 9


                                                                                                                                                                                                                If the result of this is less than :, then the number has lexicographically increasing digits.







                                                                                                                                                                                                                share|improve this answer














                                                                                                                                                                                                                share|improve this answer



                                                                                                                                                                                                                share|improve this answer








                                                                                                                                                                                                                edited Nov 18 at 18:05









                                                                                                                                                                                                                Dennis

                                                                                                                                                                                                                184k32294730




                                                                                                                                                                                                                184k32294730










                                                                                                                                                                                                                answered Nov 17 at 13:32









                                                                                                                                                                                                                dana

                                                                                                                                                                                                                1714




                                                                                                                                                                                                                1714






















                                                                                                                                                                                                                    1 2
                                                                                                                                                                                                                    next









                                                                                                                                                                                                                    Varun Patro is a new contributor. Be nice, and check out our Code of Conduct.










                                                                                                                                                                                                                     

                                                                                                                                                                                                                    draft saved


                                                                                                                                                                                                                    draft discarded


















                                                                                                                                                                                                                    Varun Patro is a new contributor. Be nice, and check out our Code of Conduct.













                                                                                                                                                                                                                    Varun Patro is a new contributor. Be nice, and check out our Code of Conduct.












                                                                                                                                                                                                                    Varun Patro is a new contributor. Be nice, and check out our Code of Conduct.















                                                                                                                                                                                                                     


                                                                                                                                                                                                                    draft saved


                                                                                                                                                                                                                    draft discarded














                                                                                                                                                                                                                    StackExchange.ready(
                                                                                                                                                                                                                    function () {
                                                                                                                                                                                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f176095%2fprint-all-lexicographically-increasing-numbers-under-10000%23new-answer', 'question_page');
                                                                                                                                                                                                                    }
                                                                                                                                                                                                                    );

                                                                                                                                                                                                                    Post as a guest















                                                                                                                                                                                                                    Required, but never shown





















































                                                                                                                                                                                                                    Required, but never shown














                                                                                                                                                                                                                    Required, but never shown












                                                                                                                                                                                                                    Required, but never shown







                                                                                                                                                                                                                    Required, but never shown

































                                                                                                                                                                                                                    Required, but never shown














                                                                                                                                                                                                                    Required, but never shown












                                                                                                                                                                                                                    Required, but never shown







                                                                                                                                                                                                                    Required, but never shown







                                                                                                                                                                                                                    Popular posts from this blog

                                                                                                                                                                                                                    How to send String Array data to Server using php in android

                                                                                                                                                                                                                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                                                                                                                                                                                                                    Is anime1.com a legal site for watching anime?