TAB

One of the works done by our Robotics and Machine Learning division,
SELF-LEVELING QUADCOPTER
Arduino based Quadcopter.
Self-leveling is acheived by the aligning the quadcopter using the readings from the gryo as well as the accelerometer.
A four channel RC transmitter is used to control the movement of the quadcopter when in flight. Kindly subscribe to our YouTube Channel and stay tuned.

Wednesday 4 November 2015

PRACTICE PROBLEM 10 -Agent Perry-(SOLVED)

Long and complex....!!!
==================================================================
import sys
def recurse(s,dim,func,mode="all",exec_all_dim=False,level=0,val=[],skip=False):
    if level<dim:
        if(exec_all_dim) and val!=[]:
            func(val)
        upp = len(s)
        low = 0
        forw = s
        if mode=="single":
            upp = 1
            forw = s[1:]
        for i in range(low,upp):
            if mode=="upper":
                forw = s[i+1:]
            elif mode=="exclude":
                forw = s[:i]+s[i+1:]
            elif mode=="upper_include":
                forw = s[i:]
            if skip:
                recurse(forw,dim,func,mode,exec_all_dim,level+1,val,skip=skip)
            recurse(forw,dim,func,mode,exec_all_dim,level+1,val+[s[i]],skip=skip)
    elif level==dim and val!=[]:
        func(val)

n = int(input())
pos = [[int(input()),int(input())] for i in range(n)]
bat = int(input())
all_comb = []
max_saves = []
saves = []
def exec(val):
    posit = [val[i][0] for i in range(len(val))]
    if sum(posit)<=bat:
        all_comb.append(posit)
        saves.append(sum([val[i][1] for i in range(len(val))]))
    elif posit == [pos[i][0] for i in range(len(pos))] and all_comb==[] and sum(posit)<bat:
        all_comb.append([pos[i][0] for i in range(len(pos))])
        saves.append(sum([pos[i][1] for i in range(len(pos))]))
    if posit == [pos[i][0] for i in range(len(pos))]:
        for i in range(len(all_comb)):
            if saves[i]==max(saves):
                max_saves.append(all_comb[i])
        min_moves = min([abs(min(max_saves[i])-max(max_saves[i])) for i in range(len(max_saves))]) if max_saves!=[] else 0
        for i in range(len(max_saves)):
            if abs(min(max_saves[i])-max(max_saves[i])) == min_moves:
                max_saves[i].sort()
                print(max_saves[i])
                sys.exit()
recurse(pos,len(pos),exec,mode="single",skip=True)


PRACTICE PROBLEM 10 - Kate's Game (SOLVED)

It is a long problem ,but quite simple.
"NO HIDDEN TESTCASE" error obtained.
Simple proceedural coding will solve the problem easily.
Further doubts are encouraged and the comments can be used for this purpose.
CODE:
========================================================================
n=int(input())
L=[]
import re
import sys
if(n<=0 or n%2==0):
    print("Invalid input")
    sys.exit()
while(True):
    k=input()
    for ch in k:
        if(re.match("[^A-Za-z]",ch)):
            print("Invalid input")
            sys.exit()
    if(len(k)==n):
        L.append(k)
    else:
        break
L2=[]
p=len(L)
L2.append(k)
for l in range(n-2):
    k=input()
    if(len(k)!=p):
        print("Invalid input")
        sys.exit()
    L2.append(k)
    for ch in k:
        if(re.match("[^A-Za-z]",ch)):
            print("Invalid input")
            sys.exit()
k=input()
for ch in k:
    if(re.match("[^A-Za-z]",ch)):
        print("Invalid input")
        sys.exit()
c=0
F=[]
for x in range(p):
    temp=list(L[x])
    for y in range(n-1):
        temp.append(L2[y][c])
    F.append(temp)
    c=c+1
W2=[]
Wv=[]
for j in range(p-1,-1,-1):
    W2.append(F[j][0])
    Wv.append(j)
for j in range(1,p//2):
    W2.append(F[j][j])
    Wv.append(j+j)
m=(p-1)//2
for j in range((p//2),-1,-1):
    W2.append(F[j][m])
    Wv.append(j+m)
    m=m+1
for j in range(1,p):
    W2.append(F[j][p-1])
    Wv.append(j+p-1)
T=sum(Wv)
F2=[]
for p in range(len(Wv)):
    temp2=[]
    temp3=0
    for q in range(p,len(W2)):
        temp2.append(W2[q])
        temp3=temp3+Wv[q]
        if(temp3!=0):
            if(T%temp3==0):
                TEMP=list(temp2)
                F2.append(TEMP)
l3=len(k)
FINAL=[]
for l in F2:
    s=''.join(l)
    for l2 in range(len(s)-l3+1):
        if(s[l2:(l2+l3)]==k):
            FINAL.append(s)
            break
FINAL.sort()
print(FINAL)
========================================================================

INTRODUCTION

Solving programming problems can often be frustating.(specially when you get errors like "HIDDEN TEST CASE OUTPUT NOT OBTAINED".)
Hopefully this blog should serve as a platform to discuss your errors and hopefully find the solution.
Looking forward to an active discussion!

P.S.:It might be a late start but its a start,that is what is important.