Skip to main content
7 of 10
deleted 52 characters in body
user202729
  • 17.6k
  • 2
  • 39
  • 71

dc (GNU), 3 distinct characters (z|P), 453 bytes

Generator program: Try it online!

Because there can be a lot of possible different states of the stack, this solution prunes the states to be considered (only the topmost 2 can have value different from the default value pushed by z); therefore the result might not be optimal.

Analysis:

There are some options of using a digit, an arithmetic operator and P.

Possible cases for the arithmetic operator are:

  • +: 1065 bytes. Throws a lot of errors. Generator program: Try it online!
  • v: 7617 bytes. (you can get it from the generator program above by removing the solve(bestReprAdd), line in the generator)
  • -: will probably result in the approximately-same or slightly-shorter program.
  • %: obviously impossible. (because, for example, 11111 mod 111 is 11, so the constructible values are those already constructible with a literal or 0)
  • ~: (unfortunately) also impossible because there's no way to discard the remainder without printing it out.
  • / and |: should be possible. Analysis pending.
  • * and ^: probably impossible, because there can only be a small set of representable numbers.
  • i: An interesting possibility (11i to increase the input base, 1i to set the input base to 1); however the input base must be between 2 and 16, so there's no way to decrease the input base, so it's not very likely to work.

Other alternatives:

  • z, P, (arithmetic operator): Terribly hard to analyze. Using zP| results in the solution above.
  • z, P, o (since the output radix is not used, it's the same as pop the stack and do nothing in this challenge): 1601 bytes.
user202729
  • 17.6k
  • 2
  • 39
  • 71