def generate_password(number, name):
# Check if name consists of only lowercase letters
if name.isalpha() and name.islower():
# Convert number to absolute value to handle negative numbers
abs_number = abs(number)
# Ensure length of name is within the specified range
name_length = min(max(len(name), 1), 100)
# Generate password using a combination of number and name
password = str(abs_number) + name[:name_length]
return password
else:
return "Invalid"
try:
# Input: Number of test cases
T = int(input())
# Process each test case
for _ in range(T):
# Input: Number and Name separated by space
test_input = input().split()
if len(test_input) == 2:
number = int(test_input[0])
name = test_input[1]
# Output: Print the password for each test case in a new line
result = generate_password(number, name)
print(result)
else:
print("Invalid input format")
except Exception as e:
print("An error occurred:", e)
Password Generator Working Code
TCS Codevita
Pls share
https://t.me/TCS_Codevita_Exam_Help
# Check if name consists of only lowercase letters
if name.isalpha() and name.islower():
# Convert number to absolute value to handle negative numbers
abs_number = abs(number)
# Ensure length of name is within the specified range
name_length = min(max(len(name), 1), 100)
# Generate password using a combination of number and name
password = str(abs_number) + name[:name_length]
return password
else:
return "Invalid"
try:
# Input: Number of test cases
T = int(input())
# Process each test case
for _ in range(T):
# Input: Number and Name separated by space
test_input = input().split()
if len(test_input) == 2:
number = int(test_input[0])
name = test_input[1]
# Output: Print the password for each test case in a new line
result = generate_password(number, name)
print(result)
else:
print("Invalid input format")
except Exception as e:
print("An error occurred:", e)
Password Generator Working Code
TCS Codevita
Pls share
https://t.me/TCS_Codevita_Exam_Help
def minVehicles(weights, limit):
weights.sort() # Sort the weights in ascending order
left, right = 0, len(weights) - 1
vehicles = 0
while left <= right:
if weights[left] + weights[right] <= limit:
left += 1
right -= 1
vehicles += 1
return vehicles
# Python 3 compatibility
try:
# Python 3
raw_input = input
except NameError:
# Python 2
pass
weights = list(map(int, raw_input().split()))
limit = int(raw_input())
result = minVehicles(weights, limit)
# Output the result without extra spaces or newline characters
print(result, end="")
Warehouse public passed ✅✅✅... python 3
weights.sort() # Sort the weights in ascending order
left, right = 0, len(weights) - 1
vehicles = 0
while left <= right:
if weights[left] + weights[right] <= limit:
left += 1
right -= 1
vehicles += 1
return vehicles
# Python 3 compatibility
try:
# Python 3
raw_input = input
except NameError:
# Python 2
pass
weights = list(map(int, raw_input().split()))
limit = int(raw_input())
result = minVehicles(weights, limit)
# Output the result without extra spaces or newline characters
print(result, end="")
Warehouse public passed ✅✅✅... python 3
WHY YOU GUYS ARE NOT SUBSCRIBING?
I WILL ONLY GIVE CODE AFTER YOU ALL WILL SUBSCRIBE
I WILL ONLY GIVE CODE AFTER YOU ALL WILL SUBSCRIBE
I AM NOT ASKING FOR MONEY.. JUST WANT YOU TO SUBSCRIBE THE CHANNEL
STILL SOME PEOPLE ARE NOT SUBSCRIBING... I CAN CHECK WHO HAVE NOT SUBSCRIBED
Solo Rider
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
typedef struct {
int x, y;
} Point;
typedef struct {
char name[20];
Point location;
} Passenger;
typedef struct {
char number[20];
Point location;
} Vehicle;
int manhattanDistance(Point p1, Point p2) {
return abs(p1.x - p2.x) + abs(p1.y - p2.y);
}
Vehicle* findNearestVehicle(Passenger passenger, Vehicle* vehicles, int m, int* assigned) {
int i;
int minDistance = INT_MAX;
Vehicle* nearestVehicle = NULL;
for (i = 0; i < m; i++) {
if (!assigned[i]) {
int distance = manhattanDistance(passenger.location, vehicles[i].location);
if (distance < minDistance || (distance == minDistance && strcmp(vehicles[i].number, nearestVehicle->number) < 0)) {
minDistance = distance;
nearestVehicle = &vehicles[i];
}
}
}
assigned[nearestVehicle - vehicles] = 1;
return nearestVehicle;
}
int main() {
int n, m,i;
scanf("%d %d", &n, &m);
Passenger passengers[n];
for ( i = 0; i < n; i++) {
scanf("%s %d %d", passengers[i].name, &passengers[i].location.x, &passengers[i].location.y);
}
Vehicle vehicles[m];
for ( i = 0; i < m; i++) {
scanf("%s %d %d", vehicles[i].number, &vehicles[i].location.x, &vehicles[i].location.y);
}
int assigned[m];
memset(assigned, 0, sizeof(assigned));
int totalDistance = 0;
for ( i = 0; i < n; i++) {
Vehicle* assignedVehicle = findNearestVehicle(passengers[i], vehicles, m, assigned);
totalDistance += manhattanDistance(passengers[i].location, assignedVehicle->location);
}
printf("%d\n", totalDistance);
return 0;
}
Solo rider
Only public Test Cases Passed
I'm Trying to Modify So for now you can try this
I will update new soon
Keep sharing
https://t.me/TCS_Codevita_Exam_Help
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
typedef struct {
int x, y;
} Point;
typedef struct {
char name[20];
Point location;
} Passenger;
typedef struct {
char number[20];
Point location;
} Vehicle;
int manhattanDistance(Point p1, Point p2) {
return abs(p1.x - p2.x) + abs(p1.y - p2.y);
}
Vehicle* findNearestVehicle(Passenger passenger, Vehicle* vehicles, int m, int* assigned) {
int i;
int minDistance = INT_MAX;
Vehicle* nearestVehicle = NULL;
for (i = 0; i < m; i++) {
if (!assigned[i]) {
int distance = manhattanDistance(passenger.location, vehicles[i].location);
if (distance < minDistance || (distance == minDistance && strcmp(vehicles[i].number, nearestVehicle->number) < 0)) {
minDistance = distance;
nearestVehicle = &vehicles[i];
}
}
}
assigned[nearestVehicle - vehicles] = 1;
return nearestVehicle;
}
int main() {
int n, m,i;
scanf("%d %d", &n, &m);
Passenger passengers[n];
for ( i = 0; i < n; i++) {
scanf("%s %d %d", passengers[i].name, &passengers[i].location.x, &passengers[i].location.y);
}
Vehicle vehicles[m];
for ( i = 0; i < m; i++) {
scanf("%s %d %d", vehicles[i].number, &vehicles[i].location.x, &vehicles[i].location.y);
}
int assigned[m];
memset(assigned, 0, sizeof(assigned));
int totalDistance = 0;
for ( i = 0; i < n; i++) {
Vehicle* assignedVehicle = findNearestVehicle(passengers[i], vehicles, m, assigned);
totalDistance += manhattanDistance(passengers[i].location, assignedVehicle->location);
}
printf("%d\n", totalDistance);
return 0;
}
Solo rider
Only public Test Cases Passed
I'm Trying to Modify So for now you can try this
I will update new soon
Keep sharing
https://t.me/TCS_Codevita_Exam_Help
SAB LOG SUBSCRIBE KARO.. EK MIN LAGEGI and TUMHARA EK QUESTION KA CODE AA JAYEGA
https://www.youtube.com/shorts/wfhCTLmxlEw
https://www.youtube.com/shorts/wfhCTLmxlEw
https://www.youtube.com/shorts/xcmj7hifWro
JALDI SUBSCRIBE KARO GUYZ... AAGE KE CODE BHI UPLOAD KRNE H
JALDI SUBSCRIBE KARO GUYZ... AAGE KE CODE BHI UPLOAD KRNE H