Editorial for Spam Classification With Neural Nets

Problem of the Week 1a

Amos Aidoo
Nov 3 · 2 min read
Photo by Pixabay from Pexels

For this problem, you are expected to pass a set of values user ids, x within a range, minX and minY inclusive through a series of n layers. If the final value is even, then that user is not a spammer otherwise, the user is a spammer. The output of your program should be the number of spammers and non-spammers.

This is how I approached the problem:

  1. The interval between successive outputs at the end of n layers is constant. (Please verify this yourself). With this fact, I pass the first two ids (minX and minX+1) through the n layers and save their outputs in variables say first and second.
  2. I then find the difference between these two values and store them in a variable diff. i.e diff = second - first
  3. With this information, I then loop from minX to minY and at each stage, I check whether first is even or odd and keep track of that information and then increase first by diff.

Below is my implementation in C++.

This isn’t the best solution you are going to get but it’s fast enough. Another editorial can be found on CodeChef, where this problem was taken from. Follow this link to view it: https://discuss.codechef.com/problems/SPAMCLAS

If you have an alternative solution, please feel free to share 👍

CSS Knust

Amos Aidoo

Written by

I found goodness in computer science.

CSS Knust

CSS Knust

Computer Science students from KNUST expressing themselves through writing on various topics.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade