11619 - SPAM! (or not)

All about problems in Volume 116. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
mike21
New poster
Posts: 5
Joined: Sat Jun 15, 2013 3:25 am

11619 - SPAM! (or not)

Post by mike21 »

Hello everybody,

I'm struggling to solve problem 11619.
I have coded it in Java, but I have a problem because I'm still getting WA.

Approach:
- use logarithm to calculate big formula
- assign probability spam/ham words (wordSpamFreq/totalSpamWords) or (wordFreqHam/totalHamWords).

Sample input:
MESSAGE SPAM
replica rolex
==
MESSAGE SPAM
replica rolex
==

P(replica/S) = 2/2 (it appears 2 times in 2 spam messages)
P(rolex/S) = 2/2
of course P(replica/H) = 0 & P(rolex/H) = 0.

I've also tried to assign P(replica/S) = 1, P (replica/H) = 0 but also not worked.

For sample input I'm getting this probabilities:

0.5
Unsure
0.9994837377387712
Spam
0.0019912881144990694
Ham

Any suggestion is helpful!

Thanks!
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11619 - SPAM! (or not)

Post by brianfry713 »

I just got AC. I'm not sure why you're using logarithm. Your probabilities are close to mine for the sample input. I used double variables in C++.

Try this input:

Code: Select all

MESSAGE SPAM
rolex rolex rolex rolex rolex rolex
==
MESSAGE HAM
Hello
==
MESSAGE CLASSIFY
Hello rolex
==
AC output:

Code: Select all

Unsure
Check input and AC output for thousands of problems on uDebug!
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11619 - SPAM! (or not)

Post by brianfry713 »

Input:

Code: Select all

MESSAGE SPAM
rolex
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
replica
==
MESSAGE CLASSIFY
rolex
==
AC Output: Spam
Check input and AC output for thousands of problems on uDebug!
mike21
New poster
Posts: 5
Joined: Sat Jun 15, 2013 3:25 am

Re: 11619 - SPAM! (or not)

Post by mike21 »

Hi,

Many thanks for your posts. :) I've got ACCEPTED :D

Other possible test case:

Code: Select all

MESSAGE SPAM
replica
rolex
==
MESSAGE SPAM
replica   rolex
==
MESSAGE HAM
Hello all
==
MESSAGE CLASSIFY
Hello                 Replica
==
MESSAGE CLASSIFY
replica          rolex and 
some other things
==
MESSAGE CLASSIFY
abc
def   ghi jkl all
==
Output:
Unsure
Spam
Ham
Post Reply

Return to “Volume 116 (11600-11699)”