Problem 361

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
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.

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


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
jovo_amf
Posts: 1
Joined: Thu Dec 08, 2011 9:51 pm

Problem 361

Post by jovo_amf »

I just don't understand the problem
Can someone explain to me why A(12) = 18?
thundre
Posts: 356
Joined: Sun Mar 27, 2011 10:01 am

Re: Problem 361

Post by thundre »

jovo_amf wrote:Can someone explain to me why A(12) = 18?
T = 01101001100101101001011001101001...

A(12)=18 because 14 through 17 never appear in T.

14: 1110
15: 1111
16: 10000
17: 10001

18: 10010 does appear, so that is the next A.
Image
mantonetti
Posts: 3
Joined: Thu Jan 26, 2012 11:00 pm

Re: Problem 361

Post by mantonetti »

Maybe my English is not enough to understand the terms of the problem, but I think there is an error: the number 4 (bin 100) appears in the sequence in places T4-T6, while the number 5 (bin 101) appears in places T3-T5 (so before number 4), and therefore to A4 should correspond n = 5 and to A5 should correspond n = 4.
Of course maybe that I didn't understand in which way n is associated with An; can someone clarify, please?
Image
User avatar
Marcus_Andrews
Administrator
Posts: 1637
Joined: Wed Nov 09, 2011 5:23 pm

Re: Problem 361

Post by Marcus_Andrews »

The question isn't asking about which binary expressions appear before/after other binary expressions. {An} is a sorted sequence of integers such that those integers have binary expressions somewhere in the Thue-Morse sequence {Tn}. 4 and 5's binary representations exist in {Tn}, so 4 and 5 are included in the sorted sequence {An}.

Example: Putting aside the 0-case, A(100) = 3251 means that the 100th element of {An} is 3251. Similarly, the 12th element is 18.
mantonetti
Posts: 3
Joined: Thu Jan 26, 2012 11:00 pm

Re: Problem 361

Post by mantonetti »

That's fine! Now I understood! (At least, I hope :wink: )

Many thanks! :D
Image
ffff0
Posts: 50
Joined: Sun Aug 21, 2011 6:26 am
Location: Moscow, Russian Federation

Re: Problem 361

Post by ffff0 »

Just wonder how many memory is required for this problem since A(10^18) has more than 2*10^9 binary digits and there are more than 3*10^9 numbers of such length?
Last edited by ffff0 on Tue Jul 17, 2012 5:01 am, edited 1 time in total.
Image
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 361

Post by TripleM »

But you only need the last 9 digits :)

You will never need an excessive amount of memory for a Project Euler problem.
ffff0
Posts: 50
Joined: Sun Aug 21, 2011 6:26 am
Location: Moscow, Russian Federation

Re: Problem 361

Post by ffff0 »

I know, but right now I need to store all tree to know which number is the right one.

Will keep thinking.
Image
User avatar
Marcus_Andrews
Administrator
Posts: 1637
Joined: Wed Nov 09, 2011 5:23 pm

Re: Problem 361

Post by Marcus_Andrews »

The problem is able to be solved in under a second and with very little memory usage.
ffff0
Posts: 50
Joined: Sun Aug 21, 2011 6:26 am
Location: Moscow, Russian Federation

Re: Problem 361

Post by ffff0 »

Looks like I'll learn this method from solution thread after brute-forsing right answer.
Image
thundre
Posts: 356
Joined: Sun Mar 27, 2011 10:01 am

Re: Problem 361

Post by thundre »

ffff0 wrote:Looks like I'll learn this method from solution thread after brute-forsing right answer.
My best-so-far solution (which I wouldn't call brute-force) bogged after 1014. :(

It is quite an interesting sequence.
Image
ffff0
Posts: 50
Joined: Sun Aug 21, 2011 6:26 am
Location: Moscow, Russian Federation

Re: Problem 361

Post by ffff0 »

Last steps of my method are brute-force. It takes 30 minutes and 2 GB of RAM to get an answer.
Image
Post Reply