Company: Human Resocia
Difficulty: medium
Flexible FizzBuzz In the classic game of FizzBuzz, a number divisible by 3 is answered with Fizz , a number divisible by 5 with Buzz , and a number divisible by both with FizzBuzz . You want a configurable version of the game, where the divisors and the words they map to are supplied at run time. A configuration together with the number to answer is packed into one string called info : a1:s1,a2:s2,...,am:sm,n a1 ... am are the divisors, s1 ... sm are the words they map to, and n is the number to answer. What to return For a valid info : if n is divisible by at least one ai , return the word si belonging to the largest such ai ; if no ai divides n , return n itself, written in decimal with no leading zeros. For an invalid info , return the exact string Invalid Argument . When is info valid? info is valid only if it is exactly a1:s1,a2:s2,...,am:sm,n with all of the following holding: 1 <= m <= 5 . Every ai is an integer with 1 <= ai <= 100 , written in decimal with no leadin