Page 1 of 1

Problem 287

Posted: Sun May 15, 2011 11:18 am
by elr
is the picture at the problem page represent D2 ?

Re: Problem 287

Posted: Sun May 15, 2011 11:57 am
by jaap
No, D2 has a different pattern of white/black pixels. The picture is only to explain the coding scheme.

Re: Problem 287

Posted: Sun May 15, 2011 7:52 pm
by elr
oh,it would have been much more useful if D2 was displayed instead of some arbitrary picture

Re: Problem 287

Posted: Mon May 16, 2011 2:50 pm
by elr
could someone please verify for me that a minimal sequence for D5 having a length of 499 ?

Re: Problem 287

Posted: Mon May 16, 2011 5:35 pm
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.

Re: Problem 287

Posted: Thu Dec 22, 2011 7:00 pm
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.

Re: Problem 287

Posted: Thu Dec 22, 2011 10:24 pm
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.

Re: Problem 287

Posted: Fri Dec 23, 2011 8:36 am
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.

Re: Problem 287

Posted: Fri Dec 23, 2011 8:41 am
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.

Re: Problem 287

Posted: Fri Dec 23, 2011 3:37 pm
by Marcus_Andrews
Try outputting intermediate steps of your program and see if there's anything you can exploit.

Re: Problem 287

Posted: Sun Sep 01, 2013 9:33 am
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?

Re: Problem 287

Posted: Fri Sep 06, 2013 1:54 pm
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.

Re: Problem 287

Posted: Sat Sep 14, 2013 4:43 pm
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...

Re: Problem 287

Posted: Fri Dec 15, 2017 9:46 pm
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?

Re: Problem 287

Posted: Fri Dec 15, 2017 10:39 pm
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.