Showing posts with label HackerEarth Solutions. Show all posts
Showing posts with label HackerEarth Solutions. Show all posts

Monday, August 13, 2018

Game of Coins : Basic Programming - Implementation - Basics of Implementation

#The solution in Python3 is as follows:


ALICE = 'Alice'
BOB = 'Bob'
# Write your code here
def lolo(N):
    return ALICE
   

def init():
    T = input()
    for num_testcases in range(int(T)):
           A = int(input())
           x = lolo(A)
           print(x)
init()

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

Sunday, July 29, 2018

Last Occurrence : Algorithms - Searching - Linear Search

#The solution in Python3 is as follows:


n,m=map(int,input().split())
a=list(map(int,input().split()))
if m in a:
    b=len(a) - a[::-1].index(m) - 1
    print(b+1)
else:
    print(-1)

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

Monday, July 16, 2018

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!!!