Skip to main content
Commonmark migration
Source Link

#Whitespace, 48 bytes

Whitespace, 48 bytes

S S S N S N S T N T T T T T T N S T N N N T S N T N S S T N T T S S T T T T T N T S N S N S S S 

Letters S (space), T (tab), and N (new-line) added as highlighting only.

Minor modification of my Whitespace answer for the I reverse the source code, you negate the output! challenge.

Try it online or try it online reversed (with raw spaces, tabs and new-lines only).

Explanation:

Utilizing the Exit Program builtin being a short palindrome NNN.
The regular program will:

SSSN # Push 0 to the stack SNS # Duplicate it TNTT # Read STDIN as integer, and store it at heap address 0 TTT # Retrieve the input from heap address 0, and push it to the stack TNST # Pop and print the top of the stack as number NNN # Exit the program, making everything after it no-ops 

The reverse program will:

SSSN # Push 0 to the stack SNS # Duplicate it TNTT # Read STDIN as integer, and store it at heap address 0 TTT # Retrieve the input from heap address 0, and push it to the stack SSTTN # Push -1 to the stack TSSN # Multiply the top two values on the stack together TNST # Pop and print the top of the stack as number NNN # Exit the program, making everything after it no-ops 

Small additional explanation of pushing a number:

  • First S: Enable Stack Manipulation
  • Second S: Push a number to the stack
  • S or T: Positive/negative respectively
  • Some S/T followed by a trailing N: number in binary, where S=0 and T=1

I.e. SSTTSTSN pushes -10. For the 0 we don't need an explicit S=0, so simply SSSN or SSTN is enough.

#Whitespace, 48 bytes

S S S N S N S T N T T T T T T N S T N N N T S N T N S S T N T T S S T T T T T N T S N S N S S S 

Letters S (space), T (tab), and N (new-line) added as highlighting only.

Minor modification of my Whitespace answer for the I reverse the source code, you negate the output! challenge.

Try it online or try it online reversed (with raw spaces, tabs and new-lines only).

Explanation:

Utilizing the Exit Program builtin being a short palindrome NNN.
The regular program will:

SSSN # Push 0 to the stack SNS # Duplicate it TNTT # Read STDIN as integer, and store it at heap address 0 TTT # Retrieve the input from heap address 0, and push it to the stack TNST # Pop and print the top of the stack as number NNN # Exit the program, making everything after it no-ops 

The reverse program will:

SSSN # Push 0 to the stack SNS # Duplicate it TNTT # Read STDIN as integer, and store it at heap address 0 TTT # Retrieve the input from heap address 0, and push it to the stack SSTTN # Push -1 to the stack TSSN # Multiply the top two values on the stack together TNST # Pop and print the top of the stack as number NNN # Exit the program, making everything after it no-ops 

Small additional explanation of pushing a number:

  • First S: Enable Stack Manipulation
  • Second S: Push a number to the stack
  • S or T: Positive/negative respectively
  • Some S/T followed by a trailing N: number in binary, where S=0 and T=1

I.e. SSTTSTSN pushes -10. For the 0 we don't need an explicit S=0, so simply SSSN or SSTN is enough.

Whitespace, 48 bytes

S S S N S N S T N T T T T T T N S T N N N T S N T N S S T N T T S S T T T T T N T S N S N S S S 

Letters S (space), T (tab), and N (new-line) added as highlighting only.

Minor modification of my Whitespace answer for the I reverse the source code, you negate the output! challenge.

Try it online or try it online reversed (with raw spaces, tabs and new-lines only).

Explanation:

Utilizing the Exit Program builtin being a short palindrome NNN.
The regular program will:

SSSN # Push 0 to the stack SNS # Duplicate it TNTT # Read STDIN as integer, and store it at heap address 0 TTT # Retrieve the input from heap address 0, and push it to the stack TNST # Pop and print the top of the stack as number NNN # Exit the program, making everything after it no-ops 

The reverse program will:

SSSN # Push 0 to the stack SNS # Duplicate it TNTT # Read STDIN as integer, and store it at heap address 0 TTT # Retrieve the input from heap address 0, and push it to the stack SSTTN # Push -1 to the stack TSSN # Multiply the top two values on the stack together TNST # Pop and print the top of the stack as number NNN # Exit the program, making everything after it no-ops 

Small additional explanation of pushing a number:

  • First S: Enable Stack Manipulation
  • Second S: Push a number to the stack
  • S or T: Positive/negative respectively
  • Some S/T followed by a trailing N: number in binary, where S=0 and T=1

I.e. SSTTSTSN pushes -10. For the 0 we don't need an explicit S=0, so simply SSSN or SSTN is enough.

Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

#Whitespace, 48 bytes

S S S N S N S T N T T T T T T N S T N N N T S N T N S S T N T T S S T T T T T N T S N S N S S S 

Letters S (space), T (tab), and N (new-line) added as highlighting only.

Minor modification of my Whitespace answer for the I reverse the source code, you negate the output! challenge.

Try it online or try it online reversed (with raw spaces, tabs and new-lines only).

Explanation:

Utilizing the Exit Program builtin being a short palindrome NNN.
The regular program will:

SSSN # Push 0 to the stack SNS # Duplicate it TNTT # Read STDIN as integer, and store it at heap address 0 TTT # Retrieve the input from heap address 0, and push it to the stack TNST # Pop and print the top of the stack as number NNN # Exit the program, making everything after it no-ops 

The reverse program will:

SSSN # Push 0 to the stack SNS # Duplicate it TNTT # Read STDIN as integer, and store it at heap address 0 TTT # Retrieve the input from heap address 0, and push it to the stack SSTTN # Push -1 to the stack TSSN # Multiply the top two values on the stack together TNST # Pop and print the top of the stack as number NNN # Exit the program, making everything after it no-ops 

Small additional explanation of pushing a number:

  • First S: Enable Stack Manipulation
  • Second S: Push a number to the stack
  • S or T: Positive/negative respectively
  • Some S/T followed by a trailing N: number in binary, where S=0 and T=1

I.e. SSTTSTSN pushes -10. For the 0 we don't need an explicit S=0, so simply SSSN or SSTN is enough.