Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 5th, 2008, 6:10 AM   #11
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Sane's Monthly Algorithms Challenge #2 [06-08]

Will it still work even if I give it a crazy room like:

XXXXXXXXXX
X........X
X.X..XXX.X
X.X.X.X..X
XXXXX.XX.X
X...X....X
X.X.XX.XXX
X.X..X...X
X.X....X.X
XXXXXXXXXX

Where that all counts as one room?
Sane is offline   Reply With Quote
Old Jun 5th, 2008, 6:54 AM   #12
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 549
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: Sane's Monthly Algorithms Challenge #2 [06-08]

If that's all one room then my program needs more work.
__________________
True Terror is to wake up one morning and discover that your high school class is running the country - Kurt Vonnegut Jr.
Ancient Dragon is offline   Reply With Quote
Old Jun 5th, 2008, 2:44 PM   #13
mbd
Programmer
 
Join Date: Nov 2007
Posts: 86
Rep Power: 1 mbd is on a distinguished road
Re: Sane's Monthly Algorithms Challenge #2 [06-08]

i am wondering who else is attempting the senior and advanced level problems. i just finished my solution to cards (my first attempt was way off proven by some new inputs i came up with). it might be useful to get some sample input from other people in case i am missing some boundary cases. anyone wanna trade inputs?
mbd is offline   Reply With Quote
Old Jun 5th, 2008, 3:14 PM   #14
mbd
Programmer
 
Join Date: Nov 2007
Posts: 86
Rep Power: 1 mbd is on a distinguished road
Re: Sane's Monthly Algorithms Challenge #2 [06-08]

1
1
2
12
23
2
1
2
2
12
21
i also have one that tests the maximum size
1000000
1
2
3
4
5
6
7
8
9
10
11
...
999999
1000000
mbd is offline   Reply With Quote
Old Jun 6th, 2008, 12:16 AM   #15
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3 Jimbo is on a distinguished road
Re: Sane's Monthly Algorithms Challenge #2 [06-08]

Bleh, why can't you accept C# as a language? Now I need to install a Java IDE. Oh, what will my co-workers say when they find out...
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote
Old Jun 6th, 2008, 6:10 AM   #16
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Sane's Monthly Algorithms Challenge #2 [06-08]

Well, like I said in the general information, you can use C#, I don't mind. The only difference is I won't be able to rank it. The reason is simple: I don't have C#.

You will have to rank your own solution according to the test files I send you. You will still be in the results and your source may still potentially appear in the analysis for others to learn from.
Sane is offline   Reply With Quote
Old Jun 7th, 2008, 12:09 AM   #17
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 856
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Re: Sane's Monthly Algorithms Challenge #2 [06-08]

I have spent days trying to figure out how to solve the senior (escalator) problem to no avail. Is there an algorithm that you have to know to solve it, or is it something that can be reasoned out? The problem reminds me of Euler cycles but I don't recall those involving one-way paths between nodes.

Last edited by titaniumdecoy; Jun 7th, 2008 at 12:32 AM.
titaniumdecoy is offline   Reply With Quote
Old Jun 7th, 2008, 1:11 AM   #18
anrchydrgn
Newbie
 
Join Date: May 2008
Posts: 2
Rep Power: 0 anrchydrgn is on a distinguished road
Re: Sane's Monthly Algorithms Challenge #2 [06-08]

Sane, under what circumstances are you checking to see if the program runs in under 10 seconds (processor type, how you are timing) and are there any algorithm books you can recommend
anrchydrgn is offline   Reply With Quote
Old Jun 7th, 2008, 9:44 AM   #19
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Sane's Monthly Algorithms Challenge #2 [06-08]

@titaniumdecoy:

You fell into my trap! You're right to think of Eulerian curcuits, but that will lead you to an overcomplicated (or incorrect) solution. A Eulerian curcuit would guarantee connectivity to and from every vertex, but that's overcomplicated. And a Eulerian curcuit must use every edge, yet some escalators may cause a curcuit to be impossible to construct, so that's incorrect.

There is a fancy algorithm that can solve senior in 3 lines that takes O(|V|^3) time, but it's not necessary to know. I've thought of two other solutions, one that takes O(|V||E|) time and one that takes O(|E|) time. The last two are quite logical and don't require any special algorithms (they can be reasoned out).

The problem becomes simpler if you try to draw out the graph and solve it by hand. Don't think of the problem as trying to construct a set of edges. We only need to know if anything is not reachable. If you need a push, let me know.

There's also a O(|V|^2|E|) solution, but it's silly and will probably time out on most of the last files.


@anrchydrgn:

I'm running on a 2 Ghz processor. I'm just timing by feel. So far working submissions either work in <2 seconds, or they work in 50 seconds. So as soon as I see it's not going to finish, I just stop it. If I see your submission is "correct", but it's just taking longer because you're using Java or something, then I'll let it slide. But if it's obviously incorrect in terms of time complexity, then it gets a time-limit exceeded.

The only book I can recommend is the one I've read. It is free online: Algorithms by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani.


@Clarification for everyone:

Just so everyone knows, escalators don't always necessarily only go up one floor. For example, an escalator can go from the 1st floor to the 5th floor. Otherwise the problem would be too easy. ;D

Last edited by Sane; Jun 7th, 2008 at 10:00 AM.
Sane is offline   Reply With Quote
Old Jun 7th, 2008, 11:33 AM   #20
mbd
Programmer
 
Join Date: Nov 2007
Posts: 86
Rep Power: 1 mbd is on a distinguished road
Re: Sane's Monthly Algorithms Challenge #2 [06-08]

Sane, my escalator solution is o(n^4) in floors and o(n^2) in escalators. It ran in way less than 10 seconds on my computer with a worst case set of data. Did you find it to take longer than that?
mbd is offline   Reply With Quote
Reply

Bookmarks

Tags
algorithms contest, programming challenges

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Uman's WEEKEND CHALLENGE uman Coder's Corner Lounge 34 Aug 5th, 2008 9:25 PM
Sane's Monthly Algorithms Challenge #1 [05-08] Sane Software Design and Algorithms 31 May 21st, 2008 10:11 PM
Good reference/tutorial for game tree algorithms Jessehk Software Design and Algorithms 10 Apr 10th, 2007 11:32 AM
Challenge: How to make daily life better with programming? tempest Coder's Corner Lounge 53 Jun 17th, 2005 2:37 AM
Weekend Challenge theduck Community Announcements and Feedback 43 Jun 3rd, 2005 4:58 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:21 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC