53
7
Background
Hello golfers! I would like to learn all the programming languages! But I kinda have a short attention span... and copying all the Hello World examples gets boring... but I like fire! ^w^
Challenge
So here is the plan! I want you all to write the smallest code that will compile, print Goodbye Cruel World!
, and then crash. Or, as a bonus twist challenge, print Hello World!
and crash with Goodbye Cruel World!
Rules
- Your score will be total character count used. The answer must be a whole executable program.
- Your program must print
Goodbye Cruel World!
to output, and then crash (unexpected error).- For a score bonus, you must print
Hello World!
to output instead, but the error message must also containGoodbye Cruel World!
. If you complete the bonus challenge, you may divide your score by 2. (Include a ! at the end of your score if you are claiming the bonus!)
- For a score bonus, you must print
- As long as the standard output still prints, and standard error still prints, the order doesn't matter. Just as long as neither can block the other from happening.
- The output must contain the contents of the above;
"
shouldn't appear in the output. - The output should contain the specified string, and nothing else.
- The crash report can contain anything, but to claim the bonus, the following regex should match
/Goodbye Cruel World!/mi
(aka, contains, ignore case/surrounding text)) - The strings
Hello World!
andGoodbye Cruel World!
are case insensitive, but otherwise should appear exactly as above. - If the language is capable of crashing (it cannot change its exit code), it needs to crash. Otherwise use the standard "error report" (i.e.,
STDERR
) for the language.
I can crash Python 3, so I have included an example Python 3 answer! Now lets all set the world on fire! ^W^
var QUESTION_ID=125282,OVERRIDE_USER=0;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:+r.match(SCORE_REG)[0],language:r.match(LANG_REG)[0].replace(/<\/?[^>]*>/g,"").trim(),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=/\d+((?=!?$)|(?= Bytes))/i,OVERRIDE_REG=/^Override\s*header:\s*/i;LANG_REG=/^[^,(\n\r\|]+/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/Sites/codegolf/all.css?v=617d0685f6f3"> <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>
Comments are not for extended discussion; this conversation has been moved to chat.
– Dennis – 2017-06-08T13:41:04.233as a bonus twist challenge, print "Hello World!" and crash with "Goodbye Cruel World!"
? – Magic Octopus Urn – 2017-06-08T14:34:54.683Suppose I'm working in a language like Java, where STDOUT and STDERR are, of course, printed in different threads. This means that, although the program, in order, prints "Hello world" and then crashes, it is possible that the stack trace will be printed first... Is that allowed? – Socratic Phoenix – 2017-06-08T14:39:55.717
@SocraticPhoenix As long as STDOUT still prints, and STDERR still prints, the order doesn't matter. Just as long as neither can block the other from happening. – Tezra – 2017-06-08T14:45:42.877
@Tezra okay... java's still really long because of boilerplate – Socratic Phoenix – 2017-06-08T14:46:40.263
@carusocomputing print "Hello World!" to STDOUT and print "Goodbye Cruel World!" to STDERR when you crash – Stephen – 2017-06-08T15:21:13.587
@StephenS I meant explain what a "bonus twist challenge" is, not what he was asking for. – Magic Octopus Urn – 2017-06-08T15:48:55.120
@carusocomputing That is further explained in the rules.
For a score bonus, you must print "Hello World!" to output instead, but the debug must also contain "Goodbye Cruel World!". If you complete the bonus challenge, you may divide your score by 2. (Include a ! at the end of your score if you are claiming the bonus!)
– Tezra – 2017-06-08T15:50:11.093@carusocomputing it is an optional bonus challenge to strive for. – Tezra – 2017-06-08T15:51:44.127
Does it actually have to crash, or can it just output to STDERR? – internet_user – 2017-06-08T16:24:33.920
@pycoder If the language is capable of crashing (Exit code != 'OK'), it needs to crash. Otherwise use the standard 'error report' (STDERR) for the language. – Tezra – 2017-06-08T16:54:09.517
The "output box"? The "debug field"? Are we supposed to guess what IDE you use and use the same one? – Peter Taylor – 2017-06-08T17:07:18.347
@PeterTaylor remnant from previous wording. Use Where ever STDOUT and STDERR go to (or is) in your language. – Tezra – 2017-06-08T17:27:34.063
So you must print "Goodbye Cruel World" to STDERR (possibly along with other text) and then have a nonzero exit code? – CalculatorFeline – 2017-06-08T19:00:39.253
@CalculatorFeline to STDOUT then crash. STDERR only matters if you go for the bonus challenge. (Please use @ Tezra in the chat at the top of the comments for further clarifications) – Tezra – 2017-06-08T19:11:13.263
1This is so much fun, I can't stop making solutions! – Adám – 2017-06-09T12:31:08.260
@Adám Thanks! That is part of my goal with my challenges. To be simple, easy, but fun. ^w^ – Tezra – 2017-06-09T12:38:18.077
Can your program print extra text? – ericw31415 – 2017-06-12T14:00:59.583
@ericw31415 Only if that is part of the error output. – Tezra – 2017-06-12T14:16:14.690
This has a bonus, and thus is code-golf. See here.
– Rɪᴋᴇʀ – 2017-06-15T01:52:42.053@Riker Did you mean to say "is not code-golf"? I think it still is, as the bonus is just an optional, harder version. The bonus modifier is just to make it viable as the preferred solution. My other options are post as separate question (would be closed as a dup), or use a different tag (which, at the end of the day, this is just 2 different difficulty code-golf challenges together, so doing that would defeat the point of the code-golf tag). For any rule, there will always be a good exception (I think this use case counts as one) And no one here seems bothered by it. – Tezra – 2017-06-16T15:47:22.233
@Tezra yes, sorry for the typo. And you're right, bonuses are intended to make an alternate solution viable. However, in this case, it's almost always shorter to include the HW part. Printing HW doesn't take as many characters as the goodbye, so it's pretty much guaranteed a bonus solution will be shorter in any given language. – Rɪᴋᴇʀ – 2017-06-16T16:14:21.880
The leaderboard isn't working because of the answer formatting. – 12Me21 – 2018-04-01T00:30:57.017
Related – JayCe – 2018-09-06T17:12:25.063
Does
Goodbye Cruel World
have to go to STDERR even ifHello World
is not included? – Titus – 2018-10-27T03:58:11.743@Titus It goes to STDOUT (or an equivalent); unless you do the bonus challenge which does require Goodbye Cruel World in the error output. – Tezra – 2018-10-29T12:31:11.950