4
Enterprise Quality Code!
TL;DR
- Answers will consist of a full program (of length < 30k) prints the the first N Prime numbers (as a base 10 representation without leading zeros unless the chosen language only supports unary or other based output) separated by newlines (optional trailing linefeed).
- You may post cracks at any time, but you must wait one hour after posting each initial bowled submission
- Leading or trailing whitespace is not acceptable (except for the trailing newline)
- An answer's score is the number of bytes in the answer. A user's score is the total number of bytes of all uncracked answers.
- An answer gets cracked when another user posts an answer (in the same language) which is a permutation of any subset of the characters used in the original answer.
- The user with the highest score will receive an accepted tick mark on his /her highest scoring post (although it doesnt really matter which specific post gets the tick)
The Inspiration for this challenge
At Pretty Good consultants there is a focus on writing "quality" verbose code that is sufficiently engineered. Your boss has decided to test you on your skills.
Consider the set of all programming languages in existence before the posting of this challenge. For this challenge there will technically be one individual "winner" in each language, however the boss will give a
Detailed Spec
The goal of this challenge is to receive an integer N strictly smaller than 2^8-1 and print the first N prime numbers (in less than 24 hours) separated by your platforms choice of new line (a trailing newline is optional). OEIS sequence A000040 in as many bytes as possible in as many languages as possible. However, note that others vying for the promotion will try to "help" you by golfing down your score. (Please note that your prime generation function should theoretically work for integer N inputs strictly smaller than 2^16-1 given enough time, the bounds for N have been reduced after realizing how slow some interpreters are (namely mine) hardcoding the list of primes is strictly forbidden)
Sample output for an input 11
2 3 5 7 11 13 17 19 23 29 31
How to participate
Pick any language X, but please avoid selecting a language which is just another version or derivative of another answer.
If there is no existing answer in language X than you will write a program (which must fit into a single post I.E it must be less than 30k characters) that solves this challenge.
The length in bytes of the source (in any reasonable preexisting textual encoding) will be added to your score. You must avoid using any unnecessary characters for reasons that will soon become apparent.
If language X already has been used to answer this question, then you must answer using any permutation of any proper subset of the characters used in the shortest answer (I.E take the shortest X answer and remove some (>=1) characters and optionally rearrange the resulting code). The previous holder of the shortest X answer will lose all of the bytes provided by his answer from his score, and the number of bytes of your submission will now be added to your score. The number of bytes golfed off gets "lost" forever.
Rules for Languages
You may only crack a submission by posting an answer in the same language (and version), but you are barred from posting an answer in language X if there exists a submission in a sufficiently similar language Y. Please do not abuse this rule posting an answer in a sufficiently similar language will receive disqualification.
Below is a leader board which removes answers with "cracked" (with any case) in their header.
var QUESTION_ID=90593,OVERRIDE_USER=46918;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 a-r});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<>]+>)^(?:(?!cracked)\i.)*[^\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>
8You've managed to stick 3 distinct scoring tags on the same challenge... – Mego – 2016-08-21T22:14:26.147
Can output be a vertical array returned by a function (like this)? Or does it have to go to STDOUT with newlines? Can the array be horizontal?
– Luis Mendo – 2016-08-21T22:26:08.530@LuisMendo I guess a vertical array is acceptable, but not that this is code-bowling and you would be better off adding the additional boilerplate, but it is up to you. I will ammend the question – Rohan Jhunjhunwala – 2016-08-21T22:27:49.057
1@RohanJhunjhunwala I don't get it. If I make it longer someone will golf it down and I lose. So I still have to make it as short as possible. Did I understand correctly? – Luis Mendo – 2016-08-21T22:32:28.207
1@LuisMendo yes if you get greedy someone will make it shorter and you lose.However, it is important to note that if you structure your code such that removal of one or more characters (followed by permuatation) will no tresult in a valid submission, you can aim for a higher score). – Rohan Jhunjhunwala – 2016-08-21T22:33:46.083
@RohanJhunjhunwala I see. Thanks. The rules were a little difficult grasping :-) – Luis Mendo – 2016-08-21T22:34:44.400
So what are the output format restrictions? Can numbers be separated by spaces? It's very important to specify very clearly, otherwise someone can come up with a shorter version that uses an accepted looser format – Luis Mendo – 2016-08-21T22:38:56.680
@LuisMendo That is why I originally restricted it to newline separated. I think I will revert back to that, if it doesnt harm your submissions. – Rohan Jhunjhunwala – 2016-08-21T22:47:39.567
Let us continue this discussion in chat.
– Rohan Jhunjhunwala – 2016-08-21T22:52:16.5507At this point, I have no idea how an answer's score is calculated or which answer would win. Also, most of the four challenge type tags are mutually exclusive, and the tag rosetta-code doesn't exist. – Dennis – 2016-08-21T23:23:50.237
@Dennis my bad meant to tag it as rosetta-stone – Rohan Jhunjhunwala – 2016-08-21T23:28:22.857
2@Dennis an answer's score is the number of bytes in the answer. A user's score is the total number of bytes of uncracked answer. An answer gets cracked when another user posts an answer (in the same language) which is a permutation of any subset of the characters used in the original answer. The user with the highest score will receive an accepted tick mark on his highest scoring post (although it doesnt really matter which specific post gets the tick) – Rohan Jhunjhunwala – 2016-08-21T23:31:36.847
1OK, that is a lot.clearer and should be added to the question body. I also recommend losing the rosetta-stone and code-bowling tags, as they don't really apply here. Neither the longest answer nor the user with the most answers will necesarily win. – Dennis – 2016-08-21T23:45:59.963
Did I understand this right? If I anticipate that it is impossible to do the task without any parentheses, then I should bloat my code with extraneous parentheses? – Adám – 2016-08-22T09:08:54.430
@Adám:
then you must answer using any permutation of any proper subset of the characters used in the shortest answer
I think the multi set of characters is meant, e.g. in your case leaving away some unnecessary parentheses but not all would count as golfing. – Laikoni – 2016-08-22T10:20:08.783Do we have to have a valid shorter code valid? – Leaky Nun – 2016-08-22T10:55:38.620
1no @LeakyNun you do notnecessarily have to code a shorters submission – Rohan Jhunjhunwala – 2016-08-22T11:29:31.513
@MartinEnder I was wondering if you could help me here. You seem to be skilled with creating automated stack snippet leaderboards. Could you possibly help me with an automated leaderboard for this challenge? – Rohan Jhunjhunwala – 2016-08-22T17:27:45.317
What does "you must wait one hour after posting each initial bowled submission " mean exactly? – Jonathan Allan – 2016-08-22T17:33:05.517
1@JonathonAllan so you can crack submissions whenever you want, but if you want to post in language X before anyone else has, you may, but the next you wish to post a submission in another language y before anyone else has, you must wait a minimum of one hour (this rule isn't too strict, but its to prevent solutions in all major languages) – Rohan Jhunjhunwala – 2016-08-22T17:39:59.817
Do we have to reduce the set of characters used, or is it enough to keep to the same set and only reduce the numbers used? – Jonathan Allan – 2016-08-22T18:59:05.547
1@JonathanAllan it is ok to just reduce the number of characters used. so if the answer to be cracked was aabbccdd then a good crack could be abcd – Rohan Jhunjhunwala – 2016-08-22T19:05:24.697
This is so close to this example program, but I don't know the language well enough to adapt it - anybody want to give it a go? http://shakespearelang.sourceforge.net/report/shakespeare/#SECTION00092000000000000000
– Dave – 2016-08-22T21:42:37.3631@Dave - pretty easy to golf down to the bear essentials (title, character descriptions, act/scene descriptions, unnecessary white space, and then with all the letters shorter adjectives and such may well be possible). (Also with the lack of an interpreter I'm not sure it's really admissible?) – Jonathan Allan – 2016-08-22T22:21:40.593
This should be neat. Just a standard, not excessively long, SQF answer is looking at ~500 chars – Οurous – 2016-08-22T23:00:31.510
@JonathanAllan transpiler + source is available here: http://shakespearelang.sourceforge.net/ (transpiles to C)
– Dave – 2016-08-23T07:11:41.427I don't see why I shouldn't be allowed to post an answer in an already-used language if I'm going to use a totally different collection of characters to try to achieve a better score. – xnor – 2016-08-23T08:54:25.407
@xnor I agree, but I dont think I should change the rules this late into the chaleenge – Rohan Jhunjhunwala – 2016-08-23T13:06:00.420
1Added a leader board - might be worth noting that if one has no room for a header that they should keep the header for the score, truncate their code and explain how to add to the code to make it work (e.g. in the Java entry by Rohan Jhunjhunwala it might say "you need to add 10 thousand more "z"s to the string in the code above). – Jonathan Allan – 2016-08-24T21:08:35.140
1...of course it seems to filter out my latest entry :/ Edit: Tested without my regex for "cracked" and still it's a no-show, odd. – Jonathan Allan – 2016-08-25T01:03:20.443
@JonathanAllan it seems to filter out my SILOS response to – Rohan Jhunjhunwala – 2016-08-25T01:05:42.207