MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Horse Race Puzzle (fwd)


I omitted "{x," in the second replacement rule, which should read
"->{x,Flatten[{y,n}],z}}".  The corrected version appears below.  

> The solutions can be computed recursively using pattern matching as 
> follows:
> 
> HorseRaces[1]={{1}};
> HorseRaces[n_]:=HorseRaces[n]=
> 	Join[
> Flatten[Map[ReplaceList[#,{x___,y___}->{x,n,y}]&,HorseRaces[n-1]],1],
>    Flatten[ReplaceList[#,{x___,y_,z___}->{x,Flatten[{y,n}],z}]&,
> 	HorseRaces[n-1]],1]
> 	]
> 
> Unfortunately, Mathematica seems to ignore the Flatten[{y,n}] command,
> returning 
> {y,n} unflattened.  However, this only gives some unambiguous extra
> nesting in the solutions.



  • Prev by Date: Re: mathematica question
  • Next by Date: Re: mathematica question
  • Previous by thread: Re: Write Protected Functions
  • Next by thread: Re: Re: Horse Race Puzzle (fwd)