R REPL*, 125 90 bytes, score 0
*(or any other R environment in which errors do not halt execution of subsequent commands: entering the program into the R interactive console works fine; alternatively (and as simulated in the ATO link) we can use the command-line option -e 'options(error=function(){})'
, which would define the language as "R -e 'options(error=function(){})'
".
x=1;if(x)cat(strrep(x,9*(2)*5-(nchar(readLines(c=stdin(),n=1))<9*(2))))
cat(strrep(1,89))#
Attempt This Online!
The strategy here is to write a 2-line program. If the first line runs Ok, it uses the second line as input (and, as a side-effect, prevents the second line from running), and checks that it contains the expected number of characters: if it does, print string s
(90 1
s); if it doesn't, print string s
without one character (all the characters are the same, so this is equivalent to removing the n
th character for any n
).
The first line is written to error (and so do nothing) if any character is removed. In this case, the second line won't be used as input, and it will run: it always prints string s
without 1 character.
The length of the entire program is expressed as 9*(2)*5
(so removing any character will error). For a similar reason, the second line is adjusted to be 18 characters long, so we can check whether its length is less than 9*(2)
.
R, 8 bytes, score 8
cat(8^8)
Attempt This Online!
In principle, we could try to wrap the R+REPL program above into a tryCatch()
expression to force it to run in base R, but this would already inflate the score to at least 10, and this trivial approach is both shorter and scores better (even though it's rather boring).