Alice , 28 18 octets
Merci à @MartinEnder pour avoir joué au golf 10 octets
=I.!'`-+?hn
>3-nO@
Essayez-le en ligne!
Cette soumission utilise une méthode différente de celle de @ MartinEnder.
Cette soumission 0x00renvoie à la fausseté et 0x01à la vérité.
Donc, voici une version qui sort 0ou à la 1place: Essayez-le!
Explication
L'explication ci-dessous concerne la version "visible". Les deux sont très similaires, sauf dans le premier programme, le dernier one convertit pas le 0ou 1en une chaîne (parce que nous sommes en mode cardinal), mais prend le nombre et affiche le caractère à ce point de code.
= Does nothing, but will be useful later on
I Read a character and push its code point onto the stack
If there is no more input, -1 is pushed instead
. Duplicate it
! Store it on the tape
# Skip the next command
o Gets skipped
'` Push 96
- Subtract it from the character
+ And add it to the total
? Load the number on the tape
h Increment it
n And negate it
For all characters that are read, ?hn results in 0,
but if -1 is pushed, then the result becomes 1
Après cela, l’IP se termine sur le bord gauche =. Si la valeur supérieure de la pile est 0, l’IP continue avec son chemin, augmentant la somme totale de tous les caractères, une fois que cela est fait avec l’entrée (le haut de la pile sera 1), puis l’IP se tournera à droite (90 degrés dans le sens des aiguilles d'une montre).
Une chose est importante à noter, la boucle sur la première ligne itérera une fois après la fin de la saisie. Ceci soustraira 97( 96du '`et -1du manque d'entrée) du total.
> Set the direction of the IP to East
3- Subtract 3 from it (yields 0 if sum is 100, something else otherwise)
n Negate it; Zero becomes 1, non-zero numbers become 0
/ Mirror; the IP gets redirected South-East
The IP reflects off the bottom and goes North-East
Now the program is in Ordinal mode, where numbers are automatically converted into strings when being used
o Output the top of the stack as a string
IP reflects off the top and heads South-East
@ End the program