Category Archives: Coding

Posts related to Codes of programs.

CodeChef : January Challenge 2018 – Maximum Score

Maximum Score Source: CodeChef You are given N integer sequences A1, A2, …, AN. Each of these sequences contains Nelements. You should pick N elements, each from one sequence; let’s denote the element picked from sequence Ai by Ei. For each i (2 ≤ i ≤ N), Ei should be strictly greater than Ei-1. Compute the maximum possible value of E1 + E2 + … + EN. If it’s impossible to pick the elements E1, E2, …, EN, print… Read More »

CodeChef : January Challenge 2018 – Rectangle

Rectangle Source: CodeChef You are given four integers a, b, c and d. Determine if there’s a rectangle such that the lengths of its sides are a, b, c and d (in any order). Input The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. The first and only line of each test case contains four space-separated integers a, b, c and d. Output… Read More »

CodeChef : December Challenge 2017 – Chef And his Cake

Chef And his Cake Source: CodeChef Chef’s girlfriend’s birthday is near, so he wants to surprise her by making a special cake for her. Chef knows that his girlfriend likes cherries on the cake, so he puts cherries on the top of the cake, but he was not satisfied. Therefore, he decided to replace some of the cherries… Read More »

HackerRank : Week of Code 35 – Lucky Purchase

Lucky Purchase: Hackerrank Sharon wants to buy a laptop for programming. She plans on buying a laptop whose price is made of digits 4 and 7 only. The number of 4s and 7s in the price should be equal. You are given laptop brand names and their prices. Find and print the name of the laptop brand that satisfies the above criteria. If there… Read More »

CodeChef : November Challenge 2017 – Periodic Palindrome Construction

Periodic Palindrome Construction Source: CodeChef Chef recently learned about concept of periodicity of strings. A string is said to have a period P, if P divides N and for each i, the i-th of character of the string is same as i-Pthcharacter (provided it exists), e.g. “abab” has a period P = 2, It also has a period of P = 4, but it doesn’t have… Read More »