23
5
Inspired by this blog post.
Write a program that outputs 99 distinct programs (in the same language) that output the string I love you
.
How the programs are separated from one another in the output will be defined by you. However, Each byte of output can only belong to at most 1 of the 99 programs.
Constraints for Output Programs
- If any string of characters is removed, then the program must not output
I love you
.
e.g.console.log('I love you');;;
is invalid because;;;
can be removed - If any two strings of characters are both removed, then the program must not output
I love you
. This is to prevent inconsequential application of pairs of characters, that pass rule 1 because removing any single string will break the program.
e.g.print((('I love you')))
is invalid, because((
and))
can be removed
There will be two categories of scoring to participate in.
- Standard code golf—smallest source code wins
- Combined code golf—smallest source code + output wins
Leaderboard
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
/* Configuration */
var QUESTION_ID = 198052; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.
/* App */
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) {
data.items.forEach(function(c) {
if (c.owner.user_id === OVERRIDE_USER)
answers_hash[c.post_id].comments.push(c);
});
if (data.has_more) getComments();
else if (more_answers) getAnswers();
else process();
}
});
}
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\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.match(SCORE_REG);
if (match)
valid.push({
user: getAuthorName(a),
size: +match[2],
language: match[1],
link: a.share_link,
});
});
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;
if (/<a/.test(lang)) lang = jQuery(lang).text();
languages[lang] = languages[lang] || {lang: a.language, 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 > b.lang) return 1;
if (a.lang < b.lang) 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);
}
}
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;
}
<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>
3Does the code have to be pristine (there is no way to produce the same result by removing any number of characters) or just following the constraints you mentioned? e.g. from Benji's program: would
print(chr(207%134)) ...
be allowed even if taking out20
,%1
, and4
would result inprint(chr(73)) ...
which yields the same result? – Zimonze – 2020-01-16T02:44:45.1332Can we use functions instead of programs? – Jonah – 2020-01-16T03:08:22.430
11There must not exist a string of characters that, when removed, does not lead to Could that be rephrased to remove the two negations? I find it very confusing – Luis Mendo – 2020-01-16T07:33:04.477
@Zimonze just the rules above. In your example, it takes the removal of 3 strings of characters to be reduced, so it's still valid. – Mason – 2020-01-16T08:30:47.137
@LuisMendo I wrestled with the wording for this a decent amount, it seems to really want to be a double negative and that was the best wording I came up with. I'm open to suggestions (from anyone). – Mason – 2020-01-16T08:33:15.333
10These double negatives are killing my chance at understanding this question. Could this be reworded without the double negatives? – ouflak – 2020-01-16T09:15:32.433
7Perhaps try: "Your solution must fail to output
I love you
if you remove any one or two strings of characters. Removal of 3 or more strings of characters is not required to fail.". Then just copy the two examples. – Zizy Archer – 2020-01-16T09:58:59.573Isn't this a [tag:metagolf] challenge? – manatwork – 2020-01-16T12:28:08.377
3I don't understand the rule
However, Each byte of output can only belong to at most 1 of the 99 programs.
. Can you clarify what you mean by that? – AdmBorkBork – 2020-01-16T13:48:18.180@AdmBorkBork, I guess Mason tried to disallow solutions where there is 1 function declaration + 99 function calls. With the rule you quoted that would be counted 99 function declarations + 99 function calls, cutting the benefit of using such cheatish combination. – manatwork – 2020-01-16T13:59:22.833
1"How the programs are separated from one another in the output will be defined by you." Can be we have no separator? The output still contains all programs. – Kevin Cruijssen – 2020-01-16T15:14:54.383
@KevinCruijssen That seems to be how most answers are doing it, so it must be allowed – Cruncher – 2020-01-16T17:08:49.673
@KevinCruijssen you can do whatever you want as long as you can show where each program starts and ends – Mason – 2020-01-16T19:54:02.017
So each output program must consist of only 2.55 distinct bytes, on average? That's less than are in the "I love you" string itself. – user253751 – 2020-01-17T14:20:48.140
@user253751 If you look at the answers that's clearly not the case. Where are you getting that number from? – Mason – 2020-01-17T18:01:24.020
@Mason I bet that number comes from a misreading of “Each byte of output can only belong to at most 1 of the 99 programs”, and frankly I also have no idea what that rule means. Could you please clarify? – Lynn – 2020-01-17T23:35:34.760
3@Lynn It seems to mean that when the output is split up into programs no byte of output can be given to two programs, e.g. abcc cannot have both the programs abc and cc since the third byte belongs to two programs. It can much more clearly be said as programs do not overlap. – Post Rock Garf Hunter – 2020-01-19T05:38:20.637