Vote count

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

Re: Vote count

Postby dagarwal82 » Sat Jul 23, 2011 12:23 am

What's wrong with my code? It's verified but failed all 3 bags. Could you please somebody point to me with the dataset for which this code fails?
http://pastebin.com/fF4DSM5f
User avatar
dagarwal82
 
Posts: 2
Joined: Sat May 14, 2011 7:12 pm

Re: Vote count

Postby admin » Sat Jul 23, 2011 5:05 am

dagarwal82 wrote:What's wrong with my code? It's verified but failed all 3 bags. Could you please somebody point to me with the dataset for which this code fails?
http://pastebin.com/fF4DSM5f


I suppose you found the problem since I saw that a submission of yours passed for that puzzle ?
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Vote count

Postby triumphdog1 » Thu Apr 12, 2012 12:37 pm

In the example, total number of votes is 10+35+7+10+25=87. The choices with the most votes, coffee and tea, each have 35 votes. 35/87 = .40229885 = 40.23%
but the example shows 43.75%
what am I doing wrong here?
User avatar
triumphdog1
 
Posts: 4
Joined: Wed Mar 30, 2011 6:14 pm

Re: Vote count

Postby Alexey Solodovnikov » Mon Apr 16, 2012 6:07 am

The input file is structured as follows:
The first line contains the number n of valid choices
The following n lines each contain a choice

So you only need to analyze the Coffee, Chocolate and Tea votes (the Soup votes should be excluded)
User avatar
Alexey Solodovnikov
 
Posts: 32
Joined: Sun Jun 26, 2011 5:54 am

Re: Vote count

Postby coach » Mon May 14, 2012 6:26 am

I don't get it,
I only manage to have the third test to work, the first and the second fail
Is there a way to have the tested files for the first and the second test?
Or to know what is the error we can have in the first and the second test and that is not present in the third test?

Here is a pastebin of my code if it helps

http://pastebin.com/nMYmQc2g
User avatar
coach
 
Posts: 3
Joined: Thu May 10, 2012 12:10 am

Re: Vote count

Postby Alexey Solodovnikov » Wed May 16, 2012 7:48 am

@coach: try the following test case :)

http://pastebin.com/PKPdc0T1
User avatar
Alexey Solodovnikov
 
Posts: 32
Joined: Sun Jun 26, 2011 5:54 am

Re: Vote count

Postby coach » Thu May 24, 2012 1:09 am

Hello,

Thank you for the advice, I added a security on multiple space as I have seen in your example but it is not the problem, I still manage to have the third test to work. However the first and the second one are still failing.

If anyone had an idea it would be helpful.
User avatar
coach
 
Posts: 3
Joined: Thu May 10, 2012 12:10 am

Re: Vote count

Postby Alexey Solodovnikov » Thu May 24, 2012 3:06 am

Ok, one more testcase:

Code: Select all
10
Coffee
Chocolate
Tea
Coffee1
Chocolate1
Tea1
Coffee2
Chocolate2
Tea2
Tea3
10
Coffee 10
Tea 35
Soup 7
Chocolate 10
Coffee 25
Coffee 10
Tea 35
Soup 7
Chocolate 10
Coffee 25


The right answer:
Code: Select all
Coffee 43,75
Tea 43,75
User avatar
Alexey Solodovnikov
 
Posts: 32
Joined: Sun Jun 26, 2011 5:54 am

Re: Vote count

Postby coach » Thu May 24, 2012 5:25 am

Thanks a lot for your example, it works now
User avatar
coach
 
Posts: 3
Joined: Thu May 10, 2012 12:10 am

Previous

Return to Puzzles

Who is online

Users browsing this forum: No registered users and 1 guest

cron