Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 559 characters in body
Source Link
Bubbler
  • 79.3k
  • 5
  • 162
  • 484

Hexagony, 6 bytes, 17 cycles

s;i>x@

Try it online!

Now the letters six are in more natural order, and the program finishes one cycle faster.

How it works

For more thorough explanation, see the previous answer below.

 A B
C > D
 E .
Execution path: ABC>CBAD>ADB.>.CE
 ^^ ^^ ^^ ^
 s; i; x; @

Hexagony , 6 bytes, 18 cycles

x>i;s@

Try it online!

Inspired by boboquack's 9-byte solution. The following quote was a big hint:

I'm slightly disappointed that I couldn't get six to work (that would be pushing it with three characters, one output, one redirection and one termination).

How it works (or, How I got to this solution)

A 6-byte program is laid out on a hexagon of side length 2, and the 7th instruction is necessarily a no-op:

 ? ?
? ? ?
 ? .

Since I needed at least one mirror, I tried out various mirrors placed at various places, until I found this:

 A >
B C D
 E .

Assuming the current memory is always positive (and there are no branches/mirrors/IP changers among ABCDE), the IP follows the path

A>ADCB>.CAD>DAC.BE

The cell C is run exactly three times, and the cells right before C are D, B, and A respectively. And the cell E is first run after three runs of C. This is exactly what we want: write one of s, i, or x on the memory and print it, and then terminate!

Now back to the actual source code:

 x >
i ; s
 @ .

And the execution path, linearized, with significant instructions emphasized:

x>xs;i>.;xs>sx;.i@
 ^^^ ^ ^^ ^
 ^^ Print 's'
 ^ ^ Print 'i'
 ^^ Print 'x'
 ^ Terminate

Hexagony, 6 bytes

x>i;s@

Try it online!

Inspired by boboquack's 9-byte solution. The following quote was a big hint:

I'm slightly disappointed that I couldn't get six to work (that would be pushing it with three characters, one output, one redirection and one termination).

How it works (or, How I got to this solution)

A 6-byte program is laid out on a hexagon of side length 2, and the 7th instruction is necessarily a no-op:

 ? ?
? ? ?
 ? .

Since I needed at least one mirror, I tried out various mirrors placed at various places, until I found this:

 A >
B C D
 E .

Assuming the current memory is always positive (and there are no branches/mirrors/IP changers among ABCDE), the IP follows the path

A>ADCB>.CAD>DAC.BE

The cell C is run exactly three times, and the cells right before C are D, B, and A respectively. And the cell E is first run after three runs of C. This is exactly what we want: write one of s, i, or x on the memory and print it, and then terminate!

Now back to the actual source code:

 x >
i ; s
 @ .

And the execution path, linearized, with significant instructions emphasized:

x>xs;i>.;xs>sx;.i@
 ^^^ ^ ^^ ^
 ^^ Print 's'
 ^ ^ Print 'i'
 ^^ Print 'x'
 ^ Terminate

Hexagony, 6 bytes, 17 cycles

s;i>x@

Try it online!

Now the letters six are in more natural order, and the program finishes one cycle faster.

How it works

For more thorough explanation, see the previous answer below.

 A B
C > D
 E .
Execution path: ABC>CBAD>ADB.>.CE
 ^^ ^^ ^^ ^
 s; i; x; @

Hexagony , 6 bytes, 18 cycles

x>i;s@

Try it online!

Inspired by boboquack's 9-byte solution. The following quote was a big hint:

I'm slightly disappointed that I couldn't get six to work (that would be pushing it with three characters, one output, one redirection and one termination).

How it works (or, How I got to this solution)

A 6-byte program is laid out on a hexagon of side length 2, and the 7th instruction is necessarily a no-op:

 ? ?
? ? ?
 ? .

Since I needed at least one mirror, I tried out various mirrors placed at various places, until I found this:

 A >
B C D
 E .

Assuming the current memory is always positive (and there are no branches/mirrors/IP changers among ABCDE), the IP follows the path

A>ADCB>.CAD>DAC.BE

The cell C is run exactly three times, and the cells right before C are D, B, and A respectively. And the cell E is first run after three runs of C. This is exactly what we want: write one of s, i, or x on the memory and print it, and then terminate!

Now back to the actual source code:

 x >
i ; s
 @ .

And the execution path, linearized, with significant instructions emphasized:

x>xs;i>.;xs>sx;.i@
 ^^^ ^ ^^ ^
 ^^ Print 's'
 ^ ^ Print 'i'
 ^^ Print 'x'
 ^ Terminate
Source Link
Bubbler
  • 79.3k
  • 5
  • 162
  • 484

Hexagony, 6 bytes

x>i;s@

Try it online!

Inspired by boboquack's 9-byte solution. The following quote was a big hint:

I'm slightly disappointed that I couldn't get six to work (that would be pushing it with three characters, one output, one redirection and one termination).

How it works (or, How I got to this solution)

A 6-byte program is laid out on a hexagon of side length 2, and the 7th instruction is necessarily a no-op:

 ? ?
? ? ?
 ? .

Since I needed at least one mirror, I tried out various mirrors placed at various places, until I found this:

 A >
B C D
 E .

Assuming the current memory is always positive (and there are no branches/mirrors/IP changers among ABCDE), the IP follows the path

A>ADCB>.CAD>DAC.BE

The cell C is run exactly three times, and the cells right before C are D, B, and A respectively. And the cell E is first run after three runs of C. This is exactly what we want: write one of s, i, or x on the memory and print it, and then terminate!

Now back to the actual source code:

 x >
i ; s
 @ .

And the execution path, linearized, with significant instructions emphasized:

x>xs;i>.;xs>sx;.i@
 ^^^ ^ ^^ ^
 ^^ Print 's'
 ^ ^ Print 'i'
 ^^ Print 'x'
 ^ Terminate

AltStyle によって変換されたページ (->オリジナル) /