Step 1 – Launch the HackerRank Website and “Sign In”. Ref: https://www.hackerrank.com/

Step 2 – Under Python click “Continue Preparation”. Choose “Python If-Else” Challenge.

Step 3 – Read the Instructions Carefully.

Step 4 – List the Requirements and Constraints in a Notepad in simple words. Learn to take notes.

Step 5 – Convert What You Understand of the Requirements and Constraints into Pseudo Logic.

If you do not recall the fundamental Math and logic concepts which you have went through in the past, here is an overview. You can Google for deeper explanation.

When % is utilised for Computational Math calculations, it is known as modulus, returning the remainder or signed remainder of a division.

Example 1: 4 % 2 = 4/2 Remainder = 0

Example 2: 5 % 2 = 5/2 Remainder = 1

Example 3: To create a range in Python, “in the range of 2 to 5” can be represented as “if 2 <= n <= 5:”

Thus by converting your Pseudo Logic in Python code, you can key in the following logic to solve the challenge.

Step 6 – Click “Run Code” to Test Your Code. Do Note if you submit code with errors, you will lose points. So “Run Code” first to ensure everything works.

Step 7 – Once you have tested that your code works, “Submit Code” to clear the challenge and earn some Hacker points.

Leave a Reply

Your email address will not be published. Required fields are marked *