Print numbers from 1 to 10

46

8

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>

Clashsoft

Posted 2016-07-21T08:58:19.090

Reputation: 835

10Related (duplicate?) – Luis Mendo – 2016-07-21T09:07:13.313

1Not exactly duplicate, this doesn't take input – Clashsoft – 2016-07-21T09:08:59.613

17If 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. – Peter Taylor – 2016-07-21T09:54:52.247

10@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.) – Martin Ender – 2016-07-21T10:01:46.180

7@MartinEnder It's too bad the other question has the silly limitation, but I still think it's a dupe when one can port over 2/3 or more of the answers with only minor modification. – xnor – 2016-07-21T10:50:56.910

18@xnor Quite frankly, I'd rather close the other challenge as a duplicate of this one. The requirement pretty much ruins it. – Dennis – 2016-07-21T14:09:15.763

I dislike the other challenge's requirement, but it's not something that we could (or should) close it for. As it stands this is a dupe of the other, more general challenge. – Mego – 2016-07-22T05:34:16.953

Is it forbidden to print any number other than the 1 to 10? – Business Cat – 2016-07-22T13:49:45.117

9I can't believe every single of the (currently) 71 answers assumes the base should be decimal… – Skippy le Grand Gourou – 2016-07-22T15:05:52.527

Does a click on "OK" qualify as separator and suffix? – Titus – 2016-07-22T15:08:39.267

2@SkippyleGrandGourou Hehe, that's brilliant. Just a simple output of 1 10 would suffice in base-2. xD – Kevin Cruijssen – 2016-08-02T14:22:25.883

1Could you clarify whether having no delimiter at all is allowed, too? I.e. 12345678910? – Martin Ender – 2016-08-13T20:11:21.333

2Could you please add a leaderboard snippet? 100+ answers is a lot to sift through manually. – Business Cat – 2016-08-16T15:14:07.907

There are languages which are so verbose that it's worth considering whether hardcoding a string consisting of all 10 numbers is shorter than actually writing a loop. Is that intentional? – None – 2017-03-25T22:33:51.970

1Cheaty-as-heck answer: do 1111111111 and argue that it printed all numbers from 1 to 10 in unary – Matthew Roh – 2017-03-26T11:34:56.343

2The "Winners by Language" section is not working – sergiol – 2017-06-19T17:06:43.817

Do we have to print delimiters? May I print a leading or trailing delimiter? – Titus – 2017-07-07T14:54:01.770

Answers

72

C, 36 bytes

main(i){while(printf("%d ",i++)<3);}

This works because the loop terminates after the first 2 digit number.

xsot

Posted 2016-07-21T08:58:19.090

Reputation: 5 069

1There's no mention of being able to pass in parameters to the function. – Ash Burlaczenko – 2016-07-21T13:27:47.083

10@AshBurlaczenko What are you talking about? This is a standard technique in golfing to initialise an int to 1. You don't need to pass any command line arguments. In fact, doing so will cause the program to produce the wrong output. – xsot – 2016-07-21T13:39:07.917

6

@AshBurlaczenko By consensus we have agreed that programs may assume they will not be called with unnecessary input (in this case, no additional command line arguments, beyond the program itself). That means i here will always be 1 when this program is run. Did you mean something else?

– FryAmTheEggman – 2016-07-21T13:41:41.810

2Sorry, I've not written C but assumed it's default value would be 0 as in every language I've used. – Ash Burlaczenko – 2016-07-21T13:50:37.123

18@AshBurlaczenko In C, the first argument to main is the number of command line arguments (including the executable name itself). Since no additional arguments are passed, that count is 1. The second argument to main is the actual list of command line arguments, but that argument is ignored in this program. – Chris Bouchard – 2016-07-21T15:43:59.620

1@MatthewRoh +1 for the +1 about that part :) – ABcDexter – 2016-07-23T19:34:18.493

48

HTML, 44 bytes

<ol><li><li><li><li><li><li><li><li><li><li>

This is longer than hardcoding the output, but it is more interesting this way. It creates an ordered list (<ol>) with ten empty list elements (<li>). By default ordered lists are delimited by decimal numbers starting with 1 and a period.

HTML5 is very forgiving regarding unclosed tags, so it closes the li tags implicitly.

NinjaBearMonkey

Posted 2016-07-21T08:58:19.090

Reputation: 9 925

5+1 for abusing HTML5's forgivingness (?). – HyperNeutrino – 2016-11-17T15:34:05.660

1Cold-blooded. I love it. – ricdesi – 2016-11-17T19:03:52.130

1Actually, NinjaBearMonkey and @HyperNeutrino, this isn’t “forgiveness” per se; HTML5 is pretty explicit about which tags are allowed to be left unclosed. It’s just that lists and list items are two that are. – KRyan – 2018-02-05T14:34:09.273

44

Bash, 12 characters

echo {1..10}

Sample run:

bash-4.3$ echo {1..10}
1 2 3 4 5 6 7 8 9 10

Bash + coreutils, 10 characters

(Just trying to be funny and using ': No such file or directory↵ls: cannot access ' as separator.)

ls {1..10}

Sample run:

bash-4.3$ ls {1..10}
ls: cannot access '1': No such file or directory
ls: cannot access '2': No such file or directory
ls: cannot access '3': No such file or directory
ls: cannot access '4': No such file or directory
ls: cannot access '5': No such file or directory
ls: cannot access '6': No such file or directory
ls: cannot access '7': No such file or directory
ls: cannot access '8': No such file or directory
ls: cannot access '9': No such file or directory
ls: cannot access '10': No such file or directory

Bash + coreutils, 6 characters

(Just trying to be boring. Or not just trying…)

seq 10

Sample run:

bash-4.3$ seq 10
1
2
3
4
5
6
7
8
9
10

manatwork

Posted 2016-07-21T08:58:19.090

Reputation: 17 865

7Last one is just seq/coreutils, bash not involved. – hyde – 2016-07-21T18:07:43.770

1@hyde: Without bash the call to seq wouldn't be possible, would it? – Mega Man – 2016-09-06T08:13:50.630

In my vision, if we leave out bash, then seq would be the interpreter. But then 10 is a valid program in “seq” language? – manatwork – 2016-09-06T08:25:45.480

Never try this at your console: echo {1..1000000000} If you curious, do with your own risk. – Brain90 – 2016-10-18T14:58:22.693

@Brain90, there is no danger on my poor 8Gb RAM machine. ;) “bash: brace expansion: failed to allocate memory for 1000000000 elements”. At least with bash 4.3.46. – manatwork – 2016-10-18T15:25:33.187

@manatwork, sorry for the mistake. I execute this $ echo {1..100000000000000} -> 14 digits zero. LED storage indicator goes crazy, and hang. 4Gb RAM. – Brain90 – 2016-10-18T15:48:49.797

@manatwork seq is not a programming language per the consensus definition here. https://codegolf.meta.stackexchange.com/questions/2028/what-are-programming-languages/2073#2073

– Sparr – 2017-06-19T18:23:18.937

@Sparr, didn't claimed it is. Is a “function” defined in one of the shell's “libraries”. – manatwork – 2017-06-19T18:30:16.233

@manatwork "then seq would be the interpreter. But then 10 is a valid program in “seq” language?" <-- seq is not a language or an interpreter of a language. – Sparr – 2017-06-20T22:17:38.830

Is the 10c version allowed as there're extra string in front of and behind – l4m2 – 2017-12-30T04:50:18.490

@l4m2, the challenge text explicitly allows arbitrary separators, prefixes and postfixes. I agree, that is probably not what the challenge author intended to say by allowing “etc., but no digits”. That is why although my solution not literally violates the requirement, I posted it only as a funny alternative. – manatwork – 2017-12-30T13:42:24.517

Seen that part . sorry – l4m2 – 2017-12-30T13:54:22.487

29

Jelly, 2 bytes

⁵R

Explanation

⁵  Return the fifth command line argument or 10
 R Range
   Implicit output

TuxCrafting

Posted 2016-07-21T08:58:19.090

Reputation: 4 547

7⁵R, two bytes – Luis Mendo – 2016-07-21T09:19:50.887

17Why on Earth would someone invent a language in which a command returns either the fifth argument or the integer 10?.. – Andreï Kostyrka – 2016-11-14T15:11:13.080

15@AndreïKostyrka Because Dennis – TuxCrafting – 2016-11-14T15:23:15.353

1Is there an encoding where is just one byte? Since it's 3 bytes in UTF-8, the length of the program should be 4 bytes. – Radovan Garabík – 2017-01-26T14:25:36.847

4@RadovanGarabík Jelly uses its own codepage – TuxCrafting – 2017-01-26T15:09:18.287

20

Brainfuck, 58 bytes

-[----->+>+<<]>--<+++++[<++<++>>-]<<-[->>>.+<<.<]>>>>--.-.

Try it online!

Loovjo

Posted 2016-07-21T08:58:19.090

Reputation: 7 357

1Beat me to it, and shorter too, will post mine anyway as I don't think we've used the same trick. Have my +1 :) – Katenkyo – 2016-07-21T10:00:15.527

I was close with 67 bytes, but not close enough: ++++++[>++++++++<-]>>>++++++++++[-<+<<+>>>]<[-<.+<.>>]<<-[>-<-]>.-. – Julian Lachniet – 2016-12-29T17:36:57.160

19

05AB1E, 2 bytes

Code:

TL

Explanation:

T   # Constant for 10
 L  # Range

Try it online!.

Adnan

Posted 2016-07-21T08:58:19.090

Reputation: 41 965

4When I saw this, I felt the need to say "tl;dr". :P +1, by the way. – HyperNeutrino – 2016-11-17T15:35:20.593

17

LOLCODE, 79 bytes

IM IN YR l UPPIN YR v TIL BOTH SAEM v AN 10
VISIBLE SUM OF v AN 1
IM OUTTA YR l

This code may need some tweaking depending on the compiler you're using. Some want you to add HAI/KTHXBYE, some want you to declare the variable ahead of time. One compiler breaks if your loop name is shorter than two characters, even though the loop name is never used.

user55852

Posted 2016-07-21T08:58:19.090

Reputation:

15

CJam, 6 5 bytes

A,:)`

1 byte saved thanks to Luis Mendo

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

Explaination:

A,      e# Push a list from 0 to 9.
  :)    e# Increment all values.
    `   e# Stringify the list.

Try it online!

Loovjo

Posted 2016-07-21T08:58:19.090

Reputation: 7 357

3i like the smileyface. (Isn't there an error in your explanation: A, creates a list from 0 to 9) – KarlKastor – 2016-07-21T11:13:22.887

15

R, 4 bytes

2:10

The ":" is probably one of the most used R commands. Improvement by Barranka in comments.

Forgottenscience

Posted 2016-07-21T08:58:19.090

Reputation: 417

2Should they require printing a string, not returning a vector, consider cat(1:10). – Andreï Kostyrka – 2016-07-22T15:54:56.027

Is there a leading whitespace? – Clashsoft – 2016-07-22T18:37:57.257

9Given that the output is [1] 1 2 3 4 5 6 7 8 9 10, maybe it would be better 2:10, which will output [1] 2 3 4 5 6 7 8 9 10 – Barranka – 2016-07-22T19:27:48.973

@Clashsoft, that was a mistake - thank you. And yes, Barranka, good point - upvoted. – Forgottenscience – 2016-07-22T21:50:07.597

14

Ruby, 8 bytes

Separated by newlines.

p *1..10

Value Ink

Posted 2016-07-21T08:58:19.090

Reputation: 10 608

*Separated by newlines. – David Conrad – 2016-07-22T17:06:28.507

You can do that? – dkudriavtsev – 2016-10-18T16:38:29.220

@DmitryKudriavtsev yes, the star causes the code to break down to p 1,2,3,4,5,6,7,8,9,10 and commas cause p to separate them by newlines. – Value Ink – 2016-10-18T18:11:10.033

OK. I didn't think that the operator has a lower precedence than range. – dkudriavtsev – 2016-10-18T18:37:57.727

12

Brainfuck, 41 bytes

+[[-<]>->>->-<-]<<[-<<+<<.+>>>>>.<]<<+.-.

Output

1 2 3 4 5 6 7 8 9 10

Try it online.

primo

Posted 2016-07-21T08:58:19.090

Reputation: 30 891

1Nice! – – – – – – Leaky Nun – 2016-07-24T10:56:58.170

11

Mathematica - 13 bytes

Echo@Range@10

Saved 4 bytes thanks to MartinEnder!

Output: >> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

Yytsi

Posted 2016-07-21T08:58:19.090

Reputation: 3 582

11

Actually, 9 Bytes

19`;1+`na

Try it here!

Explanation:

19`;1+`na

1           Push 1 to stack
 9          Push 9 to stack
  `;1+`     Push Function inside ` to stack
   ;        Push top element to stack
    1+      Add 1 to top element
       n    Run function x times (9 times)
        a   Invert stack

Stupe

Posted 2016-07-21T08:58:19.090

Reputation: 151

9Welcome to Programming Puzzles and Code Golf! – Adnan – 2016-07-21T09:29:33.563

11

Pyth, 2 bytes

ST

First time I've used a golfing lang to answer!

Explanation:

S    1-indexed range. [1, 2, ... A].
 T   Variable. Initialized to 10. (Ten)
     Implicitly printed.

charredgrass

Posted 2016-07-21T08:58:19.090

Reputation: 935

Ninja'd by seconds :/ – TuxCrafting – 2016-07-21T09:44:13.370

11

JavaScript (ES6), 29 bytes

alert([...`${1e11/81^14}`]+0)

Outputs 1,2,3,4,5,6,7,8,9,10. Not the shortest answer but I thought it was a fun calculation.

Neil

Posted 2016-07-21T08:58:19.090

Reputation: 95 035

why not alert([...'1'+234567891]+0) – edc65 – 2016-07-26T18:27:36.263

2@edc65 a) it's not as fun b) it's not as short as the previously posted JavaScript answer c) it's not even as short as alert([...'1234567891']+0). – Neil – 2016-07-26T18:45:13.577

9

MATL, 3 bytes

10:

Try it online!

The code generates the vector [1 2 ... 10] and implicitly displays it, with the numbers separated by spaces.

Luis Mendo

Posted 2016-07-21T08:58:19.090

Reputation: 87 464

9

DC, 12 bytes

...a little bit mean now...

[zzpA>L]dsLx

Unrolled:

[   # start string constant
z   # push stack length (0 on 1st cycle)
z   # push stack length (1 on 1st cycle)
p   # print top of stack
A>L # if 10(decimal) < tos: execute L
]   # end string constant, push it
d   # duplicate the string
sL  # store a copy in L
x   # execute tos (which is the other string copy)

One of the z (push stack length) operations has no corresponding operation which takes it from the stack. This way the stack grows with each iteration by one. This is abused as the loop counter.

This loop starts with an empty stack, so the 1st z pushes 0 in the 1st iteration so the printing happens after the 2nd z which correspond to duplicating the result of 1+d in the version below. This way the comparison needs to test for bigger than 10 here instead of bigger than 11 below.


DC, 14 bytes

Just straight forward...

1[p1+dB>L]dsLx

Unrolled:

1   # push 1
[   # start string constant
p   # print top of stack
1+  # add 1 to tos
d   # push tos (duplicate)
B>L # if 11(decimal) < tos: execute L
]   # end string constant, push it
d   # duplicate the string
sL  # store a copy in L
x   # execute tos (which is the other string copy)

user19214

Posted 2016-07-21T08:58:19.090

Reputation:

I wish you'd explain these =( – Evan Carroll – 2018-03-09T22:45:39.473

@EvanCarroll — Writing dc programs is easier than explaining. But I tried... ;-) – None – 2018-03-10T06:52:07.820

8

><>, 13 bytes

01+:a)?;:nao!

Explanation :

01+:a)?;:nao!

0                 push initial value of n on the stack
 1+               increments n
   :              duplicates n on the stack
    a             push 10 on the stack
     )            pops n and 10 of the stack, push n>10 on the stack
      ?;          if n>10, stops program execution
        :n        duplicates n on the stack in order to display it
          ao      display 10 (x0A, linefeed)
            !     skips the next instruction, which since ><> loops is the push 0

You can see it in action on the online interpreter.

Aaron

Posted 2016-07-21T08:58:19.090

Reputation: 3 689

Could you please add an explanation? – Clashsoft – 2016-07-21T09:19:19.853

1Run the program nao! – Cyoce – 2017-06-19T18:07:59.620

@Cyoce ><> is great to write enthusiastic pieces of code, I've got this motorcycle gear checker answer in the same vein ;)

– Aaron – 2017-06-19T18:21:39.217

7

Haskell, 17 bytes

main=print[1..10]

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

C. Quilley

Posted 2016-07-21T08:58:19.090

Reputation: 546

I'm a bit confused here... I'm almost certain that it should be [1..10]. I don't have access to a haskell compiler, but I'll double-check in the morning. – Zwei – 2016-07-21T09:29:43.700

@Zwei Ranges don't include their upper limit in Haskell. – C. Quilley – 2016-07-21T09:43:36.167

1@C.Quilley They totally do. You might be thinking of Python. – xnor – 2016-07-21T09:53:15.777

Huh, I was sure I had tested this code. Apologies for the earlier assertion. – C. Quilley – 2016-07-21T11:04:11.290

1I don't think you need the main= part; the rest has the type of a haskell program, IO (). Correct me if there is a specific ruling against this. – Lazersmoke – 2016-08-16T16:28:11.567

@Lazersmoke True, you could save 5 bytes. (Others, see here if not sure)

– ბიმო – 2017-07-19T12:38:41.720

7

Perl 6, 12 bytes

say @(1..10)

The @() is needed to convert to an array

Alternative solution:

say @(^10+1)

Builds a range [0,10) then adds one, then converts to an array.

Ven

Posted 2016-07-21T08:58:19.090

Reputation: 3 382

For Perl 5.10, 14 bytes and almost like yours: say for(1..10) – Paul Picard – 2016-07-21T13:50:01.827

@PaulPicard do post it! Perl 5 is a different language. – Ven – 2016-07-21T13:58:19.577

Can you remove the space for say@(1..10)? – Cyoce – 2017-06-23T08:53:18.053

@Cyoce alas no, it's an error. – Ven – 2017-06-23T17:04:31.523

10 bytes: say 1...10 – nwellnhof – 2019-11-18T12:10:30.567

7

Adám

Posted 2016-07-21T08:58:19.090

Reputation: 37 779

7

PowerShell, 5 bytes

1..10

Creates a dynamic range with the .. operator from 1 to 10, then that array is left on the pipeline. Output is implicit. Default .ToString() method of an array is newline, so this will be newline-separated when run in a clean shell.

AdmBorkBork

Posted 2016-07-21T08:58:19.090

Reputation: 41 581

6

MarioLANG, 34 27 25 bytes

+<
:"
+
:
+
:
+
:
+
:!
=#

Try it online!

Thanks to Jo King for -7 -9 bytes!

code:

Mario falls down, incrementing and saying his number five times, then he steps on the elevator, rides up and falls down again, incrementing and saying his number another five times. Then he walks left and falls out of the code.

14 bytes shorter than the easy way:

39 bytes

+:+:+:+:+:+:+:+:+:+
==================:

Try it online!

Dorian

Posted 2016-07-21T08:58:19.090

Reputation: 1 521

Thank you. Sometimes you just can't see the forest for the trees. – Dorian – 2019-09-18T08:12:45.573

6

Python2 - 19 17 bytes

print range(1,11)

Saved 1 byte, thanks to KevinLau - not Kenny!

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

Yytsi

Posted 2016-07-21T08:58:19.090

Reputation: 3 582

Use range instead of xrange, assuming Python 2. In fact, this current version doesn't seem to work on my machine in either Python version. – Value Ink – 2016-07-21T09:18:11.523

@KevinLau-notKenny I could've sworn that I tried that, and got nothing to STDOUT. Thanks! – Yytsi – 2016-07-21T09:20:31.110

Important: It's only Python 2 – Mega Man – 2016-07-23T18:47:57.857

@MegaMan You're right. I just felt leaving it out, since almost every other Python2 answer does that. I'll edit the title. – Yytsi – 2016-07-23T19:28:22.013

Please see my first answer on the site, it is in Python3 :D

– ABcDexter – 2016-07-23T19:36:35.413

1@ABcDexter I checked it out, very nice! The reason I didn't use Python3, was because I was forced to cast the range object that returns an iterator, to a list. – Yytsi – 2016-07-23T19:39:13.163

1@TuukkaX Yes, exactly. I'll try some other languages too. Thanks :). – ABcDexter – 2016-07-23T19:44:27.197

@TuukkaX: You don't need to cast, but it would be a titch longer in Py3: print(*range(1,11)) – ShadowRanger – 2017-06-23T03:55:36.190

@ShadowRanger Yup, my bad. ABcDexter already submitted that Py3 snippet :P – Yytsi – 2017-06-23T04:58:49.960

6

Java 7, 53 51 52 bytes (loop)

void l(){for(int i=0;++i<11;)System.out.println(i);}

Alternative 51 bytes (hardcoded is shorter.., but considered a default loophole, so not allowed):

void h(){System.out.print("1 2 3 4 5 6 7 8 9 10");}

Alternative 54 bytes (recursive):

int i=1;void r(){System.out.println(i);if(i++<10)r();}

Ungolfed & test code for all three:

Try it here.

class Main{
  static void h(){
    System.out.print("1 2 3 4 5 6 7 8 9 10");
  }      

  static void l(){
    for(int i=0; ++i < 11;){
      System.out.println(i);
    }
  }

  static int i = 1;
  static void r(){
    System.out.println(i);
    if(i++ < 10){
      r();
    }
  }

  public static void main(String[] a){
    h();
    System.out.println();
    l();
    System.out.println();
    r();
  }
}

EDIT: For funsies: As correctly pointed out by @SkippyLeGrandGourou, the base of the 1 to 10 isn't specified in the question, so here is (non-code-golfed) Java code that outputs 1 to 10 in the bases 2 to 10:

Try it here.

BASE-2: 1 10 
BASE-3: 1 2 10 
BASE-4: 1 2 3 10 
BASE-5: 1 2 3 4 10 
BASE-6: 1 2 3 4 5 10 
BASE-7: 1 2 3 4 5 6 10 
BASE-8: 1 2 3 4 5 6 7 10 
BASE-9: 1 2 3 4 5 6 7 8 10 
BASE-10: 1 2 3 4 5 6 7 8 9 10 

Kevin Cruijssen

Posted 2016-07-21T08:58:19.090

Reputation: 67 575

Loop can be for(int i=1;i<11;)System.out.println(i++), saves one byte. – Clashsoft – 2016-07-21T09:23:15.180

@zyabin101 Changed the order so the hard-coded answer is non-competing. Still left it in the answer though, since it's pretty funny (and sad) that hard-coded is the shortest way to print 1-10 in Java 7.. – Kevin Cruijssen – 2016-07-21T10:00:29.650

2@zyabin101 Except when the question is tagged [tag:kolmogorov-complexity]. – Neil – 2016-07-22T19:43:46.627

@Neil Oh, right. o_o – user48538 – 2016-07-22T19:49:25.550

1Java 8's the clear winner here thanks to lambdas! ()->java.util.stream.IntStream.range(1,11).forEach(System.out::println). Why you say it's longer? It's Java 8... Java 8 is shorter by default! I didn't even put braces before and after the code! I can even count to 98 without getting an extra character! See? Java 8 rules! – Olivier Grégoire – 2017-06-23T08:39:54.630

6

J, 6 bytes

1+i.10

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

Explaination:

1+       NB. Add one to...
  i.10   NB. A range from 0 to 9.

Loovjo

Posted 2016-07-21T08:58:19.090

Reputation: 7 357

My thought was >:i.10, but that's the same thing. – Dane – 2016-07-22T21:40:29.327

6

Fuzzy Octo Guacamole, 7 bytes

1.25*$:

Multiplies 2*5, takes the range of that and 1, and prints the whole stack.

1.25*$:
1.      # Push 1 to the stack and switch stacks
  25*   # Push 10 to the stack
     $  # Push every number in the inclusive range on the top of inactive stack and top of active stack ([1,2,3,4,5,6,7,8,9,10])
      : # Print the stack, which is a list containing the numbers.

Rɪᴋᴇʀ

Posted 2016-07-21T08:58:19.090

Reputation: 7 410

6

Vim, 12 bytes

i1<Esc>qqYp<C-a>q8@q

Outputs

1
2
3
4
5
6
7
8
9
10

Explanation:

i1<Esc>qqYp<C-a>q8@qZZ
       qqYp<C-a>q      -- Macro q: duplicate line and increment (6)
i1<Esc>                -- Insert 1 (3)
                 8@q   -- Run macro q 8 times (3)

Tested on Neovim 0.1.4, which to my knowledge is keystroke-compatible with Vim.

Zwei

Posted 2016-07-21T08:58:19.090

Reputation: 484

Nice. I came up with iYp<C-v><C-a>1<Esc>d^9@-ZZ. Same byte count. – primo – 2016-07-24T12:07:06.250

3Shorter. :) – James – 2016-11-16T21:36:04.307

5

Retina, 13 bytes

I've got two solutions at this byte count, but it doesn't seem optimal:


_10$*
1
$.`_

11$*_
\B
$.`

They both use _ as separators, prefix and suffix.

Try the first online! Or try the other one!

Martin Ender

Posted 2016-07-21T08:58:19.090

Reputation: 184 808

5

Sesos (binary), 5 bytes

Hexdump:

0000000: 2c4bbc 3301                                       ,K.3.

Try it online!

How it works

The binary file above has been generated by assembling the following SASM code.

Sesos is a language "based on brainfuck", but is "concise, can be typed easily, has somewhat flexible I/O, and is safe for work".

set numout    ;sets the output to printing a number per line,
              ;instead of characters.
add 10        ;now the tape is [10,0,...]
jmp           ;start of loop
              ;sets an entry marker and jump to the jnz instruction.
    fwd 1          ;forward the data head 
    add 1          ;add 1 to the cell under data head
    put            ;output (as number)
    rwd 1          ;rewind the data head by 1 cellby 1 cell
    sub 1          ;subtract 1 from the cell under data head
                   ;the tape goes from [0,10] to [1,9], to [2,8]
                   ;to ... [8,2] to [9,1] to [10,0] and then halts.
              ;(implicit jnz) end of loop, goto "jmp" if not zero

In brainfuck: ++++++++++[>+.<-] (assuming decimal output).

Leaky Nun

Posted 2016-07-21T08:58:19.090

Reputation: 45 011

5

PHP, 25 23 bytes

Saved 2 bytes thanks to manatwork.

 <?=join(_,range(1,10));

Creates an array of [1 .. 10] and echoes the values separated by _s.

Business Cat

Posted 2016-07-21T08:58:19.090

Reputation: 8 927

You could take advantage of the freedom to choose the separator. Using “_” as Martin Ender's Retina solution does would reduce the length by 2. (At the obvious price of an undefined constant notice, which is fine as PHP's suggested production configuration not displays notices anyway.)

– manatwork – 2016-07-21T14:08:37.283

@manatwork: That is very strange, I had no idea that was even possible. Thanks for the suggestion! – Business Cat – 2016-07-21T14:16:02.337

Same length: for(;$i++<10;)echo$i,_; – Ismael Miguel – 2016-07-22T02:36:09.067

@IsmaelMiguel: That's longer because it requires the full <?php and not just <?= – Business Cat – 2016-07-22T12:38:15.113

@BusinessCat Not exactly. It is meant to be executed using the -r argument. And the -r argument is free

– Ismael Miguel – 2016-07-22T12:45:45.917

Short open tags are still valid and still on by default; they only removed <%, <%= and <script language="php"> in php 7. Your output format can be whatever your language supports. --> print_r(range(1,10)); is two bytes shorter with -r

– Titus – 2016-07-22T13:37:10.680

@Titus: I avoided using print_r or var_dump because I wasn't sure if it was allowed. I know it says any arbitrary separator, but those functions will print extra numbers (the keys of the array) which may be against the rules of the challenge. – Business Cat – 2016-07-22T13:48:10.197

1True. and the join(_ is prettier anyway; just keep it like that. But let me add two variations of Ismael´s idea: while($i<10)echo++$i,_; and while(++$i%11)echo$i,_; (same length, but with -r) – Titus – 2016-07-22T14:12:22.940

Question answered: challenge edited to you may not output any other numbers. Never mind, this is nice. – Titus – 2016-07-22T20:26:49.083

5

JavaScript, 25 24 bytes

for(i=1;i<11;)alert(i++)

Kruga

Posted 2016-07-21T08:58:19.090

Reputation: 231

1Welcome to PPCG! I think you can save a byte by doing alert(i++) (and removing the other i++). – Martin Ender – 2016-07-21T14:00:11.030

Too bad the question stipulates that the order must be ascending, otherwise you could've saved a byte by using a decrementing while loop instead of the for loop like so i=10;while(i)alert(i--). – kamoroso94 – 2016-08-02T14:43:41.337

Doesn't the code have to be embedded in a function? – ericw31415 – 2017-06-15T21:04:33.493

@ericw31415 https://codegolf.meta.stackexchange.com/a/2422/56627

– Kruga – 2017-06-16T07:53:49.413

5

PostScript, 12 bytes

1 1 10{=}for

Output:

1
2
3
4
5
6
7
8
9
10

(Most PostScript interpreters don't actually have a proper stdout, or even a command line, but GhostScript has both and can be used to run this program.)

Stefan Gustavson

Posted 2016-07-21T08:58:19.090

Reputation: 51

5

><> (Fish) 10 bytes

1l:naoa=?;

This is my first submission and I know their is already a Fish answer but I don't have the reputation to comment.

The main difference is using the l to place the length of the stack onto the stack allowing us to bypass 'adding one' saving a byte.

Using l also means we don't need to preserve the stack value (just the length) so we do not need to duplicate the top of the stack to preserve our values, saving another 2 bytes (one for the duplication of the stack value and another as we do not need to skip any instructions for preserving the stack).

Teal pelican

Posted 2016-07-21T08:58:19.090

Reputation: 1 338

4

Brainfuck, 53 bytes

++++++++[->++++++>+>++++<<<]>>+[-<+.>>.<]<--------.-.

user9882

Posted 2016-07-21T08:58:19.090

Reputation: 41

2Welcome to PPCG! – Martin Ender – 2018-02-20T14:52:14.020

Try it online! – Dennis – 2018-02-21T02:57:35.210

4

RUBY, 24 bytes 18 bytes

n=0;10.times{puts n+=1}

thanks to @A_

10.times{|n|p n+1}

Almarks

Posted 2016-07-21T08:58:19.090

Reputation: 41

18 bytes – None – 2019-11-18T08:17:48.480

..thanks to @A_ – Almarks – 2019-11-18T08:38:18.217

4

Groovy, 11 characters

print 1..10

Sample run:

bash-4.3$ groovy -e 'print 1..10'
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

manatwork

Posted 2016-07-21T08:58:19.090

Reputation: 17 865

4

Julia, 12 bytes

show([1:10])

In Julia, x:y is a range, inclusive. To cast to a list you need to put brackets around it. Otherwise it will just print the literal characters 1:10.

1 byte saved due to @Dennis. Turns out show works the same as print in this case.

Rɪᴋᴇʀ

Posted 2016-07-21T08:58:19.090

Reputation: 7 410

show([1:10]) is 12 bytes, not 13. That needs to be fixed in the header. – user48538 – 2016-07-21T13:32:58.140

4

Atari Basic, 29 Bytes

1 for i=1 to 10
2 ? i
3 next i

user902383

Posted 2016-07-21T08:58:19.090

Reputation: 1 360

1 for i=1 to 10:? i:next is probably more concise? I'm certain that Atari BASIC allows multi-statemented lines – Shaun Bebbers – 2018-03-09T10:30:15.457

Also if Atari BASIC is similar to Commodore (Microsoft) BASIC, you won't need to say next i - simply next – Shaun Bebbers – 2018-03-09T10:31:23.407

4

BrainFuck, 55 Bytes

+++++++++>-->-[-----<+>]+++++++++[-<.+<.>>]<<[->-<]>.-.

Output:

1   2   3   4   5   6   7   8   9   10

(Indents as seperators)

Try it here:

https://fatiherikli.github.io/brainfuck-visualizer/#KysrKysrKysrPi0tPi1bLS0tLS08Kz5dKysrKysrKysrWy08Lis8Lj4+XTw8Wy0+LTxdPi4tLg==

Cameron McCluskie

Posted 2016-07-21T08:58:19.090

Reputation: 346

4

Plain TeX (58 bytes)

\newcount\c\loop\advance\c1 \the\c\ \ifnum\c<10\repeat\bye

enter image description here

musarithmia

Posted 2016-07-21T08:58:19.090

Reputation: 531

4

, 7 bytes

⩤ 1,Ⅹ

Prints out

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

Implicit print, is 10 and is range(a, b) so the overall pseudocode is stdout.write(range(1, 10))

Note that, while it is only 5 characters, it still takes up 7 bytes, this is due to the and the not being ASCII characters. (Ⅹ is the Roman numeral version)

emiflake

Posted 2016-07-21T08:58:19.090

Reputation: 131

O my god, another ESMin golfer! Yay! Also, ⩤⁽1Ḋ is 4 chars/7 bytes ( is the variable for 10, and groups numbers/variables into arguments). – Mama Fun Roll – 2016-08-02T15:05:36.087

@MamaFunRoll Yeah, ESMin is awesome! Thanks for the tip. – emiflake – 2016-08-02T15:07:31.027

3

Vim, 9 keystrokes

I saw that there was already a vim answer, but it's not the shortest, so I thought I'd post the shortest one for completeness sake.

10O0<esc>v{g<C-a>

This only works in vim 8, or later versions of vim 7.4.

Explanation:

10                  " Ten times:
  O                 " Open a newline
   0<esc>           " And insert a 0
         v{         " Visually select everything
           g<C-a>   " And create an increasing sequence

James

Posted 2016-07-21T08:58:19.090

Reputation: 54 537

huh. Didn't know about the g<C-a> trick. GG. – Zwei – 2016-11-17T02:23:05.557

3

JavaScript, 14 bytes

_=>12345678910

In the question, it doesn't say anywhere that you must use a delimiter. In fact, it says that I can use any output format that I want, so this answer is valid.

ericw31415

Posted 2016-07-21T08:58:19.090

Reputation: 2 229

3

Sinclair ZX80 (4/8K ROM) or Sinclair ZX81/ZX Spectrum (27 tokenized BASIC bytes for the ZX80, 38 tokenized BASIC bytes for the ZX81)

 1 FOR I=1 TO 10
 2 PRINT I
 3 NEXT I

Or (direct mode, probably works on all 8-bit variants of BASIC):

 PRINT 1,2,3,4,5,6,7,8,9,10

Sinclair ZX Spectrum (and other BASIC variants except the ZX80/ZX81):

 1 FOR I=1 TO 10:PRINT I:NEXT I

Simple, no?

Shaun Bebbers

Posted 2016-07-21T08:58:19.090

Reputation: 1 814

3

x86 assembly (32-bit, Linux), 40 bytes

Prints out the numbers from 1 to 10, separated by newlines. The last number is not followed by a newline.

0: 31 db 43 89 d8 b4 0a 50 89 da 42 89 e1 c6 01 30
1: 00 01 50 8d 04 12 cd 80 58 40 3f 73 ee 66 c7 01
2: 31 30 30 e4 cd 80 48 cd 80

Ungolfed:

00000000 <_start>:
   0:   31 db                   xor    %ebx,%ebx
   2:   43                      inc    %ebx
   3:   89 d8                   mov    %ebx,%eax
   5:   b4 0a                   mov    $0xa,%ah
   7:   50                      push   %eax
   8:   89 da                   mov    %ebx,%edx
   a:   42                      inc    %edx

0000000b <loop>:                                                                                     
   b:   89 e1                   mov    %esp,%ecx                                                     
   d:   c6 01 30                movb   $0x30,(%ecx)                                                  
  10:   00 01                   add    %al,(%ecx)                                                    
  12:   50                      push   %eax                                                          
  13:   8d 04 12                lea    (%edx,%edx,1),%eax                                            
  16:   cd 80                   int    $0x80                                                         
  18:   58                      pop    %eax                                                          
  19:   40                      inc    %eax                                                          
  1a:   3f                      aas                                                                  
  1b:   73 ee                   jae    b <loop>                                                      

0000001d <end>:                                                                                      
  1d:   66 c7 01 31 30          movw   $0x3031,(%ecx)                                                
  22:   30 e4                   xor    %ah,%ah
  24:   cd 80                   int    $0x80
  26:   48                      dec    %eax
  27:   cd 80                   int    $0x80

The most notable part of the optimization is the aas instruction, which checks if %al is 10 or above, and, if it is, sets the carry flag, and decrements %al by 6. It is meant to be used to adjust for subtraction—you might find the corresponding aaa, which adds 6 instead, used in a real program here. I have instead made use of it because subtracting 6 gets me 4, which is exactly the number I need for another write syscall—saving me another lea instruction.

ObsequiousNewt

Posted 2016-07-21T08:58:19.090

Reputation: 836

3

Whitespace, 61 59 bytes

[S S S T    N
_Push_1][N
S S N
_Create_Label_0][S N
S _Duplicate][T N
S T _Print_integer][S S S T N
_Push_1][T  S S S _Add][S N
S _Duplicate][S S S T   S T S N
_Push_10][S N
S _Duplicate][T N
S S _Print_char][S N
T   _Swap][T    S S T   _Subtract][N
T   T   S N
_Jump_to_Label_1_if_negative][N
S N
N
_Jump_to_Label_0]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online.

Explanation:

Command    Explanation                 Stack          STDOUT    STDERR

SSSTN      Push 1                      [1]
NSSN       Create Label_LOOP           [1]
 SNS        Duplicate (1)              [1,1]
 TNST       Print as integer           [1]            1
 SSSTN      Push 1                     [1,1]
 TSSS       Add (1+1)                  [2]
 SNS        Duplicate (2)              [2,2]
 SSSTSTSN   Push 10                    [2,2,10]
 SNS        Duplicate (10)             [2,2,10,10]    
 TNSS       Print as character         [2,2,10]       \n
 SNT        Swap top two               [2,10,2]
 TSST       Subtract (10-2)            [2,8]
 NTTSN      Jump to Label_1 if neg.    [2]
 NSNN       Jump to Label_LOOP         [2]

 SNS        Duplicate (2)              [2,2]
 TNST       Print as integer           [2]             2
 SSSTN      Push 1                     [2,1]
 TSSS       Add (2+1)                  [3]
 SNS        Duplicate (3)              [3,3]
 SSSTSTSN   Push 10                    [3,3,10]
 SNS        Duplicate (10)             [3,3,10,10]
 TNSS       Print as character         [3,3,10]        \n
 SNT        Swap top two               [3,10,3]
 TSST       Subtract (10-3)            [3,7]
 NTTSN      Jump to Label_1 if neg.    [3]
 NSNN       Jump to Label_LOOP         [3]

 ...

 SNS        Duplicate (9)              [9,9]
 TNST       Print as integer           [9]             9
 SSSTN      Push 1                     [9,1]
 TSSS       Add (9+1)                  [10]
 SNS        Duplicate (10)             [10,10]
 SSSTSTSN   Push 10                    [10,10,10]
 SNS        Duplicate (10)             [10,10,10,10]
 TNSS       Print as character         [10,10,10]      \n
 SNT        Swap top two               [10,10,10]
 TSST       Subtract (10-10)           [10,0]
 NTTSN      Jump to Label_1 if neg.    [10]
 NSNN       Jump to Label_LOOP         [10]

 SNS        Duplicate (10)             [10,10]
 TNST       Print as integer           [10]            10
 SSSTN      Push 1                     [10,1]
 TSSS       Add (10+1)                 [11]
 SNS        Duplicate (11)             [11,11]
 SSSTSTSN   Push 10                    [11,11,10]
 SNS        Duplicate (10)             [11,11,10,10]
 TNSS       Print as character         [11,11,10]      \n
 SNT        Swap top two               [11,10,11]
 TSST       Subtract (10-11)           [11,-1]
 NTTSN      Jump to Label_1 if neg.    [11]                     Label_1 not found error

Kevin Cruijssen

Posted 2016-07-21T08:58:19.090

Reputation: 67 575

3

MATLAB/Octave, 4 bytes

1:10

Simply prints the numbers 1 through 10 as a vector, with spaces separating them (may have newline if your window is not wide enough)

costrom

Posted 2016-07-21T08:58:19.090

Reputation: 478

3Does it matter that this also outputs ans =? You may need to wrap it in a disp – Suever – 2016-07-22T01:59:32.940

1@Suever no, I don't think so. "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 [...]). However, you may not output any other numbers." There are no extra digits or numbers. – bers – 2016-07-23T18:24:59.940

3

Excel 6 bytes

=ROW(

Select the cells A1:A10, type the above (once only) and ctrl-shift-enter as an array formula (which links the cells in an array, with one common formula).

Note the total lack of numerals entered in this process. :-)

enter image description here

Joffan

Posted 2016-07-21T08:58:19.090

Reputation: 832

Not sure this is allowed. It requires a specific state (A1:A10 selected) and input (1,2,3,4,5,6,7,8,9,10) – Cyoce – 2016-09-02T00:45:51.710

@Cyoce It doesn't require any numeric input. The range selection could potentially be specified with f5 A1:A10 enter which would be 8 more keystrokes. – Joffan – 2016-09-02T16:25:50.957

3

Elixir, 18 bytes

for n<-1..10,do: n

Output:

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

Note: This is using iex, the Elixir REPL.

David Conrad

Posted 2016-07-21T08:58:19.090

Reputation: 1 037

3

Whitespace,

71 bytes, thanks to LeakyNun,

63 bytes, thanks to Kevin

Spaces substituted with S, tabs with T, linefeeds with L:

(extra spaces inserted for readability)

SSSTL LSSTL SLS TLST SSSTSTSL TLS SSSSTL TSSS SLS SSSTSTTL TSST LTSSL LSLTL

Run it!


Output:

1
2
3
4
5
6
7
8
9
10

ABcDexter

Posted 2016-07-21T08:58:19.090

Reputation: 181

@LeakyNun Ok, i'll update the code. I used Notepad++ for the bytecount. – ABcDexter – 2016-07-24T08:42:14.470

Yes, precisely. I've updated the edits you suggested :) – ABcDexter – 2016-07-24T09:09:17.993

1You can save a lot of bytes by changing the two labels to just one byte. – Leaky Nun – 2016-07-24T09:35:58.980

You can also remove the LLL at the end. – Leaky Nun – 2016-07-24T09:36:12.247

1

i.e. here: SSSTL LSSTL SLS TLST SSSTSTSL TLS SSSSTL TSSS SLS SSSTSTTL TSST LTSSL LSLTL LSSSL LLL

– Leaky Nun – 2016-07-24T09:37:07.910

1that would be 71 bytes – Leaky Nun – 2016-07-24T09:40:58.257

1

You can remove the exit and second label: SSSTL LSSTL SLS TLST SSSTSTSL TLS SSSSTL TSSS SLS SSSTSTTL TSST LTSSL LSLTL. It will exit with an error after it has outputted all 10 integers, but that's allowed according to the meta. Try it online (63 bytes).

– Kevin Cruijssen – 2018-03-13T20:28:13.833

3

ShadyAsFuck, 10 9 bytes

PPPPPz_G]

This is basically ++++++++++[>+.<-] in BrainFuck and outputs the numerical values as character codes.

Try It Online!

flawr

Posted 2016-07-21T08:58:19.090

Reputation: 40 560

Removing a byte: PPPPPz_G] – Addison Crump – 2016-08-02T20:13:53.190

3

T-SQL, 53 46 Bytes

Saved 7 bytes thanks to @t-clausen.dk

DECLARE @ INT=1z:PRINT @ SET @+=1IF @<11GOTO z

Also 17 bytes (though it feels like cheating):

PRINT 12345678910

S.Karras

Posted 2016-07-21T08:58:19.090

Reputation: 241

Can be done easier, here are 2 examples - fiddle

– t-clausen.dk – 2016-08-29T09:31:29.563

3

Stata, 40 bytes

loc i=1
wh `i'<11 {
di `i'
loc i=`i'+1
}

Output

1
2
3
4
5
6
7
8
9
10

f1rstguess

Posted 2016-07-21T08:58:19.090

Reputation: 181

Hello, and welcome to PPCG! Do you need all the whitespace? – NoOneIsHere – 2016-09-01T17:36:55.963

Thank you. Yes, the whitespace is required, alas. – f1rstguess – 2016-09-01T17:43:07.817

You can use a global (gl) instead of local. Then you access the variable with $i. That should save some bytes. I'm happy to find another STATA user on PPCG! – bmarks – 2017-02-17T05:06:10.233

3

Morse code, 65 bytes

.---- ..--- ...-- ....- ..... -.... --... ---.. ----. .----- ----

Copy and paste here to try it out (and listen to the code): http://morsecode.scphillips.com/translator.html

f1rstguess

Posted 2016-07-21T08:58:19.090

Reputation: 181

3

Hexagony, 31 bytes

<8!~\\\..)\M\~={{'$;$@.......9$

Try it Online!

Still feeling that there are too many no-ops. Had a 34 bytes first draft:

<{."@;.)!.8.{{..M.\\.\'.$(...0=..1

Expanded 31 bytes solution

   < 8 ! ~
  \ \ \ . .
 ) \ M \ ~ =
{ { ' $ ; $ @
 . . . . . .
  . 9 $ . .
   . . . .

As in the first draft, uses a < to deflect the IP to NW direction.

This trick is found to be quite useful (for me) when the ending path is short enough after a loop.

Instead of using 10, I used 9 and negate it so the loop is still running 10 times (-9 -8 ... 0 all to the "Left" branch).

Although I managed to increase the number of no-ops in the main loop (NW), I can't modify the main loop due to positioning concerns... Maybe easier to golf off more bytes without using the negation trick.

And though I very much like re-using ops, this time I left a lot of no-ops and used a lot of $ skip commands to keep the loop running.

Oh I really love this language!

Sunny Pun

Posted 2016-07-21T08:58:19.090

Reputation: 821

2

Befunge-98, 9 bytes

1+:.:9`kq

Shortened from 11 thanks to a suggestion from ais523.

A step by step description:

1    push 1 to stack.
+    pop top two stack items and add them. push result.
     popping an empty stack returns 0, which is why
     this works the first loop around.
:    dup top.
.    print top of stack as integer.
     Funge-98 standard states that integer printing
     puts a space afterward automatically.
:    dup top.
9    push 9.
`    pop two items, first b then a.
     push 1 if a > b, else 0.
k    execute next char n times.
     n is top of stack.
     if n is 0, the next char is just skipped.
q    quit.

This program loops because Funge-98 lines wrap around.

Old Versions

11 bytes

1+:.:a\`!kq

snail_

Posted 2016-07-21T08:58:19.090

Reputation: 1 982

The not(10>TOS) (a\\!) calculation is taking up quite a lot of space here, and you might be able to shorten it. Wouldn't it be shorter to translate this simply as TOS>9 (9``)? – None – 2016-11-16T04:39:07.830

Right, that is a lot better! Down to 9 chars now. – snail_ – 2016-11-16T19:10:02.970

My solution would have been a-:!k@b+:. for 10 bytes

– MildlyMilquetoast – 2017-06-19T17:19:39.800

2

Python 3 (REPL): 17 Bytes

list(range(1,11))

Outputs a list of ints!

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

Try it online!

MildCorma

Posted 2016-07-21T08:58:19.090

Reputation: 39

1Provide a reason for down voting please. This meets the requirements of the challenge in less bytes than the other Python 3 example on here. I would also love to have commented on that solution, but i need rep to do anything on here... – MildCorma – 2017-01-26T15:36:46.447

3I did not downvote, but if you actually run this as a python program, it won't output anything; this only works in the REPL. I don't see that as a reason to downvote. though. – HyperNeutrino – 2017-01-26T15:39:36.320

2

Commodore BASIC, method 1 (28 bytes)

0?1,2,3,4,5,6,7,8,9,10

Method 2 (27 26 bytes)

0FORI=1TO10:?I:NEXT

Method 3 (40 39 bytes)

0I=1
1?I:I=I+1:IFI<11THEN1

Method 4 (32 31 bytes)

0?I:I=I+1:IFI<11THEN0
I=1:GOTO0

Method 5 (20 bytes)

0?"12345678910

Method 6 (25 bytes) CBM BASIC V2 only [C64/C64Mini or VIC-20]

0I=I+1:?I:ON-(I<10)GOTO

I'm working out the memory used with ? 38911-(fre(0)-65536*(fre(0)<0)) on a Commodore 64.

Shaun Bebbers

Posted 2016-07-21T08:58:19.090

Reputation: 1 814

2

TI-Basic, 9 bytes

seq(I,I,1,10

Timtech

Posted 2016-07-21T08:58:19.090

Reputation: 12 038

2

PHP, 23 bytes

while($i<10)echo++$i,_;

prints a trailing delimiter, run with -nr.

or

<?=join(_,range(1,10));

(already posted by BusinessCat a year ago)

or

for(;$i++<10;)echo$i,_;

(by Ismael Miguel in a comment to BusinessCat´s answer)


21 bytes without the delimiters: while($i<10)echo++$i; or <?=join(range(1,10));

21 bytes with native array output: print_r(range(1,10)); (run with -r)

Titus

Posted 2016-07-21T08:58:19.090

Reputation: 13 814

But the first one was already posted almost an year ago by Business Cat in his PHP solution, where you also participated in the discussion… [confused smiley]

– manatwork – 2017-07-07T15:22:21.920

@manatwork True ... Didn´t find that when I browsed the answers. I added references. – Titus – 2017-07-07T15:34:03.110

2

Brain-Flak, 30 bytes

((()()()()()){}){(({})[()])}{}

Try it online!

James

Posted 2016-07-21T08:58:19.090

Reputation: 54 537

2

Commercial, 649 bytes

A now 1 dollar off!
B now 1 dollar off!
A has been selling out worldwide!
A: made by the makers of B
A has been selling out worldwide!
A: made by the makers of B
A has been selling out worldwide!
A: made by the makers of B
A has been selling out worldwide!
A: made by the makers of B
A has been selling out worldwide!
A: made by the makers of B
A has been selling out worldwide!
A: made by the makers of B
A has been selling out worldwide!
A: made by the makers of B
A has been selling out worldwide!
A: made by the makers of B
A has been selling out worldwide!
A: made by the makers of B
A has been selling out worldwide!
A: made by the makers of B

Try it online!

I tried to do this in a loop, but Jumps in Commercial are weird and I couldn't get it to work properly

Skidsdev

Posted 2016-07-21T08:58:19.090

Reputation: 9 656

2

Fortran 95, 32 bytes

It was the only language I know that was not used yet :P

program o
print*,(i,i=1,10)
end

Thiago Oleinik

Posted 2016-07-21T08:58:19.090

Reputation: 341

2

Kotlin, 16 bytes

print((1..9)+10)

Beautified

print((1..9)+10)

Test

fun f() =
print((1..9)+10)

fun main(args: Array<String>) {
    f()
}

TIO

TryItOnline

jrtapsell

Posted 2016-07-21T08:58:19.090

Reputation: 915

2

brainfuck, 53 bytes

++++++++++[->+++++>+>+<<<]>-->-[-<+.>>.<]<--------.-.

Try it online!

Explanation :

++++++++++              # set initial counter to ten
[->+++++>+>+<<<]        # creates ascii cell, second counter, and newline
>-->-                   # fixes ascii and counter cell values
[-<+.>>.<]              # prints digits one through nine
<--------.-.            # prints the ten

Output:

1
2
3
4
5
6
7
8
9
10

X1M4L

Posted 2016-07-21T08:58:19.090

Reputation: 1 586

It's not really different enough from the previous answer for me to upvote, but I appreciate the explanation. Also, this answer is much shorter

– Jo King – 2018-02-21T03:49:44.220

1And welcome to PPCG! – Jo King – 2018-02-21T03:56:08.047

2

Keg, 12 bytes

1(91+|:. ,1+

Output is separated by spaces

How it works

1   Pushes 1
(   Begins for loop
91+|   For loop will run 10 times
:.     Output the top element of the stack
 ,     Output space
1+     Add one to the top element of the stack
End bracket gets added automaticly

Try it Online!

EdgyNerd

Posted 2016-07-21T08:58:19.090

Reputation: 1 106

I am working on supporting \ in loop conditions as in this (1 byte less)

– None – 2019-08-10T13:54:09.990

Oh yeah, I did try that and was wondering why that wasn't working, but I just compromised with 91+ – EdgyNerd – 2019-08-10T13:57:51.877

That isn't working because you can't escape a character in a for loop repetition indicator. If you read the implementation, you will find that the escaping character is simply skipped. (I just created a PR for it. JonoCode9374 will probably merge it.) – None – 2019-08-10T14:00:51.393

Whoops, there is an issue in my source code that makes it in fact 2 bytes less. (A 1-to-10-printing program written using 10 bytes!)

– None – 2019-08-10T14:05:45.463

Should we create a Keg chatroom to discuss new features and golfing? – EdgyNerd – 2019-08-10T14:31:08.340

Yes of course. I have created one, but no one chatted there. It is possibly because I created it too early. – None – 2019-08-10T14:34:28.297

I have created a solution that is 1 byte shorter. (I have neither an idea how I wrote my program nor how the program does the countup.)

– None – 2019-08-10T14:36:55.157

Oh wow, thought mine was pretty optimal. Can you link me to that chatroom? – EdgyNerd – 2019-08-10T14:38:57.577

I can't find it anymore. It is probably frozen. You might want to create a chatroom yourself. – None – 2019-08-10T14:40:50.270

Ok, done

– EdgyNerd – 2019-08-10T14:45:51.523

2

Brian & Chuck, 17 bytes

1	1{?
!{.+>-?>.-.

Try it online!

code:

Brian:
1   1   ("1", 9, "1") constants
{?      restart Chuck's code

Chuck:  
{       Move Brian to the leftmost character
.+      Print and increment character
>-      decrement counter
?       if counter is greater than zero, switch to Brian (restart Chuck's code)
>.-.    print 10

Dorian

Posted 2016-07-21T08:58:19.090

Reputation: 1 521

2

Hexadecimal Stacking Pseudo-Assembly Language, 54 bytes

203039400000120000201A8540000012000020000A400000120000

Try it online!

203039 input 0x3039 (decimal 12345)
400000 push that on stack
120000 print it
201A85 input 0x1A85 (decimal 6789)
400000 push that on stack
120000 print it
20000A input 0xA (decimal 10)
400000 push that on stack
120000 print it

Dorian

Posted 2016-07-21T08:58:19.090

Reputation: 1 521

2

BrainFuck, 41 Bytes

-[----->+>+<<]>---<++++[->+.+.<]>+.>--.-.

Output

12345678910

Try it online

Parsa Shahzeidi

Posted 2016-07-21T08:58:19.090

Reputation: 21

2

naz, 50 bytes

1x1f1a1o2x1v0m9a1a1o1v0x1f1f1f1f1f1f1f1f1f8s1o1s1o

Explanation (with 0x commands removed)

1x1f                   # Function 1
    1a1o               # Add 1 to the register and output
        2x1v           # Store the new value in variable 1
            0m9a1a1o   # Output a newline
                    1v # Read variable 1 into the register
1f1f1f1f1f1f1f1f1f     # Call function 1 nine times
8s1o                   # Subtract 8 and output
1s1o                   # Subtract 1 and output

sporeball

Posted 2016-07-21T08:58:19.090

Reputation: 461

2

Dyvil, 20 bytes

for(x<-1..10)print x

21 bytes

for x<-1..10{print x}

Two ways to do the same thing: for-each loop over the range 1..10 with type-inferred loop variable x. The loop body calls the built-in print(int) function with the argument x.


22 bytes

print{for x<-1..10{x}}

This version calls the built-in print(AutoPrinter.()->void) method. An AutoPrinter instance is implicitly available to the {for ...} block, which is passed as an anonymous function. The AutoPrinter class has an applyStatement(any) method, which is called when an expression like x appears in a statement context. The implementation forwards to print(any), which prints the expression.


24 bytes

(1..10).forEach(print _)

Functional approach; creates an IntRange object and calls its forEach(int -> void) (higher order) method. The argument is an anonymous lambda function that passes the argument to the aforementioned print(int) method. In this case, print _ is syntactic sugar for the lambda expression x => print x. Again, the types are inferred by the compiler, so that it internally becomes (int x) => print x.


Output in all cases:

1
2
3
4
5
6
7
8
9
10

Clashsoft

Posted 2016-07-21T08:58:19.090

Reputation: 835

2

Brachylog, 6 5 bytes

Saved one byte thanks to @mat

10yb.

Try it online!

Explanation

10y        Get the list [0:1:2:3:4:5:6:7:8:9:10]
   b.      Output is that list minus the first element

Fatalize

Posted 2016-07-21T08:58:19.090

Reputation: 32 976

5 bytes: 10yb. – mat – 2016-07-21T11:57:43.900

@mat Thanks, I didn't thought of that, even though it's even simpler! – Fatalize – 2016-07-21T12:00:31.913

2

Lua, 25 Bytes

for i=1,10 do print(i)end

Katenkyo

Posted 2016-07-21T08:58:19.090

Reputation: 2 857

2

Julia 0.2, 11 bytes

print(1:10)

Pretty self explanatory. 1:10 is a range, and print expands it.

Elenian

Posted 2016-07-21T08:58:19.090

Reputation: 71

2

Perl 5.10, 14 13 bytes

Almost the same as Perl 6:

say for 1..10

I could've done something like say"@{[1..10]}" which is the exact same thing as in Perl 6, but it is too long. :p

Each number is outputted on a separate line.

Thanks to manatwork for saving 1 byte!

Try it here!

Paul Picard

Posted 2016-07-21T08:58:19.090

Reputation: 863

1No need for parenthesis around statement modifier's condition. – manatwork – 2016-07-21T14:10:01.087

@manatwork Indeed, thanks! – Paul Picard – 2016-07-21T14:11:52.727

2OP says separators are ok but not required. I'd just use say 1..10 – Alex Howansky – 2016-07-21T17:47:11.307

2

Brainfuck, 66 Bytes

Sadly, Someone found a 58 Bytes solution, but as we both have different way of solving this, I'll post mine anyway.

+++[>+++>++<<-]>>+[>+++++++<-]>[>+>+<<-<+>]<--<[>>>.+<<.<-]>>>>.-.

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

Here's what the tape looks like at each step, the * shows where the pointer lies.

+++[>+++>++<<-] tape (0*:9:6)cell-2: counter for printing;cell-3: used for ascii-value of 1
>>+[>+++++++<-] tape (0:9:0*:49) 49 is the ascii value of 1
>[>+>+<<-<+>]   tape (0:9:49:0*:49:49) duplicate it 3 times
<--<            tape (0:9*:47:0:49:49) one will be used as a delimiter "/"
[>>>.+<<.<-]    tape (0:0*:47:0:57:49) outputs the numbers 1..9 separated by "/"
>>>>.-.         tape (0:0:47:0:49:48) outputs 10

Katenkyo

Posted 2016-07-21T08:58:19.090

Reputation: 2 857

2

Common Lisp, 29 bytes

(dotimes(n 10)(print(+ n 1)))

CocoaBean

Posted 2016-07-21T08:58:19.090

Reputation: 309

2Perhaps this would save 1 byte? (dotimes(n 10)(print(1+ n))) – gsl – 2016-07-23T08:11:15.353

2

QBIC, 9 bytes

[1|10:?a]

Explanation

[       ]  FOR <x> = ...NEXT; note that <x> becomes the symbol a-z, based on availability
 1|10      <x> goes from 1 to 10, an increment could be specified with ||
     :     End of FOR-loop specification
      ?a   Print the value of a

EDIT: A non-competing entry saves me one byte two bytes:

[q|z:?a

QBIC now supports variable params for FOR, and q through z are initialised in QBIC to represent 1-10, so saved a byte on the 10. Woohoo! Also, QBIC now detects any unclosed language constructs (IF/DO/FOR) at the end of a program and auto-closes 'm.

EDIT2: QBIC now has a variable number of parameters for its FOR loops. It by default assumes a loop from 1 to 10. Providing 1 parameter (y) makes it run from 1 to y, Providing 2 parameters (x and y) loops from x to y. Providing 3 parameters changes the interval: FOR a = x TO y STEP z. Using the defaults gives us this 4-byter:

[|?a

steenbergh

Posted 2016-07-21T08:58:19.090

Reputation: 7 772

2

Convex, 3 bytes

A´`

Try it online!

GamrCorps

Posted 2016-07-21T08:58:19.090

Reputation: 7 058

2

Swift 3 (Jun 20, 2016), 20 bytes

print(Array(1...10))

Try it online!

Just doing print(1...10) (un)surprisingly prints 1...10 to STDOUT, so we need to unwrap the Range object into an Array. A Set would be shorter, but does not guarantee order (and in practice doesn't, either).

CAD97

Posted 2016-07-21T08:58:19.090

Reputation: 1 367

2

Cheddar, 7 bytes

->1|>10

Prett simple. |> is range operator. [0, 10] is:

->|>10

Downgoat

Posted 2016-07-21T08:58:19.090

Reputation: 27 116

What does -> do? Also pretty* – Cyoce – 2016-09-02T01:15:26.893

@Cyoce -> is a function with no arguments. Like ()=> in JavaScript but in Cheddar if you have no args you can drop the parens – Downgoat – 2016-09-02T01:49:41.350

2

Python3 : 22 19 bytes

print(*range(1,11))

Output:

1 2 3 4 5 6 7 8 9 10

ABcDexter

Posted 2016-07-21T08:58:19.090

Reputation: 181

1That output is not for that code. range() with a single parameter generates starting from 0. – manatwork – 2016-11-14T10:53:47.490

@manatwork Oh, my bad. Updating it :) – ABcDexter – 2016-11-14T11:09:55.043

2

UGL, 20 bytes

cuuuuu$+$Rl$d:_lorO:

Try it online!

Leaky Nun

Posted 2016-07-21T08:58:19.090

Reputation: 45 011

2

Hexagony, 37 Bytes

Minified:

........./..\..10$\("\.$...).>{<!@.._

Try It Online!

Layed Out:

   . . . .
  . . . . .
 / . . \ . .
1 0 $ \ ( " \
 . $ . . . )
  . > { < !
   @ . . _

X88B88

Posted 2016-07-21T08:58:19.090

Reputation: 91

The challenge isn't entirely clear about this, but I think using no delimiter at all is not the OP's intention.

– Martin Ender – 2016-08-13T20:12:05.510

2

Latex, 62 Bytes

\documentclass{book}\begin{document}12345678910\end{document}

Thanks @egreg

Chad

Posted 2016-07-21T08:58:19.090

Reputation: 391

2

R, 9 bytes

cat(1:10)

cat prints, 1:10 creates the numbers 1 to 10.

user5957401

Posted 2016-07-21T08:58:19.090

Reputation: 699

2

Brain-Flak, 30 bytes

((()()()()()){}){(({})[()])}{}

Try it online!

Explanation

For a documentation of what each command does, see the GitHub page.

((()()()()()){}){(({})[()])}{}

((()()()()()){})                 push 10
                {(({})[()])}     while top != 0: pop top, push top, push top-1
                            {}   pop

Leaky Nun

Posted 2016-07-21T08:58:19.090

Reputation: 45 011

2

Java, 47 bytes

()->{for(int i=0;i++<10;System.out.print(i));};

Ungolfed test program

public static void main(String[] args) {
    Runnable r = () -> {
        for (int i = 0; i++ < 10; System.out.print(i));
    };

    r.run();
}

36 bytes (non competing)

()->IntStream.range(0,11).toArray();

Doesn't include imports :(

Shaun Wild

Posted 2016-07-21T08:58:19.090

Reputation: 2 329

2

TrumpScript, 45 bytes

Say "1 2 3 4 5 6 7 8 9 10"!
America is great.

Don't even try using a loop... it's much much longer.

Edit: to clarify, TrumpScript uses only numbers greater than 1,000,000, so counting from 1 to 10 would require a lot of variables.

Aryaman

Posted 2016-07-21T08:58:19.090

Reputation: 161

2

Dip, 2 bytes

Tl

Body must be at least 30 characters; you entered 16.

Oliver Ni

Posted 2016-07-21T08:58:19.090

Reputation: 9 650

1

Brainf***, 57 Bytes

++++[>++++<-]>[>++>+++>+++<<<-]+++++++++[>>+.<.<-]>>>+.-.

This is my first attempt at a program in this language. I think it's pretty optomized

bioweasel

Posted 2016-07-21T08:58:19.090

Reputation: 307

Are you sure? I'm afraid this in best case outputs the characters with codes 1..10 (“␁␂␃␄␅␆␇␈␉␊”), not the numbers 1..10. – manatwork – 2016-11-16T20:19:05.880

Yeah, so that's my bad. The Esoteric IDE that I'm using has it print out 1,2,3...10 – bioweasel – 2016-11-16T20:22:11.270

1Okay, I've redone it. Does that look better? – bioweasel – 2016-11-16T21:29:39.467

Yepp, except the . immediately after the last loop, which outputs an unnecessary ␀ character. – manatwork – 2016-11-17T11:17:12.220

Ha. Forgot about that. I was using that for troubleshooting. Thanks for the help! – bioweasel – 2016-11-17T15:18:45.720

1

MATLAB, 4 Bytes

1:10

Output:

 1     2     3     4     5     6     7     8     9    10

The colon operator acts as a range function in Matlab, working from the preceding number to second one, with a default step of 1. (1:3) returns [1,2,3]

As for printing, MatLab Auto prints any line not terminated with a semicolon; Printing a line actually saves space!

Ando Bando

Posted 2016-07-21T08:58:19.090

Reputation: 731

1

Brainfuck, 59 Bytes

+++++[>++++++++++>++<<-]>-<+++++++++[>.+>.<<-]>---------.-.

Mitchell Humphrey

Posted 2016-07-21T08:58:19.090

Reputation: 348

1

Cubix, 12 bytes

\;;u>)ONo-?@

Test it online! I will add an explanation within the next few hours.

ETHproductions

Posted 2016-07-21T08:58:19.090

Reputation: 47 880

1

Pushy, 3 bytes

TR_

(non-competing as the language postdates the challenge)

It's extremely simple:

T  % Push 10
R  % Generate range (1 to 10, including both endpoints)
_  % Output representation of stack (1 2 3 4 5..)

FlipTack

Posted 2016-07-21T08:58:19.090

Reputation: 13 242

1

SmileBASIC, 19 bytes

FOR I=1TO 10?I
NEXT

Nothing to see here

12Me21

Posted 2016-07-21T08:58:19.090

Reputation: 6 110

1

Batch: 36 bytes

for /l %%i in (1,1,10) do (echo %%i)

Breakdown:

for: for operation in batch. Similar to C.

/l: option for the above command

%%i: define %%i, or %i in CMD, just like how you would define i in a for loop in C

in (1,1,10): pretty much "in (start, step, increment)", or in C " for (start, increment, step)".

do: well, run the code after this each time %%i is between 1-10.

(echo %%i): print %%i which is going from 1 to 10

180Five

Posted 2016-07-21T08:58:19.090

Reputation: 37

1

Q/KDB+ 8 Bytes

1+til 10

Explanation:

til 10

Outputs list of numbers 0 to 9

1+

Increments each number in the list by one

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

Adam J

Posted 2016-07-21T08:58:19.090

Reputation: 81

1 byte shorter using k shorthand 1+(!)10 – streetster – 2017-06-15T22:26:59.377

1

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]

Jimmy Johnson

Posted 2016-07-21T08:58:19.090

Reputation: 71

1

Microscript, 7 bytes

10c1p]h

Microscript II, 10 bytes

0s{1+Ps}s10*

SuperJedi224

Posted 2016-07-21T08:58:19.090

Reputation: 11 342

1

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

steenbergh

Posted 2016-07-21T08:58:19.090

Reputation: 7 772

@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?) – steenbergh – 2018-02-03T11:54:26.957

1

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.)

– DLosc – 2018-02-03T17:48:00.473

1

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.

xyz123

Posted 2016-07-21T08:58:19.090

Reputation: 123

1

J-uby, 4 bytes (non-competing)

10.+

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

Cyoce

Posted 2016-07-21T08:58:19.090

Reputation: 2 690

So, what is J-uby? Is it like Ruby's analog of Pyth, combined with J or something like that? – Zacharý – 2017-06-19T20:41:58.213

@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. – Cyoce – 2017-06-19T20:45:07.340

(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? – Zacharý – 2017-06-19T20:47:17.327

@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. – Cyoce – 2017-06-19T20:52:37.980

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? – Zacharý – 2017-06-19T21:02:48.420

@ZacharyT If I ever learn Perl I'll have to try that. It certainly is the authority on wacky language features. – Cyoce – 2017-06-19T21:05:26.193

1

PHP (with goto) - 46 38 34 bytes

More byte-saving suggestion from Shaggy:

<?php Z:echo@++$i;if($i<10)goto Z;

And people say that goto is the work of the Devil. Or something.

Try it online

PHP (goto-less) - 30 29 bytes

<?php while(@$i<11)echo@$i++;

PHP - 11 bytes

12345678910

Well, someone had to?

Shaun Bebbers

Posted 2016-07-21T08:58:19.090

Reputation: 1 814

1Save 4 bytes by replacing ten with a single character variable name and another 4 by removing the php. – Shaggy – 2019-06-11T11:43:47.690

Thanks, then I won't have goto ten but anyways – Shaun Bebbers – 2019-06-11T15:41:38.943

1Why is the 11-byte version non-competing? This is a [tag:kolmogorov-complexity] challenge; hardcoded answers are allowed. – pppery – 2019-09-20T23:27:03.787

Okay I will amend if you say that I must. – Shaun Bebbers – 2019-09-21T10:13:26.747

1

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)

Charlie

Posted 2016-07-21T08:58:19.090

Reputation: 11 448

4 bytes now – ASCII-only – 2018-02-21T01:01:03.253

1

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

Stephen

Posted 2016-07-21T08:58:19.090

Reputation: 12 293

1

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.

Stan Strum

Posted 2016-07-21T08:58:19.090

Reputation: 436

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 [...]). – Tornado547 – 2017-12-29T07:17:46.607

This means that ST is valid – Tornado547 – 2017-12-29T07:18:01.920

@Tornado547 wow, that is odd. many thanks – Stan Strum – 2017-12-30T03:49:59.380

1

Julia 0.6, 11 bytes

show.(1:10)

Try it online!

gggg

Posted 2016-07-21T08:58:19.090

Reputation: 1 715

1

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?

DLosc

Posted 2016-07-21T08:58:19.090

Reputation: 21 213

1

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)

Hugh Williams

Posted 2016-07-21T08:58:19.090

Reputation: 51

1

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!

Yytsi

Posted 2016-07-21T08:58:19.090

Reputation: 3 582

1

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)

Bolce Bussiere

Posted 2016-07-21T08:58:19.090

Reputation: 970

1

Pyt, 3 bytes

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

Try it online!

FantaC

Posted 2016-07-21T08:58:19.090

Reputation: 1 425

1

hakr14

Posted 2016-07-21T08:58:19.090

Reputation: 1 295

1

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...

Brian H.

Posted 2016-07-21T08:58:19.090

Reputation: 513

1

Stax, 2 bytes

Am

Run online

Added for completeness.

A       Push 10
 m      Map over range, implicit output

Weijun Zhou

Posted 2016-07-21T08:58:19.090

Reputation: 3 396

1

Jotlin, 15 12 bytes

p((0..9)+10)

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

jrtapsell

Posted 2016-07-21T08:58:19.090

Reputation: 915

1

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)

moonheart08

Posted 2016-07-21T08:58:19.090

Reputation: 693

1

(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

Yotam Salmon

Posted 2016-07-21T08:58:19.090

Reputation: 201

1

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

Jhynjhiruu Rekrap

Posted 2016-07-21T08:58:19.090

Reputation: 61

1

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.

Bubbler

Posted 2016-07-21T08:58:19.090

Reputation: 16 616

1

Deadfish~, 4 bytes

{io}

Try it online!

Increment, then output; repeat ten times.

Reinstate Monica

Posted 2016-07-21T08:58:19.090

Reputation: 1 382

1

(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.

user85052

Posted 2016-07-21T08:58:19.090

Reputation:

0ėɧ 3 bytes in the new interpreter – Lyxal – 2019-09-16T04:24:30.870

ėø once I add the ø operator – Lyxal – 2019-09-16T04:26:08.983

1

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.

roblogic

Posted 2016-07-21T08:58:19.090

Reputation: 554

1

Seed, 4232 4039 3981 bytes

To be golfed.

11 806065440241409087125357198607542800075970572928765093042958164984128856153119364694304946533565974155065813564463607464907294493213625991570210498180131922642836049048379926678214090306958078942950505666942158861663318082805922649360548872276728753092705551896201785489318797454097467866454815778688721780170362909784978852186756623253868868917034035335528463229661772327867673360158173714723733025733656646487909489808220640703644162017799947346882823939914644265408484708544566367174322747059393061445510836708923637982737011363312927325448282786060215442674975310709523697911998742881715764878830975686475127091070151990734113230052589483007904386955837951416230150553553131824081272209795780490205576443141598594094128682959852257277648831764416301409205933849585487706444517684177487650836580944108733813423567329150282262574305747736976499413900964122878760201959007114022481011295839141271138446203186069264532462250500186116493184286012088625239590991537830133224608224949348931933311034455280978164515936125672561757104517575527099692465553902153481143524868360127998596923638301974413167583429193105287970847431486813381197765539764522094782334194830005111603128673518265195317929281022739571069159575305773074583173243911197334517405412628068284686691469982559791730541223895403558031955848768117060646768348463561209935808045637507281128179915889035768211511504144114447348017724691523076211025635445333081644368060430405389019848215116047520242946447978917490619742817523907421559319563570816232286092378925478777387843124296450405990835394943021252863488969545687903232603331252281246680860082655523490245738107512918342578050153655018310720283275985429190062871812385817909146120892975424714212971890662091259299688100739835789852338707333214399083184648552682989269071097042033924364887158088125417342061047907455595001558776113845342454604060641417114322284932278126981432767955018317987960683429833483125151020913178712494155310545261553444170641615117711305756617133820567957209040625095889033833683868477968222981257864647555382502179925116320599028456728151421211950504164587366555426478479957000176097833838329163859553682184378396176530388849222864560228925976975341162944244301834305126128097819354250219559409487388887032429560483598135806164050794728591878728116747953265919795701481292222092677282626562421120330436952746759320383166496345689472683465785160396471114988424810146619802843389460581036625456336614635949441077117888570209114560201469774858952308539634363125726651042307946127813908314293240378846347559662225224004298822713302904050471977675138246925540751643515879128105969891674920959645532198204680833150120401421252646736795292132103275342152265451058336500878555688383134027160586652276624279294501247326175308886148638933724425782375226226354458022684652099014849380343822015940473137950787091045988775407006084669595433268270085699081145780497235745383972369977375564713816849012360495596752065665250235877504147680897910657602532177993907221958136528121236676455264099257048759319470710174615005668917675853889646496531814039709503285164186416096735666867062585670181891889551756178657495723233678891549411496581200696462439988553007997103954989290028776888309286564702133992674291744804531900851060090385178725409757099606879757766288322010567612896350258272282241111517435795569303408578713936760574865986977532034796036053889911992836923158428809242575557886427002935479153509101800373188079516076598125218940752155364580400861924119667725548877677649837117601878482958020472764206345843076482381692875591020886968748894499648171413242376922343979630964910668516043571246988639289969853916731069660002514237788846617524295024699798200028558752532671916185460167291108476912591550362203490594401624213451585637461718363114331483866061411154610681167668195013207060532734483192219734129165226320299742868143084807270641847983148272764305800992489421803505337228286598600236556437401089147741524552516814465259338644189950504662

Try it online!

Krzysztof Szewczyk

Posted 2016-07-21T08:58:19.090

Reputation: 3 819

1

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.

Ben

Posted 2016-07-21T08:58:19.090

Reputation: 131

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.) – Value Ink – 2019-09-16T23:52:35.443

I mean, just alert([1,2,3,4,5,6,7,8,9,10]) is way shorter – Jo King – 2019-09-17T00:39:47.523

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 – Value Ink – 2019-09-17T04:37:17.137

(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. – Ismael Miguel – 2019-11-18T11:43:21.780

1

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.

user85052

Posted 2016-07-21T08:58:19.090

Reputation:

1

Clojure REPL, 12 bytes

(range 1 11)

I think this is self explanatory code

Ampersanda

Posted 2016-07-21T08:58:19.090

Reputation: 121

Hello and welcome to PPCG. The challenge asks for a program to output to stdout, meaning you either need to add println or potentially declare your language as "Clojure REPL" per standard rules. – Jonathan Frech – 2019-09-17T07:25:02.647

Oh I see, thank you – Ampersanda – 2019-09-18T01:30:47.833

1

Turing Machine Language, 199 bytes

0 * 1 r 1
1 _ _ r 2
2 * 2 r 3
3 _ _ r 4
4 * 3 r 5
5 _ _ r 6
6 * 4 r 7
7 _ _ r 8
8 * 5 r 9
9 _ _ r a
a * 6 r b
b _ _ r c
c * 7 r d
d _ _ r e
e * 8 r f
f _ _ r g
g * 9 r h
h _ _ r i
i * 1 r j
j * 0 r k

Try it online!

ouflak

Posted 2016-07-21T08:58:19.090

Reputation: 925

1

Putt, 2 bytes

X:
X # Roman Numeral for 10
 : # Ranger operator pushes [1..N]
    # Putt implicitly prints

ajmwagar

Posted 2016-07-21T08:58:19.090

Reputation: 11

1

Perl 5, 13 bytes

say for 1..10

Example execution

perl -E 'say for 1..10'

booshlinux

Posted 2016-07-21T08:58:19.090

Reputation: 81

1

Poetic, 163 bytes

this is asking a lot
o,i admit i was a victim
i was tired of this situation
o,i had a break
i couldnt be sicker of it
thats a very different outcome than i thought

Try it online!

Outputs the numbers from 1 to 10, separated by ASCII 0 (NUL) characters.

For being such a simple type of program, this was an interesting challenge to golf.

JosiahRyanW

Posted 2016-07-21T08:58:19.090

Reputation: 2 600

1

Intcode, 49 bytes

4,15,1001,15,1,15,8,15,16,14,1006,14,0,99,-1,1,11

Why am I still doing this? Because it's fun. That's why.

Lyxal

Posted 2016-07-21T08:58:19.090

Reputation: 5 253

1

Wren, 28 bytes

System.write((1..10).toList)

Try it online!

Explanation

System.write(              )  // Output
             (1..10)          // Numbers from 1 to 10
                    .toList   // Converted to a list

user85052

Posted 2016-07-21T08:58:19.090

Reputation:

1

Intcode, 44 42 bytes

-2 bytes thanks to rootbeersoup

204,8,9,8,1205,8,0,99,1,2,3,4,5,6,7,8,9,10

Try it online!

Isn't it unfortunate that a just-hardcode solution outgolfs the other intcode answer by six bytes?

pppery

Posted 2016-07-21T08:58:19.090

Reputation: 3 987

Saves 2 chars: 204,8,9,8,1205,8,0,99,1,2,3,4,5,6,7,8,9,10 – rootbeersoup – 2020-01-30T05:33:16.243

1

W z, 4 bytes

10aM

Just does a range from (implicit) 1 to 10.

user85052

Posted 2016-07-21T08:58:19.090

Reputation:

1

Spice, 55 bytes

My solution is posted as to the language spec, which currently fails because of an interpreter bug. To run against the interpreter the score falls to 63 bytes due to 2 NUL statements being required.

;a@ADD a 1 a;SWI a 10 0;LOD std::sort.spice ^a a;OUT a;

Or with the additional NULs.

;a@NUL;NUL;ADD a 1 a;SWI a 10 2;LOD std::sort.spice ^a a;OUT a;

Un-golfed Explanation

;a@          - declare variable 'a'
ADD a 1 a;   - ADD a[0] to 1 and insert at a[0], empty "a" implicitly 0
SWI a 10 0;  - If a[0] < 10, jump to line 0 (ADD...)
LOD std::sort.spice ^a a; - Use std lib to sort a 1->10
OUT a;       - Output a

Slord6

Posted 2016-07-21T08:58:19.090

Reputation: 71

1

GolfScript, 6 bytes

It hasn't been done? Then great. Generates 0 to 10 and removes 0, then it evaluates.

11,1>`

Try it online!

user85052

Posted 2016-07-21T08:58:19.090

Reputation:

1

W, 2 bytes

Tk

Constant 10, then range from 1 to that. Added for completeness.

user85052

Posted 2016-07-21T08:58:19.090

Reputation:

1

Batch, 35 bytes

@for /l %%i in (1,1,10)do @echo %%i

Hardcoding would have saved 10 bytes...

Neil

Posted 2016-07-21T08:58:19.090

Reputation: 95 035

you can cut the CR/LF to save two bytes. – peter ferrie – 2018-03-16T04:15:16.453

@peterferrie But there is no CR/LF... – Neil – 2018-03-16T08:48:07.310

1

Bubblegum, 17 bytes

00000000: 026f eafc 0f98 211e 5d50 d0aa 25bc 6f2a  .o....!.]P..%.o*
00000010: d1                                       .

Outputs 1 2 3 4 5 6 7 8 9 10. The program is compressed using BB96, whereas other schemes are longer due to compression-format headers.

LegionMammal978

Posted 2016-07-21T08:58:19.090

Reputation: 15 731

1

PHP, 20 bytes

1 2 3 4 5 6 7 8 9 10

Standard output is implicit outside of PHP tags when reading from a file or standard input.

I'm assuming that an empty separator does not meet the 'arbitrary separator' constraint.

1133261

Posted 2016-07-21T08:58:19.090

Reputation: 137

2

Hardcoding the output is a standard loophole.

– Neil – 2016-07-21T19:02:03.563

6@Neil, except [tag:kolmogorov-complexity]. – Qwertiy – 2016-07-22T19:34:34.590

1

Pyke, 2 bytes

TS

Try it here!

one_range(10)

Blue

Posted 2016-07-21T08:58:19.090

Reputation: 26 661

1

ListSharp, 37 bytes

[FOREACH NUMB IN 1 TO 10 AS i]
SHOW=i

Pretty straight forward

as a sidenote => is this cheating?

SHOW="10,9,8,7,6,5,4,3,2,1"

downrep_nation

Posted 2016-07-21T08:58:19.090

Reputation: 1 152

1

Hardcoding the output is a standard loophole.

– Neil – 2016-07-21T19:04:24.957

"Often, this vulnerability is an indicator of a dumb question" – downrep_nation – 2016-07-21T19:27:32.713

1@Neil, except [tag:kolmogorov-complexity]. – Qwertiy – 2016-07-22T19:34:10.463

1

Racket, 15 bytes

(cdr(range 11))

Racket's interpreters implicitly print return values of expressions to standard output, which is nice.

Steven H.

Posted 2016-07-21T08:58:19.090

Reputation: 2 841

1

Lua, 26 bytes

for i=1,10 do print(i) end

Prints them in seperate lines.

TheCrimulo

Posted 2016-07-21T08:58:19.090

Reputation: 21

1

Duplicate of Katenkyo's answer posted ~9 hours earlier.

– manatwork – 2016-07-22T08:37:54.173

1

Excel VBA, 47 Bytes

Sub t()
For i = 1 To 10: MsgBox i: Next
End Sub

tjb1

Posted 2016-07-21T08:58:19.090

Reputation: 561

You can lose 9 bytes by condensing your whitespace down and removing the () following Sub to Sub t For i=1To 10:MsgBox i:Next End Sub – Taylor Scott – 2017-03-25T20:51:30.050

1

Scala, 14 bytes

print(1 to 10)

output

Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

leonidv

Posted 2016-07-21T08:58:19.090

Reputation: 131

1

Minecraft 26

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

I know there is no special clue in it but I don't know.

Real answer:

scoreboard objective add a dummy

Repeating

give @p wool
stats entity @p set AffectedItems a @p
scoreboard player set @p a 0
clear @p wool 0 0
tellraw @p {"selector":"@p","objective":"a"}

Roman Gräf

Posted 2016-07-21T08:58:19.090

Reputation: 2 915

IIRC you don't need the quotes when using the say command. But this is not relevant, because your answer with the say command is invalid anyway, because hardcoding the output is a standard loophole everywhere other than at [kolmogorov-complexity] challenges. See http://meta.codegolf.stackexchange.com/a/1063/29672

– CocoaBean – 2016-07-23T11:22:08.297

@CocoaBean This IS [tag:kolmogorov-complexity] – SuperJedi224 – 2017-01-26T18:54:24.900

1

Racket, 12 bytes

(range 1 11)

Prints '(1 2 3 4 5 6 7 8 9 10).

Gibstick

Posted 2016-07-21T08:58:19.090

Reputation: 119

1

Befunge, 14 * 3 - 1 = 41 bytes

0v          <
 >:1+::.55+-|
            @

Quick and dirty befunge '93 solution. I'm sure it could be improved, maybe I'll look into it tomorrow. 41 bytes is the 14 * 3 grid in total, excluding a final newline, there are actually 16 characters in the source.

rael_kid

Posted 2016-07-21T08:58:19.090

Reputation: 341

1

Go, 73 bytes

package main 
import "fmt"
func main(){for i:=1;i<11;i++{fmt.Println(i)}}

Try it online!

Ronronner

Posted 2016-07-21T08:58:19.090

Reputation: 129

1Hello, and welcome to PPCG! This is a great first post. – NoOneIsHere – 2016-07-21T21:03:32.077

Normally, we use a header like I edited in with the number of bytes in your submission. – NoOneIsHere – 2016-07-21T21:05:25.353

1

Element, 13 bytes

10'[1+2:`\
`]

Try it online

This outputs one number per line with a trailing newline. This can be shorted to 12 bytes if I replace the newline with a letter (like the letter x). It works by creating a FOR loop, which repeatedly increments the top of the stack, duplicates it, and outputs it.

PhiNotPi

Posted 2016-07-21T08:58:19.090

Reputation: 26 739

Nice! You're in your element! :D – mbomb007 – 2016-07-21T21:16:18.850

1

JS, 75 Bytes

a=[0,1,2,3,4,5,6,7,8,9,10]; for(a[0];a[0]<a.length;a[0]++){alert(a[a[0]]);}

Ronronner

Posted 2016-07-21T08:58:19.090

Reputation: 129

1

Befunge-93, 12 bytes

1::.9`#@_1+#

Explanation:

1             Start stack with the number 1
  :.          Print the number on top of the stack
 :  9`        Set (number on top of the stack) > 9
      #       Skip the next character, which would otherwise stop the program
        _     Is the number in the top of the stack true (i.e. not 0)?
       @      If yes, stop the program
         1+   If no, add 1 to the top of the stack
           #  Skip the next character. Since we're at the edge of the program,
              it would wrap to the beginning, so the character being skipped is
              the "1" at the left edge. That is, "don't put 1 on the stack again"

user55852

Posted 2016-07-21T08:58:19.090

Reputation:

110 bytes – Jo King – 2018-02-01T02:12:31.140

1

Maple, 10 bytes

seq(1..10)

Output:

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

DSkoog

Posted 2016-07-21T08:58:19.090

Reputation: 560

1

F# 17 bytes

Equal to Haskell !! yuppee.

printf"%A"[1..10]

Output:

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

For each number on a separate line, 28 bytes:

Seq.iter(printfn"%d")[1..10]

If you remove the standard output permission, simply [1..10] prints out the numbers in F# interactive.

[1..10];;
> val it : int list = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10]

asibahi

Posted 2016-07-21T08:58:19.090

Reputation: 371

1

Linux ASM, 52 Bytes

file format elf32-i386


Disassembly of section .text:

08048060 <_start>:
 8048060:   31 c9                   xor    ecx,ecx
 8048062:   31 db                   xor    ebx,ebx
 8048064:   31 d2                   xor    edx,edx
 8048066:   31 ff                   xor    edi,edi
 8048068:   43                      inc    ebx
 8048069:   66 81 c7 20 31          add    di,0x3120
 804806e:   57                      push   edi
 804806f:   89 e7                   mov    edi,esp
 8048071:   42                      inc    edx
 8048072:   42                      inc    edx
 8048073:   83 c1 0a                add    ecx,0xa

08048076 <loc_16h>:
 8048076:   87 cf                   xchg   edi,ecx
 8048078:   31 c0                   xor    eax,eax
 804807a:   83 c0 04                add    eax,0x4
 804807d:   83 ff 01                cmp    edi,0x1
 8048080:   75 08                   jne    804808a <loc_2ah>
 8048082:   c7 04 24 20 31 30 ff    mov    DWORD PTR [esp],0xff303120
 8048089:   42                      inc    edx

0804808a <loc_2ah>:
 804808a:   cd 80                   int    0x80
 804808c:   66 ff 41 01             inc    WORD PTR [ecx+0x1]
 8048090:   87 cf                   xchg   edi,ecx
 8048092:   e2 e2                   loop   8048076 <loc_16h> 

C0D3R3D

Posted 2016-07-21T08:58:19.090

Reputation: 11

1

golflua, 13 characters

(Rewrite of Katenkyo's Lua answer. Appreciations should be expressed by upvoting the original answer.)

~@i=1,10w(i)$

Sample run:

bash-4.3$ golflua -e '~@i=1,10w(i)$'
1
2
3
4
5
6
7
8
9
10

manatwork

Posted 2016-07-21T08:58:19.090

Reputation: 17 865

1

Verbosy 31 Bytes

~0 /0 ~10 /1 :a: ^0 o \0 -1 >-a

Verbosy is a language that I wrote btw. The explanation can be found in README.md.

Sweeper

Posted 2016-07-21T08:58:19.090

Reputation: 131

1

JavaScript, 30 bytes

for(i=0;i++<10;)console.log(i)

But I still love it that good old for beats all the pretty ES versions:

[...Array(10)].map((_,i)=>console.log(i+1)) 43 Bytes
alert([...Array(10)].map((_,i)=>i+1)) 37 Bytes
alert(Array(10).fill().map((_,i)=>i+1)) 39 Bytes
i=[...Array(11)].keys();i.next();alert([...i]) 46 Bytes
alert([...[...Array(11)].keys()].slice(1)) 42 Bytes
alert([...Array(11).keys()].slice(1)) 37 Bytes

Titus

Posted 2016-07-21T08:58:19.090

Reputation: 13 814

why do you need the |0 in the second functional solution? – Paolo Bonzini – 2016-07-22T16:30:36.063

@Paolo Bonzini: not needed ... copy&paste leftovers – Titus – 2016-07-22T16:37:47.467

1Someone already did this, although they used alert instead of console.log. – Neil – 2016-07-22T19:48:42.553

@Neil: Thought I had browsed all answers. Can you link it? – Titus – 2016-07-22T20:09:15.320

@Titus It was one of the first ;)

– Swivel – 2016-07-22T20:13:10.143

Actually I thought about replacing console.log with alert, but see my comment on the question. – Titus – 2016-07-22T20:23:49.770

1

LOLCODE, 67 55 bytes

VISIBLE 1 AN 2 AN 3 AN 4 AN 5 AN 6 AN 7 AN 8 AN 9 AN 10

OldBunny2800

Posted 2016-07-21T08:58:19.090

Reputation: 1 379

2VISIBLE "1 2 3 4 5 6 7 8 9 10" is only 30 bytes. – Leaky Nun – 2016-07-22T16:52:17.130

Oh wow. i'm dumb. – OldBunny2800 – 2016-07-22T16:57:25.583

I can't do that exactly though because the challenge is to print integers, not strings. – OldBunny2800 – 2016-07-22T16:58:45.037

2Is there any difference in the result? – Leaky Nun – 2016-07-22T16:59:04.880

Not to the user reading the output, but to the compiler yes. – OldBunny2800 – 2016-07-22T17:00:01.193

1

Alright, it's a loophole anyway.

– Leaky Nun – 2016-07-22T17:01:18.303

1This is [tag:kolmogorov-complexity] which is an exception to the loophole, right? – OldBunny2800 – 2016-07-22T17:03:47.617

wait... – Leaky Nun – 2016-07-22T17:04:29.273

I don't know, people here seem to avoid that loophole.

– Leaky Nun – 2016-07-22T17:05:40.400

@OldBunny2800 Correct. – SuperJedi224 – 2017-01-26T15:55:00.453

1

JavaScript with UnderscoreJS, 20 Bytes

alert(_.range(1,11))

Titus

Posted 2016-07-21T08:58:19.090

Reputation: 13 814

A similar solution was posted here. Posting a comment suggesting a byte improvement may be a good option next time :) – Swivel – 2016-07-22T20:16:32.910

That´s not one byte, that´s 50%. – Titus – 2017-07-28T05:36:43.077

1

JShell (Java 9), 37 36 bytes

for(int i=1;i<11;i++)printf("%d ",i)

Java 9 has a REPL called JShell. You'll need an early access build of Java 9 to run it. Once it's installed, just run jshell, paste, and voilà !

Realized after looking at other solutions that newlines aren't a requirement. Saved 1 byte.

David Conrad

Posted 2016-07-21T08:58:19.090

Reputation: 1 037

1

Brainfuck, 34 bytes

With input checkbox checked.

,.>,-.>++++++++[<<+.>.>-],.-.!1!1

Output

1 2 3 4 5 6 7 8 9 10

Roger Perkins

Posted 2016-07-21T08:58:19.090

Reputation: 19

I don't think this challenge is supposed to take input. – James – 2016-07-22T18:15:09.950

Are you sure this is a correct solution? The code isn't supposed to take input at all, something that the ! suggests. – Erik the Outgolfer – 2016-11-14T14:01:50.913

1

Kona, 5 bytes

Code:

1+!10

Output:

1 2 3 4 5 6 7 8 9 10

Aearnus

Posted 2016-07-21T08:58:19.090

Reputation: 251

1

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.

DarkPhantom

Posted 2016-07-21T08:58:19.090

Reputation: 191

seems that 7 is missing – roblogic – 2019-09-15T03:57:11.240

1@roblogic wow, you are right, fixed. – DarkPhantom – 2019-09-16T15:48:17.037

1

GolfScript, 5 bytes

11,(;

Try it online!

CocoaBean

Posted 2016-07-21T08:58:19.090

Reputation: 309

The official interpreter produces no whitespace (or comma) between the values. – primo – 2016-07-24T11:58:01.000

1

CoffeeScript, 19 characters

console.log [1..10]

Sample run:

bash-4.3$ coffee -e 'console.log [1..10]'
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]

On-line test

manatwork

Posted 2016-07-21T08:58:19.090

Reputation: 17 865

1

MoonScript, 17 characters

(Rewrite of Katenkyo's Lua answer. Appreciations should be expressed by upvoting the original answer.)

for i=1,10print i

Sample run:

bash-4.3$ moon <(echo 'for i=1,10print i')
1
2
3
4
5
6
7
8
9
10

manatwork

Posted 2016-07-21T08:58:19.090

Reputation: 17 865

1

TI-BASIC, 9 bytes

seq(X,X,1,10

TI-BASIC is tokenized, so seq( is represented as 1 byte, as are all the other characters. The seq function is actually more powerful: the first X is an expression, and the second X is the variable that is used in the expression using the values 1 to 10, instead of using the predefined variable for X. For example, the squares of the numbers from 1 to 10 would be seq(X²,X,1,10.

NinjaBearMonkey

Posted 2016-07-21T08:58:19.090

Reputation: 9 925

1

JavaScript, 31 bytes

for(i=1;i<11;i++)console.log(i)

Just a for loop that prints the number on every execution. The range of the for loop is 1 to 10.

Davis

Posted 2016-07-21T08:58:19.090

Reputation: 131

1

This is essentially the same as another answer.

– NinjaBearMonkey – 2016-07-23T15:23:34.053

1

Clojure, 20 bytes

(print (range 1 11))

Output:

(1 2 3 4 5 6 7 8 9 10)

Lightbulb1

Posted 2016-07-21T08:58:19.090

Reputation: 111

1

C++ : 67 bytes

#include<iostream>
int main(int i){for(;i<11;std::cout<<i++<<",");}

Output:

1 2 3 4 5 6 7 8 9 10

ABcDexter

Posted 2016-07-21T08:58:19.090

Reputation: 181

1

I think it would be enough to just count the pure code without the main function and the include, the C# solution also didnt do it http://codegolf.stackexchange.com/a/87419/53809

– Tom Doodler – 2016-08-16T14:13:40.350

1

VIM, using Bash and coreutils: 9 bytes

:!seq 10

ttq

Posted 2016-07-21T08:58:19.090

Reputation: 111

2Technically this is 10 bytes because you need to hit <CR> for the command to work. – James – 2016-11-16T21:31:06.297

1

@DJMcMayhem Good point. However, it does not need <CR>for the command to work if the command is passed to vim from the shell vim -c ':r!seq 10'. Of course one has to hit <CR> to execute the command from the shell, but this is then 'technically' not part of the vim command. Slightly different, but one could even argue that a C program without a newline wouldn't be valid either link.

– ttq – 2016-12-06T11:18:41.360

Actually, if you were to take that approach, you wouldn't even need the colon, so it could be 8. I think technically that would be a vimscript answer (or ex?), rather than vim. You could post that as a separate answer I suppose – James – 2016-12-06T23:00:16.570

It can be even reduced to 7 bytes, if you only care about displaying the numbers 1 to 10. Then the r can be omitted too. – ttq – 2016-12-07T12:37:04.343

1

K, 5 Bytes

    1+!10
1 2 3 4 5 6 7 8 9 10

Explanation;

!2    --> 0 1
!5    --> 0 1 2 3 4
!10   --> 0 1 2 3 4 5 6 7 8 9
1+!10 --> 1 2 3 4 5 6 7 8 9 10

Chromozorz

Posted 2016-07-21T08:58:19.090

Reputation: 338

1

C#, 54 bytes

n=>{for(int i=1;i<11;)System.Console.Write(i+++" ");};

TheLethalCoder

Posted 2016-07-21T08:58:19.090

Reputation: 6 930

Only one byte shorter than n=>{System.Console.Write("1,2,3,4,5,6,7,8,9,10");};. Silly C#! Edit: Actually, if I take out the spaces VS added, this comes in at 51... – BMac – 2016-10-19T00:57:24.160

@BMac Yeah but solutions like that are no fun! And with the above I could pass I through as an argument and force it to 1 saving 4 bytes and probably some other changes :) On second thoughts that's disallowed so no I can't do that – TheLethalCoder – 2016-10-19T08:20:53.517

1

RETURN, 7 bytes

1{11
}.

Try it here.

Mama Fun Roll

Posted 2016-07-21T08:58:19.090

Reputation: 7 234

1

Fourier, 12 bytes

Prints a leading newline

10(10aX^o~X)

Try it online!

Beta Decay

Posted 2016-07-21T08:58:19.090

Reputation: 21 478

1

GNU sed, 22 21 bytes

c1 2 3 4 5 6 7 8 9 10

With coreutils, the code is only 7 bytes long!

eseq 10

Adding to the diversity of languages used so far, I present a sed solution. The consensus is that sed is exempt from the "no input" rule, since the script doesn't start without.

Run:

echo | sed -f script.sed

seshoumara

Posted 2016-07-21T08:58:19.090

Reputation: 2 878

1

Emmet (HTML) - 6 bytes

You'll have to excuse me, I'm new to code golf but I think I understand the concept.

{$}*10

Output:

12345678910

Alternatively, if it's required for the numbers to be seperate, adding a p infront of the braces will put it into <p> tags, like so:

<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p>7</p>
<p>8</p>
<p>9</p>
<p>10</p>

It also requires a tab to make it "go", I've left that out of the byte count.

Please let me know if I've stuffed up somewhere. Thanks!

N.J.Dawson

Posted 2016-07-21T08:58:19.090

Reputation: 111

1

Silicon, 3 bytes

(Silicon uses CP037, so 3 bytes, not 4.)

0Â\

Explanation:

0Â\
  \     Push a list with the numbers in the range...
0       Zero
 Â      Ten

m654

Posted 2016-07-21T08:58:19.090

Reputation: 765

1

Seriously/Actually, 3 bytes

9uR

Try it online: Seriously, Actually

Explanation:

9uR
9u   push 9, increment (10)
  R  range(1, 11) ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

Mego

Posted 2016-07-21T08:58:19.090

Reputation: 32 998

1

Java 7, 50 bytes

void m{for(int i=1;i<11;System.out.println(i++));}

nul lun

Posted 2016-07-21T08:58:19.090

Reputation: 121

Welcome to Programming Puzzles & Code Golf! Just so you know, the downvote was cast automatically by the Community user when your answer was edited. I consider this a bug. I'd upvote, but I don't know Java and have no idea how to test your code. Could you maybe include a link to an online interpreter?

– Dennis – 2016-10-18T16:38:15.867

1

APL, 3 bytes

⍳10

Explanation:

⍳   range
10   10

Niclas M

Posted 2016-07-21T08:58:19.090

Reputation: 61

Of course, your ⎕IO must be 1. – Zacharý – 2016-11-15T00:53:09.930

@ZacharyT Which is its default value – user41805 – 2017-03-25T19:48:39.707

Depending on the APL you use. – Zacharý – 2017-03-26T23:18:37.323

1

k, 5 bytes

1+!10

Explanation:

1+ //Projection of +, add 1 to the argument
!10 // "til" 10 - i.e. generate a list of numbers from 0 to n-1

Output:

1 2 3 4 5 6 7 8 9 10

Paul Kerrigan

Posted 2016-07-21T08:58:19.090

Reputation: 189

You can also do 1_!11, which seems faster (at least in kdb+).. count 0..10 then drop the first element, rather than adding 1 to each item of a 10 item list. – streetster – 2017-06-15T22:34:40.833

1

Lithp, 64 bytes

((import "lists")(def f #::((each (seq 1 10) #N::((print N))))))

Fairly simple, but unfortunately fairly verbose. I'm counting the import because modules don't automatically load (ie, each and seq are from the lists module, and need to be imported manually.)

To use:

(
    (import "lists")(def f #::((each (seq 1 10) #N::((print N)))))
    (f)
)

Alternate Answer, 68 bytes, recursive and no modules

(def x #::((def y #N::((print N)(if (< N 10) ((y (+ N 1))))))(y 1)))

Defines a recursive function y which calls itself until N is 10.

I've made this a little more readable here:

(
    (def x #::(
        (def y #N::(
            (print N)
            (if (< N 10) (
                (y (+ N 1))
            ))
        ))
        (y 1)
    ))
    (x)
)

Sadly my language is a bit verbose, but Lisp-like language tend to do that. I'm more interested in ensuring the language can handle everything I'd want to throw at it.

Andrakis

Posted 2016-07-21T08:58:19.090

Reputation: 361

1

DARTMOUTH BASIC,42 BYTES

EH, WHY NOT?

1 FOR I=1 TO 10
2 PRINT I
3 NEXT I
4 END

Zacharý

Posted 2016-07-21T08:58:19.090

Reputation: 5 710

Do you need the 4 END with DARTMOUTH BASIC? Does the symbolic listing not end when there is nothing left to interpret? – Shaun Bebbers – 2019-06-11T15:48:28.590

1

ASMD, 5 bytes

T(i{p

Body must be at least 30 characters; you entered 20.

Oliver Ni

Posted 2016-07-21T08:58:19.090

Reputation: 9 650

1

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)}

F. George

Posted 2016-07-21T08:58:19.090

Reputation: 317

1

APL with any ⎕IO, 9 bytes.

1-⎕IO-⍳10

APL with ⎕IO=0, 5 bytes.

1+⍳10

Zacharý

Posted 2016-07-21T08:58:19.090

Reputation: 5 710

1

Japt, 3 bytes

1oB

This is very simple: o creates a semi-inclusive range between two values, and B is pre-defined to 11. Thus, this creates the range [1..11), or [1,2,3,4,5,6,7,8,9,10], which is automatically sent to STDOUT.

Test it online!

ETHproductions

Posted 2016-07-21T08:58:19.090

Reputation: 47 880

Why not just ? (EDIT: Should have checked the date first!) – Shaggy – 2018-02-20T15:32:23.820

0

Excel VBA, 20 Bytes

Anonymous VBE immediates window function that takes no input and outputs to the VBE Immediates window

For i=1To 10:?i:Next

Taylor Scott

Posted 2016-07-21T08:58:19.090

Reputation: 6 709

0

LibreLogo, 20 bytes

Code:

print set range 1 11

Output:

enter image description here

Grant Miller

Posted 2016-07-21T08:58:19.090

Reputation: 706

0

Triangular, 15 bytes

S](l.U@..i/AS%<

Formats into this triangle:

    S
   ] (
  l . U
 @ . . i
/ A S % <
  1. The first command, S, stashes the top of stack (0) in memory. (This is only so that the U will work the first time.)
  2. ( opens a loop.
  3. U pulls memory onto stack.
  4. i increments the stack value.
  5. < directs the IP left, hitting %, which prints the top of stack as an integer.
  6. S stashes the top of stack in memory.
  7. A pushes 10 to the stack.
  8. / directs the IP up-right, hitting @, which prints the top of stack (10) as ASCII (\n).
  9. l checks if the second-to-last stack value (the counter value) is less than 10.
  10. If so, jump back to (. Otherwise, exit the program.

MD XF

Posted 2016-07-21T08:58:19.090

Reputation: 11 605

14 – Reinstate Monica – 2019-09-16T13:17:59.467

0

tcl, 23

time {puts [incr i]} 10

demo

sergiol

Posted 2016-07-21T08:58:19.090

Reputation: 3 055

0

><>, 10 bytes

llnao:9=?;

Try it online!

Explanation:

This program pushes the length of the stack instead of trying to increment the top of the stack, because l is shorter than 1+, and you can do it to an empty stack.

l             Push the length of the stack. The first time through pushes 0.
 ln           Print the length of the stack. The first time through prints 1.
   ao         Print a linefeed. (ASCII value 10)
     :9=      If the top of the stack is 9 (i.e. we just printed 10), push 1. 
              Otherwise, push 0.
        ?;    If the top of the stack is non-0, end the program.

              Wrap to the start and Repeat. At the end of the loop, we end up
              with one more value on the stack than we started with.

MildlyMilquetoast

Posted 2016-07-21T08:58:19.090

Reputation: 2 907

Whoops, I didn't see the other ><> answer that also uses the length of the stack as an incrementer. I'm going to leave this up, but you should really go upvote them if you're going to upvote me. It's even the same byte count.

– MildlyMilquetoast – 2017-06-19T18:03:25.657

0

anyfix, 3 bytes

⁴RK

Note that TIO says that this is 5 bytes but that is because of the unicode character ; in the codepage of anyfix (which is the same as the Jelly codepage), this solution encodes to 3 bytes.

Explanation

⁴   10
 R  Range [1..10]
  K Join on spaces

Alternatively, ⁴RY separates by newlines. R⁴K and R⁴Y also work because one of the key features of anyfix is that it works with prefix, infix, and postfix (though K and Y will work regardless of what's on the stack because if the top of the stack is not a list or does not exist, then it will use the entire stack as a list). Alternatively, R⁴ or ⁴R and the @l interpreter flag will make it output [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]] because @l makes it output the stack as its string representation in Python.

Try it online!

HyperNeutrino

Posted 2016-07-21T08:58:19.090

Reputation: 26 575

0

8th, 18 bytes

( . cr ) 1 10 loop

Chaos Manor

Posted 2016-07-21T08:58:19.090

Reputation: 521

0

MY (noncompeting), 3 bytes

Here's the hex:

0A 49 27

Finally, a reasonable solution. Explanation:

0A - Push 10 to the stack
49 - Pop n; Push [1 ... n]
27 - Pop n; Output n

Zacharý

Posted 2016-07-21T08:58:19.090

Reputation: 5 710

0

TLDCode, 12 10 Bytes

='1'p9{c+}

Clears the stack of the default input, pushes 1 to the stack, parses it from a string to a number, reapeats c+ 9 times, which copies the top of the stack and pushes to the stop of the stack, then incremetnts it. Implicitly prints the stack with _ as the seperator.

Output

1_2_3_4_5_6_7_8_9_10

Previous attempt (12 bytes)

'1'pe9{n+e}=

Pushes 1 to the stack, parses it from a string to a number and prints, then repeats n+e 9 times, which prints a new line, increments the top of the stack and then prints the top. Then it clears the stack to avoid the implicit printing of the default input.

Output

1
2
3
4
5
6
7
8
9
10

The_Lone_Devil

Posted 2016-07-21T08:58:19.090

Reputation: 191

0

AWK, 26 bytes

BEGIN{for(;i<=9;)print++i}

Try it online!

I don't see an AWK answer, so here we go. I chose to use <=9 rather than <10 just to add a little variety since they have the same byte-count. :)

Robert Benson

Posted 2016-07-21T08:58:19.090

Reputation: 1 339

Initially I had i++ in the for-loop, but that required a space in the print command. – Robert Benson – 2017-06-22T17:39:28.940

1A while loop would be the same length here. – CalculatorFeline – 2017-06-22T20:03:24.263

True, @CalculatorFeline, but since a while loop is never fewer bytes than a for loop, I've gotten out of the habit of using them. – Robert Benson – 2017-06-22T20:19:54.953

I think you can change BEGIN to END to save 2 bytes. – dingledooper – 2019-10-01T23:34:15.487

If you use END, then AWK will expect to receive input. The try online would work, but if you typed it in, it would wait until input was supplied. You could just do a <ctrl-d> in bash, but it still expects something as input when you have an END statement. – Robert Benson – 2019-11-18T15:57:00.880

0

Firebird, 113 bytes

The compacted select, used to calculate the score is below:

WITH RECURSIVE T AS (SELECT 1 AS I FROM RDB$DATABASE UNION ALL SELECT 1+I FROM T WHERE I < 10 ) SELECT * FROM T

The formated select:

WITH RECURSIVE T AS (
  SELECT 1 AS I
  FROM RDB$DATABASE
  UNION ALL
  SELECT 1+I
  FROM T
  WHERE I < 10
)
SELECT *
FROM T

Short explanation: I start with a select on a system table from firebird, witch always has only one record. Then, using recursion on that projection, I add the column "I" until it reaches 10.

Filipe Santos

Posted 2016-07-21T08:58:19.090

Reputation: 21

Welcome to PPCG! Seems like a decent first post, but I think that you could improve it by giving a short explanation for how it works. – Taylor Scott – 2017-06-22T19:56:15.960

1Thanks. Yes, I should have add a short explanation on my answer. Already updated it. – Filipe Santos – 2017-06-22T20:00:54.913

Can you remove some of the spaces/newlines? – CalculatorFeline – 2017-06-22T20:02:50.947

@CalculatorFeline Yes I Can! Will do that now, thanks! – Filipe Santos – 2017-06-22T20:04:23.860

0

Python 2.7, 17 bytes

print range(1,11)

Why 11? The range() function is non-inclusive for the end argument.

repl.it

juniorRubyist

Posted 2016-07-21T08:58:19.090

Reputation: 875

Duplicate of TuukkaX's Python2 answer posted 11 months earlier. (With sufficient privileges you could see that there are already 3 completely or partially identical deleted answers too.)

– manatwork – 2017-06-23T07:51:29.407

@manatwork Oops. Sorry. – juniorRubyist – 2017-06-23T16:16:32.510

0

Swift 3, 20 bytes

print(Array(1...10))

A. Pooja

Posted 2016-07-21T08:58:19.090

Reputation: 41

Welcome on Programming Puzzle & Code Golf. About the downvote on your answer: it was automatically applied by the system when @Toto edited your answer from the "First Post" review queue; but no one actually downvoted it. Happy golfing! – Dada – 2017-06-23T08:44:40.017

0

Python 3, 24 bytes

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

Try it online!

Simon

Posted 2016-07-21T08:58:19.090

Reputation: 129

0

Carrot, 20 bytes

1 2 3 4 5 6 7 8 9 10

Or if we don't need a separator for 11 bytes:

12345678910

Anything before a ^ in Carrot is placed onto the stack and then that is implicitly output at the end of the program.

With the current version of Carrot this seems to be the shortest way of doing it although I would like to post a none hard coded version if I find one.

TheLethalCoder

Posted 2016-07-21T08:58:19.090

Reputation: 6 930

0

Python 2, 19 Bytes

print range(11)[1:]

Try it online!

Rohit-Pandey

Posted 2016-07-21T08:58:19.090

Reputation: 169

0

AnyDice, 10 bytes

output d10

Try it here.

This program creates and outputs a single 10 sided die. This lists out the numbers on the die (1-10) next to a bar graph of the probabilities in the standard output form.

DanTheMan

Posted 2016-07-21T08:58:19.090

Reputation: 3 140

0

Eukleides, 26 bytes

for i=1 to 10
print i
end

Beats hardcoding by 2 bytes.

brhfl

Posted 2016-07-21T08:58:19.090

Reputation: 1 291

0

T-SQL, 27 bytes

Boring answer.

PRINT'1,2,3,4,5,6,7,8,9,10'

Less boring with a WHILE, 51 bytes

DECLARE @ INT=1WHILE @<11BEGIN PRINT @ SET @+=1 END

WORNG ALL

Posted 2016-07-21T08:58:19.090

Reputation: 61

0

><>, 17 Bytes

1>:nao1\
;\?(b:+/

Pretty basic:

1                       | Push 1 to the stack
 >                      | Make sure pointer is going the right direction
  :n                    | Duplicate the number and print it
    ao                  | Print a new line
      1\                | Increment, redirect pointer
      +/                |-┘ 
   (b:                  | Check that the result is less than 11
;\?                     | If it is, continue looping, else end.

Bolce Bussiere

Posted 2016-07-21T08:58:19.090

Reputation: 970

0

Implicit, 10 bytes

(;.@%<10)&

Try it online!

(            do..while loop
 ;            pop (nothing initially, n<10 after that)
  .           increment (0 initially, n after that)
   @          output ASCII value of n for delimiter
    %         output n as integer
     <10      push n<10
        )    loop while top of stack truthy (n<10)
         &   exit (no implicit output)

Output (? denotes an unprintable):

?1?2?3?4?5?6?7?8    9
10

MD XF

Posted 2016-07-21T08:58:19.090

Reputation: 11 605

0

Bitwise, 208 191 175 bytes

-17 bytes using the registers 3 and 4 instead of function frame registers
-16 bytes using position-based jumps instead of LABELs

.A:
AND $1 $2 3
XOR $1 $2 $1
SL 3 &1 $2
JMP &-4 $2
RET $1
.G:
NOT $1 3
A $2 3 4
A 4 &1 4
SR 4 &31 4
AND 4 &1 4
RET 4
.L:
G $2 $1 3
RET 3
A 1 &1 1
OUTI 1 &1
L 1 &10 2
JMP &-4 2

Try it online!

Explanation:

.A:          # subroutine: arg3 = arg1 + arg2
.G:          # subroutine: arg3 = arg1 > arg2
.L:          # subroutine: arg3 = arg1 < arg2
A 1 &1 1     # add l1 (literal 1) to r1 (register 1)
OUTI 1 &1 -1 # output r1 as integer
L 1 &10 2    # set r2 to r1 < 10
JMP &-4 2    # jump 3 lines back in the code if r2 is nonzero

Output:

1 2 3 4 5 6 7 8 9 10 

MD XF

Posted 2016-07-21T08:58:19.090

Reputation: 11 605

0

Cubically, 16 bytes

(*1+1/1%@LUL'B)8

Try it online!

(*1+1/1%@LUL'B)8
(                 do..while loop
 *1+1/1            add 1 to notepad
       %           print notepad as integer
        @          output notepad as ASCII (delimiters)
         LUL'B     algorithm with period 10
              )8  loop while cube unsolved

Output (? denotes an unprintable):

1?2?3?4?5?6?7?8?9   10

MD XF

Posted 2016-07-21T08:58:19.090

Reputation: 11 605

0

FALSE, 18 17 bytes

0[1+$11-][$."
"]#

Explanation:

0 {push 0}
{conditional function}
[
 1+ {add 1}
 $11- {check if 11}
]
{loop function}
[
 $. {print number}
 "
" {print line break}
]
# {while loop (run second function while first returns true)}

12Me21

Posted 2016-07-21T08:58:19.090

Reputation: 6 110

0

uBASIC, 20 bytes

Anonymous function that takes no input and outputs to the console

0Forx=1To10:?x:NextX

Try it online!

Taylor Scott

Posted 2016-07-21T08:58:19.090

Reputation: 6 709

0

Python3 - 19 Characters

print(*range(1,11))

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

Ankit

Posted 2016-07-21T08:58:19.090

Reputation: 29

0

Rust, 42 bytes

fn main(){for i in 1..11{print!("{},",i)}}

Konrad Borowski

Posted 2016-07-21T08:58:19.090

Reputation: 11 185

0

jamal, 17 characters

{@for i/1..10/i }

Sample run:

bash-4.4$ jamal.pl number.jam
1 2 3 4 5 6 7 8 9 10 

manatwork

Posted 2016-07-21T08:58:19.090

Reputation: 17 865

0

Keg, 8 bytes

Still wasn't used to the flags...


Ï_(. ,

Try it online!

user85052

Posted 2016-07-21T08:58:19.090

Reputation:

0

Rogex, 27 bytes

90B300d00901e00100701a20f00

Try it online!

Explained

90B 300 d00 # Set the loop value to 11
901         # Set the buffer to 1
e00         # While the buffer isn't equal to 11
    100 701 # Print the buffer then increment it
    a20     # Print a space
f00         # End loop

Rogex answer number 2! Also, my 101st answer! (´• ヮ •`)

Lyxal

Posted 2016-07-21T08:58:19.090

Reputation: 5 253

0

jq, 12 characters

(11 characters code + 1 character command line option.)

range(1;11)

Sample run:

bash-4.3$ jq -n 'range(1;11)'
1
2
3
4
5
6
7
8
9
10

On-line test

manatwork

Posted 2016-07-21T08:58:19.090

Reputation: 17 865

0

Bc, 14 characters

while(i++<10)i

Sample run:

bash-4.3$ bc <<< 'while(i++<10)i'
1
2
3
4
5
6
7
8
9
10

manatwork

Posted 2016-07-21T08:58:19.090

Reputation: 17 865

0

JavaScript (using external library) (39 bytes)

x=>console.log(_.Range(1,10).Write(""))

Link to lib:https://github.com/mvegh1/Enumerable/

Explanation of code: _.Range creates the array [1,..10], Write joins the array into a string, console.log puts to StdOut

applejacks01

Posted 2016-07-21T08:58:19.090

Reputation: 989

I was thinking about using something like Underscore's range, but figured something pure would be a bit more impressive. Nice solution! – Swivel – 2016-07-21T20:03:49.347

Thanks! Yeah yours is way shorter than mine hahaha, I need to learn the ... syntax! – applejacks01 – 2016-07-21T20:31:06.013

MDN has an article on the Spread Operator :) -- I started with [...Array(10)].map((v,i)=>++i), but that was 30 bytes and I was hoping to do better than the first JavaScript answer on here (24 bytes)! Then I realized that a String is, more or less, just an array of characters. So I tried the spread operator, and viola!

– Swivel – 2016-07-21T20:36:23.377

Ahhhh ok wow I see what its doing. Not bad!! – applejacks01 – 2016-07-21T20:40:03.277

0

JavaScript (Node.JS 5 / Harmony / ES2015), 19 bytes

[...`123456789`,10]

Output

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

Try it here or run node -p -e "[...'123456789',10]"

(For older versions of Node.js, like LTS 4.4.7, use node --harmony)

Swivel

Posted 2016-07-21T08:58:19.090

Reputation: 109

Previous attempts were: [...Array(10)].map((v,i)=>++i) and [...Array(11).keys()].slice(1), but both ended up with 30 bytes, which was less than the other JavaScript submissions here. – Swivel – 2016-07-22T14:41:26.310

1>

  • Your code does not print the integers; but as -p clearly adds functionality to it, there should be some penalty for it imo. 2) When I log that to my console (without node), I get an array with nine strings and one integer 3) This is pretty close to a hard coded result.
  • < – Titus – 2016-07-22T14:56:06.180

    There were both an [...Array(10)].map((_,i)=>i+1) and an [...Array(11).keys()].slice(1) elsewhere, just wrapped with alert making them 37 bytes – Paolo Bonzini – 2016-07-22T16:45:06.410

    @Titus (1) This is Node.JS, not browser-based JavaScript. They are two different things. However, I can kind of see your point with -p. (2) "This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), prefixes and postfixes (like [...])." (3) Arguable. – Swivel – 2016-07-22T20:05:35.687

    @PaoloBonzini You're late to the party. Both of those were posted by Titus four hours ago. Both of which I left in the comments here and on another answer roughly 24 hours ago :) Granted, I didn't put them in my solution, but that's beside the point. -- As for using an alert instead, I defer to (1) in my response to Titus. I primarily develop in Node.JS and use the Node.JS REPL, not browser-based JavaScript. These are two different platforms; similar implementations of a similar spec, but arguably not the same exact thing. I respect the position, though. – Swivel – 2016-07-22T20:10:15.813

    @Swivel: (1) accepted, my mistake. Keep telling people that JavaScript is not Java, now I fall for the same trap. (2) accepted. (3) now that I think of it, yes it is arguable. Ok, I learned some Node.JS from it. – Titus – 2016-07-22T20:19:13.603

    @Titus No problem at all! Learning is what it's all about! :) I've learned a ton looking through the answers on code-golf and others; I'm sure tons of others have too. – Swivel – 2016-07-22T20:22:54.630