Hackerrank – Project Euler+ #007 – 10001st prime

Hackerrank – Problem description The problem description – Hackerrank. Solution The challenge has upper constraint that we could have at most 10 001 prime numbers from the smallest (2). I found out that the upper bound is the number 104 743. There exist first 10 001 prime numbers. We calculate list all of them and […]

Hackerrank – Project Euler+ #006 – Sum square difference

Hackerrank – Problem description The problem description – Hackerrank. Solution We calculate 3 equations for every number from 1 to N. Sum of squares:     Square of sum:     Result – Difference between sums:     I created solution in: Java All solutions are also available on my GitHub profile. Java

Hackerrank – Project Euler+ #005 – Smallest multiple

Hackerrank – Problem description The problem description – Hackerrank. Solution We need to make a prime factorization of number (problem constraints), because some of the numbers are divisors of the other numbers. We reduce unnecessary multiplications and divisions. We could use Sieve of Eratosthenes to calculate all prime numbers from 2 to N. Let’s calculate […]

Hackerrank – Project Euler+ #004 – Largest palindrome product

Hackerrank – Problem description The problem description – Hackerrank. Solution We need to find out if the product of two 3-figured number is a palindrome and it is smaller than exercise upper constraint. My solution starts with initializing two numbers as 999. I continually decremented second number by 1, until it is equal to 100. […]

Hackerrank – Project Euler+ #003 – Largest prime factor

Hackerrank – Problem description The problem description – Hackerrank. Solution We can use the algorithm where we find out a list of all prime number divisor – prime factorization. Let find the beginning prime number. The smallest prime number is 2. We divide the given number with actual divisor (actual prime number) until the division […]

Hackerrank – Project Euler+ #002 – Even Fibonacci numbers

Hackerrank – Problem description The problem description – Hackerrank. Solution We will calculate Fibonacci numbers sequence using known algorithm. If the next number is even, add it to the result sum. We end up calculations when the next Fibonacci number is greater than upper number constraint. I created solution in: Ruby All solutions are also […]

Hackerrank – Project Euler+ #001 – Multiples of 3 and 5

Hackerrank – Problem description The problem description – Hackerrank. Solution There is N defined as the maximum constraint. We could start from 3 to N and sum all numbers divisible by 3 and 5 (using modulo operation). Unfortunately this is not correct solution, because there are some numbers which are summed 2 times. These numbers […]

Hackerrank – Grading Students

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution We will use professor’s rules and transform all grades: – We find how many times (n) is 5 in given grade – if it is divisible without a remainder, we do nothing – it not we round it to neareast […]

Hackerrank – Between Two Sets

Hackerrank – Problem description The problem description – Hackerrank. Solution I created an array of all positive numbers, which satisfy conditions specified in problem statement. This set should contain elements from to . I filter all numbers from the set that are valid for an equation a . The array of positive numbers can be […]

Hackerrank – The Hurdle Race

Hackerrank – Problem Statement A description of the problem can be found on Hackerrank. Solution We need to find the highest hurdle. If it is greater than k then substract its height with k and we have the result. Otherwise print 0. I created solution in: Scala Java JavaScript Ruby All solutions are also available […]