I think the question as above is clear, but just in case:
Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline.
Qualifying programs will be those whose output is longer (in bytes) than the source code of the program, measured in bytes (assuming ASCII or UTF-8 encoding for the program source code).
I.e. the code must be shorter than the number of digits in the resulting number.
Leading zeros are disallowed under all circumstances. Counting leading zeroes trivialises the problem; ignoring leading zeros unnecessarily complicates the question.
The winning program will be the qualifying program which prints the integer with the smallest magnitude.
Leaderboard snippet
var QUESTION_ID = 67921;
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;
function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; }
function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; }
function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); }
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*)(?:,|[-\u2013] ).*?([\d,^!e+]+)(?=\:?[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;
var OVERRIDE_REG = /^Override\s*header:\s*/i;
function getAuthorName(a) { return a.owner.display_name; }
function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); var match = body.replace(/<sup>([^\n<]*)<\/sup>/g, "^1ドル").replace(/\(\d+(?:\^\d+,)? [\w\s]+\)/g, "").replace(/floor\(10\^(\d+)\/9\)/g, "1ドル ones").replace(/(\d+) ones/g, function (_, x) { return Array(+x + 1).join(1); }).match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2].replace(/,/g, "").replace(/(\d+)\s*\^\s*(\d+)/, function (_, a, b) { return Math.pow(a, b); }).replace(/(\d+)!/, function (_, n) { for (var i = 1, j = 1; i <= n; i++) j *= i; return j; }), language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) return -1; return 0; }); for (var i = 0; i < langs.length; ++i) { var language = jQuery("#language-template").html(); var lang = langs[i]; language = language.replace("{{LANGUAGE}}", lang.lang) .replace("{{NAME}}", lang.user) .replace("{{SIZE}}", lang.size) .replace("{{LINK}}", lang.link); language = jQuery(language); jQuery("#languages").append(language); } }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="language-list"> <h2>Shortest Solution 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> <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> <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>
181 Answers 181
Retina, score 1
The empty program counts the number of matches of the empty regex in the input (which is the empty string). That's exactly 1 match, so it prints 1.
-
44\$\begingroup\$ ... WE HAVE A WINNER. \$\endgroup\$Arandur– Arandur2015年12月28日 15:11:04 +00:00Commented Dec 28, 2015 at 15:11
-
10\$\begingroup\$ Just btw, I'd say the number of matches is infinite. The empty string can repeat an unlimited number of times and be matched infinitely. \$\endgroup\$nicael– nicael2015年12月28日 15:19:15 +00:00Commented Dec 28, 2015 at 15:19
-
57\$\begingroup\$ @nicael Luckily, that's not how regex works. ;) \$\endgroup\$Martin Ender– Martin Ender2015年12月28日 15:19:46 +00:00Commented Dec 28, 2015 at 15:19
-
8\$\begingroup\$ @MartinBüttner that depends on your regex engine. I've definitely encountered systems that will crap out if you ever try to match the empty string. \$\endgroup\$Sparr– Sparr2015年12月28日 16:30:42 +00:00Commented Dec 28, 2015 at 16:30
-
22\$\begingroup\$ @LorenPechtel that rule applies only to quine challenges where the empty program is trivially a solution in most languages. I think it's fair game here, since this empty program actually has non-trivial semantics and Retina does not have this behaviour because of challenges like this but because it's the only consistent generalisation of its behaviour for all single-line programs. \$\endgroup\$Martin Ender– Martin Ender2015年12月30日 07:27:15 +00:00Commented Dec 30, 2015 at 7:27
Pyth, 10
T
First attempt at using Pyth. Having had the question clarified, it seems 10 will be the smallest number. In Pyth the letter T starts off as the number 10, so this simply prints 10 which is larger than the length of the source code. You can try it here.
-
110\$\begingroup\$ I like how your first attempt at using Pyth is just the letter T. \$\endgroup\$djechlin– djechlin2015年12月28日 15:34:58 +00:00Commented Dec 28, 2015 at 15:34
-
8
-
2\$\begingroup\$ This is a polygot, this works in 05AB1E too. 05ab1e.tryitonline.net/#code=VA \$\endgroup\$Magic Octopus Urn– Magic Octopus Urn2016年10月24日 16:46:50 +00:00Commented Oct 24, 2016 at 16:46
bc, 10
A
Luckily, bc prints the result of the last expression by default. A is interpreted as a hex digit, so results in 10.
-
2\$\begingroup\$ But there're already (at least) 5 similar answers, including the solution with
A, because many golfing languages are defining A as 10. \$\endgroup\$nicael– nicael2015年12月28日 18:42:25 +00:00Commented Dec 28, 2015 at 18:42 -
49\$\begingroup\$ @nicael Yes, that's true. I claim this answer is different because
bcis not a golfing language. It is in fact a Posix-defined language available by default on just about any standard *nix system you can find. \$\endgroup\$Digital Trauma– Digital Trauma2015年12月28日 18:45:34 +00:00Commented Dec 28, 2015 at 18:45
Fishing, score (削除) 7,958,661,109,946,400,884,391,936 (削除ここまで) 1,208,925,819,614,629,174,706,176
Is this the highest non-trivial-looking score ever in a minimization challenge? (Even though it has been golfed by 84.8%)
v+CCCCCCCCCC
`32`nSSSSP
Explanation
v Sets the casting direction to down
+ Increments the casting distance by 1
CCCCCCCCCC Casts the rod
`32` Pushes a string "32" to the stack
n Converts the stack from a string to an integer
SSSS Repeated squaring of the stack
P Prints the stack
The number is 32^16 and has 25 digits. The code is 24 bytes long. The previous answer was 6^32.
-
2\$\begingroup\$ Brought a tear to my eye. Thank you for your contribution. \$\endgroup\$Arandur– Arandur2015年12月28日 14:53:06 +00:00Commented Dec 28, 2015 at 14:53
-
35\$\begingroup\$ It will probably still beat Java... Hopefully. \$\endgroup\$Arcturus– Arcturus2015年12月28日 14:53:35 +00:00Commented Dec 28, 2015 at 14:53
-
3\$\begingroup\$ Well, it beats C#... \$\endgroup\$LegionMammal978– LegionMammal9782015年12月28日 15:52:53 +00:00Commented Dec 28, 2015 at 15:52
-
\$\begingroup\$ Why 6 and not 9? \$\endgroup\$Stack Exchange Broke The Law– Stack Exchange Broke The Law2015年12月30日 02:10:37 +00:00Commented Dec 30, 2015 at 2:10
-
\$\begingroup\$ @immibis The goal of the challenge is to minimize the score, so it's not just minimizing bytes; putting 9 before would have increased my score unnecessarily. \$\endgroup\$Arcturus– Arcturus2015年12月30日 02:59:47 +00:00Commented Dec 30, 2015 at 2:59
MATLAB, 1,000,000,000 (109)
Also works with Octave
disp(1e9)
Never going to beat the esolangs, but just for fun, this is the smallest MATLAB/Octave will be able to do, so thought I would post it anyway.
-
20\$\begingroup\$ The esolang answers, while valid, are kinda boring. Glad to see one that isn't! \$\endgroup\$Arandur– Arandur2015年12月28日 14:50:25 +00:00Commented Dec 28, 2015 at 14:50
-
1\$\begingroup\$ perl
say 1e9is slightly shorter, if you want to improve your golf score. (Though it's nowhere near the smaller integer for which this approach works...) \$\endgroup\$derobert– derobert2016年01月03日 07:23:35 +00:00Commented Jan 3, 2016 at 7:23 -
\$\begingroup\$ @derobert True. 1e1 would satisfy the problem statement and give a score of 10 (the lower, the better) (Assuming a char is 1 byte) \$\endgroup\$dberm22– dberm222016年01月05日 13:18:15 +00:00Commented Jan 5, 2016 at 13:18
-
\$\begingroup\$ @dberm22
10(2 characters) is not longer than1e1(3 characters) \$\endgroup\$SuperJedi224– SuperJedi2242016年01月05日 14:05:25 +00:00Commented Jan 5, 2016 at 14:05 -
\$\begingroup\$ @SuperJedi224 Ahh, I read it as the magnitude of the printed number has to be larger than the bytecount, not the number of digits in the printed number. Thanks for the clarification. \$\endgroup\$dberm22– dberm222016年01月05日 15:36:59 +00:00Commented Jan 5, 2016 at 15:36
TI-84 BASIC, 120
5!
ᴇ2 would score better if not for the silly UTF-8 requirement. (It's only two bytes in the calculator's native tokenized encoding, but it's 4 in UTF-8...)
-
\$\begingroup\$ Maybe I’m missing something, but the string "E2" is only two bytes in UTF-8... \$\endgroup\$jbg– jbg2015年12月30日 09:10:25 +00:00Commented Dec 30, 2015 at 9:10
-
11\$\begingroup\$ @JasperBryant-Greene
ᴇandEare not the same character. In TI-BASIC,ᴇis scientific notation andEis a variable. \$\endgroup\$SuperJedi224– SuperJedi2242015年12月30日 13:14:16 +00:00Commented Dec 30, 2015 at 13:14 -
4\$\begingroup\$ Thanks :) I should have noticed that the character was subtly-smaller-than-full-height... \$\endgroup\$jbg– jbg2015年12月30日 13:27:22 +00:00Commented Dec 30, 2015 at 13:27
-
\$\begingroup\$ Wouldn't
3!score better? \$\endgroup\$dberm22– dberm222016年01月05日 13:23:52 +00:00Commented Jan 5, 2016 at 13:23 -
1\$\begingroup\$ @NobodyNada This time the question specifically said to score in UTF8, for some reason. \$\endgroup\$SuperJedi224– SuperJedi2242016年05月08日 11:11:12 +00:00Commented May 8, 2016 at 11:11
C#, score (削除) 10^72 (削除ここまで) (削除) 10^70 (削除ここまで) (削除) 10^64 (削除ここまで) 10^63
class A{static void Main(){System.Console.Write($"1{0:D63}");}}
That's 1,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000. I guess that I tried...
-
1\$\begingroup\$ Stunning, really. \$\endgroup\$Arandur– Arandur2015年12月28日 15:46:19 +00:00Commented Dec 28, 2015 at 15:46
-
6\$\begingroup\$ Wouldn't
Write(new string('1',70))be better? \$\endgroup\$lynn– lynn2015年12月28日 18:02:01 +00:00Commented Dec 28, 2015 at 18:02 -
1\$\begingroup\$ You can write it out as a double rather than a string, which shortens it to 10^56 :
class A{static void Main(){System.Console.Write(1e56);}}\$\endgroup\$goric– goric2015年12月30日 17:00:13 +00:00Commented Dec 30, 2015 at 17:00 -
1\$\begingroup\$ @goric That just outputs
1E+56. \$\endgroup\$LegionMammal978– LegionMammal9782015年12月30日 17:50:38 +00:00Commented Dec 30, 2015 at 17:50
JavaScript, score 100,000,000,000 (or 1*1011)
alert(1e11)
This is if using alert. Though you can get 100 000 000 times lesser score if using console:
1e3
Score 1000 as you can see, I'm not sure it counts using the console though.
-
\$\begingroup\$ I don't know why it wouldn't count! \$\endgroup\$Arandur– Arandur2015年12月28日 14:49:17 +00:00Commented Dec 28, 2015 at 14:49
-
7\$\begingroup\$ @Arandur I'm guessing "I'm not sure it counts" refers to the lower score of 1000, since that requires using the console as a REPL, rather than being a full program. \$\endgroup\$trichoplax is on Codidact now– trichoplax is on Codidact now2015年12月28日 14:52:05 +00:00Commented Dec 28, 2015 at 14:52
-
\$\begingroup\$ @tri exactly, made a clarification. \$\endgroup\$nicael– nicael2015年12月28日 14:53:48 +00:00Commented Dec 28, 2015 at 14:53
-
13\$\begingroup\$ +1 for alert, I would not allow the automatic console output \$\endgroup\$edc65– edc652015年12月28日 14:58:26 +00:00Commented Dec 28, 2015 at 14:58
PlatyPar, 59
#
# starts a numeric base-60 literal, and since no digits are found, it ends up as 59. This started as a happy accident, but since I have already [ab]used this bug in another answer, I kept it.
Here's another approach, my take on the boring way that everyone and their grandmother used for this challenge.
PlatyPar, 100000000 (9 digits)
'18Md0+;
Explanation
'1 ## push "1" (a string) to the stack
8Md ; ## repeat 8 times
0+ ## add a 0
## [implicitly] print the result
C, 1000000000000000000000000000 (28 digits)
main(){printf("1%027d",0);}
Similar to my C++ answer, without the #include <stdio.h>
(Ignore the warning about missing declaration of printf. Thanks @Dennis)
Newline would require an additional 2 bytes, using format 1%029d\n
Brainf**k, 11111111111111111111111111111111111 (~1e34)
And another reduction:
+++++++[>+++++++>+<<-]>>[<.....>-]
Which gives 35 consecutive 1's, or approximately 1e34.
A bit smaller still
++++++++[>++++++>+<<-]>+>+[<....>-]
Gives 36 1's which is a number about 11% larger than 1e35.
Thanks to @Martin Büttner for knocking off a couple of characters reducing the total output by a factor of 100 with this code (yields 1e36):
++++++[>++++++++>++<<-]>+.->[<...>-]
My old code (yields 1+e38):
++++++++[>++++++>++<<-]>+.->+++[<..>-]
I've been experimenting with esolangs out of boredom. This is the best I could do in BF. I wonder if it is possible to make it smaller?
You can try it online here.
-
-
\$\begingroup\$ @Mauris impressive! \$\endgroup\$Tom Carpenter– Tom Carpenter2015年12月30日 13:15:47 +00:00Commented Dec 30, 2015 at 13:15
-
\$\begingroup\$ This is not code golf;the goal is to print the smallest number, your score is 10. \$\endgroup\$The Fifth Marshal– The Fifth Marshal2015年12月28日 14:26:02 +00:00Commented Dec 28, 2015 at 14:26
-
\$\begingroup\$ @ppp "The number must be longer in bytes than the program -- have more digits than the code has characters" - OP's just edited. \$\endgroup\$nicael– nicael2015年12月28日 14:32:47 +00:00Commented Dec 28, 2015 at 14:32
-
2\$\begingroup\$ You have not misunderstood; if the Japt program
Aprints 10, then this is a valid program with a score of 10. \$\endgroup\$Arandur– Arandur2015年12月28日 14:34:48 +00:00Commented Dec 28, 2015 at 14:34 -
3\$\begingroup\$ Woohoo, my language is tied for <s>first</s> second place! glares at Retina \$\endgroup\$ETHproductions– ETHproductions2015年12月28日 16:21:20 +00:00Commented Dec 28, 2015 at 16:21
-
5\$\begingroup\$ Any reason for downvote? \$\endgroup\$nicael– nicael2015年12月28日 19:14:18 +00:00Commented Dec 28, 2015 at 19:14
Python 2, 101010101010
print'10'*6
-
2\$\begingroup\$ Since the OP asked for the smallest integer, why did you pick an exponent of seven? Does it print without commas? \$\endgroup\$WGroleau– WGroleau2015年12月29日 04:51:42 +00:00Commented Dec 29, 2015 at 4:51
-
\$\begingroup\$ @WGroleau it does print without any commas, justachat.freevar.com/test.php \$\endgroup\$nicael– nicael2015年12月29日 06:28:11 +00:00Commented Dec 29, 2015 at 6:28
Brainfuck, 3333333333333333333333333 (25 threes)
This is written "from scratch" so I think it's okay to post a separate answer:
-[>+>+<<-----]>-[-->.<]
23 bytes long.
-
\$\begingroup\$ I was considering a bf solution, are there any current interpreters that only output as numbers? \$\endgroup\$Rohan Jhunjhunwala– Rohan Jhunjhunwala2017年05月05日 23:21:46 +00:00Commented May 5, 2017 at 23:21
-
\$\begingroup\$ @RohanJhunjhunwala this outputs 51 (the ASCII code for
"3") 25 times. \$\endgroup\$Level River St– Level River St2017年05月06日 02:16:00 +00:00Commented May 6, 2017 at 2:16 -
\$\begingroup\$ @LevelRiverSt what Im saying is that there might exist a bf interpreter that doesn't input as ascii and only does integer output, thus (-.) would output 255. \$\endgroup\$Rohan Jhunjhunwala– Rohan Jhunjhunwala2017年05月06日 02:32:47 +00:00Commented May 6, 2017 at 2:32
Labyrinth, score 10,000,000
1!!!!>@
It might be possible to bring this down by one order of magnitude, but I can't find anything right now.
The first 1!!!! prints 1000. Then > shifts the source code to
@1!!!!>
which avoids early termination. Then the IP hits a dead end and turns around. Now !!!! prints four more zeroes and @ terminates the program.
Samau, 42
A
A pushes the Answer to the Ultimate Question of Life, The Universe, and Everything onto the stack. Then the top of the stack is automatically printed.
-
1\$\begingroup\$ I think something is wrong with your commit messages :P \$\endgroup\$Doorknob– Doorknob2016年01月03日 07:23:56 +00:00Commented Jan 3, 2016 at 7:23
-
5\$\begingroup\$ @Doorknob冰 I don't know how to write commit messages, so I just use random emojis. \$\endgroup\$alephalpha– alephalpha2016年01月03日 09:17:33 +00:00Commented Jan 3, 2016 at 9:17
-
8\$\begingroup\$ Ok, here's the real question: what does
Qpush? \$\endgroup\$Cyoce– Cyoce2016年03月08日 15:20:03 +00:00Commented Mar 8, 2016 at 15:20
-
3\$\begingroup\$ +1. Yep, I think that's optimal in dc. Unusually bc is shorter. \$\endgroup\$Digital Trauma– Digital Trauma2015年12月28日 19:00:22 +00:00Commented Dec 28, 2015 at 19:00
-
\$\begingroup\$ I thought I was doing well with
6d^p(yielding 46656), but you have that beat - well done! \$\endgroup\$Toby Speight– Toby Speight2016年01月06日 17:19:29 +00:00Commented Jan 6, 2016 at 17:19
-
\$\begingroup\$ Why not
3FNoutputting6? \$\endgroup\$Peter Taylor– Peter Taylor2016年03月25日 07:42:02 +00:00Commented Mar 25, 2016 at 7:42 -
\$\begingroup\$ @PeterTaylor The number has to be greater in length, not greater in magnitude. \$\endgroup\$Addison Crump– Addison Crump2016年03月26日 13:29:43 +00:00Commented Mar 26, 2016 at 13:29
C, 11111111111111111111111111111111111 (35 ones)
main(c){while(c++<36)putchar(49);}
Maybe there's a shorter way. The lack of a simple way to print big numbers in C makes it tricky.
-
\$\begingroup\$ Why not
Y, score 2? \$\endgroup\$Peter Taylor– Peter Taylor2016年03月25日 07:43:19 +00:00Commented Mar 25, 2016 at 7:43 -
2\$\begingroup\$ Because
2is only one character, so it isn't longer than the source code. \$\endgroup\$Dennis– Dennis2016年03月25日 12:48:45 +00:00Commented Mar 25, 2016 at 12:48
Python 2, 107918163081
print 69**6
-
\$\begingroup\$ You can remove the space between
printand the2. \$\endgroup\$Bakuriu– Bakuriu2015年12月29日 19:40:52 +00:00Commented Dec 29, 2015 at 19:40 -
2\$\begingroup\$ @Bakuriu No you can't \$\endgroup\$Blue– Blue2015年12月29日 20:24:38 +00:00Commented Dec 29, 2015 at 20:24
-
\$\begingroup\$
69**6is only107918163081. \$\endgroup\$Neil– Neil2015年12月29日 23:15:23 +00:00Commented Dec 29, 2015 at 23:15 -
2\$\begingroup\$ Interstingly enough, this also works in Perl. \$\endgroup\$Grimmy– Grimmy2016年01月04日 16:17:10 +00:00Commented Jan 4, 2016 at 16:17
-
\$\begingroup\$ Technically, you can remove the space by replacing it with a
+. \$\endgroup\$mbomb007– mbomb0072024年01月29日 15:26:46 +00:00Commented Jan 29, 2024 at 15:26
Java, 111111111111111111111111111111111111111111111111111111111111111111111111111111111 (81 ones)
interface A{static void main(String[]a){for(A i:new A[81])System.out.print(1);}}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I've underlined the part that is actually "variable" here; everything else is absolutely necessary for a working Java program.
Presumably this is shorter than mucking around with Java's BigInteger.
-
\$\begingroup\$ Presumably ... - perhaps
System.out.print(BigInteger.TEN.pow(10));- is that one character less? Sorry - nowhere near big enough - and.pow(10).pow(10)is longer. \$\endgroup\$OldCurmudgeon– OldCurmudgeon2015年12月29日 13:31:23 +00:00Commented Dec 29, 2015 at 13:31 -
\$\begingroup\$ You can replace
interfacewithclass. \$\endgroup\$LegionMammal978– LegionMammal9782015年12月30日 11:46:48 +00:00Commented Dec 30, 2015 at 11:46 -
2\$\begingroup\$ But then
mainwould need to bepublic. \$\endgroup\$lynn– lynn2015年12月30日 12:01:13 +00:00Commented Dec 30, 2015 at 12:01 -
7\$\begingroup\$ you can shave off 2 characters by doing this for the for loop: for(A a:new A[81]) \$\endgroup\$Jack Ammo– Jack Ammo2016年01月01日 21:48:33 +00:00Commented Jan 1, 2016 at 21:48
-
\$\begingroup\$ @OldCurmudgeon Would
.pow(100)not work for some reason? \$\endgroup\$ETHproductions– ETHproductions2016年03月16日 15:50:18 +00:00Commented Mar 16, 2016 at 15:50
Cubix, 100100
@'dOu
Cubix is a 2-dimensional, stack-based esolang. Cubix is different from other 2D langs in that the source code is wrapped around the outside of a cube.
Explanation
The first thing the interpreter does is figure out the smallest cube that the code will fit onto. In this case, the edge-length is 1. Then the code is padded with no-ops . until all six sides are filled. Whitespace is removed before processing, so this code is identical to the above:
@
' d O u
.
Now the code is run. The IP (instruction pointer) starts out on the far left face, pointing east.
The first char the IP encounters is ', which pushes the next byte onto the stack; this byte is d, or 100. Next is O, which outputs the top item (100) as an integer.
Then the IP hits u, which turns it to the right, moves it forward, then turns it again. It switches to the bottom face pointing north, then rotates to the east. This wraps it to the O again, outputting 100, then up to @ which terminates the program.
-
2\$\begingroup\$ It specifies that the text encoding should be UTF-8 - is that followed here? \$\endgroup\$Addison Crump– Addison Crump2015年12月28日 14:58:32 +00:00Commented Dec 28, 2015 at 14:58
-
2\$\begingroup\$ I was going to say -- this might be the first esolang that actually can't trivially answer this question. \$\endgroup\$Arandur– Arandur2015年12月28日 14:59:52 +00:00Commented Dec 28, 2015 at 14:59
-
1\$\begingroup\$ @FlagAsSpam I missed that unusual rule. It's fixed now. \$\endgroup\$Dennis– Dennis2015年12月28日 15:27:18 +00:00Commented Dec 28, 2015 at 15:27
MATL, 1000
1e3
Note: latest GitHub commit of the compiler works on Octave as well as on Matlab.
This interprets the number in scientific notation, and implicitly prints it, thus producing the output
1000
Perl, 1000000000
print 1e9
Straightforward.
-
1\$\begingroup\$ Can't you reduce your score by using
say? \$\endgroup\$Neil– Neil2015年12月29日 23:10:35 +00:00Commented Dec 29, 2015 at 23:10 -
\$\begingroup\$ That would require enabling the
-Eflag, I suppose. I'm not sure how to count that, in this challenge. \$\endgroup\$lynn– lynn2015年12月30日 01:16:55 +00:00Commented Dec 30, 2015 at 1:16 -
1\$\begingroup\$ Since "
-M5.010, when needed, is free," you shouldn't have to count it at all. \$\endgroup\$ThisSuitIsBlackNot– ThisSuitIsBlackNot2015年12月30日 20:47:32 +00:00Commented Dec 30, 2015 at 20:47
C++, 1e46
#include <stdio.h>
main(){printf("1%046d",0);}
Newline would require an additional 2 bytes, using format "1%048d\n"
-
\$\begingroup\$ I don't think C++ allows you to omit the return type of
main(). OTOH, this would make a good C answer... \$\endgroup\$Toby Speight– Toby Speight2018年03月12日 11:01:02 +00:00Commented Mar 12, 2018 at 11:01 -
\$\begingroup\$
#include <stdio.h>=>#include<stdio.h>or even#include<cstdio>\$\endgroup\$l4m2– l4m22022年12月14日 17:12:41 +00:00Commented Dec 14, 2022 at 17:12
O, 10
A
Apparently the score is the number we print!
Explore related questions
See similar questions with these tags.
1.0an integer? \$\endgroup\$