I am trying to understand code used to solve the 100 doors problem of rosettacode. The code in question is this
n=100;
tmp=ConstantArray[-1,n];
Do[tmp[[i;;;;i]]*=-1;,{i,n}];
Do[Print["door ",i," is ",If[tmp[[i]]==-1,"closed","open"]],
{i,1,Length[tmp]}]
I understand every line except the third. I have never seen the construct
Do[tmp[[i;;;;i]]*=-1;,{i,n}];
what do these semicolons inside a list do. What is the * for?
FullForm, e.g.,Hold[tmp[[i;;;;i]]] //FullFormorHold[tmp[[i ;; ;; i]] *= -1] // FullForm– Carl Woll Oct 18 '17 at 15:36