The Caribbean salesman

Discuss about the puzzles, but without giving the solutions please !!!

The Caribbean salesman

Postby admin » Wed Dec 29, 2010 2:02 am

Bob is a salesman in the Caribbean islands. While he is sunbathing on the white sand beach or admiring the emerald sea while slurping a Rhum cocktail, Bob uses this relaxing time to plan for his trip to visit his customers.


Last edited by admin on Fri Jan 14, 2011 7:53 pm, edited 2 times in total.
Reason: Edit
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: The Caribbean salesman

Postby Alexey Solodovnikov » Wed Jul 27, 2011 11:10 am

Uff, the last testcase (test_30_150) is pretty hard, IMHO :) Only two guys have passed it.
User avatar
Alexey Solodovnikov
 
Posts: 32
Joined: Sun Jun 26, 2011 5:54 am

Re: The Caribbean salesman

Postby davidb » Wed Jul 27, 2011 4:33 pm

Actually it really depends on your algorithm, the last test case isn't the most time consuming if you look at the actual submission reports. But yeah, that's a difficult problem for sure and getting the right algorithm is key.
User avatar
davidb
 
Posts: 24
Joined: Thu Dec 23, 2010 1:55 am

Re: The Caribbean salesman

Postby Alexey Solodovnikov » Thu Jul 28, 2011 3:14 am

Indeed I have two different approaches for sparse and dense graphs, the dense graph version should be more optimized. Here is my java submission result that fails on the last testcase only. Could you please upload your version? :)

the.caribbean.salesman.png
the.caribbean.salesman.png (49.85 KiB) Viewed 1888 times

PS. If someone needs more than 100 testcases, grab them here:
http://facebook-puzzles-testcases.googl ... ebulll.zip
User avatar
Alexey Solodovnikov
 
Posts: 32
Joined: Sun Jun 26, 2011 5:54 am

Re: The Caribbean salesman

Postby davidb » Thu Jul 28, 2011 8:33 am

My Python submission results:
http://codercharts.com/submission/233

My C++ submission results (slightly different algo, I didn't optimize it as much as the python one):
http://codercharts.com/submission/272

You'll have to be logged in to see the reports. Just as a small hint, I use a single algo regardless of whether the graph is dense or sparse.
User avatar
davidb
 
Posts: 24
Joined: Thu Dec 23, 2010 1:55 am

Re: The Caribbean salesman

Postby Alexey Solodovnikov » Fri Jul 29, 2011 6:35 am

Thanks! Great result indeed, will try to rewrite my algo - already have ideas :)
User avatar
Alexey Solodovnikov
 
Posts: 32
Joined: Sun Jun 26, 2011 5:54 am

Re: The Caribbean salesman

Postby gonzzas » Thu Nov 17, 2011 4:36 pm

Hi all,

I have a question regarding this problem. In the problem specification there is never mentioned if Bob must return (or not) to the starting point, so I initially assumed that Bob doesn't need to end where he started.

But after looking at the example, it looks like my initial assumption is wrong and Bob in fact needs to return to the initial point.

Because if Bob doesn't need to end where he started, he can travel through all islands with only the following tickets (at least one of the possibilities):

1 2 4 5 6 7 with the cost of 150.

So - just to clarify - Bob needs in fact to end in the same island where he started right?

Thank you all.

Regards
gonzzas
User avatar
gonzzas
 
Posts: 1
Joined: Mon Oct 31, 2011 5:18 pm

Re: The Caribbean salesman

Postby Alexey Solodovnikov » Fri Nov 18, 2011 1:51 am

gonzzas wrote:So - just to clarify - Bob needs in fact to end in the same island where he started right?


Yep. It should be the cycle or few cycles but all connected. Consider the following important testcase:

1 C0 C1 619
2 C0 C2 837
3 C0 C3 765
4 C1 C0 850
5 C1 C2 69
6 C1 C3 106
7 C2 C0 1
8 C2 C1 841
9 C2 C3 877
10 C3 C0 117
11 C3 C1 580
12 C3 C2 873

The right result should be :)

912
1 5 6 7 10

PS. Original problem is here: http://www.facebook.com/careers/puzzles.php?puzzle_id=1
PPS. A lot of testcases are here: http://facebook-puzzles-testcases.googl ... ebulll.zip
User avatar
Alexey Solodovnikov
 
Posts: 32
Joined: Sun Jun 26, 2011 5:54 am


Return to Puzzles

Who is online

Users browsing this forum: No registered users and 0 guests

cron