46
\$\begingroup\$

This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet:

Print all Integers from 1 to 10 inclusive in ascending order to standard output.

Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), and prefixes and postfixes (like [...]). However, you may not output any other numbers than 1 through 10. Your program may not take any input. Standard loopholes are disallowed.

This is , so shortest answer in bytes wins!

Leaderboard

var QUESTION_ID=86075,OVERRIDE_USER=42570;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

\$\endgroup\$
  • 10
    \$\begingroup\$ Related (duplicate?) \$\endgroup\$ – Luis Mendo Jul 21 '16 at 9:07
  • 17
    \$\begingroup\$ If the only change is hard-coding a single parameter then that falls under the banner of "trivial change", and by the standards of this site still counts as a dupe. \$\endgroup\$ – Peter Taylor Jul 21 '16 at 9:54
  • 10
    \$\begingroup\$ @PeterTaylor The other challenge has a huge problem with the integer limits though. The way it's specified every TC language that doesn't have 64-bit integers needs to implement them. (And that affects quite a lot of languages.) \$\endgroup\$ – Martin Ender Jul 21 '16 at 10:01
  • 18
    \$\begingroup\$ @xnor Quite frankly, I'd rather close the other challenge as a duplicate of this one. The requirement pretty much ruins it. \$\endgroup\$ – Dennis Jul 21 '16 at 14:09
  • 9
    \$\begingroup\$ I can't believe every single of the (currently) 71 answers assumes the base should be decimal… \$\endgroup\$ – Skippy le Grand Gourou Jul 22 '16 at 15:05

227 Answers 227

1
4 5
6
7 8
1
\$\begingroup\$

Python 3: 24 bytes

print(list(range(1,11)))

Simply print a list of the range.

Outputs:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Microscript, 7 bytes

10c1p]h

Microscript II, 10 bytes

0s{1+Ps}s10*
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Perl, 19 bytes

@x=1..10;print"@x"; 

The ".." operator can print an ascending list of numbers or letters.

So @x = A..Z; print "@x"; will print capital letters A through Z.

I saved quite a few bytes by removing all spaces.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

J-uby, 4 bytes (non-competing)

10.+

In J-uby, n.+ is the same as [*1..n].

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ So, what is J-uby? Is it like Ruby's analog of Pyth, combined with J or something like that? \$\endgroup\$ – Zacharý Jun 19 '17 at 20:41
  • \$\begingroup\$ @ZacharyT it's not like pyth. J-uby is an extension of ruby that gives it concise fictional programming features in the style of J. I'm now adding other methods as aliases to make it more suitable for code golfing. The most important principle is that any valid Ruby code is valid J-uby code. \$\endgroup\$ – Cyoce Jun 19 '17 at 20:45
  • \$\begingroup\$ (It's not fictional, it's functional). So it's just somewhat like the Babel ES6 transpiler, in the fact that it converts J-uby code to Ruby? \$\endgroup\$ – Zacharý Jun 19 '17 at 20:47
  • \$\begingroup\$ @ZacharyT auto correct is annoying. And since Ruby is awesome, you can just require 'juby' and then it is a j-uby program through metaprogramming. \$\endgroup\$ – Cyoce Jun 19 '17 at 20:52
  • \$\begingroup\$ Yeah, I love how you used Ruby's wacky language features to enhance it. I wonder what someone could do with Perl this way, considering you can define new operators? \$\endgroup\$ – Zacharý Jun 19 '17 at 21:02
1
\$\begingroup\$

Charcoal, 5 bytes

I…·¹χ

Try it online!

Explanation:

I        Implicitly print the elements (casted as string) of
  …·      the inclusive range
    ¹χ    from 1 to 10 (default value of the χ variable)
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Pyth, 4 2 bytes

Well, I guess I think more about legitimate functionality/usability, but this is Code Golf, where usability comes after functionality.

-2 by not formatting my output.

ST

Explanation:

S        1-indexed range from 1 - ...
 T       Ten

Try It Online!

Pyth, 4 bytes

VSTN

Explanation:

V        For...
 ST      in the 1-indexed range from 1 - 10 (T)
   N     Print the current item

Try it online!

Or alternatively...

VThN

Explanation:

V        For...
 T       In range from 0 - 9
  hN     Print (the current item + 1)

Try it online!

Pretty simple.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), prefixes and postfixes (like [...]). \$\endgroup\$ – Tornado547 Dec 29 '17 at 7:17
  • \$\begingroup\$ This means that ST is valid \$\endgroup\$ – Tornado547 Dec 29 '17 at 7:18
  • \$\begingroup\$ @Tornado547 wow, that is odd. many thanks \$\endgroup\$ – Stan Strum Dec 30 '17 at 3:49
1
\$\begingroup\$

Kotlin: 30?/31/49 bytes


Variable of function type: 30 bytes

val a={(1..10).map(::println)}

This might be considered cheating.

Invokable via a() like the later function. Functions are first-class citizens in Kotlin, so they can be assigned to variables aswell. The type of ´val a´ is technically () -> List<Unit>, a function that takes nothing and returns a "list of nothing", but we wouldn't be on code golf using a language that doesn't have implicit types, would we? 😊


Function: 31 bytes

fun a(){(1..10).map(::println)}


Executable: 49 bytes

fun main(a:Array<String>){(1..10).map(::println)}
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Julia 0.6, 11 bytes

show.(1:10)

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Pip, 3+1 = 4 bytes

\,t

Runs with the -n flag to separate the output with newlines.

Try it online!

Explanation:

\,         Inclusive range of 1 to
  t        10
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ @DLosc Thanks, that shortens it considerably. But how does it owrk though? Does \, create a range-object with the values 1 to t==10 inclusive, which it auto-prints (as that range-object is the last variable touched by Pip?) \$\endgroup\$ – steenbergh Feb 3 '18 at 11:54
  • 1
    \$\begingroup\$ Yep! Exactly. (It's possible this is "using features newer than the question," because I can't recall when I changed the behavior so non-infinite ranges would output like lists, but that's allowable anyway. \, is not an issue--it was added last January.) \$\endgroup\$ – DLosc Feb 3 '18 at 17:48
1
\$\begingroup\$

Forte, 64 bytes

12PRINT42-41:LET42=42+1:LET11=11+3
13LET99=11
99LET12=12+3
40END

Try it online!

How?

In Forte, you do things by redefining numbers. For example, LET 4=5 is a statement that defines 4 to be 5. From now on, anytime 4 occurs in the program, it is replaced by 5--even as the result of expressions like 2+2. There are no looping constructs in the language; control flow is accomplished by redefining line numbers.

With that introduction, let's look at what this program does.

The first line executed is line 12. This prints 42-41, which (currently) results in 1. Next, it redefines 42 to be 42+1--that is, 43. From now on, anytime 42 occurs in the program, we'll actually use the value 43. Finally, it redefines 11 to be 11+3--that is, 14. This is setup for the loop we're about to enter.

  • Redefinitions: 11->14; 42->43

Line 13 is executed next. It redefines 99 to be 11--except 11 has previously been redefined, so 99 actually becomes 14.

  • Redefinitions: 11,99->14; 42->43

Now, the previous instruction has an effect on the control flow, because 99 happens to be a line number. Line 99 is now considered to be line 14, and thus we execute it next (rather than line 40, which would otherwise have come next). This line redefines 12 to be 12+3--that is, 15.

  • Redefinitions: 11,99->14; 12->15; 42->43

And now the next instruction is the newly christened line 15, which prints 42-41 again... except that 42 is now 43, so it actually outputs 2. It then redefines 42 43 as 44 and 11 14 as 17.

  • Redefinitions: 11,14,99->17; 12->15; 42,43->44

The next instruction is line 17 (the original line 99), which redefines 15 to be 18. And so lines 12/15/18 and 99/11/14/17 keep alternating back and forth, incrementing each other and printing ever-increasing values of 42-41, until we reach line 39. This prints 10 (42 now having reached a value of 51), redefines 42 and 11 again (but that won't matter), and then we move on to the next statement, line 40--which ends the program.

Simple, right?

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

17, 48 bytes

17 was made after the challenge was released, so it is not competing, though it still scored worse than most other answers because it isn't a golfing language, or very usable at all.

Outputs 1 to 10 seperates by \x11 (ascii value 17)

0{#
1 +
:
10 @
9 >
0 @
# $$
$}777{0 10 @
0 0 @}

Block 777(first block run): Initialises value 17 to 0. Runs block 0

Block 0: Loads value 17(relies on returning of 17 from stack when empty stack), adds 1, duplicates, stores at 17, if value > 9 pushes 1, else 0, stores value at 0, loads from 17, prints number, print ascii charater 17(relies on returning of 17 from stack when empty stack again)

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Perl 6, 11 bytes

Two solutions with the same count:

print ^10+1

and

print 1..10

Output: 1 2 3 4 5 6 7 8 9 10

Try both of them on Try It Online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Sd, 50 Bytes

++++++++++@**********.-/.-/.-/.-/.-/.-/.-/.-/.-/.!

How it works:

++++++++++                                          | Set variable 1 to 10
          @                                         | Mark read location
           **********                               | Set variable 2 to 10
                     .                              | Replace the instruction in position given by variable 2 with the ascii character given by variable 1
                      -/.                           | Subtract one from each variable and repeat
                         -/.-/.-/.-/.-/.-/.-/.-/.   | Repeat some more
                                                 !  | Print all values before the @ (as ascii)
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Pyt, 3 bytes

1ᴇř
1     push 1
 ᴇ    10^1
  ř   range from 1 to 10
      Implicit output

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Javascript (potentially non-competing)

As a function (6 bytes):

_=>110

Full program (10 bytes):

alert`110`

This prints all number from 1 to 10 inclusive in binary...
If you closely read the question, there is never any mention about mandatory separators (thus allowing 123456...) nor the output's base...

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Stax, 2 bytes

Am

Run online

Added for completeness.

A       Push 10
 m      Map over range, implicit output
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Canvas, 4 2 bytes

AR

Try it here!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Jotlin, 15 12 bytes

p((0..9)+10)

Gets the numbers 0..10, makes a list out of them, and then prints the result

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

QUARK, Non competing 7 bytes

5.625 bytes encoded.

1 10⋯

This is incredibly simple. Just pushes 1 and 10 to the stack, and creates a inclusive range out of them. The interpreter prints out the contents of the stack when the program ends, so no print command is needed. (Plus the print command doesn't work with arrays yet, and prints out a garbled mess, so :P)

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

(non-competing) rig, 3 bytes

rig is a work-in-progress esoteric stack-based language. I'm just having fun with looking for challenges it can already solve, with its few commands.

τr+

is a valid code that prints "1,2,3,4,5,6,7,8,9,10"

Try it here

Why?

τ    - push 10 to the stack              [10]
 r   - push range(10) to the stack       [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  +  - increment every element           [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
     - implicit print
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

KoopaScript, 78 (28, 20) bytes

def i a if \%va is \%v set a 0;setath a \%va + 1;if \%va smaller 11 print \%va

This prints the numbers 1 to 10, as well as a lot of information about the currently running code (because reasons). KS doesn't actually have a way to break loops yet, so this keeps running until the interpreter is reloaded. It stops printing at 10, though.

def i a               - Define a function with the name i and call it 1000/NaN (i.e. many) times a second
if \%va is \%v        - if the variable with the name a is undefined,
set a 0;              - set it to 0
setath a \%va + 1;    - set the variable a to <the variable with the name a> + 1
if \%va smaller 11    - if the variable with the name a is smaller than 11,
print \%va            - trace the variable with the name a

To avoid printing debug info, either load this in an init script, or use this slightly longer (90) version that disables logging:

def i a set verbose;if \%va is \%v set a 0;setath a \%va + 1;if \%va smaller 11 print \%va

set verbose;          - set the variable called 'verbose' (which handles whether to trace debugging stuff) to ""

Alternatively,

print "1 2 3 4 5 6 7 8 9 10"

This is only 28 bytes and technically does what the specification entails. Other commands, e.g. if, display all the numbers, but, as it's caused by an error in the program, it doesn't display if logging is disabled.

Technically,

1 2 3 4 5 6 7 8 9 10

prints all the numbers with commas between them, in the debug log. That brings it down to 20. I guess it's up to the reader (stacker? golfer?) to decide which one is the most correct

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Stack Cats, 28 + 4 (-nm) = 32 bytes

-(:!_:!_:-_-_]>{<:_-!:]}]<)-

Try it online!

Stack Cats is a reversible esoteric language by Martin Ender. All of its commands can be reversed by applying the command's mirror image, and the whole code itself must be the mirror image of itself. Since half of the code is always redundant, it has -l and -m flags which allow to omit half of the program. -m appends the mirror image to the right (except the center character), so the full program is -(:!_:!_:-_-_]>{<:_-!:]}]<)-(>[{[:!-_:>}<[_-_-:_!:_!:)-.

Stack Cats operates on an infinite tape of stacks, all of which are initially empty with infinite amount of implicit zeroes at the bottom. Here is a summary for the relevant commands:

  • - Negate the top.
  • ! Apply bitwise NOT to the top.
  • : Exchange top two elements of the current stack.
  • _ Pop a, Pop b, Push b, Push b-a.
  • >, < Move the cursor right or left.
  • ], [ Move the cursor right or left, along with the top. (Also called "Push")
  • (, ) Enter or exit a loop if the top is strictly positive.
  • { Enter a loop and remember the top.
  • } Exit a loop if the current top is equal to the remembered top.

Also, due to the limitations of the language, the input/output occurs only at the start/end of the program. At the start of the program, each input is pushed to the initial stack, which has a -1 at the bottom. At the end of the program, all values on the stack are printed from top to bottom, with optional -1 at the bottom ignored. So this program starts with a single -1 on the stack, and ends with 1..10 on the current stack.

How the code works:

Code    Stack                  Description
        [-1]
-(      [1]                    Negate the top; Enter the loop
:!_     [1 0]->[1 -1]->[1 2]   Swap top two (with implicit zero); Bit-NOT; Subtract
:!_     [2 1]->[2 -2]->[2 4]   Same
:-_     [4 2]->[4 -2]->[4 6]   Swap; Unary minus; Subtract
-_      [4 -6]->[4 10]         Generate 10
]>      [4] [10] [*]           Push 10 to a new stack; Move right again
{                              Remember 0
<:      [4] [n 0*] [...]       Swap with implicit zero
_-!     [4] [n n-1*] [...]     Generate n-1
:]      [4] [n-1] [... n*]     Push n to the right
}                              Loop while n is not zero
]<                             Remove last zero
)                              Top is 1; Exit the loop
-(...)-                        Skip the rest

There is a standard construct <(...)*(...)> which allows to ignore half of the program, in order to program more effectively by human. I used a similar one -(...)-(...)- which utilizes the initial -1, but it only works with no-input programs and the final top should be strictly positive.

Ignoring half of the program is quite a waste of space, so there is an open bounty for more efficient golfing with both halves. I'm aiming for this in the long run, though it's not yet clear how to even start tackling the problem.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

cQuents, 6 4 bytes

#t&$

Try it online!

Explanation

#t       Set default input (n) to 10
  &      Mode: Sequence 2 (print first n items in sequence, 1-indexed)
   $     Each item in the sequence is the current index
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Deadfish~, 4 bytes

{io}

Try it online!

Increment, then output; repeat ten times.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

(K+R)eg, 6 bytes (SBCS)

6 bytes:

\
ï_(.

11 bytes:

9(9|:"1-)1$

Try it online!

One byte longer

How it works

9(9|:"1-) # A countup program from 1 to 9 and then (astonishingly) adds a 0; I have no idea how it works.
1         # Push 1
$         # Swap top 2 items
# The stack is implicitly outputted.
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ 0ėɧ 3 bytes in the new interpreter \$\endgroup\$ – Lyxal Sep 16 '19 at 4:24
  • \$\begingroup\$ ėø once I add the ø operator \$\endgroup\$ – Lyxal Sep 16 '19 at 4:26
1
\$\begingroup\$

TacO, 7 bytes

@%10
 i

try it online! The number 10 is the first branch of the looping construct %, so TacO runs the second branch, which just contains i, 10 times, giving i numbers 1-10.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Seed, 4232 4039 3981 bytes

To be golfed.

11 806065440241409087125357198607542800075970572928765093042958164984128856153119364694304946533565974155065813564463607464907294493213625991570210498180131922642836049048379926678214090306958078942950505666942158861663318082805922649360548872276728753092705551896201785489318797454097467866454815778688721780170362909784978852186756623253868868917034035335528463229661772327867673360158173714723733025733656646487909489808220640703644162017799947346882823939914644265408484708544566367174322747059393061445510836708923637982737011363312927325448282786060215442674975310709523697911998742881715764878830975686475127091070151990734113230052589483007904386955837951416230150553553131824081272209795780490205576443141598594094128682959852257277648831764416301409205933849585487706444517684177487650836580944108733813423567329150282262574305747736976499413900964122878760201959007114022481011295839141271138446203186069264532462250500186116493184286012088625239590991537830133224608224949348931933311034455280978164515936125672561757104517575527099692465553902153481143524868360127998596923638301974413167583429193105287970847431486813381197765539764522094782334194830005111603128673518265195317929281022739571069159575305773074583173243911197334517405412628068284686691469982559791730541223895403558031955848768117060646768348463561209935808045637507281128179915889035768211511504144114447348017724691523076211025635445333081644368060430405389019848215116047520242946447978917490619742817523907421559319563570816232286092378925478777387843124296450405990835394943021252863488969545687903232603331252281246680860082655523490245738107512918342578050153655018310720283275985429190062871812385817909146120892975424714212971890662091259299688100739835789852338707333214399083184648552682989269071097042033924364887158088125417342061047907455595001558776113845342454604060641417114322284932278126981432767955018317987960683429833483125151020913178712494155310545261553444170641615117711305756617133820567957209040625095889033833683868477968222981257864647555382502179925116320599028456728151421211950504164587366555426478479957000176097833838329163859553682184378396176530388849222864560228925976975341162944244301834305126128097819354250219559409487388887032429560483598135806164050794728591878728116747953265919795701481292222092677282626562421120330436952746759320383166496345689472683465785160396471114988424810146619802843389460581036625456336614635949441077117888570209114560201469774858952308539634363125726651042307946127813908314293240378846347559662225224004298822713302904050471977675138246925540751643515879128105969891674920959645532198204680833150120401421252646736795292132103275342152265451058336500878555688383134027160586652276624279294501247326175308886148638933724425782375226226354458022684652099014849380343822015940473137950787091045988775407006084669595433268270085699081145780497235745383972369977375564713816849012360495596752065665250235877504147680897910657602532177993907221958136528121236676455264099257048759319470710174615005668917675853889646496531814039709503285164186416096735666867062585670181891889551756178657495723233678891549411496581200696462439988553007997103954989290028776888309286564702133992674291744804531900851060090385178725409757099606879757766288322010567612896350258272282241111517435795569303408578713936760574865986977532034796036053889911992836923158428809242575557886427002935479153509101800373188079516076598125218940752155364580400861924119667725548877677649837117601878482958020472764206345843076482381692875591020886968748894499648171413242376922343979630964910668516043571246988639289969853916731069660002514237788846617524295024699798200028558752532671916185460167291108476912591550362203490594401624213451585637461718363114331483866061411154610681167668195013207060532734483192219734129165226320299742868143084807270641847983148272764305800992489421803505337228286598600236556437401089147741524552516814465259338644189950504662

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Javascript 45 Bytes

alert("10charstrn".split("").map((e,i)=>i+1))

This is currently quite poor, but if there happens to be a JS constant which is an array of length 10, this could improve a lot.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Array(10).fill() is the first thing that came to mind for an array of length 10. (Array(10).map... does not work, at least on my browser.) \$\endgroup\$ – Value Ink Sep 16 '19 at 23:52
  • \$\begingroup\$ I mean, just alert([1,2,3,4,5,6,7,8,9,10]) is way shorter \$\endgroup\$ – Jo King Sep 17 '19 at 0:39
  • \$\begingroup\$ I'm pretty sure alert([1,2,3,4,5,6,7,8,9,10]) is already an answer somewhere within these seven pages of answers... might as well golf the method that's already here methinks \$\endgroup\$ – Value Ink Sep 17 '19 at 4:37
  • \$\begingroup\$ (top+'').split('',10) <-- saves 1 byte compared to "10charstrn".split(""). top refers to window.top, and the string representation is "[object Window]" (15 chars). The .split() method takes a separator and an optional limit. Since all you need is 10 chars, split into an array, this should do just fine. \$\endgroup\$ – Ismael Miguel Nov 18 '19 at 11:43
1
\$\begingroup\$

ROOP, 15 bytes

123456789
h(10)

Solution with hardcoded numbers, I'm still trying to find a shorter program.

In this language each digit becomes an individual object. Number 10 is written in parenthesis to make it a single object. The operator h prints all objects that are currently in the program, separated by a space, then halt.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ seems that 7 is missing \$\endgroup\$ – roblogic Sep 15 '19 at 3:57
  • 1
    \$\begingroup\$ @roblogic wow, you are right, fixed. \$\endgroup\$ – DarkPhantom Sep 16 '19 at 15:48
1
\$\begingroup\$

Keg, 5 bytes

I am too lazy to change my answers to conform the new code page, unless I get notified.

ėÏ_(.

Push 10(saving a byte), take iota [10..0], remove last, and then print.

| improve this answer | |
\$\endgroup\$
1
4 5
6
7 8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.