A000035 is n mod 2, in case the site goes down or you're too lazy to check yourself. Charset:
023456789\`efu
Taking the "somehow still Turing-complete" route. I suppose I could've added 51 or so non-ASCII chars to improve my score, but that feels kind of like cheating.
Takes input through prompt
and outputs through alert
, and can be run in any modern browser.
Intended solution:
\u0046\u0075\u006e\u0063\u0074\u0069\u006f\u006e`\u0046\u0075\u006e\u0063\u0074\u0069\u006f\u006e\u0028\u0046\u0075\u006e\u0063\u0074\u0069\u006f\u006e\u0028\u0022\u0072\u0065\u0074\u0075\u0072\u006e\u0028\u0034\u0038\u0032\u002f\u0032\u0029\u002e\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0032\u0032\u0029\\u002\u0062\u0027\u0065\u0072\u0074\u0028\u0070\u0072\u006f\\u006\u0064\u0070\u0074\u0028\u0029\u0025\u0032\u0029\u0027\u0022\u0029\u0028\u0029\u0029\u0028\u0029```
which, when the escapes are removed, translates to
Function`Function(Function("return(482/2).toString(22)\u002b'ert(pro\u006dpt()%2)'")())()```
which simplifies again to
Function`Function(Function("return(482/2).toString(22)+'ert(prompt()%2)'")())()```
This works because JavaScript allows \uXXXX
escapes in variable names (though not in arbitrary code, as Java does). The outer Function`code```
is necessary to run the code at all, since the entire thing needs to be escaped.
(If you're confused about how this works: JavaScript has something called tagged template literals, which for our purposes is just a function call on a string; it just uses f`string`
instead of f("code")
. So Function`code```
is about the same as Function("code")()
.)
Now, because of the lack of the hexadecimal chars 1abcd
, we'll have to double-encode certain necessary characters such as the m
in prompt()
. So instead of \u006d
, it becomes \\u006\u0064
. But now we need to evaluate this as a string twice to make sure this gets fully decoded. (pro\u006dpt()
would work just fine, but using \u002b
as +
would not.) This is what the second Function(code)()
is for.
One further obstacle exists: there's no 1
in the charset, necessary to create an a
from \u0061
. So there's no way to generate an a
by unescaping a string (I checked, the octal representation is \141
). Instead, we can generate it with e.g. (20/2).toString(20)
. I went ahead and generated al
in this manner because l
would require double-escaping like m
.
But the problem now is that the innermost Function
call is now just generating a string. In order to actually execute it, we need to return it from the function and pass it to a third Function
call. This we do, and finally our journey is complete.
*I am aware of using ${}
within template literals, but those aren't in the charset, alright?
1Lower score is better? Or higher? So in essence we're trying to find a restricted character set that makes it difficult for someone else to make a program in the chosen language, after we've already worked out a solution? – BradC – 2017-07-27T16:56:15.893
1Do we need to use all the bytes in our set? I would guess yes but it should probably be specified in the challenge. – Shaggy – 2017-07-27T17:06:35.260
1@Shaggy generally no, you can includes others for red herrings, but robbers can use everything – Stephen – 2017-07-27T17:08:31.977
Do we count newlines as a separate byte or as \n? – JAD – 2017-07-27T17:13:41.760
@StepHen does that mean that you can include bytes that aren't even part of your language to get a higher score? – H.PWiz – 2017-07-27T17:16:36.993
@H.PWiz you'd have to ask WheatWizard about no-ops – Stephen – 2017-07-27T17:17:20.600
1Can robbers use the same byte twice or more? – Mr. Xcoder – 2017-07-27T17:19:08.043
1@mrxcoder I would think so, else we are just finding anagrams. – JAD – 2017-07-27T17:24:27.300
@Mr.Xcoder
You are then to secretly write a program in that language that computes the nth term sequence using only the bytes in the set.
only the bytes in that set, so dupes are allowed – Stephen – 2017-07-27T17:50:59.423Do I understand right that the robber could (if characters allow) hardcode an enormous table of values corresponding to the b file? This could be hard for cops to avoid. – xnor – 2017-07-27T18:52:54.200
@xnor Yes that would be possible. The problem is OEIS sequence do not have rigorous specifications, so we can only confirm via test battery. – Post Rock Garf Hunter – 2017-07-27T19:51:34.387
1
What do you mean by "b-list"? Is that the list of terms shown on the page that has the "list", i.e. http://oeis.org/A000004/list ?
– Azulflame – 2017-07-27T23:21:20.4702
@Azulflame The b-files are files that are associated with each sequence the can be accessed by replacing the
– Post Rock Garf Hunter – 2017-07-27T23:47:00.373A
with ab
and appending a.txt
. For example https://oeis.org/b4.txt would access the b-files for that sequence.Can the byteset contain non-printable-ASCII? (i.e. can I inflate my score by including 0x00-0x1f and 0x7f-0xff?) – Doorknob – 2017-07-28T03:40:44.823
@Doorknob Yes it can, the question is about chiefly about bytes and is agnostic to characters. – Post Rock Garf Hunter – 2017-07-28T03:50:42.830