All coding Solution
13.1K subscribers
185 photos
181 files
36 links
Download Telegram
class Food:
def init(self,name,protien,fat,carb):
self.name=name
self.protien=protien
self.fat=fat
self.carb=carb

class Nutrition:
def init(self,status,lfood):
self.status=status
self.lfood=lfood
def setEnergy(self):
result=[]
for i in lfood:
for k,v in status.items():

temp=(i.protien+i.fat+i.carb)
if(temp>=v[0] and temp<=v[1]):
result.append(str(i.name)+" - "+str(temp)+" - "+k)
if(len(result)==0):
return None
else:
return result
def getEnergyRichFood(self,checkenergy):
ans=[]
for i in lfood:
temp=(i.protien+i.fat+i.carb)
if(temp<=checkenergy):
ans.append(i.name+" : "+str(temp))
if(len(ans)==0):
return None
else:
return ans
n=int(input())
lfood=[]

for i in range(n):
name=input()
protien=float(input())
fat=float(input())
carb=float(input())
lfood.append(Food(name,protien,fat,carb))
status={}
cnt=int(input())
for i in range(cnt):
st=input()
l=[]
l.append(int(input()))
l.append(int(input()))
status[st]=tuple(l)
checkenergy=int(input())
obj=Nutrition(status,lfood)
result=obj.setEnergy()
ans=obj.getEnergyRichFood(checkenergy)
if(result!=None):
print("Energy of Food:")
for i in result:
print(i)
if(ans!=None):
print("Food within given criteria:")
for i in ans:
print(i)
else:
print("No Food Found")

Food code

python


Telegram- https://t.me/Allcodingsolution
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;

public class Solution {

public static void main(String[] args){
Scanner sc = new Scanner(System.in);
List<Mobile> list = new ArrayList<>();
for(int i=0;i<4;i++){

String mobileId = sc.nextLine();
String modelName = sc.nextLine();
String price = sc.nextLine();
String brand = sc.nextLine();

Mobile mobile = new Mobile(Integer.parseInt(mobileId),Integer.parseInt(price),modelName,brand);
mobile.setMobileId(Integer.parseInt(mobileId));
mobile.setPrice(Integer.parseInt(price));
mobile.setModelName(modelName);
mobile.setBrand(brand);

list.add(mobile);
}

String brand = sc.nextLine();

int ans = countMobilesByBrand(list,brand);
if(ans == 0){
System.out.println("No such mobile found.");
}
else {
System.out.println(ans);
}

Mobile ans1 =getSecondHighestPricedMobile(list);
if(Objects.isNull(ans1)){
System.out.println("No such mobile found.");
}else{
System.out.println(ans1.getModelName());
System.out.println(ans1.getPrice());
System.out.println(ans1.getBrand());
}

}

public static class Mobile {
private int mobileId;
private String modelName;
private int price;
private String brand;

public Mobile(int mobileId, int price, String modelName, String brand) {
this.mobileId = mobileId;
this.price = price;
this.modelName = modelName;
this.brand = brand;
}

public int getMobileId() {
return mobileId;
}

public void setMobileId(int mobileId) {
this.mobileId = mobileId;
}

public int getPrice() {
return price;
}

public void setPrice(int price) {
this.price = price;
}

public String getModelName() {
return modelName;
}

public void setModelName(String modelName) {
this.modelName = modelName;
}

public String getBrand() {
return brand;
}

public void setBrand(String brand) {
this.brand = brand;
}



}
private static int countMobilesByBrand(List<Mobile> list, String brand) {
int count = 0;
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getBrand().equals(brand))
count++;
}
return count;
}

private static Mobile getSecondHighestPricedMobile(List<Mobile>list){
int max = -1;
int ans =-1;
for (int i = 0; i < list.size(); i++) {
if(list.get(i).getPrice()%2 ==0)
continue;
if(max == -1) {
max = list.get(i).getPrice();
continue;
}

int value = list.get(i).getPrice();
if(value > max){
ans = max;
max = value;
continue;
}
if(value>ans){
ans = value;
}
}
if(ans == -1)
return null;
for(int i = 0; i < list.size(); i++){
if(ans == list.get(i).getPrice())
return list.get(i);
}
return null;
}

}

Mobile. Code java

Telegram :- https://t.me/Allcodingsolution
👍1
Python Unix Code

Telegram :- https://t.me/Allcodingsolution
Java code
One test cases passes

Telegram :- https://t.me/Allcodingsolution
Infytq
Maximu of 4 unique upper case alphabets

💯% test cases passed


@Allcodingsolution
@Allcodingsolution
@Allcodingsolution
👍1
Infytq
Maximu of 4 unique upper case alphabets

💯% test cases passed

@Allcodingsolution
@Allcodingsolution
@Allcodingsolution
INFYTQ
Helath is wealth Code
Phyton 3

💯% test cases passed

@Allcodingsolution
@Allcodingsolution
@Allcodingsolution
Guys I have sended the code that are working and passed
If it is not passing to you you can done mistakes please check the code again

@Allcodingsolution
@Allcodingsolution
@Allcodingsolution
@Allcodingsolution
INFYTQ M×N Matrix Code
💯% all test cases passed

@Allcodingsolution
@Allcodingsolution
@Allcodingsolution
Smallest character python3 code Accenture exam all testcases passed code i given

Accenture exam

@Allcodingsolution
@Allcodingsolution
@Allcodingsolution
@Allcodingsolution
@Allcodingsolution