BYE-LAWS of the H.PIPER STEAM-ENGINE RAILROAD (H.P.S-E.R.R.)
1. Every train on the H.P.S-E.R.R. must comprise only consecutively serial-numbered wagons.
2. Once chosen, such wagons must be assembled in ascending order of the quantity, size and (if necessary) power of the distinct prime factors of the wagons’ serial-numbers; e.g car 41 before car 1681(41,41) before car 39(3,13 )before car 30(2,3,5).
3. The lowest serial-numbered wagon must be in caboose* position.
If the serial-number of the first wagon in today's train is a perfect cube, what is the maximum length of the train?
(Small hint: wagon No. 194481 is the most recent addition to the rolling stock of the H.P.S-E.R.R.)
There is also a bonus, for the ingenious reader.
* a 'caboose' is the last wagon at the back end of the train.
using the following code in Mathematica I found the longest possible train (when largest possible serial is 194481) is 195 cars long, its serial numbers range from 4095 to 4289 with the first car being 4096=16^3
the order of the serial numbers is{4096,4099,4111,4127,4129,4133,4139,4153,4157,
4159,4177,4201,4211,4217,4219,4229,4231,4241,
4243,4253,4259,4261,4271,4273,4283,4289,4106,
4126,4138,4162,4166,4174,4178,4198,4222,4226,
4258,4262,4274,4282,4286,4124,4132,4156,4196,
4204,4244,4252,4276,4232,4168,4184,4112,4208,
4192,4288,4107,4101,4119,4143,4197,4227,4269,
4281,4287,4113,4149,4167,4203,4239,4131,4205,
4105,4115,4135,4145,4195,4265,4285,4225,4175,
4109,4151,4193,4207,4249,4103,4169,4213,4279,
4121,4097,4267,4237,4117,4163,4247,4181,4141,
4223,4171,4183,4187,4189,4098,4146,4206,4254,
4122,4194,4266,4190,4210,4150,4250,4102,4214,
4202,4246,4114,4238,4142,4118,4234,4154,4116,
4164,4188,4236,4212,4220,4100,4172,4228,4268,
4108,4148,4152,4248,4104,4120,4280,4136,4264,
4216,4272,4176,4240,4144,4128,4256,4160,4224,
4155,4215,4245,4125,4137,4179,4263,4191,4173,
4251,4233,4161,4209,4275,4221,4257,4185,4235,
4165,4255,4277,4123,4147,4199,4110,4170,4242,
4134,4182,4218,4278,4230,4158,4130,4270,4186,
4260,4140,4284,4180,4200,4095}
the code used to find this was:
IsFirst[x_,y_]:=(
If[xƒú1,Return[True],
If[yƒú1,Return[False],
fx=FactorInteger[x];
fy=FactorInteger[y];
lngx=Length[fx];
lngy=Length[fy];
If[lngx<lngy,Return[True],
If[lngy<lngx,Return[False],
found=False;
i=1;
While[!found && i„Tlngx,
px=fx[[i,1]];
pxp=fx[[i,2]];
py=fy[[i,1]];
pyp=fy[[i,2]];
If[px<py,found=True;Return[True],
If[py<px,found=True;Return[False],
If[pxp<pyp,found=True;Return[True],
If[pyp<pxp,found=True;Return[False];
];];];];
++i;
];
];];
];];
);
lmt=194481;
maxlng=0;
maxtrain={};
ProgressIndicator[Dynamic[n^3/lmt]]
For[n=1,n^3„Tlmt,++n,
s=n^3;
c=s-1;
train={s};
While[IsFirst[c+1,c] && c>0,
AppendTo[train,c];
--c;
];
++c;
x=s+1;
While[IsFirst[s,x] && IsFirst[x,c] && x„Tlmt,
AppendTo[train,x];
++x;
];
train=Sort[train,IsFirst];
lng=Length[train];
If[lng>maxlng,
maxlng=lng;
maxtrain=train;
];
];
maxlng
maxtrain[[1]]^(1/3)
Min[maxtrain]
Max[maxtrain]
maxtrain
|
Posted by Daniel
on 2010-10-02 11:43:01 |