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 code-golf, 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>
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.8831Could you clarify whether having no delimiter at all is allowed, too? I.e.
12345678910
? – Martin Ender – 2016-08-13T20:11:21.3332Could 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.3432The "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