Skip to main content

Command Palette

Search for a command to run...

Coding Problems

Published
2 min read
Coding Problems
M

Hi everyone! I'm Mojtaba Maleki, an AI Researcher and Software Engineer at The IT Solutions Hungary. Born on February 11, 2002, I hold a BSc in Computer Science from the University of Debrecen. I'm passionate about creating smart, efficient systems, especially in the fields of Machine Learning, Natural Language Processing, and Full-Stack Development. Over the years, I've worked on diverse projects, from intelligent document processing to LLM-based assistants and scalable cloud applications. I've also authored four books on Computer Science, earned industry-recognized certifications from Google, Meta, and IBM, and contributed to research projects focused on medical imaging and AI-driven automation. Outside of work, I enjoy learning new things, mentoring peers, and yes, I'm still a great cook. So whether you need help debugging a model or seasoning a stew, I’ve got you covered!

Introduction

Hey there, coding club! Are you ready for a juicy coding challenge? Today, we are going to help Pete and Billy divide their watermelon in a very special way. But don't worry, we won't be cutting any real watermelons, only coding our way through this problem. So, put on your coding hats and let's dive in!

The Problem

Pete and Billy have bought a watermelon that weighs w kilos. They want to divide the watermelon into two parts in such a way that each part weighs an even number of kilos. However, the two parts don't have to be equal in weight. Our task is to help them figure out whether this is possible or not.

The input should be a number and the output has to be YES or NO.

here is an example:

input:
8
output:
YES

The Solution

We can solve this problem by using some simple logic. If the weight of the watermelon is an odd number, then it cannot be divided into two even parts. However, if the weight of the watermelon is an even number, then we can divide it into two even parts by simply checking if the weight is divisible by 2.

So, let's implement this logic in Python code:

x = int(input())
if x % 2 == 0 and x > 2: # Check if the weight is even and greater than 2
    print("YES")
else:
    print("NO")

Conclusion

And there you have it, folks! We have helped Pete and Billy divide their watermelon into two even parts using our coding skills. I hope you found this problem to be as fun and juicy as a real watermelon. See you in the next coding challenge!

More from this blog

Learn From My Devlog, Tips and Tricks for Becoming a Better Developer

36 posts

Back-end Developer at The IT Solutions. I build scalable AI tools with Django & friends. Tech enthusiast, lifelong learner, and coffee-fueled coder ☕ based in Debrecen, Hungary.