Tuesday, July 17, 2018

MAXGRITH - Maximum Girth : Classical

#The solution in Python3 is as follows:


for _ in range(int(input())):
n = int(input())
print ((((n+1)*2)//3) % 1000000007)


#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!

The Hurdle Race : Algorithms - Implementation

#The solution in Python3 is as follows:


n,k=map(int,input().split())
a=list(map(int,input().split()))
b=max(a)
if k>b:
    print(0)
else:
    print(b-k)

#Keep visiting for more solutions of HackerRank problems in Python 3.Thank you!!!

Monday, July 16, 2018

Designer PDF Viewer : Algorithms - Implementation

#The solution in Python3 is as follows:


a=list(map(int,input().split()))
s=input()
b=[]
alfa = "abcdefghijklmnopqrstuvwxyz"
rdict = dict([ (x[1],x[0]) for x in enumerate(alfa) ])
for i in s:
      b.append(a[rdict[i]])
print(len(b)*max(b))

#Keep visiting for more solutions of HackerRank problems in Python 3.Thank you!!!

Angry Professor : Algorithms - Implementation

#The solution in Python3 is as follows:


for _ in range(int(input())):
       n,k=map(int,input().split())
       a=list(map(int,input().split()))
       s=sum(1 for number in a if number<=0)    #Count the no. of  -ve numbers.
       if s>=k:
             print("NO")
        else:
             print("YES")

#Keep visiting for more solutions of HackerRank problems in Python 3.Thank you!!!

Soft Sort : Basic Programming - Implementation - Basics of Implementation

#The solution in Python3 is as follows:


if __name__ == '__main__':
    N = [0] * 1000000
    n = 1
    for i in range(1, 1000001):
        n = (n * i) % 1000000007
        N[i - 1] = n


    T = int(input())
    for t in range(0, T):
        n = int(input())
        print(3*(N[n - 1] + 1) % 1000000007)

#Keep visiting for more solutions of HackerEarth problems in Python 3.Thank you!!!

Thursday, July 12, 2018

Little Jhool and psychic powers : Basic Programming - Implementation - Basics of Implementation

#The solution in Python3 is as follows:


b=input()
a='000000'
c='111111'
if a in b or c in b:
    print("Sorry, sorry!")
else:
    print("Good luck!")

#Keep visiting for more solutions of HackerEarth problems in Python 3.Thank you!!!

Roy and Wobbly Numbers : Practice - Math

#The solution in Python3 is as follows:


import math
for _ in range(int(input())):
    n,k=list(map(int,input().split()))
    odd=math.ceil(k/9)
    even=k%9
    if even<=odd:
            if even!=0:
                even-=1
            else:
                even=9
                if k==81:
                    even-=1
       
    if k>81:
        print(-1)
    else:
        l=[]
        for i in range(n):
            if i%2==0:
                l.append(str(odd))
            else:
                l.append(str(even))
        print("".join(l))

#Keep visiting for more solutions of HackerRank problems in Python 3.Thank you!!!