Skip to main content
typo fix
Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

Charcoal, 56 bytes

WS⊞υιP⪫υ¶W⊕⌕⪪HIO>^<v¹KK¿‹ι⁴¿⁼⊖ι﹪φ²⎚M✳⊗φ«≔ιφ✳⊗φψ»≔KKθ⎚⁼θψ

Try it online! Link is to verbose version of code. Takes input as a list of newline-terminated strings and outputs - if the program does not halt, nothing if it halts. Explanation:

WS⊞υιP⪫υ¶

Input the instructions and print them to the canvas without moving the cursor.

W⊕⌕⪪HIO>^<v¹KK

While the character under the cursor is a valid instruction:

¿‹ι⁴

If this was an intersection-type character, then...

¿⁼⊖ι﹪φ²⎚

... if this intersection should halt the program thanthen clear the canvas, causing the loop to exit, ...

M✳⊗φ

... otherwise move on through the intersection.

«≔ιφ✳⊗φψ»

Otherwise, update the direction, replace the current character with a null marker and move in the new direction.

≔KKθ⎚⁼θψ

Output whether the cursor landed on a null marker, indicating an infinite loop.

Charcoal, 56 bytes

WS⊞υιP⪫υ¶W⊕⌕⪪HIO>^<v¹KK¿‹ι⁴¿⁼⊖ι﹪φ²⎚M✳⊗φ«≔ιφ✳⊗φψ»≔KKθ⎚⁼θψ

Try it online! Link is to verbose version of code. Takes input as a list of newline-terminated strings and outputs - if the program does not halt, nothing if it halts. Explanation:

WS⊞υιP⪫υ¶

Input the instructions and print them to the canvas without moving the cursor.

W⊕⌕⪪HIO>^<v¹KK

While the character under the cursor is a valid instruction:

¿‹ι⁴

If this was an intersection-type character, then...

¿⁼⊖ι﹪φ²⎚

... if this intersection should halt the program than clear the canvas, causing the loop to exit, ...

M✳⊗φ

... otherwise move on through the intersection.

«≔ιφ✳⊗φψ»

Otherwise, update the direction, replace the current character with a null marker and move in the new direction.

≔KKθ⎚⁼θψ

Output whether the cursor landed on a null marker, indicating an infinite loop.

Charcoal, 56 bytes

WS⊞υιP⪫υ¶W⊕⌕⪪HIO>^<v¹KK¿‹ι⁴¿⁼⊖ι﹪φ²⎚M✳⊗φ«≔ιφ✳⊗φψ»≔KKθ⎚⁼θψ

Try it online! Link is to verbose version of code. Takes input as a list of newline-terminated strings and outputs - if the program does not halt, nothing if it halts. Explanation:

WS⊞υιP⪫υ¶

Input the instructions and print them to the canvas without moving the cursor.

W⊕⌕⪪HIO>^<v¹KK

While the character under the cursor is a valid instruction:

¿‹ι⁴

If this was an intersection-type character, then...

¿⁼⊖ι﹪φ²⎚

... if this intersection should halt the program then clear the canvas, causing the loop to exit, ...

M✳⊗φ

... otherwise move on through the intersection.

«≔ιφ✳⊗φψ»

Otherwise, update the direction, replace the current character with a null marker and move in the new direction.

≔KKθ⎚⁼θψ

Output whether the cursor landed on a null marker, indicating an infinite loop.

Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

Charcoal, 56 bytes

WS⊞υιP⪫υ¶W⊕⌕⪪HIO>^<v¹KK¿‹ι⁴¿⁼⊖ι﹪φ²⎚M✳⊗φ«≔ιφ✳⊗φψ»≔KKθ⎚⁼θψ

Try it online! Link is to verbose version of code. Takes input as a list of newline-terminated strings and outputs - if the program does not halt, nothing if it halts. Explanation:

WS⊞υιP⪫υ¶

Input the instructions and print them to the canvas without moving the cursor.

W⊕⌕⪪HIO>^<v¹KK

While the character under the cursor is a valid instruction:

¿‹ι⁴

If this was an intersection-type character, then...

¿⁼⊖ι﹪φ²⎚

... if this intersection should halt the program than clear the canvas, causing the loop to exit, ...

M✳⊗φ

... otherwise move on through the intersection.

«≔ιφ✳⊗φψ»

Otherwise, update the direction, replace the current character with a null marker and move in the new direction.

≔KKθ⎚⁼θψ

Output whether the cursor landed on a null marker, indicating an infinite loop.