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 12 characters in body
Source Link
Martin Ender
  • 198.2k
  • 67
  • 455
  • 998

Hexagony, 9 bytes

?{?/*!@'/

Try it online!

This is actually fairly straightforward. Here is the unfolded version:

 ? { ?
 / * ! @
' / . . .
 . . . .
 . . .

The / just redirect the control flow to the second line to save bytes on the third. That reduces the code to this linear program:

?{?'*!@

This linear code on its own would actually be a valid solution if the input was limited to strictly positive numbers, but due to the possibility of non-positive results, this isn't guaranteed to terminate.

The program makes use of three memory edges in a Y-shape:

A B
 \ /
 |
 C

The memory pointer starts on edge A pointing towards the centre.

? Read first input into edge A.
{ Move forward to edge B.
? Read second input into edge B.
' Move backward to edge C.
* Multiply edges A and B and store the result in C.
! Print the result.
@ Terminate the program.

I ran a brute force search for 7-byte solutions (i.e. those that fit into side-length 2), and if I didn't make a mistake (or there's a busy-beaver-y solution that takes a long time to complete, which I doubt) then a 7-byte solution doesn't exist. There might be an 8-byte solution (e.g. by reusing the ? or using only one redirection command instead of two /), but that's beyond what my brute force search can do, and I haven't found one by hand yet.

Hexagony, 9 bytes

?{?/*!@'/

Try it online!

This is actually fairly straightforward. Here is the unfolded version:

 ? { ?
 / * ! @
' / . . .
 . . . .
 . . .

The / just redirect the control flow to the second line to save bytes on the third. That reduces the code to this linear program:

?{?'*!@

This on its own would actually be a valid solution if the input was limited to strictly positive numbers, but due to the possibility of non-positive results, this isn't guaranteed to terminate.

The program makes use of three memory edges in a Y-shape:

A B
 \ /
 |
 C

The memory pointer starts on edge A pointing towards the centre.

? Read first input into edge A.
{ Move forward to edge B.
? Read second input into edge B.
' Move backward to edge C.
* Multiply edges A and B and store the result in C.
! Print the result.
@ Terminate the program.

I ran a brute force search for 7-byte solutions (i.e. those that fit into side-length 2), and if I didn't make a mistake (or there's a busy-beaver-y solution that takes a long time to complete, which I doubt) then a 7-byte solution doesn't exist. There might be an 8-byte solution (e.g. by reusing the ? or using only one redirection command instead of two /), but that's beyond what my brute force search can do, and I haven't found one by hand yet.

Hexagony, 9 bytes

?{?/*!@'/

Try it online!

This is actually fairly straightforward. Here is the unfolded version:

 ? { ?
 / * ! @
' / . . .
 . . . .
 . . .

The / just redirect the control flow to the second line to save bytes on the third. That reduces the code to this linear program:

?{?'*!@

This linear code on its own would actually be a valid solution if the input was limited to strictly positive numbers, but due to the possibility of non-positive results, this isn't guaranteed to terminate.

The program makes use of three memory edges in a Y-shape:

A B
 \ /
 |
 C

The memory pointer starts on edge A pointing towards the centre.

? Read first input into edge A.
{ Move forward to edge B.
? Read second input into edge B.
' Move backward to edge C.
* Multiply edges A and B and store the result in C.
! Print the result.
@ Terminate the program.

I ran a brute force search for 7-byte solutions (i.e. those that fit into side-length 2), and if I didn't make a mistake (or there's a busy-beaver-y solution that takes a long time to complete, which I doubt) then a 7-byte solution doesn't exist. There might be an 8-byte solution (e.g. by reusing the ? or using only one redirection command instead of two /), but that's beyond what my brute force search can do, and I haven't found one by hand yet.

added 11 characters in body
Source Link
Martin Ender
  • 198.2k
  • 67
  • 455
  • 998

Hexagony, 9 bytes

?{?/*!@'/

Try it online!

This is actually fairly straightforward. Here is the unfolded version:

 ? { ?
 / * ! @
' / . . .
 . . . .
 . . .

The / just redirect the control flow to the second line to save bytes on the third. That reduces the code to this linear program:

?{?'*!@

This on its own would actually be a valid solution if the input was limited to strictly positive numbers, but due to the possibility of non-positive results, this isn't guaranteed to terminate.

The program makes use of three memory edges in a Y-shape:

A B
 \ /
 |
 C

The memory pointer starts on edge A pointing towards the centre.

? Read first input into edge A.
{ Move forward to edge B.
? Read second input into edge B.
' Move backward to edge C.
* Multiply edges A and B and store the result in C.
! Print the result.
@ Terminate the program.

I ran a brute force search for 7-byte solutions (i.e. those that fit into side-length 2), and if I didn't make a mistake (or there's a busy-beaver-y solution that takes a long time to complete, which I doubt) then a 7-byte solution doesn't exist. There might be an 8-byte solution (e.g. by reusing the ? or using only one redirection command instead of two /), but that's beyond what my brute force search can do, and I haven't found one by hand yet.

Hexagony, 9 bytes

?{?/*!@'/

Try it online!

This is actually fairly straightforward. Here is the unfolded version:

 ? { ?
 / * ! @
' / . . .
 . . . .
 . . .

The / just redirect the control flow to the second line to save bytes on the third. That reduces the code to this linear program:

?{?'*!@

This would actually be a valid solution if the input was limited to strictly positive numbers, but due to the possibility of non-positive results, this isn't guaranteed to terminate.

The program makes use of three memory edges in a Y-shape:

A B
 \ /
 |
 C

The memory pointer starts on edge A pointing towards the centre.

? Read first input into edge A.
{ Move forward to edge B.
? Read second input into edge B.
' Move backward to edge C.
* Multiply edges A and B and store the result in C.
! Print the result.
@ Terminate the program.

I ran a brute force search for 7-byte solutions (i.e. those that fit into side-length 2), and if I didn't make a mistake (or there's a busy-beaver-y solution that takes a long time to complete, which I doubt) then a 7-byte solution doesn't exist. There might be an 8-byte solution (e.g. by reusing the ? or using only one redirection command instead of two /), but that's beyond what my brute force search can do, and I haven't found one by hand yet.

Hexagony, 9 bytes

?{?/*!@'/

Try it online!

This is actually fairly straightforward. Here is the unfolded version:

 ? { ?
 / * ! @
' / . . .
 . . . .
 . . .

The / just redirect the control flow to the second line to save bytes on the third. That reduces the code to this linear program:

?{?'*!@

This on its own would actually be a valid solution if the input was limited to strictly positive numbers, but due to the possibility of non-positive results, this isn't guaranteed to terminate.

The program makes use of three memory edges in a Y-shape:

A B
 \ /
 |
 C

The memory pointer starts on edge A pointing towards the centre.

? Read first input into edge A.
{ Move forward to edge B.
? Read second input into edge B.
' Move backward to edge C.
* Multiply edges A and B and store the result in C.
! Print the result.
@ Terminate the program.

I ran a brute force search for 7-byte solutions (i.e. those that fit into side-length 2), and if I didn't make a mistake (or there's a busy-beaver-y solution that takes a long time to complete, which I doubt) then a 7-byte solution doesn't exist. There might be an 8-byte solution (e.g. by reusing the ? or using only one redirection command instead of two /), but that's beyond what my brute force search can do, and I haven't found one by hand yet.

deleted 3 characters in body
Source Link
Martin Ender
  • 198.2k
  • 67
  • 455
  • 998

Hexagony, 9 bytes

?{?/*!@'/

Try it online!

This is actually fairly straightforward. Here is the unfolded version:

 ? { ?
 / * ! @
' / . . .
 . . . .
 . . .

The / just redirect the control flow to the second line to save bytes on the third. That reduces the code to this linear program:

?{?'*!@

This would actually be a valid solution if the input was limited to strictly positive numbers, but due to the possibility of non-positive results, this isn't guaranteed to terminate.

The program makes use of three memory edges in a Y-shape:

A B
 \ /
 |
 C

The memory pointer starts on edge A pointing towards the centre.

? Read first input into edge A.
{ Move forward to edge B.
? Read second input into edge B.
' Move backward to edge C.
* Multiply edges A and B and store the result in C.
! Print the result.
@ Terminate the program.

I'veI ran a brute force search for 7-byte solutions (i.e. those that fit into side-length 2), and if I didn't make a mistake (or there's a busy-beaver-y solution that takes a long time to complete, which I doubt) then a 7-byte solution doesn't exist. There might be an 8-byte solution (e.g. by reusing the ? or using only one redirection command instead of two /), but that's beyond what my brute force search can do, and I haven't found one by hand yet.

Hexagony, 9 bytes

?{?/*!@'/

Try it online!

This is actually fairly straightforward. Here is the unfolded version:

 ? { ?
 / * ! @
' / . . .
 . . . .
 . . .

The / just redirect the control flow to the second line to save bytes on the third. That reduces the code to this linear program:

?{?'*!@

This would actually be a valid solution if the input was limited to strictly positive numbers, but due to the possibility of non-positive results, this isn't guaranteed to terminate.

The program makes use of three memory edges in a Y-shape:

A B
 \ /
 |
 C

The memory pointer starts on edge A pointing towards the centre.

? Read first input into edge A.
{ Move forward to edge B.
? Read second input into edge B.
' Move backward to edge C.
* Multiply edges A and B and store the result in C.
! Print the result.
@ Terminate the program.

I've ran a brute force search for 7-byte solutions (i.e. those that fit into side-length 2), and if I didn't make a mistake (or there's a busy-beaver-y solution that takes a long time to complete, which I doubt) then a 7-byte solution doesn't exist. There might be an 8-byte solution (e.g. by reusing the ? or using only one redirection command instead of two /), but that's beyond what my brute force search can do, and I haven't found one by hand yet.

Hexagony, 9 bytes

?{?/*!@'/

Try it online!

This is actually fairly straightforward. Here is the unfolded version:

 ? { ?
 / * ! @
' / . . .
 . . . .
 . . .

The / just redirect the control flow to the second line to save bytes on the third. That reduces the code to this linear program:

?{?'*!@

This would actually be a valid solution if the input was limited to strictly positive numbers, but due to the possibility of non-positive results, this isn't guaranteed to terminate.

The program makes use of three memory edges in a Y-shape:

A B
 \ /
 |
 C

The memory pointer starts on edge A pointing towards the centre.

? Read first input into edge A.
{ Move forward to edge B.
? Read second input into edge B.
' Move backward to edge C.
* Multiply edges A and B and store the result in C.
! Print the result.
@ Terminate the program.

I ran a brute force search for 7-byte solutions (i.e. those that fit into side-length 2), and if I didn't make a mistake (or there's a busy-beaver-y solution that takes a long time to complete, which I doubt) then a 7-byte solution doesn't exist. There might be an 8-byte solution (e.g. by reusing the ? or using only one redirection command instead of two /), but that's beyond what my brute force search can do, and I haven't found one by hand yet.

Source Link
Martin Ender
  • 198.2k
  • 67
  • 455
  • 998
Loading

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