Posts

Showing posts from June, 2021

Define Class Event

Define Class Event Example Input/Output 1: Input: 5 TreasureHunt 200 60 ProjectExpo 500 180 RapidFireQuiz 200 20 PaperPresentation 400 120 Hackathon 500 180 Output: RapidFireQuiz 200 20 TreasureHunt 200 60 PaperPresentation 400 120 Hackathon 500 180 ProjectExpo 500 180 Exaplanation: Here N = 5. After sorting the events based on the given conditions, the events become RapidFireQuiz 200 20 TreasureHunt 200 60 PaperPresentation 400 120 Hackathon 500 180 ProjectExpo 500 180 Example Input/Output 2: Input: 6 ProjectExpo 800 180 TreasureHunt 100 90 Hackathon 800 240 TechQuiz 100 30 HexCoding 800 180 PaperPresentation 800 180 Output: TechQuiz 100 30 TreasureHunt 100 90 HexCoding 800 180 PaperPresentation 800 180 ProjectExpo 800 180 Hackathon 800 240 CODE SNIPPET:  class Event implements Comparable<Event> {     private String title="";     private int registrationFee,duration;     public Event(String title,int registration,int duration)     { ...

alphabet matrix minimum sum path

 PYTHON PROGRAM      r,c = map(int,input().split()) l = [input().lower().split()for i in range(r)] xs,ys = map(lambda x:int(x)-1,input().split()) xe,ye = map(lambda x:int(x)-1,input().split()) vh = [];hv=[];i,j = xs,ys while(i!=xe):     vh.append(ord(l[i][j])-ord('a')+1)     i+=1 if(i<xe)else -1 while(j!=ye):     vh.append(ord(l[i][j])-ord('a')+1)     j+=1 if(j<ye)else -1 vh.append(ord(l[i][j])-ord('a')+1) i,j=xs,ys while(j!=ye):     hv.append(ord(l[i][j])-ord('a')+1)     j+=1 if(j<ye)else -1 while(i!=xe):     hv.append(ord(l[i][j])-ord('a')+1)     i+=1 if(i<xe)else -1 hv.append(ord(l[i][j])-ord('a')+1) vh = sum(vh);hv = sum(hv);print(min([vh,hv]))

Function Calculate Distance DC[02/05/2021]

Function Calculate Distance typedef struct point {     int X;     int Y; } Point; IMPORTANT: Do not write the main() function as it is already defined. Example Input/Output 1: Input: 4 5 7 6 Output: 3.16 Explanation: The first point is (4, 5). The second point is (7, 6). The distance between the given two points is 3.16 (The distance is printed with the precision up to 2 decimal places). Example Input/Output 2: Input: 9 -2 0 0 Output: 9.22  CODE SNIPPET: double calculateDistance(Point *point1,Point *point2) { int x1=point1->X; int x2=point2->X; int y1=point1->Y; int y2=point2->Y; return sqrt(pow((x2-x1),2)+pow((y2-y1),2)); }