Restricted Source Gauntlet

Description

Python restricted source golfing. Each solution should be separated by 10 hashtags plus a newline.

For each of the following trigrams, you must provide an ascii only program that prints the exact string Hello, World! without including any of the strings in their source code. The four challenges are “eir”, “ctv”, “).c”, “(dt”

Judge

(async function* (context: Context): Challenge {
  // Single Test
  const solutions = context.code.split(/##########\r?\n/);

  if (solutions.length !== 4) {
    yield context.registerTestCase(
      new TestCase("Expressions count", "Fail", {
        Text: `Expected 4 solutions, found ${solutions.length}.`,
      }),
    );
    return context.noFailures();
  }

  const asciiOnly = [...context.code].every((x) => x.codePointAt(0)! < 128);
  if (!asciiOnly) {
    yield context.registerTestCase(
      new TestCase("Ascii only", "Fail", {
        Text: `Expected only ascii characters.`,
      }),
    );
    return context.noFailures();
  }

  const problems = ["eir", "ctv", ").c", "(dt"];

  for (let i = 0; i < problems.length; i++) {
    if (!solutions[i]) continue;

    // check matches format
    const usesBanned = [...problems[i]].some((char) =>
      solutions[i].includes(char),
    );

    yield context.registerTestCase(
      new TestCase("Banned characters", !usesBanned ? "Pass" : "Fail", {
        Text: `Solution ${i} (${JSON.stringify(solutions[i])}) uses one of the banned characters \`${problems[i]}\``,
      }),
    );

    if (usesBanned) continue;

    // check outputs "Hello, World!"
    // TODO: await here or no?
    yield (await context.runCode(solutions[i]))
      .assertEquals("Hello, World!")
      .setName(`Solution ${i} output`);
  }

  // give 1000 points for each empty solution
  const score = solutions
    .map((sol) => sol.length + (!sol ? 1000 : 0))
    .reduce((a, b) => a + b);

  // Finally, the challenge is passed if no test cases failed
  return context.noFailures(score);
});

Example Code

##########
##########
##########

Comments