RE: Horse Race Puzzle (fwd)
- To: mathgroup at smc.vnet.net
- Subject: [mg9259] RE: [mg9162] Horse Race Puzzle (fwd)
- From: Robert Pratt <rpratt at math.unc.edu>
- Date: Fri, 24 Oct 1997 01:01:14 -0400
- Sender: owner-wri-mathgroup at wolfram.com
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.