Skip to main content
1 of 2
V. Courtois
  • 956
  • 5
  • 15

Scala, 158 bytes

Still golfable IMO, but I'm okay with it for now. Returns 0 for non-halting Foos and 1 for halting Foos. Takes the input in a as an Array[Int], so h is taken as 0.

var u=Seq[Array[Int]]()//Keep track of all states var i=0//Index do{if(a(i)==0)return 1//Halt u:+=a.clone//Add current state in the tracker var k=i//Stock temp index i=(a(i)+i)%a.length//Move index to next step if(i<0)i+=a.length//Modulus operator in Scala can return a negative value... a(k)*=(-1)}while(u.forall(_.deep!=a.deep))//Change sign of last step ; check if we are in a previously encountered step 0//Returns 0 if we met a previous step 

It is pretty long to run (around 4 seconds for all the test cases) because of the multiple full-array lookups I did, plus the .deep that create copies... But you can still try it online.

V. Courtois
  • 956
  • 5
  • 15