- - PR -
Look! Ma' the script can compute!
| 投稿者 | 投稿内容 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
投稿日時: 2001-09-21 03:38
"Mathematical Goodbye" by Mori Hiroshi has this quiz:
suppose five balls are numbered and linked in a ring, sum the numbers of balls that are in consequtive places. when the sums range all the numbers from 1 to 21, find the numbers. hints: there is a ball numbered "1" there is a ball numbered "2" extra credit: program in w2k batch script. | ||||||||||||
|
投稿日時: 2001-09-21 03:43
need more hint?
the maximum number is 10. solution is unique taking into account order/symmetry good luck! | ||||||||||||
|
投稿日時: 2001-09-21 11:01
Hi Oregon,
Yes I have worked the answer out. It was fun! I used a simple breadth first search technique to find the answer. Should I post the answer here now? Or Should I wait for others to enjoy this question? I don't know how to write windows batch script, so I didn't do that. If you are interested, I can write a Java program to find the answer. [ メッセージ編集済み 編集者: H2 編集日時 2001-09-21 11:11 ] | ||||||||||||
|
投稿日時: 2001-09-23 08:33
good to hear! mine is a horse-deer search and human post-process to identify the uniqueness.
how thoughtful, but I don't care. we're free and all up to you.
love to see that! maybe you can crosspost it to "Java Solutions" as well. extra credit (2): if we say the original problem N(5)=21, what is N(6)? | ||||||||||||
|
投稿日時: 2001-09-23 19:37
I have made the java program. You can download it at my home page, here(English) OR 日本語ページへ. I put a lot of comments on the source, so people can understand what I am doing. Pleas ask me any questions if code is not understandable.
You can compile it by:
and run the program by:
It will use breadth first search that I used to find the solution. The program is very inflexible as it only solves the same problem over and over. The output will never change I explain what I did. (because TwentyOne does exactly the samething as I did, you can follow the source, too) 1. fix 1 at one of the ball as we know 1 has to go somewhere 2. pick any place for 2, again, because we know 2 has to be somewhere 3. now, pick a number between 3 and 10 4. place that number picked at one of the ball which are not used yet 5. Add 1, 2 and number we picked at step 3 6. list all the combination of number that can sum up to 21 with the sum that we found in step 5 7. place the numbers of combinations on the ball 8. test them if they can make the numbers go to step 11 if solution is found 9. if none of them work, then go back to step 3 pick another number and repeat 10 if all numbers were tried, go back to step 2 and pick different place for it and repeat 11. FINISH! Since, the program is very inflexible, it only solves N(5). I think I can modify it to find the other question, but I have not enough time for it at moment, I'll try if I have time.
What is horse-deer search? I have never heard of it. I am very curious. [ メッセージ編集済み 編集者: H2 編集日時 2001-09-23 19:38 ] [ メッセージ編集済み 編集者: H2 編集日時 2001-09-23 19:38 ] | ||||||||||||
|
投稿日時: 2001-09-27 08:40
H2 figured it right.
hers' my code in w2k script based on BAKA search
| ||||||||||||
|
投稿日時: 2001-09-27 09:00
OH!! I got it. Horse(馬)&Deer(鹿) Search!! I didn't realize... | ||||||||||||
|
投稿日時: 2001-09-28 00:06
N(4)=13 (2 solutions: max element 7)
[1 2 6 4] [1 3 2 7] N(5)=21 (1 sol: max: 10) [1 2 10 2 5] N(6)=31 (5 sol: max: 14) [1 2 5 4 6 13] [1 2 7 4 12 5] [1 3 2 7 8 10] [1 3 6 2 5 14] [1 7 3 2 4 14] N(7)=? any one? I dare not try in w2k script on my PC. | ||||||||||||
