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

Step 2 – Under Python click “Continue Preparation”. Choose “Division” 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 code.

There are many solutions to solve a logic problems.

Why in this instance was “if year can be evenly divided by 4” > converted into > if year % 4 == 0:

% will provide a remainder of a division. If the remainder is 0 it means whatever number year contains, it can be evenly divided by 4. Which fits the requirements.

Example if year is = 100

100/ 4 = Value of 25 AND Remainder of 0

If remainder is 0, then it is evenly divided by 4 and we can set leap year as True.

This solution is adapted for even division of 100 and 400 logic.

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 *