Problem 287

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
elr
Posts: 67
Joined: Thu Apr 09, 2009 9:47 am

Problem 287

Post by elr »

is the picture at the problem page represent D2 ?
Image
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 287

Post by jaap »

No, D2 has a different pattern of white/black pixels. The picture is only to explain the coding scheme.
elr
Posts: 67
Joined: Thu Apr 09, 2009 9:47 am

Re: Problem 287

Post by elr »

oh,it would have been much more useful if D2 was displayed instead of some arbitrary picture
Image
elr
Posts: 67
Joined: Thu Apr 09, 2009 9:47 am

Re: Problem 287

Post by elr »

could someone please verify for me that a minimal sequence for D5 having a length of 499 ?
Image
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 287

Post by jaap »

elr wrote:could someone please verify for me that a minimal sequence for D5 having a length of 499 ?
Yes, I think that's correct.
Fogmeister
Posts: 27
Joined: Mon Aug 22, 2011 11:20 am

Re: Problem 287

Post by Fogmeister »

I'm not going to beat any speed records with my program but it's going to get the right answer (I think). It does for smaller values of N anyway. (My only problem might be overflow issues).

For anyone else who has solved it what kind of run times do you get? I've been trying to think of a more efficient algorithm than the one I have but struggling to think how it can be done any other way?!

I've searched for quad tree stuff but nothing has jumped out at me yet.

Lol, will be interesting to read the other solutions.
Image
User avatar
Marcus_Andrews
Administrator
Posts: 1637
Joined: Wed Nov 09, 2011 5:23 pm

Re: Problem 287

Post by Marcus_Andrews »

Without any sort of optimizations other than the "crucial" one, it shouldn't take more than a minute or two in C++. There are other optimizations you can use that'll bring total runtimes down to less than a second.
Fogmeister
Posts: 27
Joined: Mon Aug 22, 2011 11:20 am

Re: Problem 287

Post by Fogmeister »

OK, when I said I wasn't going to break any speed records I really wasn't joking.

By iterating up through N I've just calculated how long it's likely to take for N = 24...

485... days.

I think I need a better solution.
Image
Fogmeister
Posts: 27
Joined: Mon Aug 22, 2011 11:20 am

Re: Problem 287

Post by Fogmeister »

Marcus Stuhr wrote:Without any sort of optimizations other than the "crucial" one, it shouldn't take more than a minute or two in C++. There are other optimizations you can use that'll bring total runtimes down to less than a second.
Thanks, I'll need to re-think my strategy.

ATM, it uses a very human strategy to work it out.

I calculates N=5 in 0.003 seconds (ish) and then N=13 takes 9 seconds, N=14 about 40 seconds, N=15 takes 171 seconds.

So I'm looking at an approximate increase of about 2^2 each time. Which makes perfect sense looking at the problem.
Image
User avatar
Marcus_Andrews
Administrator
Posts: 1637
Joined: Wed Nov 09, 2011 5:23 pm

Re: Problem 287

Post by Marcus_Andrews »

Try outputting intermediate steps of your program and see if there's anything you can exploit.
tomboy
Posts: 5
Joined: Sun Sep 01, 2013 9:24 am

Re: Problem 287

Post by tomboy »

This problem really vexes me. I am convinced my solution is correct (and it runs nicely in ~10 seconds in Haskell for D24), yet my solution for D5 varies extraordinarily from the 499 that were posted here earlier.

So I followed my algorithm by hand - and got the same solution of 128 for D5 that my algorithm spits out.
Hence I reckon my method of counting is flawed.

Could someone confirm the following counts for me for D5 for the first 4 subquadrants: 30, 44, 23, 30 + 1 = 128 - or give me the correct numbers?
Image
thundre
Posts: 356
Joined: Sun Mar 27, 2011 10:01 am

Re: Problem 287

Post by thundre »

tomboy wrote:Could someone confirm the following counts for me for D5 for the first 4 subquadrants: 30, 44, 23, 30 + 1 = 128 - or give me the correct numbers?
156 + 128 + 128 + 86 + 1 = 499

Your numbers for those (24)2 quadrants match mine for some of the (23)2 quadrants in D5.
Image
tomboy
Posts: 5
Joined: Sun Sep 01, 2013 9:24 am

Re: Problem 287

Post by tomboy »

okay, was a stupid typo. i checked for <= 2^(N-2) instead of <= 2^(2N-2).

But now the performance went down. Takes 8minutes for D20. Now let's see how we can optimize that...
Image
User avatar
yourmaths
Posts: 47
Joined: Mon Aug 25, 2014 11:00 am

Re: Problem 287

Post by yourmaths »

Hmm...

It seems like each encoding can refer to different images. For example, 011101010 could refer to both:

ox
xx

as well as

ooxx
ooxx
xxxx
xxxx

(here o represents white and x represents black squares). The larger image could be enforced by splitting one of the 2x2 squares but then that encoding could also represent an 8x8 image and so on.

Does this matter?
level = lambda number_solved: number_solved // 25
Image
User avatar
sjhillier
Administrator
Posts: 561
Joined: Sun Aug 17, 2014 4:59 pm
Location: Birmingham, UK
Contact:

Re: Problem 287

Post by sjhillier »

I think you're right that if you were using this as a genuine image encoding scheme, you'd also have to specify the size, which is not contained in the code itself as described here. However, for the purposes of this problem, we do know N, so the problem is completely determined, even if the encoding scheme is not complete for practical purposes.
Post Reply