
Coding challenge - ColinWright
http://www.bittorrent.com/company/about/developer_challenge
======
anonymoushn
This problem is not about a Golomb ruler. When dealing with Golomb rulers you
care about uniqueness of lengths across all pairs, while in this problem you
do not.

If you had 4 oranges and 5 bowls, you could place them as follows:

1 1 0 1 1

This arrangement is not a Golomb ruler because the lengths 1 and 3 both occur
more than once, but it is a valid solution to a smaller version of the problem
in the OP.

------
joss82
I made a python program to check every possible combination. It should run for
1 more hour and then should spit "no solution found".

Is there any smarter way to do it (in software) without brute forcing?

~~~
anonymoushn
The answer to this problem is not zero.

To the best of my knowledge all of the smarter ways to do it are just smarter
ways to brute force it.

~~~
joss82
You are right, I mistakenly thought that it was about a Golomb ruler, which it
is not.

EDIT: Found 7555794 solutions, took my 2GHz P4 30 minutes.

~~~
fferen
Got the same answer with a slightly improved brute force search, in about 3
minutes. I spent more time than that trying to find a "clever" way to do it,
lol.

~~~
eLod

      barnabas:btch pota$ time python btch.py 
      found: 7555794
    
      real	1m18.464s
      user	1m18.417s
      sys	0m0.031s
    

(i5 2500k)

~~~
joss82
Nice! Would you show us the source?

~~~
anonymoushn
It might be similar to mine: <http://pastie.org/2007710>

Run on 2.4Ghz Core 2 Duo:

    
    
      $time python oranges.py 
      7555794
    
      real	1m24.252s
      user	1m23.841s
      sys	0m0.144s
    

You can still get this to be much faster if you stuff this information into
bitmasks, especially if you do it in one of the other languages. You can also
get a lot of speedup out of more clever pruning if you're willing to
precompute a bunch of stuff.

Edit: It seems like a lot of the function calls this program makes are
unnecessary. This version runs about 37 seconds faster without any of the
trickery I mentioned: <http://pastie.org/2007699>

------
eatmyownface
Ah, Golomb's Ruler. Did Golom find this in a cave? HEEERRRRP.

------
rivd
correct me if im making a stupid mistake here, but isnt this just proving that
the optimal golomb ruler for order 9 has a length of 44 ?

------
pdhborges
Looks like Golomb ruler to me.

~~~
CJefferson
Exactly.

I would just feed this to a counting SAT, or constraint, solver.

If I wrote the constraint solver, does that count as an acceptable answer?

There are some fancy ways of doing this, involving lots of bitshifting, which
are quite fun.

Edit: Remove mis-remembered bitshifting.

------
stsc
I bet on 5631408

~~~
anonymoushn
What would you like to wager?

