- 积分
- 16
- 注册时间
- 2006-6-3
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2008-4-25 03:50:06
|
显示全部楼层
来自 美国
原帖由 FreddyMusic 于 2008-4-24 15:17 发表 
We have two possiblity:
1. To make dynamic list with more digitals and one pcs shorter rings.
Eg. digital 1-11 or 1-13, / Rings 6 or 7 pcs ( One digital in one ring space )
then check the mid ...
According to my understanding, we were just asked for dynamic controls, the sliders. It is simple. I don't think they are asking for more complicated problems and algorithms. By slightly modifying your code, I come up with- rsum = 11;
- Print["Control the identical target sum of each circle by " Slider[
- Dynamic[rsum], {3, 24, 1}]]
- Print["Current target sum is " Style[Dynamic[rsum], Large, Bold, Purple]]
- Dynamic[{
- numberintwo = Permutations[Range[1, 9], {4}];
- csum = Total[numberintwo, {2}];
- v = rsum*5 - 45;
- p = Flatten[Position[csum, v]];
-
- (* Search pandigital list *)
- Sol = {};
- Do[{cc = numberintwo[[p[]]];
- r = { rsum - cc[[1]], cc[[1]], rsum - cc[[1]] - cc[[2]],
- cc[[2]], rsum - cc[[2]] - cc[[3]], cc[[3]],
- rsum - cc[[3]] - cc[[4]], cc[[4]], rsum - cc[[4]]};
- r1 = Union[r];
- If[
- Min[r1] == 1 && Max[r1] == 9 &&
- Length[r1] == 9, {Sol = Append[Sol, r]}];}, {i, Length[p]}];
-
- (* Plot digital and rings *)
- If[Sol == {},
- Graphics[{Text[
- Style["No solution.", Large, Bold, Purple], {0, 0},
- Automatic]}, ImageSize -> {575, 300}],
- GraphicsGrid[Table[
- Graphics[{Thickness[0.01],
- (* Plot Olympic five rings *)
- RGBColor[0, .5, .76], Circle[{0, 0}, 2],
- RGBColor[34/256, 30/256, 29/256], Circle[{4.5, 0}, 2],
- RGBColor[235/256, 29/256, 42/256], Circle[{9, 0}, 2],
- RGBColor[251/256, 178/256, 49/256], Circle[{2.25, -2.25}, 2],
- RGBColor[1/256, 156/256, 88/256], Circle[{6.75, -2.25}, 2],
- (* Replot Olympic five rings to make it connect *)
- RGBColor[0, .5, .76], Circle[{0, 0}, 2, {-Pi/3, 0}],
- RGBColor[34/256, 30/256, 29/256],
- Circle[{4.5, 0}, 2, {-Pi/3, 0}],
- RGBColor[34/256, 30/256, 29/256],
- Circle[{4.5, 0}, 2, {Pi*1.3, Pi*1.5}],
- RGBColor[235/256, 29/256, 42/256],
- Circle[{9, 0}, 2, {Pi*1.3, Pi*1.5}],
- (* Plot Numbers in rings *)
- Text[Style[Sol[[2 i + j]][[1]], 20, Purple], {0, 0}],
- Text[
- Style[Sol[[2 i + j]][[2]], 20, Purple], {2.25/2, -2.25/2}],
- Text[Style[Sol[[2 i + j]][[3]], 20, Purple], {2.25, -2.25}],
- Text[
- Style[Sol[[2 i + j]][[4]], 20,
- Purple], {(2.25 + 4.5)/2, -2.25/2}],
- Text[Style[Sol[[2 i + j]][[5]], 20, Purple], {4.5, 0}],
- Text[
- Style[Sol[[2 i + j]][[6]], 20,
- Purple], {(4.5 + 6.75)/2, -2.25/2}],
- Text[Style[Sol[[2 i + j]][[7]], 20, Purple], {6.75, -2.25}],
- Text[
- Style[Sol[[2 i + j]][[8]], 20,
- Purple], {(6.75 + 9)/2, -2.25/2}],
- Text[Style[Sol[[2 i + j]][[9]], 20, Purple], {9, 0}]
- }], {i, 0, Length[Sol]/2 - 1}, {j, 1, 2}],
- ImageSize -> {575, 300}]]}]
复制代码 You see the range of sum is from 3 to 24. The basic reason is that there are at least two or at most three numbers in any circle, so the sum can not be less than 1+2 or greater than 9+8+7. Definitely, this is a necessary condition.
And I remove "found" because we have checked fully. "No solution" is the fact.
[ 本帖最后由 pcqsl 于 2008-4-25 04:31 编辑 ] |
|