Posts

Showing posts from January, 2021

Grooving Monkeys

  Grooving Monkeys N  monkeys are invited to a party where they start dancing. They dance in a circular formation, very similar to a Gujarati Garba or a Drum Circle. The dance requires the monkeys to constantly change positions after every  1  second. The change of position is not random & you, in the audience, observe a pattern. Monkeys are very disciplined & follow a specific pattern while dancing. Consider  N = 6 , and an array  monkeys = {3,6,5,4,1,2} . This array (1-indexed) is the dancing pattern. The value at  monkeys[i] , indicates the new of position of the monkey who is standing at the  i th  position. Given  N  & the array  monkeys[ ] , find the time after which all monkeys are in the initial positions for the 1st time. Constraints 1<=t<=10  (test cases) 1<=N<=10000  (Number of monkeys) Input Format First line contains single integer  t , denoting the number of test cases.Each t...

Prime Sum

  Accept a number   N   up to   5   digits long in the positional numeral system formed by symbols   0, 1, ... 9, A, ..., Z . Also, accept another symbol   S   other than zero. Considering  N  to be represented in the least base possible between  2  and  36 , identify the smallest prime number greater than   N  that contains at least one occurrence of  S  in it in base  S + 1 . (Refer example section for a better understanding). Prime number should be identified with respect to Base 10 i.e. a regular prime number. Constraints Length of N <= 5 Max Base = 36 Face values for symbols: Symbol => Value in base 10 0 => 0 1 => 1 2 => 2 …. 9 => 9 A => 10 B => 11 …. Z => 35 Input Format First line contains  T , the number of test cases. Each test case contains: One line containing two integers,  N  and  S  separated with space. Output Print the smallest pri...