Competitive Programming: The New Chess?

Photo by Vlad Sargu on Unsplash

0x557af2Cab087A42e71d5F70D80Be13991cB287B2

Aside from building things programmers are often solving problems.

And there is a growing community of them devoting most of their free time to doing just that!

Problem solving on the competitive programming platform Codeforces.

So what is competitive programming?

In this article I want to show you around code forces, get started solving our first problem and get on our way to becoming a Grandmaster — which btw, is a real title on the platform along with several other contestant rankings.

Contestants Ranking System

So let’s get to it shall we?

Our ranking right now is definitely Newbie, so we need to get working to change that!

We will begin by heading over to Codeforces and navigating to “PROBLEMSET”.

The best way to begin is by solving the easier problems first, to find those we can sort them by the number of people that have been able to solve by clicking the ✅ :

At the time of writing the easiest one appears to be “A. Watermelon”, so let start with this one.

The Problem states:

A. Watermelon

time limit per test

1 second

memory limit per test

64 megabytes

input

standard input

output

standard output

One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.

Pete and Billy are great fans of even numbers, that’s why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that’s why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.

Input

The first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys.

Output

Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case.

Examples

input

8

output

YES

Note

For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos).

While you can solve this problem on your own file, you can use the built in console by clicking “submit” and choosing your preferred language.

I will be solving this using JavaScript…

So this is a simple problem, basically what I did was I built a function that takes in the watermelon’s weight and then used a conditional statement to check if this number was evenly divisible and if so I added the condition that this number be greater than 2, this is because if the weight is equal to or less than 2 the division would not return an even numbers:

const divide = weight => weight > 2 && weight % 2 === 0

And now we can simply click on the submit button, And wait for your verdict.

Go and give these problem sets a shot! Lots of fun and suspense await you!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store