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

Step 2 – Click into “Continue Preparation” under Problem Solving. Choose “Compare the Triplets” Challenge.

Step 3 – Read the Instructions Carefully.

Change the Programming Language to Python 3.

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.

With a basic understanding that we will be comparing the elements in two different list, and assign scores to Alice and Bob based on internal rules, we can come to an understanding that to get the machine to do a series of task, we need to use computational time – this means we need to cast a loop.

As both list are of the same length. We can use the length of one list, to define how many cycles of compute time the loop shall run.

for i in range(len(a)):

Convert the rules to assign scores to Alice and Bob.

if a[i] > b[i]:

            alice_scores += 1

        elif a[i] < b[i]:

            bob_scores += 1

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 *