Posts

Showing posts from August, 2017

CodeChef (AUG17 LunchTime) : Mathison and pangrams - MATPAN

Problem: Mathison and pangrams Mathison recently inherited an ancient papyrus that contained some text. Unfortunately, the text was not a pangram . Now, Mathison has a particular liking for holoalphabetic strings and the text bothers him. The good news is that Mathison can buy letters from the local store in order to turn his text into a pangram. However, each letter has a price and Mathison is not very rich. Can you help Mathison find the cheapest way to obtain a pangram? Input  The first line of the input file will contain one integer, T , representing the number of tests. Each test will be formed from two lines. The first one contains 26 space-separated integers, representing the prices of all letters. The second will contain Mathison's initial text (a string of N lowercase letters). Output  The output file will contain T lines, one for each test. Each line will contain the answer for the corresponding test. Constraints : 1 ≤ T ≤ 10 1 ≤ N ≤ 50,0

HackerRank - 101 Hack 51 - Fair Cake Cutting

Problem: Fair Cake Cutting Leha is a young man from Belarus. He loves cakes really much. In Leha's country, cakes are always evenly divided between people. Leha wants to know how many people he should invite to his party if he has a cake whose size is equal to units and he wants each person to get exactly units of cake. Note that Leha doesn't take a piece for himself; in other words, the cake is only divided among the people he invited to the party. Input Format The first line contains three space-separated integers describing the respective values of , , and . Constraints It is guaranteed that the answer is an integer. Output Format Print a single integer denoting , the number of people he should invite to his party. Sample Input 0   5 10 1 Sample Output 0   2 Explanation 0 In this sample case, , and . Leha wants each person to get units of cake. He has a cake whose size is unit, so