26
\$\begingroup\$

The cops thread can be found here: The Mystery String Printer (Cops)

Your challenge

  • Choose a submission from the cops thread, and print out the string from an answer in that thread.
  • The submission that you choose must not be safe (it must be newer than 7 days).
  • Your program, function, or REPL script needs to follow the same rules as the cops thread. Just to recap:

    • Your program must be ≤128 characters (if a cop's submission is in a smaller range of program lengths, your program must also be in that length range. For example, if a cop's program is ≤32 bytes, your program must be ≤32 bytes).
    • The program must produce the same output every time it is run.
    • No cryptographic functions.
    • The program must not take input.
    • No standard loopholes.
  • All new submissions must use the same language. Submissions from before this rule was made are fine, even if they don't.

Scoring

Scoring works similarly for robbers, but it is slightly different:

  • Cracking any program of ≤8 bytes gives 1 point.
  • Cracking a ≤16 byte program gives 2 points. ≤32 bytes gives 4 points, and so on.
  • Every additional submission, no matter the length, earns +5 points
  • Each cop's submission can only be cracked once- only the first person to crack each submission gets the points.

Submissions

Each answer must include

  • A link to the cop's submission.
  • Your program and programming language.
  • Also have the cop's program length (as a power of 2) as the last number in your header.

Additionally, please comment on the cop's submission with a link to your answer.

Here is a Stack Snippet to generate leaderboards. Please leave a comment if there is a problem with the snippet. If you would like to see all open cop submissions, see the snippet in the cops' challenge.

/* Configuration */

var QUESTION_ID = 60329; // Obtain this from the url
// It will be like http://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";

/* App */

var answers = [],
  answers_hash, answer_ids, answer_page = 1,
  more_answers = true,
  comment_page;

function answersUrl(index) {
  return "//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 "//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) {

        answers_hash[c.post_id].comments.push(c);

      });

      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var POINTS_REG = /(?:<=|≤|&lt;=)\s?(?:<\/?strong>)?\s?(\d+)/
var POINTS_REG_ALT = /<h\d>.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;


function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {

  var valid = [];
  var open = [];

  answers.forEach(function(a) {

    var body = a.body;
    var cracked = false;

    var points = body.match(POINTS_REG);
    if (!points) points = body.match(POINTS_REG_ALT);

    if (points) {
      var length = parseInt(points[1]);
      var crackedpoints = 0;
      if (length > 64) crackedpoints = 16;
      else if (length > 32) crackedpoints = 8;
      else if (length > 16) crackedpoints = 4;
      else if (length > 8) crackedpoints = 2;
      else crackedpoints = 1;

      valid.push({
        user: getAuthorName(a),
        numberOfSubmissions: 1,
        points: crackedpoints

      });
    }
  });

  var pointTotals = [];
  valid.forEach(function(a) {

    var index = -1;
    var author = a.user;
    pointTotals.forEach(function(p) {
      if (p.user == author) index = pointTotals.indexOf(p);
    });

    if (index == -1) pointTotals.push(a);
    else {
      pointTotals[index].points += a.points;
      pointTotals[index].numberOfSubmissions++;
    }

  });

  pointTotals.forEach(function(a) {
    a.points += +((a.numberOfSubmissions - 1) * 5);
  });

  pointTotals.sort(function(a, b) {
    var aB = a.points,
      bB = b.points;
    return (bB - aB != 0) ? bB - aB : b.numberOfSubmissions - a.numberOfSubmissions;
  });

  pointTotals.forEach(function(a) {


    var answer = jQuery("#answer-template").html();
    answer = answer
      .replace("{{NAME}}", a.user)
      .replace("{{SUBMISSIONS}}", a.numberOfSubmissions)
      .replace("{{POINTS}}", a.points);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);


  });

}
body {
  text-align: left !important
}
#answer-list {
  padding: 20px;
  width: 240px;
  float: left;
}
#open-list {
  padding: 20px;
  width: 450px;
  float: left;
}
table thead {
  font-weight: bold;
  vertical-align: top;
}
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>Robber's Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr>

        <td>Author</td>
        <td>Submissions</td>
        <td>Score</td>
      </tr>
    </thead>
    <tbody id="answers">

    </tbody>
  </table>
</div>

<table style="display: none">
  <tbody id="answer-template">
    <tr>
      <td>{{NAME}}</td>
      <td>{{SUBMISSIONS}}</td>
      <td>{{POINTS}}</td>
    </tr>
  </tbody>
</table>

This contest is now closed.

Overall winner: kennytm

Most submissions: Sp3000

(Note that the amount of submissions doesn't translate exactly to the points, as the length of the cracked program is counted when calculating the score).

\$\endgroup\$
  • \$\begingroup\$ Note: every additional submission earns 5 points \$\endgroup\$ – Daniel M. Oct 12 '15 at 20:13

93 Answers 93

1
\$\begingroup\$

Mathematica, quartata, 25 <= 64 bytes

2^315 3^117 75844139371^9

Method

output = 368921261...764501504

test = FactorInteger[output]
(* {{2,315},{3,117},{7,18},{11,9},{13,9},{17,9},{19,9},{23,9},{31,9},{47,9}} *)

(Times @@ Power @@@ Drop[test, 2])^(1/9)
(* 75844139371 *)

2^315 3^117 75844139371^9 == output
(* True *)
\$\endgroup\$
1
\$\begingroup\$

J, randomra, ≤ 8

#:/:|i:9

Try it online.

Cracking the code

Each row looks like the binary representation of a small integer, specifically of these integers:

9 8 10 7 11 6 12 5 13 4 14 3 15 2 16 1 17 0 18

These integers are a permutation of the range 0 … 18, so they were most likely the product of "grading up" a list of length 19.

Grading that list up once more yields

17 15 13 11 9 7 5 3 1 0 2 4 6 8 10 12 14 16 18

meaning that we must find a list whose elements are in the same order as this one. This very same list would work, but we must find another that fits in the byte range.

An obvious candidate is

9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9

which can be generated by applying absolute value to the list

_9 _8 _7 _6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6 7 8 9

How it works

  • i:9 generates the range -9 … 9.

  • | applies absolute value to each integer in that range.

  • /: "grades up", i.e., sorts the indices of the above list by the values at those indices.

  • #: converts the resulting indices to binary.

\$\endgroup\$
1
\$\begingroup\$

TI-BASIC, Cᴏɴᴏʀ O'Bʀɪᴇɴ, ≤2

θStep

I was thinking of using one of these window tokens for my 4-byte cop, but I didn't want to abuse the "may assume default settings" rule too much.

\$\endgroup\$
  • \$\begingroup\$ I was thinking Tstep, but this works as well. Nice job! \$\endgroup\$ – Conor O'Brien Nov 7 '15 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.