hackerrank
HackerRank - Minimum Height Triangle
· ☕ 2 min read · ✍️ devoalda
Introduction Given integers b and a, find the smallest integer h, such that there exists a triangle of height h, base b, having an area of at least a. Example Input Output 1 2 3 4 # Input: 2 2 # Output: 2 {: file="Input and Output” } Explanation: The task is to find the height of the triangle having base b = 2 and area a = 2.

HackerRank - Project Euler #1: Multiples of 3 and 5
· ☕ 2 min read · ✍️ devoalda
Introduction If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below N. Input and Output Format 1 2 3 4 5 6 7 # Input: 2 10 100 # Output: 23 2318 {: file="Input and Output” }

HackerRank - Handshake
· ☕ 1 min read · ✍️ devoalda
Introduction At the annual meeting of Board of Directors of Acme Inc. If everyone attending shakes hands exactly one time with every other attendee, how many handshakes are there? Input and Output Format 1 2 3 4 5 6 7 # Input: 2 1 2 # Output: 0 1 {: file="Input and Output” } Process This is a math challenge. So using the primitive way of counting, I counted the number of handshakes for each number of attendees, I came up with this:

HackerRank - Sherlock and Divisors
· ☕ 2 min read · ✍️ devoalda
Introduction Watson gives an integer N to Sherlock and asks him: What is the number of divisors of N that are divisible by 2? Input and Output Format 1 2 3 4 5 6 7 8 # Input: 2 9 8 # Output: 0 3 {: file="Input and Output” } Explanation 9 has three divisors 1, 3 and 9 none of which is divisible by 2. 8 has four divisors 1,2,4 and 8, out of which three are divisible by 2.

HackerRank - Printing Tokens
· ☕ 2 min read · ✍️ devoalda
Introduction Given a sentence, s, print each word of the sentence in a new line. Input and Output Format 1 2 3 4 5 6 7 # Input: This is C # Output: This is C {: file="Input and Output” } Process This was a pretty simple challenge. Completing the code, I’ve added a for loop to print each character at a time, scanning for any blank spaces and “replacing” that with a newline escape character \n.

HackerRank - Sum of Digits of a Five Digit Number
· ☕ 2 min read
Introduction Given a five digit integer, print the sum of its digit Input: 5 digit number, n Output: sum of 5 digit number Input and Output Format # Input 10564 # Output 16 {: file="Sum Of Digits of a Five Digit Number.c” } $1+0+5+6+4=16$ This is a watered-down version of the question {: .prompt-info } Process This was my thought process while attempting this challenge. Calculate the number of digits By dividing the number by 10 and incrementing a counter in a while loop The number of digits can be found In a for loop to loop through the total number of digits (5) sum += number % 10 number /= 10 This is to remove the LSB of the number for each iteration of the loop Print out the sum Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #include <stdio.