Skip to main content
added explanation
Source Link
Jo King
  • 48.1k
  • 6
  • 131
  • 187

Perl 6, 46 43 36 bytes

{$_.=rotate(.[0]*=-1)xx 2**$_;!.[0]} 

Try it online!

Represents halt by 0 and returns true if the machine halts. This repeats the logic 2**(length n) times, where if the pointer ends up on the halt cell, it stays there, otherwise it will be on a non-halt cell. This works because there are only 2**n possible states (ignoring halt cells) for the Foo machine to be in, since each non-halt cell has only two states. Okay yes, there are states than that, but due to the limited possible transitions between pointers (and therefore states) there will be less than 2**$_ states... I think

Explanation

{ } # Anonymous codeblock xx 2**$_ # Repeat 2**len(n) times .[0]*=-1 # Negate the first element $_.=rotate( ) # Rotate the list by that value ;!.[0] # Return if the first element is 0 

Perl 6, 46 43 36 bytes

{$_.=rotate(.[0]*=-1)xx 2**$_;!.[0]} 

Try it online!

Represents halt by 0 and returns true if the machine halts. This repeats the logic 2**(length n) times, where if the pointer ends up on the halt cell, it stays there, otherwise it will be on a non-halt cell. This works because there are only 2**n possible states (ignoring halt cells) for the Foo machine to be in, since each non-halt cell has only two states. Okay yes, there are states than that, but due to the limited possible transitions between pointers (and therefore states) there will be less than 2**$_ states... I think

Perl 6, 46 43 36 bytes

{$_.=rotate(.[0]*=-1)xx 2**$_;!.[0]} 

Try it online!

Represents halt by 0 and returns true if the machine halts. This repeats the logic 2**(length n) times, where if the pointer ends up on the halt cell, it stays there, otherwise it will be on a non-halt cell. This works because there are only 2**n possible states (ignoring halt cells) for the Foo machine to be in, since each non-halt cell has only two states. Okay yes, there are states than that, but due to the limited possible transitions between pointers (and therefore states) there will be less than 2**$_ states... I think

Explanation

{ } # Anonymous codeblock xx 2**$_ # Repeat 2**len(n) times .[0]*=-1 # Negate the first element $_.=rotate( ) # Rotate the list by that value ;!.[0] # Return if the first element is 0 
-7 bytes
Source Link
Jo King
  • 48.1k
  • 6
  • 131
  • 187

Perl 6, 46 43 4336 bytes

{$!=0;($_.=rotate($!-=.[$!]*=[0]*=-1)%=$_)xx 2**$_;!.[$!][0]} 

Try it online!Try it online!

Represents halt by 0 and returns true if the machine halts. This repeats the logic 2**(length n) times, where if the pointer ends up on the halt cell, it stays there, otherwise it will be on a non-halt cell. This works becauseThis works because there are only 2**n possible states (ignoring halt cells) for the Foo machine to be in, since each non-halt cell has only two states. Okay yes, there are only 2**n possible states than that, but due to the limited possible transitions between pointers (ignoring halt cellsand therefore states) for the Foo machine tothere will be in, since each non-halt cell has only twoless than 2**$_ states... I think

Explanation:

{ } # Anonymous code block $!=0; # Initialise $! to 0 ( )xx 2**$_ # Loop 2**n times .[$!]*=-1 # Negate the current cell $!-= # And subtract the result from the pointer ( )%=$_ # Modulo the result by n to wrap around ;!.[$!] # Return if halted 

Perl 6, 46 43 bytes

{$!=0;(($!-=.[$!]*=-1)%=$_)xx 2**$_;!.[$!]} 

Try it online!

Represents halt by 0 and returns true if the machine halts. This repeats the logic 2**(length n) times, where if the pointer ends up on the halt cell, it stays there, otherwise it will be on a non-halt cell. This works because there are only 2**n possible states (ignoring halt cells) for the Foo machine to be in, since each non-halt cell has only two states.

Explanation:

{ } # Anonymous code block $!=0; # Initialise $! to 0 ( )xx 2**$_ # Loop 2**n times .[$!]*=-1 # Negate the current cell $!-= # And subtract the result from the pointer ( )%=$_ # Modulo the result by n to wrap around ;!.[$!] # Return if halted 

Perl 6, 46 43 36 bytes

{$_.=rotate(.[0]*=-1)xx 2**$_;!.[0]} 

Try it online!

Represents halt by 0 and returns true if the machine halts. This repeats the logic 2**(length n) times, where if the pointer ends up on the halt cell, it stays there, otherwise it will be on a non-halt cell. This works because there are only 2**n possible states (ignoring halt cells) for the Foo machine to be in, since each non-halt cell has only two states. Okay yes, there are states than that, but due to the limited possible transitions between pointers (and therefore states) there will be less than 2**$_ states... I think

-3 bytes
Source Link
Jo King
  • 48.1k
  • 6
  • 131
  • 187

Perl 6, 4646 43 bytes

{$!=0;(($!-=.[$!]=]*=-.[$!]1)%=$_)xx 2**$_;!.[$!]} 

Try it online!Try it online!

Represents halt by 0 and returns true if the machine halts. This repeats the logic 2**(length n) times, where if the pointer ends up on the halt cell, it stays there, otherwise it will be on a non-halt cell. This works because there are only 2**n possible states (ignoring halt cells) for the Foo machine to be in, since each non-halt cell has only two states.

Explanation:

{  } # Anonymous code block $!=0; # Initialise $! to 0 (  )xx 2**$_ # Loop 2**n times .[$!]=]*=-.[$!]1 # Negate the current cell $!-=  # And subtract the result from the pointer (  )%=$_ # Modulo the result by n to wrap around   ;!.[$!] # Return if halted 

Perl 6, 46 bytes

{$!=0;(($!-=.[$!]=-.[$!])%=$_)xx 2**$_;!.[$!]} 

Try it online!

Represents halt by 0 and returns true if the machine halts. This repeats the logic 2**(length n) times, where if the pointer ends up on the halt cell, it stays there, otherwise it will be on a non-halt cell. This works because there are only 2**n possible states (ignoring halt cells) for the Foo machine to be in, since each non-halt cell has only two states.

Explanation:

{  } # Anonymous code block $!=0; # Initialise $! to 0 (  )xx 2**$_ # Loop 2**n times .[$!]=-.[$!] # Negate the current cell $!-=  # And subtract the result from the pointer (  )%=$_ # Modulo the result by n to wrap around   ;!.[$!] # Return if halted 

Perl 6, 46 43 bytes

{$!=0;(($!-=.[$!]*=-1)%=$_)xx 2**$_;!.[$!]} 

Try it online!

Represents halt by 0 and returns true if the machine halts. This repeats the logic 2**(length n) times, where if the pointer ends up on the halt cell, it stays there, otherwise it will be on a non-halt cell. This works because there are only 2**n possible states (ignoring halt cells) for the Foo machine to be in, since each non-halt cell has only two states.

Explanation:

{ } # Anonymous code block $!=0; # Initialise $! to 0 ( )xx 2**$_ # Loop 2**n times .[$!]*=-1 # Negate the current cell $!-= # And subtract the result from the pointer ( )%=$_ # Modulo the result by n to wrap around ;!.[$!] # Return if halted 
-2 bytes + explanation
Source Link
Jo King
  • 48.1k
  • 6
  • 131
  • 187
Loading
Source Link
Jo King
  • 48.1k
  • 6
  • 131
  • 187
Loading