Code Wars: How the Grinch Almost Ended Christmas

Thank you for visiting this post! Be sure to also take a look at my other work on LinkedIn, Github, and my website.

Oh. My. Goodness. I was so excited to solve this Algo. The Grinch has initiated an attack on the North Pole! We need to take out his Missiles before they hit the workshop and destroy all the gifts!

Who doesn’t love a good holiday themed ANYTHING?? Even if it means the possible destruction of the North Pole!

Let’s get started!

Problem

Please click the link below to view the Problem Statement

Solution

I start out by creating a for of loop so that I can access the elements of the missiles object. Using dot notation, I add a new {key: value}, with impact as the key, and the value = to the missiles distance / missiles speed. By doing this, I know what time each missile is scheduled to hit.

Then, I sort the object by the impact time, loop through the new sorted object of missiles and pushed the missile name into our answer array.

As always, here is a faster, optimal, one liner solution! This is not my code! I’ve linked the programmer’s CodeWars solution below. Please check him out!

Conclusion

Thank you so much for stopping by! Stay tuned for more Algorithm Content!

Please checkout my online portfolio and feel free to connect with me on Linkedin!

Sources:

https://www.codewars.com/users/Fbasham,

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Whitelist Registration for the Digital Fitness Pre-sale is Open!

Continuous Integration for Rails 6 with Semaphore, Travis and Coveralls Part 2

Amazon Relational Database Services

Starting out with Drupal ( Install DevDesktop )

TryHackMe — Tartarus WriteUp

https://tryhackme.com/room/tartaraus

The Ideal Hackathon Team

Questions you should ask before signing up for a new internet provider

Homebrew Brewfile Dump with Haskell

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Stephanie Segura

Stephanie Segura

More from Medium

LeetCode Strobogrammatic Number

The number 619 is strobogrammatic.

Quick Sort (With 3 partitions)

Word Pattern

plusOne