Your test case actually helped me detect a bug in my code!quantumf wrote:Every scenario I devise I test by hand to check the result, and the algorithm does it correctly. I've tried branching, multiple branching, nested branching, re-combining, isolated structures. Nothing doesn't work. Most probably I'm still missing some fundamental concept.bernds wrote:No idea, it could be anything. Are you sure none of your dominos fall more than once?quantumf wrote:That's a fair point and good hint. Now I keep failing on Test 3, but I can't conceive of a test scenario that makes my code fail. Can anyone advise a fiendish structure that will challenge my solution?
Here, for instance, I calculate 11, which is presumably correct?Code: Select all
1 13 14 3 1 2 1 3 2 4 2 5 4 6 4 7 4 8 6 10 7 11 8 12 5 12 3 9 12 13 9 12 4 5 3
L19 Programming Problem Championship: Round 3 (Graphs)
-
gamesorry
- Lives with ko
- Posts: 149
- Joined: Thu Jan 22, 2015 6:03 pm
- Rank: 3d
- GD Posts: 0
- KGS: 3d
- DGS: 3d
- OGS: 3d
- Has thanked: 276 times
- Been thanked: 49 times
Re: L19 Programming Problem Championship: Round 3
-
bernds
- Lives with ko
- Posts: 259
- Joined: Sun Apr 30, 2017 11:18 pm
- Rank: 2d
- GD Posts: 0
- Has thanked: 46 times
- Been thanked: 116 times
Re: L19 Programming Problem Championship: Round 3
Guess I'll be learning something when Solomon posts how to approach problem B. I have a solution (I think), it's just too slow. Maybe I'm missing something obvious, or maybe I somehow need to treat this as more of geometry problem. Hmm.
- quantumf
- Lives in sente
- Posts: 844
- Joined: Tue Apr 20, 2010 11:36 pm
- Rank: 3d
- GD Posts: 422
- KGS: komi
- Has thanked: 180 times
- Been thanked: 151 times
Re: L19 Programming Problem Championship: Round 3
Cool, I get 0,1,34, so something to look at.Solomon wrote:Agree with bernds, edge cases are probably what's biting you. Try something sillier, like below (my output is 0, 2, and 41 respectively):
- quantumf
- Lives in sente
- Posts: 844
- Joined: Tue Apr 20, 2010 11:36 pm
- Rank: 3d
- GD Posts: 422
- KGS: komi
- Has thanked: 180 times
- Been thanked: 151 times
Re: L19 Programming Problem Championship: Round 3
E is a really nice problem, and one of the most real world applicable examples I've seen in these problems. Trying to optimize this is a nice challenge - currently getting S/O so need to see if converting my recursive graph traversal to an iterative solution helps. Definitely helped to write a generator here, any hand constructed examples were way too small to push the memory or performance.
- quantumf
- Lives in sente
- Posts: 844
- Joined: Tue Apr 20, 2010 11:36 pm
- Rank: 3d
- GD Posts: 422
- KGS: komi
- Has thanked: 180 times
- Been thanked: 151 times
Re: L19 Programming Problem Championship: Round 3
Thanks, got it now. Funny how one can have blind spots to such un-intuitive constructions - dominoes knocking themselves over just didn't occur to me.quantumf wrote:Cool, I get 0,1,34, so something to look at.Solomon wrote:Agree with bernds, edge cases are probably what's biting you. Try something sillier, like below (my output is 0, 2, and 41 respectively):
Re: L19 Programming Problem Championship: Round 3
I had a similar problem until I noticed that the description says "The input for each room consists of one or more lines containing:".jeromie wrote:I seem to be having an odd problem parsing the file in problem F.
Best regards,
Ulrich
-
jeromie
- Lives in sente
- Posts: 902
- Joined: Fri Jan 31, 2014 7:12 pm
- Rank: AGA 3k
- GD Posts: 0
- Universal go server handle: jeromie
- Location: Fort Collins, CO
- Has thanked: 319 times
- Been thanked: 287 times
Re: L19 Programming Problem Championship: Round 3
Thanks. Ugh, that is an awful file format, especially since the example is all on one line.ugoertz wrote:I had a similar problem until I noticed that the description says "The input for each room consists of one or more lines containing:".jeromie wrote:I seem to be having an odd problem parsing the file in problem F.
Best regards,
Ulrich
Edit: And my program works after I fix my parsing error. (Correctly.
-
bernds
- Lives with ko
- Posts: 259
- Joined: Sun Apr 30, 2017 11:18 pm
- Rank: 2d
- GD Posts: 0
- Has thanked: 46 times
- Been thanked: 116 times
Re: L19 Programming Problem Championship: Round 3
Ok, I was missing something obvious, and now I've got the efficient algorithm. Produces the same output as my previous one on all my testcases... but now it's WA instead of TLEbernds wrote:Guess I'll be learning something when Solomon posts how to approach problem B. I have a solution (I think), it's just too slow. Maybe I'm missing something obvious, or maybe I somehow need to treat this as more of geometry problem. Hmm.
- Solomon
- Gosei
- Posts: 1848
- Joined: Tue Apr 20, 2010 9:21 pm
- Rank: AGA 5d
- GD Posts: 0
- KGS: Capsule 4d
- Tygem: 치킨까스 5d
- Location: Bellevue, WA
- Has thanked: 90 times
- Been thanked: 835 times
Re: L19 Programming Problem Championship: Round 3
I have pretty good ideas on how to solve E (Build Dependencies) and F (XYZZY), and will try to solve them before Mother's Day (US edition) dinner, but D (Chess Tournament) I'm not so sure. Only way I can see it modeled is a mixed graph with directed and undirected edges, but that just sounds like a nightmare and I'm unversed on any algorithms for handling mixed graphs. Whatever I manage to get, I will write how I solved tomorrow before work.
-
bernds
- Lives with ko
- Posts: 259
- Joined: Sun Apr 30, 2017 11:18 pm
- Rank: 2d
- GD Posts: 0
- Has thanked: 46 times
- Been thanked: 116 times
Re: L19 Programming Problem Championship: Round 3
Hint: it's simpler than that. Not too hard a problem at all really once you figure out one step.Solomon wrote:I have pretty good ideas on how to solve E (Build Dependencies) and F (XYZZY), and will try to solve them before Mother's Day (US edition) dinner, but D (Chess Tournament) I'm not so sure. Only way I can see it modeled is a mixed graph with directed and undirected edges, but that just sounds like a nightmare and I'm unversed on any algorithms for handling mixed graphs. Whatever I manage to get, I will write how I solved tomorrow before work.
- quantumf
- Lives in sente
- Posts: 844
- Joined: Tue Apr 20, 2010 11:36 pm
- Rank: 3d
- GD Posts: 422
- KGS: komi
- Has thanked: 180 times
- Been thanked: 151 times
Re: L19 Programming Problem Championship: Round 3
Any suggestions for how to construct a tough/pathological problem for BuildDependencies? I've tried very long (100,000 files that depend in sequence on one another) and very wide (100,000 files that depend on a single file), but my code is near instantaneous with these, and yet I'm getting TLE on test 2. Are we expected to deal with circular dependencies?
-
gamesorry
- Lives with ko
- Posts: 149
- Joined: Thu Jan 22, 2015 6:03 pm
- Rank: 3d
- GD Posts: 0
- KGS: 3d
- DGS: 3d
- OGS: 3d
- Has thanked: 276 times
- Been thanked: 49 times
Re: L19 Programming Problem Championship: Round 3
I think there are no circular dependencies in test data (I didn't handle such cases).quantumf wrote:Are we expected to deal with circular dependencies?
-
jeromie
- Lives in sente
- Posts: 902
- Joined: Fri Jan 31, 2014 7:12 pm
- Rank: AGA 3k
- GD Posts: 0
- Universal go server handle: jeromie
- Location: Fort Collins, CO
- Has thanked: 319 times
- Been thanked: 287 times
Re: L19 Programming Problem Championship: Round 3
There is extra, unused data in the file, I.e. Files that do not need to be rebuilt. It is those extra unconnected files that gave my algorithm fits. (I think.)quantumf wrote:Any suggestions for how to construct a tough/pathological problem for BuildDependencies? I've tried very long (100,000 files that depend in sequence on one another) and very wide (100,000 files that depend on a single file), but my code is near instantaneous with these, and yet I'm getting TLE on test 2. Are we expected to deal with circular dependencies?
- Solomon
- Gosei
- Posts: 1848
- Joined: Tue Apr 20, 2010 9:21 pm
- Rank: AGA 5d
- GD Posts: 0
- KGS: Capsule 4d
- Tygem: 치킨까스 5d
- Location: Bellevue, WA
- Has thanked: 90 times
- Been thanked: 835 times
Re: L19 Programming Problem Championship: Round 3
Well I managed to get E and F as I'd hoped (I think I spent more time tinkering with input and forgetting about cin.ignore() than the actual algorithm for E...), but with only 30 minutes before I have to visit family and not coming back until past the deadline, it looks like I won't be able to squeeze D in
(although I'll most likely be pondering the problem at the dinner table...).
-
gamesorry
- Lives with ko
- Posts: 149
- Joined: Thu Jan 22, 2015 6:03 pm
- Rank: 3d
- GD Posts: 0
- KGS: 3d
- DGS: 3d
- OGS: 3d
- Has thanked: 276 times
- Been thanked: 49 times
Re: L19 Programming Problem Championship: Round 3
Overlooking the following statement for Problem F costs me 26 trials to figure out:
(I even used 'try - except ValueError' statements to catch the weird input exception)
"The input for each room consists of one or more lines"
but finally I got all problems despite the huge penalties
Edit: Ah, it seems some of you have already pointed out the pitfall ...
(I even used 'try - except ValueError' statements to catch the weird input exception)
"The input for each room consists of one or more lines"
but finally I got all problems despite the huge penalties
Edit: Ah, it seems some of you have already pointed out the pitfall ...