Alice , 15 bytes
/O.
\io/R%e,R:R
Pruébalo en línea!
Explicación
La división de enteros y el módulo de Ruby (en los que se implementan los de Alice) se definen de tal manera que usar un divisor negativo ya hace lo que queremos. Si negamos el divisor, obtenemos automáticamente el módulo correcto, y obtenemos menos el cociente que queremos. Entonces, la forma más fácil de resolver esto es negando un montón de números:
/ Switch to Ordinal mode.
i Read all input as a string "e o".
. Duplicate the string.
/ Switch to Cardinal mode.
R Implicitly convert the top string to the two integer values it
contains and negate o.
% Compute e%-o.
e, Swap the remainder with the other copy of the input string. We can't
use the usual ~ for swapping because that would convert the string
to the two numbers first and we'd swap e%-o in between e and o instead
of to the bottom of the string.
R Negate o again.
: Compute e/-o.
R Negate the result again.
\ Switch to Ordinal mode.
O Output -(e/-o) with a trailing linefeed.
o Output e%-o.
The code now bounces through the code for a while, not doing much except
printing a trailing linefeed when hitting O again. Eventually, the IP
reaches : and attempts a division by zero which terminates the program.
r
como la negación de lo realr
para los idiomas que usan bytes sin firmar para almacenar datos o asumir un desbordamiento? (-1
→1
/255
)