Hackerrank – Chocolate Feast

Problem Statement A description of the problem can be found on Hackerrank. Solution Calculate count of chocolates: chocolates = money / price . Count of chocolates is count of wrappers, too. Free chocolates are calculated: divide chocolates with count of chocolates needed for discount add solution of the division to chocolates new wrappers count is: […]

Hackerrank – Cavity Map

Problem Statement A description of the problem can be found on Hackerrank. Solution Filter all matrix indexes that are at the periphery. For all the rest choose one index and compare its value with all neighbours (left, right, up, down). If it is greater than all neighbours, replace it with ‘X’. I created solution in […]

Hackerrank – Service Lane

Problem Statement A description of the problem can be found on Hackerrank. Solution Find minimum in given array from index i to j. I created solution in 4 languages: Scala Java JavaScript Ruby All solutions are also available on my GitHub. Scala

Java

JavaScript

Ruby

Hackerrank – Encryption

Problem Statement A description of the problem can be found on Hackerrank. Solution Calculate a width and height of a required matrix: height = ceil(length(input_string) width = floor(length(input_string) Then create a height x width matrix containing a characters from input_string. Transpose the matrix and print all rows. Node: Instead we can print all columns of […]