Posts

Showing posts from August, 2020

XML Basics2

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mydoc[  <!ELEMENT mydoc(address,name,company,phone)>  <!ELEMENT address (#PCDATA)>  <!ELEMENT name (#PCDATA)>  <!ELEMENT company (#PCDATA)>  <!ELEMENT phone (#PCDATA)> ]> <mydoc> <address>   <name>Tejanth</name>   <company>oracle</company>   <phone>6281104020</phone> </address> </mydoc>

XML Basics

 <?xml version="1.0"?> <scet> <cse> <top1>X</top1> <top2>Y</top2> <top3>Z</top3> </cse> </scet>

Dolout Program In Python

 LH  = int(input().strip()) UH  = int(input().strip()) LW  = int(input().strip()) UW  = int(input().strip()) dct = {} max_len = 0 count = 0 def f(x,y):   global count, max_len   count += 1   if x<y:     x, y = y,x   if x==0 or y==0:     return 0   if x==y:     return 1   else:     if (x,y) not in dct:       dct[(x,y)] = 1+f(x-y,y)       if len(dct)>max_len: max_len = len(dct)       if ((x-y,y) in dct): del dct[(x-y,y)]     return dct[(x,y)] res = 0 for i in range(LH,UH+1):   for j in range(LW,UW+1):     res += f(i,j) print(res)

Grooving Monkey Program In Python

 def grov_monkey(r):     z=r     x=[0]*len(r)     c = 0     while(x!=r):         c+=1         x=[0]*len(r)         for i in range(len(r)):             x[r[i]-1]=z[i]         z=x     return (c) t=int(input()) for i in range(t):    m,n=list(map(int,input().split())),int(input())     res=grov_monkey(m)     print(res)

Hedger Program In Python

 def market(stocks,costs,profits,count,result):    maxindex=profits.index(max(profits))    maxval=costs[maxindex]    #print(" index ",maxindex,"  val ",maxval)    for i in range(int(stocks[1])):        if stocks[2]>count and stocks[2]>=count+maxval:            count=count+maxval            result=result+((maxval*profits[maxindex])/100)        else:            print(int(result))            return result    profits.pop(maxindex);costs.pop(maxindex)    #print(result)    market(stocks,costs,profits,count,result) stock=re.findall(r"[-+]?\d*\.\d+|\d+",input()) cost=re.findall(r"[-+]?\d*\.\d+|\d+",input()) profit=re.findall(r"[-+]?\d*\.\d+|\d+",input()) stocks=[];costs=[];profits=[] for i in stock:    stocks.append(float(i)) for i in cost:    costs.append(float(i)) for i in profit:    profits.append(float(i)) #print(stocks) #print(costs) #print(profits) count=0;result=0 val=market(stocks,costs,profits,count,result)

Swayamvar Program In Python

 n= int(input()) groom= input() brid=input() c_r = brid.count('r') c_m = brid.count('m') lst = [i for i in groom] for i in groom:     if i == 'r':         if c_r==0:             print(len(lst), end='')             break         c_r-=1         lst.pop(0)     elif i == 'm':         if c_m==0:             print(len(lst),end='')             break         c_m-=1         lst.pop(0) else:     print(0,end='')

Faulty Keyboard Program in Python

 p=input("") q=input("") p=list(p.split(" ")) q=list(q.split(" ")) for t in range(0,len(q)-1):     c=[0 for i in range(t,len(q))] for i in p:     for j in range(len(q)):         k=0     while(k):         m2=c.index(m1) for i in range(m2,len(c)):     if(c[i]==m1):         if(ord(q[i])<ord(q[m2])):             m2=i     else:         m2=c.index(m1)         q[m2],q[t]=q[t],q[m2] print("".join(q))

Constellation Program In Pythyon

 n = int(input()) r1 = "" r2 = "" r3 = "" if 3 <= n <= 10 ** 5:     for i in range(3):         for j in range(n):             if i == 0:                 r1 += input().replace(" ", "")             if i == 1:                 r2 += input().replace(" ", "")             if i == 2:                 r3 += input().replace(" ", "") else:     print("Not within range") # Main_solution def starcounter(a):  # count number of "*"     cnt = 0     for i in a:         if i == "*":             cnt += 1     return cnt def nospacestar(line):  # Divide_connected_star by 3     n = 3     os = []     out = [(line[i:i + n]) for i in range(0, len(line), n)]     for k in out:         os.append(k)     return os def final(rw, rw1, rw2):  # final_method     o = []     arr = []     o = rw.replace("#", "#$").split("$")  # replace "#" with dollor & spl

Battle Program In Python.

 from math import gcd, factorial, floor, ceil from fractions import Fraction import operator as op from functools import reduce def nCr(n, r):     r = min(r, n-r)     numer = reduce(op.mul, range(n, n-r, -1), 1)     denom = reduce(op.mul, range(1, r+1), 1)     return Fraction(numer,denom) T = int(input().strip()) for _ in range(T):   A, H, L1, L2, M, C = tuple(map(int,input().strip().split()))   special_needed, L = ceil((H-M*A)/C), Fraction(L1,L2)   count = Fraction(0)   for k in range(special_needed,M+1):     count += nCr(M,k)*L**k*(1-L)**(M-k)   p1,p2 = count.numerator, count.denominator   if p1==0:     print('RIP')   else:     _ = gcd(p1,p2)     print('{}/{}'.format(p1//_,p2//_))