Problem 315
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
In particular don't post any code fragments or results.
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
-
LarryBlake
- Posts: 100
- Joined: Sat Aug 29, 2009 8:49 pm
-
LarryBlake
- Posts: 100
- Joined: Sat Aug 29, 2009 8:49 pm
Re: Problem 315
I think I didn't understand the question originally.
Let's say the first prime is 10000019. I don't calculate the transition from that to the next prime. I add up the digits and get 11, then add those and get 2, figuring out the transitions on the way. Then I go to the next prime.
1. Is that correct?
2. Do I clear Max's clock after I reach 2, or does that stay as the transition to the next prime?
EDIT: For those who read this, the answer to both questions is yes. Prime, then its transitions, then clear. Then next prime.
Let's say the first prime is 10000019. I don't calculate the transition from that to the next prime. I add up the digits and get 11, then add those and get 2, figuring out the transitions on the way. Then I go to the next prime.
1. Is that correct?
2. Do I clear Max's clock after I reach 2, or does that stay as the transition to the next prime?
EDIT: For those who read this, the answer to both questions is yes. Prime, then its transitions, then clear. Then next prime.

- jaap
- Posts: 588
- Joined: Tue Mar 25, 2008 3:57 pm
- Contact:
Re: Problem 315
Yes, the specification for the clock states "... and then it will go black, waiting for the next number.", and that holds for both Sam's and Max's implementation of the clock.
P.S. Did anyone else notice that the animation of Sam's clock (on the left) is a little weird - the first 1 of 11 doesn't appear in the same place as the 3 in 137 did.
P.S. Did anyone else notice that the animation of Sam's clock (on the left) is a little weird - the first 1 of 11 doesn't appear in the same place as the 3 in 137 did.
-
arie
- Posts: 5
- Joined: Wed Sep 16, 2009 10:03 pm
Re: Problem 315
A more important detail: both clocks should be at least 8 digits wide (it's not a mod 1000 problem, nor a 3-digit-shifting-window-clock problem).jaap wrote:Did anyone else notice that the animation of Sam's clock (on the left) is a little weird - the first 1 of 11 doesn't appear in the same place as the 3 in 137 did.
Still a nice animation.
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 315
Sam and Max have built very CLEVER clocks with a lot of features.arie wrote:A more important detail: both clocks should be at least 8 digits wide (it's not a mod 1000 problem, nor a 3-digit-shifting-window-clock problem).jaap wrote:Did anyone else notice that the animation of Sam's clock (on the left) is a little weird - the first 1 of 11 doesn't appear in the same place as the 3 in 137 did.
Still a nice animation.
First of all their clocks use a proportional font. Clever isn't it?
Secondly, for larger numbers they use a smaller font automatically.
However, we didn't think it wise to highlight all the clever features of their clocks because that would distract from the problem.

War ruins the life and health of untold numbers of innocent children.
-
arie
- Posts: 5
- Joined: Wed Sep 16, 2009 10:03 pm
-
random_dg
- Posts: 1
- Joined: Tue Dec 21, 2010 9:26 pm
Re: Problem 315
Hi,
I don't know if it will help, but in a previous question (one of the first 50 I believe) you called that same mathematical transition a digital sum, but now you call it a digital root. That was confusing. Perhaps you'd consider rephrasing it? (I see I'm not the first one who entered the forum to check about it).
Best regards.
I don't know if it will help, but in a previous question (one of the first 50 I believe) you called that same mathematical transition a digital sum, but now you call it a digital root. That was confusing. Perhaps you'd consider rephrasing it? (I see I'm not the first one who entered the forum to check about it).
Best regards.
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 315
The digital root of a number is something else than calculating the sum of the digits of a number once.
See http://en.wikipedia.org/wiki/Digital_root, http://mathworld.wolfram.com/DigitalRoot.html
and Problem 159 (View Problem)
See http://en.wikipedia.org/wiki/Digital_root, http://mathworld.wolfram.com/DigitalRoot.html
and Problem 159 (View Problem)

War ruins the life and health of untold numbers of innocent children.
-
eppie
- Posts: 14
- Joined: Sat Jul 02, 2011 5:19 pm
Re: Problem 315
The problem states:
"The two clocks are fed all the prime numbers between A = 10^7 and B = 2x10^7. "
Does this mean I can just feed the primes from a file, or is calculating all the primes in this 10^7 interval count as running time? Does this too need to fit in the 1 minute rule?
"The two clocks are fed all the prime numbers between A = 10^7 and B = 2x10^7. "
Does this mean I can just feed the primes from a file, or is calculating all the primes in this 10^7 interval count as running time? Does this too need to fit in the 1 minute rule?
- jaap
- Posts: 588
- Joined: Tue Mar 25, 2008 3:57 pm
- Contact:
Re: Problem 315
That's entirely up to you.eppie wrote:Does this mean I can just feed the primes from a file, or is calculating all the primes in this 10^7 interval count as running time? Does this too need to fit in the 1 minute rule?
However it is possible to generate those primes very quickly (a few seconds at most), and having code that does that is very useful in many of the other problems.
- rayfil
- Administrator
- Posts: 1412
- Joined: Sun Mar 26, 2006 5:30 am
- Location: Quebec, Canada
- Contact:
Re: Problem 315
It's also a good idea to make yourself a file with all the primes up to 100 Mb. You then load whatever section is required for problems where primes are needed. There's no reason to recalculate all those primes each and every time you do need them. Consider it as one of your reusable tools.
When you assume something, you risk being wrong half the time.
-
jochenkeutel
- Posts: 6
- Joined: Thu Oct 13, 2011 2:01 am
Re: Problem 315
For some reason I get a wrong answer. Could please someone tell me if this is right:
last p < 2000000: 1999993
For this p=1999993:
Sam needs 116 transitions.
Max needs 78 transitions.
Thanks, Jochen.
last p < 2000000: 1999993
For this p=1999993:
Sam needs 116 transitions.
Max needs 78 transitions.
Thanks, Jochen.
- rayfil
- Administrator
- Posts: 1412
- Joined: Sun Mar 26, 2006 5:30 am
- Location: Quebec, Canada
- Contact:
Re: Problem 315
Those seem correct. I would assume you know that p=1999993 is not in the targeted range.For this p=1999993:
Sam needs 116 transitions.
Max needs 78 transitions.
When you assume something, you risk being wrong half the time.
-
drwhat
- Posts: 45
- Joined: Tue Sep 06, 2011 4:56 am
Re: Problem 315
Digital 6s and 9s
Does a 6 have the top horizontal bar, and 9 have the bottom horizontal bar (and this use 6 of the 7 bars each?) or do they only use 5 of them each?
Does a 6 have the top horizontal bar, and 9 have the bottom horizontal bar (and this use 6 of the 7 bars each?) or do they only use 5 of them each?
-
mynameisalreadytaken
- Posts: 20
- Joined: Sun Sep 25, 2011 11:20 pm
-
drwhat
- Posts: 45
- Joined: Tue Sep 06, 2011 4:56 am
Re: Problem 315
Heh i missed that part under it.
Though didnt matter I just ran it both ways and got the right answer in
Though didnt matter I just ran it both ways and got the right answer in
-
jochenkeutel
- Posts: 6
- Joined: Thu Oct 13, 2011 2:01 am
Re: Problem 315
Funny. Just forgotten a 0 in the start and end number of the loop ... Just took the right numbers now, and solution is correct.rayfil wrote:Those seem correct. I would assume you know that p=1999993 is not in the targeted range.For this p=1999993:
Sam needs 116 transitions.
Max needs 78 transitions.
Thank you very much!
- jake223
- Posts: 61
- Joined: Mon Apr 25, 2011 5:15 am
- Location: USA
- Contact:
Re: Problem 315
I get the right numbers for all the test cases but wrong for the answer. Are the following numbers right for the gaps between the values of Max's clock and Sam's clock?
Code: Select all
1 0
2 0
3 0
5 0
7 0
11 2
13 6
17 6
19 18
23 8
29 8
31 4
37 14
41 2
43 6
47 10
53 10
59 16
61 4
67 14
71 4
73 16
79 18
83 10
89 16
97 12
-
mdean
- Posts: 206
- Joined: Tue Aug 02, 2011 2:05 am
Re: Problem 315
My guess is you forgot about the overhang on the 7. Just doing it in my head, 17 and 37 appear to be wrong. I didn't look much past that point.jake223 wrote:I get the right numbers for all the test cases but wrong for the answer. Are the following numbers right for the gaps between the values of Max's clock and Sam's clock?Code: Select all
1 0 2 0 3 0 5 0 7 0 11 2 13 6 17 6 19 18 23 8 29 8 31 4 37 14 41 2 43 6 47 10 53 10 59 16 61 4 67 14 71 4 73 16 79 18 83 10 89 16 97 12

- jake223
- Posts: 61
- Joined: Mon Apr 25, 2011 5:15 am
- Location: USA
- Contact:
Re: Problem 315
I get 37->10 is 2+3=5 and 10->1 is 2; (2+5)*2=14
I get 17->8 is 3; 3*2=6.
Both are correct. Thanks anyway.
I get 17->8 is 3; 3*2=6.
Both are correct. Thanks anyway.


