อลิซ , 28 18 ไบต์
ขอบคุณ @MartinEnder สำหรับการเล่นกอล์ฟขนาด 10 ไบต์
=I.!'`-+?hn
>3-nO@
ลองออนไลน์!
การส่งนี้ใช้วิธีอื่นที่ไม่ใช่คำตอบของ @ MartinEnder
การส่งนี้ส่งออก0x00สำหรับเท็จและ0x01เพื่อความจริง
ดังนั้นนี่คือรุ่นที่มีเอาต์พุต0หรือ1แทนที่: ลอง!
คำอธิบาย
คำอธิบายด้านล่างนี้สำหรับรุ่น "มองเห็นได้" ทั้งคู่มีลักษณะคล้ายกันมากยกเว้นในโปรแกรมแรกตัวสุดท้ายoไม่แปลง0หรือ1เป็นสตริง (เพราะเราอยู่ในโหมดที่สำคัญ) แต่ใช้ตัวเลขและเอาท์พุทอักขระที่จุดโค้ดนั้นแทน
= 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
หลังจากนี้ IP =ล้อมรอบไปที่ขอบด้านซ้ายที่ หากค่าสูงสุดของสแต็คคือ0IP ยังคงดำเนินต่อไปพร้อมกับพา ธ ของมันเพิ่มผลรวมทั้งหมดของอักขระทั้งหมดเมื่อเสร็จสิ้นด้วยอินพุต (ด้านบนของสแต็กจะเป็น1) IP จะเลี้ยวขวา (90 องศาตามเข็มนาฬิกา)
สิ่งหนึ่งที่สำคัญคือต้องทราบการวนรอบบนบรรทัดแรกจะวนซ้ำหลังจากอินพุตสิ้นสุดลง วิธีนี้จะลบ97( 96จาก'`และ-1จากการขาดอินพุต) จากผลรวม
> 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