Posts

Showing posts from September, 2018

The Hurdle Race - HackerRank.

Image
Dan is playing a video game in which his character competes in a hurdle race. Hurdles are of varying heights, and Dan has a maximum height he can jump. There is a magic potion he can take that will increase his maximum height by   unit for each dose. How many doses of the potion must he take to be able to jump all of the hurdles. Given an array of hurdle heights  , and an initial maximum height Dan can jump,  , determine the minimum number of doses Dan must take to be able to clear all the hurdles in the race. For example, if   and Dan can jump   unit high naturally, he must take   doses of potion to be able to jump all of the hurdles.

Electronics Shop - HackerRank.

Image
Monica wants to buy a keyboard and a USB drive from her favorite electronics store. The store has several models of each. Monica wants to spend as much as possible for the   items, given her budget. Given the price lists for the store's keyboards and USB drives, and Monica's budget, find and print the amount of money Monica will spend. If she doesn't have enough money to both a keyboard  and  a USB drive, print  -1  instead. She will buy only the two required items.

Utopian Tree - HackerRank.

Image
The Utopian Tree goes through  2  cycles of growth every year. Each spring, it  doubles  in height. Each summer, its height increases by  1  meter. Laura plants a Utopian Tree sapling with a height of  1  meter at the onset of spring. How tall will her tree be after   growth cycles? For example, if the number of growth cycles is  , the calculations are as follows:

Grading Students - HackerRank.

Image
HackerLand University has the following grading policy: Every student receives a   in the inclusive range from   to  . Any   less than   is a failing grade. Sam is a professor at the university and likes to round each student's   according to these rules: If the difference between the   and the next multiple of   is less than  , round   up to the next multiple of  . If the value of   is less than  , no rounding occurs as the result will still be a failing grade. For example,   will be rounded to   but   will not be rounded because the

Beautiful Days at the Movies - HackerRank.

Image
Lily likes to play games with integers. She has created a new game where she determines the difference between a number and its reverse. For instance, given the number  , its reverse is  . Their difference is  . The number   reversed is  , and their difference is  . She decides to apply her game to decision making. She will look at a numbered range of days and will only go to a movie on a  beautiful day . Given a range of numbered days,   and a number  , determine the number of days in the range that are  beautiful . Beautiful numbers are defined as numbers where   is evenly divisible by  . If a day's value is