Programming Assignment-1: Cab and walk
Arun is working in an office which is N blocks away from his house. He wants to minimize the time it takes him to go from his house to the office.
He can either take the office cab or he can walk to the office.
Arun's velocity is V1 m/s when he is walking. The cab moves with velocity V2 m/s but whenever he calls for the cab, it always starts from the office, covers N blocks, collects Arun and goes back to the office.
The cab crosses a total distance of N meters when going from office to Arun's house and vice versa, whereas Arun covers a distance of while walking.
Help Arun to find whether he should walk or take a cab to minimize the time.
Input Format:
A single line containing three integer numbers N, V1, and V2 separated by a space.
Output Format:
Print 'Walk' or 'Cab' accordingly
Constraints:
1<=V1, V2 <=100
1<=N<=200
Example-1:
Input:
5 10 15
Output:
Cab
Example-2:
Input:
2 10 14
Output:
Walk
He can either take the office cab or he can walk to the office.
Arun's velocity is V1 m/s when he is walking. The cab moves with velocity V2 m/s but whenever he calls for the cab, it always starts from the office, covers N blocks, collects Arun and goes back to the office.
The cab crosses a total distance of N meters when going from office to Arun's house and vice versa, whereas Arun covers a distance of while walking.
Help Arun to find whether he should walk or take a cab to minimize the time.
Input Format:
A single line containing three integer numbers N, V1, and V2 separated by a space.
Output Format:
Print 'Walk' or 'Cab' accordingly
Constraints:
1<=V1, V2 <=100
1<=N<=200
Example-1:
Input:
5 10 15
Output:
Cab
Example-2:
Input:
2 10 14
Output:
Walk
Code:
n,v1,v2=input().split(" ")
n,v1,v2=int(n),int(v1),int(v2)
tv1=(2**.5*n/v1)
tv2=(2*n/v2)
if(tv1>tv2):
print("Cab",end="")
else:
print("Walk",end="")
Programming Assignment-2: End-Sort
Given a list A of N distinct integer numbers, you can sort the list by moving an element to the end of the list. Find the minimum number of moves required to sort the list using this method in ascending order.
Input Format:
The first line of the input contains N distinct integers of list A separated by a space.
Output Format
Print the minimum number of moves required to sort the elements.
Example:
Input:
1 3 2 4 5
Output:
3
Explanation:
In the first move, we move 3 to the end of the list. In the second move, we move 4 to the end of the list, and finally, in the third movement, we move 5 to the end.
Input Format:
The first line of the input contains N distinct integers of list A separated by a space.
Output Format
Print the minimum number of moves required to sort the elements.
Example:
Input:
1 3 2 4 5
Output:
3
Explanation:
In the first move, we move 3 to the end of the list. In the second move, we move 4 to the end of the list, and finally, in the third movement, we move 5 to the end.
Code:
x=[int(x) for x in input().split()]
x1=sorted(x)
c=0
for i in range(len(x)):
if x[i]==x1[c]:
c=c+1
print(len(x)-c,end="")
Programming Assignment-3: Semi Primes
A semiprime number is an integer which can be expressed as a product of two distinct primes. For example 15 = 3*5 is a semiprime number but 9 = 3*3 is not .
Given an integer number N, find whether it can be expressed as a sum of two semi-primes or not (not necessarily distinct).
Input Format:
The first line contains an integer N.
Output Format:
Print 'Yes' if it is possible to represent N as a sum of two semiprimes 'No' otherwise.
Example:
Input:
30
Output:
Yes
Explanation:
N = 30 can be expressed as 15+15 where 15 is a semi-prime number (5*3 = 15)
NOTE: N is less than equal to 200
Given an integer number N, find whether it can be expressed as a sum of two semi-primes or not (not necessarily distinct).
Input Format:
The first line contains an integer N.
Output Format:
Print 'Yes' if it is possible to represent N as a sum of two semiprimes 'No' otherwise.
Example:
Input:
30
Output:
Yes
Explanation:
N = 30 can be expressed as 15+15 where 15 is a semi-prime number (5*3 = 15)
NOTE: N is less than equal to 200
Code:
prime1=[]
prime2=[]
semiprime1=[]
semiprime2=[]
last=[]
n=int(input())
for i in range(2,n):
for j in range(2,i):
if(i%j==0):
break
else:
prime1.append(i)
prime2.append(i)
for i in prime1:
for j in prime2:
if i!=j and i*j<=n:
semiprime1.append(i*j)
semiprime2.append(i*j)
semiprime1.sort()
semiprime2.sort()
for i in semiprime1:
for j in semiprime2:
if(i+j<=n):
if (i+j) not in last:
last.append(i+j)
last.sort()
if n in last:
print("Yes",end="")
else:
print("No",end="")
Keep it up
ReplyDeleteGood
ReplyDeleteNice Blog!!! keep Posting!!!
ReplyDeleteTrekking And Camping in Dharamshala Dhauladhars Range – Kangra Valley –
Drop us a line and we will plan these treks for you! We will make it come true. No matter how strange or wild or tricky.
Himalaya Cab Provide Best Taxi services in dharamshala & kangra.
We offer pickup & dropoff Taxi services from Dharamshala airport to Mcleodganj.
Dharamshala taxi services www.himalayacab.com
Best Taxi Service in Kangra,
Best Tax Service in Mcleodganj, Best Taxi Service in Gaggal Airport, Best Taxi Service in kangra Airport, Best Taxi Service in Dharamshala Airport
Nice Article and keep writing 👍A preferred taxi/cab service in Dharamhsla.
ReplyDeleteDharamhsla taxi service
Eskişehir
ReplyDeleteDenizli
Malatya
Diyarbakır
Kocaeli
1D2
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
UD07L
I was under a tight deadline, but Python Assignment Help delivered my assignment on time. Their punctuality is commendable.
ReplyDeletePython Assignment Help
A8F86
ReplyDeleteAntalya Lojistik
Antep Lojistik
Amasya Lojistik
Tunceli Evden Eve Nakliyat
Çankırı Lojistik
B81F3
ReplyDeleteAmasya Evden Eve Nakliyat
Şırnak Lojistik
Antalya Evden Eve Nakliyat
Maraş Evden Eve Nakliyat
Diyarbakır Evden Eve Nakliyat
0ADFA
ReplyDeleteŞırnak Lojistik
Muş Evden Eve Nakliyat
Sinop Lojistik
Gümüşhane Parça Eşya Taşıma
Osmaniye Parça Eşya Taşıma
B9F77
ReplyDeleteAmasya Evden Eve Nakliyat
Mardin Evden Eve Nakliyat
Rize Lojistik
Antalya Evden Eve Nakliyat
Tekirdağ Lojistik
35F6F
ReplyDeleteKarapürçek Parke Ustası
Adıyaman Lojistik
Silivri Duşa Kabin Tamiri
Sivas Lojistik
Kayseri Evden Eve Nakliyat
Huobi Güvenilir mi
Muğla Evden Eve Nakliyat
Burdur Lojistik
Niğde Parça Eşya Taşıma
9C3CA
ReplyDeleteErzurum Şehir İçi Nakliyat
Altındağ Boya Ustası
Kütahya Şehirler Arası Nakliyat
Isparta Şehir İçi Nakliyat
İstanbul Parça Eşya Taşıma
Adıyaman Şehir İçi Nakliyat
Kırşehir Lojistik
Eskişehir Şehirler Arası Nakliyat
Çerkezköy Çekici
5D37E
ReplyDeleteKilis Lojistik
Etlik Fayans Ustası
Antalya Evden Eve Nakliyat
Kütahya Parça Eşya Taşıma
Bolu Parça Eşya Taşıma
Erzurum Evden Eve Nakliyat
Uşak Şehir İçi Nakliyat
Ankara Boya Ustası
Burdur Lojistik
BB1BF
ReplyDeleteYozgat Parça Eşya Taşıma
Ünye Organizasyon
Bingöl Evden Eve Nakliyat
Van Lojistik
Denizli Şehir İçi Nakliyat
Karaman Evden Eve Nakliyat
Amasya Evden Eve Nakliyat
Bingöl Lojistik
Nexa Coin Hangi Borsada