30 Days of Code — Day 7

Tyler Carter
1 min readMar 9, 2021
Photo by Chris Ried on Unsplash

Welcome to day 7 of 30 Days of Code from Hacker Rank!

The Task

Given an array, A , of N integers, print A‘s elements in reverse order as a single line of space-separated numbers.

The Code

The Result

>? 4
>? 1 4 3 2
… 2 3 4 1

Conclusion

The first time I looked at the task I way overcomplicated this in my head. I was going to build on previous lessons and assign a class, define some methods, etc. But, as part of this challenge I have been trying to come up with ways to simplify the code I write. I had written a similar solution for the previous challenge and decided to just change it slightly to start the list at the last element in the list (arr[::-1]).

Overall a good challenge and I would suggest adding further challenges on top of the dailies from the website.

Here is a link to the day_6 answer/challenge I wrote about previously: 30 Days of Code — Day 6.

--

--

Tyler Carter
0 Followers

I am currently an Operations Program Manager for Microsoft. I have been teaching myself Python to use for Data Analytics and Machine Learning.