uk
Feedback

Не попадись на ботовода! Telemetrio знаходить і позначає такі канали мітками 👉 Хочеш бачити мітку, оформляй підписку

Infosys | IBM | Accenture Exam Help

Infosys | IBM | Accenture Exam Help

Відкрити в Telegram

Any Online Assessment Help Available ✅ Admin - @Codehelpdesk 😇 ⭕ Daily Jobs and Internships Updates ⭕ Any Online Assesment Help Available ⭕ IT/ Non-IT Job Updates

Показати більше
4 685
Підписники
Немає даних24 години
-57 днів
+930 днів
Архів дописів
from collections import defaultdict class Pair: def init(self, first, second): self.first = first self.second = second def eq
from collections import defaultdict

class Pair:
    def init(self, first, second):
        self.first = first
        self.second = second

    def eq(self, other):
        return self.first == other.first and self.second == other.second

    def hash(self):
        return hash((self.first, self.second))

def main():
    num_wires = int(input())
    paths = []
    point_to_segments_map = defaultdict(list)

    for _ in range(num_wires):
        x1, y1, x2, y2 = map(int, input().split())
        delta_x = x2 - x1
        delta_y = y2 - y1
        steps = max(abs(delta_x), abs(delta_y))
        step_x = 0 if delta_x == 0 else delta_x // abs(delta_x)
        step_y = 0 if delta_y == 0 else delta_y // abs(delta_y)
        path = []

        for step in range(steps + 1):
            current_x = x1 + step_x * step
            current_y = y1 + step_y * step
            path.append(Pair(current_x, current_y))
            point_to_segments_map[Pair(current_x, current_y)].append(len(paths))

        paths.append(path)

    animal_resistances = {}
    animal_info = input().split()
    for info in animal_info:
        animal, resistance = info.split(":")
        animal_resistances[animal] = int(resistance)

    touched_animal = input()
    total_voltage = 0

    for point, segments in point_to_segments_map.items():
        if len(segments) >= 2:
            overlap_count = len(segments)
            min_cost = float("inf")

            for segment_id in segments:
                segment_path = paths[segment_id]
                index = segment_path.index(point)
                left_moves = index
                right_moves = len(segment_path) - index - 1
                move_cost = min(left_moves, right_moves) if left_moves > 0 and right_moves > 0 else max(left_moves, right_moves)
                min_cost = min(min_cost, move_cost)

            total_voltage += overlap_count * min_cost

    if touched_animal in animal_resistances:
        if total_voltage >= animal_resistances[touched_animal]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

    valid_animal_count = sum(1 for resistance in animal_resistances.values() if total_voltage >= resistance)
    success_rate = valid_animal_count / len(animal_resistances)
    print("{:.2f}".format(success_rate))

if name == "main":
    main()
Fence voltage - CodeVita ✅
30 лист 2024, 03:38

🔴Form the string Available 🔴 Fully accepted ✅ Dm @Codehelpdesk ⭐
30 лист 2024, 02:29
30 лист 2024, ~03:33

Fence voltage ✅
Fence voltage ✅
30 лист 2024, 02:18

Search with the Question name Find and answer and execute the code ✅ Without plagiarism 🔥 Share channel in your groups 😇 Those who are writing exam give ❤️
For Queries @Codehelpdesk ⭐
30 лист 2024, 01:56

int area(const vector<pair<int, int>>& p) {
    int n = p.size(), a = 0;
    for (int i = 0; i < n; i++) {
        int j = (i + 1) % n;
        a += p[i].first * p[j].second;
        a -= p[j].first * p[i].second;
    }
    return abs(a) / 2;
}

int main() {
    int n, x1, y1, x2, y2, mx = 0;
    cin >> n;
    set<pair<int, int>> pts;

    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        pts.insert({x1, y1});
        pts.insert({x2, y2});
    }

    vector<pair<int, int>> v(pts.begin(), pts.end());
    int sz = v.size();

    for (int i = 0; i < sz; i++) {
        for (int j = i + 1; j < sz; j++) {
            for (int k = j + 1; k < sz; k++) {
                mx = max(mx, area({v[i], v[j], v[k]}));
            }
        }
    }

    cout << mx << endl;
    return 0;
}
Max area - Codevita ✅
30 лист 2024, 01:56

#include <bits/stdc++.h>   
using namespace std;   
typedef long long altLong;   

int main() {   
    int n;   
    cin >> n;   
    vector<vector<pair<int, int>>> paths(n);   
    map<pair<int, int>, vector<int>> ptSegMap;   

    for (int i = 0; i < n; i++) {   
        int x1, y1, x2, y2;   
        cin >> x1 >> y1 >> x2 >> y2;   
        int dx = x2 - x1, dy = y2 - y1;   
        int steps = max(abs(dx), abs(dy));   
        int sx = (dx == 0) ? 0 : dx / abs(dx);   
        int sy = (dy == 0) ? 0 : dy / abs(dy);   
        for (int j = 0; j <= steps; j++) {   
            int cx = x1 + sx * j;   
            int cy = y1 + sy * j;   
            paths[i].emplace_back(make_pair(cx, cy));   
            ptSegMap[{cx, cy}].emplace_back(i);   
        }   
    }   

    cin.ignore();   
    string line;   
    getline(cin, line);   
    unordered_map<string, int> valMap;   

    stringstream ss(line);   
    string k;   
    int v;   
    while (ss >> k) {   
        if (k.back() == ':') {   
            k.pop_back();   
            ss >> v;   
            valMap[k] = v;   
        }   
    }   

    string tKey;   
    cin >> tKey;   

    altLong cost = 0;   

    for (auto &entry : ptSegMap) {   
        if (entry.second.size() >= 2) {   
            int overlap = entry.second.size();   
            int minCost = INT_MAX;   
            for (auto segID : entry.second) {   
                auto &path = paths[segID];   
                auto it = find(path.begin(), path.end(), entry.first);   
                int idx = distance(path.begin(), it);   
                int left = idx;   
                int right = path.size() - idx - 1;   
                int moveCost = min(left, right);   
                minCost = min(minCost, moveCost);   
            }   
            cost += (altLong)overlap * minCost;   
        }   
    }   

    if (valMap.find(tKey) != valMap.end()) {   
        if (cost >= valMap[tKey]) {   
            cout << "Yes\n";   
        } else {   
            cout << "No\n";   
        }   
    } else {   
        cout << "No\n";   
    }   

    int validCount = 0, totalCount = valMap.size();   
    for (auto &entry : valMap) {   
        if (cost >= entry.second) {   
            validCount++;   
        }   
    }   

    double successRate = (double)validCount / totalCount;   
    cout << fixed << setprecision(2) << successRate;   

    return 0;   
}
Fence Voltage - Codevita⚡
30 лист 2024, 01:54

struct P {
    double a, b;
    P(double a = 0, double b = 0) : a(a), b(b) {}
};

P r(const P &p, double t) {
    return P(p.a * cos(t) - p.b * sin(t),
             p.a * sin(t) + p.b * cos(t));
}

pair<double, double> g(const vector<P> &q, double t) {
    double x1 = 1e9, x2 = -1e9, y1 = 1e9, y2 = -1e9;
    for (const auto &p : q) {
        P s = r(p, t);
        x1 = min(x1, s.a);
        x2 = max(x2, s.a);
        y1 = min(y1, s.b);
        y2 = max(y2, s.b);
    }
    return {x2 - x1, y2 - y1};
}

int main() {
    int n;
    cin >> n;
    vector<P> q(n);

    for (int i = 0; i < n; ++i) {
        cin >> q[i].a >> q[i].b;
    }

    double m = 1e9, w = 0, h = 0;

    for (int i = 0; i < 360; ++i) {
        double t = i * M_PI / 180.0;
        auto [cw, ch] = g(q, t);
        double a = cw * ch;
        if (a < m) {
            m = a;
            w = cw;
            h = ch;
        }
    }

    if (w > h) {
        swap(w, h);
    }

    cout << fixed << setprecision(0) << round(w) << " "
         << fixed << setprecision(0) << round(h);

    return 0;
}
Folder Area - Codevita ✅
30 лист 2024, 01:43

pair<double, double> r(double px, double py, double x1, double y1, double x2, double y2) {
    double a = y2 - y1;
    double b = x1 - x2;
    double c = x2 * y1 - x1 * y2;
    double d = (a * px + b * py + c) / sqrt(a * a + b * b);
    double nx = px - 2 * d * (a / sqrt(a * a + b * b));
    double ny = py - 2 * d * (b / sqrt(a * a + b * b));
    return {nx, ny};
}

int main() {
    double ar;
    cin >> ar;

    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double s = sqrt(ar);
    vector<pair<double, double>> cr = {
        {0, 0},
        {0, s},
        {s, s},
        {s, 0},
    };

    set<pair<double, double>> pts(cr.begin(), cr.end());

    for (const auto& c : cr) {
        auto [rx, ry] = r(c.first, c.second, x1, y1, x2, y2);
        pts.insert({rx, ry});
    }

    for (const auto& p : pts) {
        cout << fixed << setprecision(2) << p.first << " " << p.second << endl;
    }

    return 0;
}
Flooded area - Codevita ✅
30 лист 2024, 01:31

Search with the Question name Find and answer and execute the code ✅ Within plagiarism 🔥 Share channel in your groups 😇 Those who are writing exam give ❤️
For Queries @Codehelpdesk ⭐
30 лист 2024, 01:21

I shared almost all the codes 🫡 Share channel to ur frnds ❤️ More codes will be uploaded 💪
30 лист 2024, 01:17
30 лист 2024, ~01:17

I shared almost all the codes 🫡 Share channel to ur frnds ❤️ More codes will be uploaded 💪 https://t.me/codinghelpdesk
30 лист 2024, 01:16

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> ids(n), costs(n);

    for (int i = 0; i < n; i++) cin >> ids[i];
    for (int i = 0; i < n; i++) cin >> costs[i];

    int budget;
    cin >> budget;

    int maxItems = 0, minCost = 0;

    for (int i = 0; i < n; i++) {
        int itemCost = costs[i];
        int quantity = budget / itemCost;

        if (quantity > 0) {
            int currentItems = 0, currentCost = 0;

            for (int j = 0; j < n; j++) {
                if (i != j && ids[i] % ids[j] == 0) {
                    currentItems += quantity;
                    currentCost += costs[j] * quantity;
                }
            }

            if (currentItems > maxItems || (currentItems == maxItems && currentCost > minCost)) {
                maxItems = currentItems;
                minCost = currentCost;
            }
        }
    }

    cout << maxItems << " " << minCost << endl;

    return 0;
}
Buzz Day Sale - Codevita ✅
30 лист 2024, 01:11

from collections import deque
import itertools

def get_shortest_path(grid, N):
    start = None
    end = None
    for i in range(N):
        for j in range(N):
            if grid[i][j] == 'S':
                start = (i, j)
            elif grid[i][j] == 'D':
                end = (i, j)

    queue = deque([(start, 0)])
    visited = {start}

    while queue:
        (x, y), dist = queue.popleft()
        if grid[x][y] == 'D':
            return dist

        for nx, ny in [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]:
            if 0 <= nx < N and 0 <= ny < N and (nx, ny) not in visited and grid[nx][ny] != 'T':
                visited.add((nx, ny))
                queue.append(((nx, ny), dist + 1))
    return float('inf')

def get_sheets(grid, N, M):
    sheets = []
    for i in range(0, N, M):
        for j in range(0, N, M):
            sheet = []
            for x in range(M):
                row = []
                for y in range(M):
                    row.append(grid[i+x][j+y])
                sheet.append(row)
            sheets.append(sheet)
    return sheets

def make_grid(arrangement, sheets, N, M):
    grid = [["" for _ in range(N)] for _ in range(N)]
    num_sheets = N // M

    for idx, sheet_idx in enumerate(arrangement):
        sheet = sheets[sheet_idx]
        base_i = (idx // num_sheets) * M
        base_j = (idx % num_sheets) * M

        for i in range(M):
            for j in range(M):
                grid[base_i + i][base_j + j] = sheet[i][j]
    return grid

def solve():
    N, M = map(int, input().split())
    original_grid = [list(input().strip()) for _ in range(N)]

    sheets = get_sheets(original_grid, N, M)
    num_sheets = (N // M) ** 2

    s_sheet = d_sheet = None
    for i, sheet in enumerate(sheets):
        for row in sheet:
            if 'S' in row:
                s_sheet = i
            if 'D' in row:
                d_sheet = i

    min_dist = float('inf')
    nums = list(range(num_sheets))
    nums.remove(s_sheet)
    nums.remove(d_sheet)

    for middle_perm in itertools.permutations(nums):
        arrangement = [s_sheet] + list(middle_perm) + [d_sheet]
        grid = make_grid(arrangement, sheets, N, M)
        min_dist = min(min_dist, get_shortest_path(grid, N))

    return min_dist

if name == "main":
    print(solve())
Arrange Map - Codevita ✅
30 лист 2024, 01:09

string s;
    cin >> s;
    int n = s.length(), res = 0;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    int lw = s[0] - '0', lwv = v[0];
    for (int i = 1; i < n; ++i) {
        if (s[i] - '0' == lw) {
            res += min(lwv, v[i]);
            lwv = max(lwv, v[i]);
        } else {
            lw = s[i] - '0';
            lwv = v[i];
        }
    }
    cout << res;
    return 0;
}
Alternating String - Codevita ✅
30 лист 2024, 00:59

#include <bits/stdc++.h>
using namespace std;

struct Point {
    int x, y;
};

int squaredDistance(const Point& a, const Point& b) {
    int dx = a.x - b.x;
    int dy = a.y - b.y;
    return dx * dx + dy * dy;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    vector<vector<int>> earringEdges(N, vector<int>());
    
    for(int i=0; i<N; i++){
        int K;
        cin >> K;
        vector<Point> points(K);
        for(int j=0; j<K; j++) cin >> points[j].x >> points[j].y;
        
        vector<int> edges;
        for(int j=0; j<K; j++){
            int next = (j+1) % K;
            edges.push_back(squaredDistance(points[j], points[next]));
        }
        earringEdges[i] = edges;
    }

    bool found = false;
    int e1 = -1, e2 = -1;
    
    for(int i=0; i<N && !found; i++){
        for(int j=i+1; j<N && !found; j++){
            if(earringEdges[i].size() != earringEdges[j].size()) continue;
            int K = earringEdges[i].size();
            for(int s=0; s<K && !found; s++){
                bool match = true;
                for(int k=0; k<K; k++){
                    if(earringEdges[i][k] != earringEdges[j][(k+s)%K]){
                        match = false;
                        break;
                    }
                }
                if(match){
                    e1 = i+1;
                    e2 = j+1;
                    found = true;
                }
            }
        }
    }
    
    if(found){
        cout << e1 << " " << e2;
    } else {
        cout << "No matching pair found.";
    }
    
    return 0;
}


Find Pairs - Codevita✅
30 лист 2024, 00:57

import java.util.*;

public class RitikaTask {

    private static int[] canFormWithDeletions(String sub, String mainStr, int maxDeletions) {
        int i = 0, j = 0, deletionsUsed = 0;
        while (i < mainStr.length() && j < sub.length()) {
            if (mainStr.charAt(i) == sub.charAt(j)) {
                i++;
                j++;
            } else {
                deletionsUsed++;
                if (deletionsUsed > maxDeletions) {
                    return new int[] {i, deletionsUsed};
                }
                i++;
            }
        }
        return new int[] {i, deletionsUsed};
    }

    private static boolean canMatchCharacter(char c, List<String> substrings) {
        for (String sub : substrings) {
            if (sub.indexOf(c) >= 0) {
                return true;
            }
        }
        return false;
    }

    public static String solveRitikaTask(List<String> substrings, String mainStr, int k) {
        int n = mainStr.length();
        int deletionsUsed = 0;
        StringBuilder formedString = new StringBuilder();
        boolean isAnyMatch = false;

        for (int i = 0; i < n; i++) {
            if (!canMatchCharacter(mainStr.charAt(i), substrings)) {
                return "Impossible";
            }
        }

        for (int i = 0; i < n;) {
            boolean matched = false;
            for (String sub : substrings) {
                int[] result = canFormWithDeletions(sub, mainStr.substring(i), k - deletionsUsed);
                int newIndex = result[0];
                int usedDeletions = result[1];

                if (newIndex > 0) {
                    matched = true;
                    isAnyMatch = true;
                    formedString.append(mainStr.substring(i, i + newIndex));
                    i += newIndex;
                    deletionsUsed += usedDeletions;
                    break;
                }
            }
            if (!matched) {
                break;
            }
        }

        if (formedString.length() == n) {
            if (deletionsUsed <= k) {
                return "Possible";
            } else {
                return formedString.toString().trim();
            }
        } else if (isAnyMatch) {
            return "Nothing";
        } else if (deletionsUsed > k) {
            return formedString.toString().trim();
        } else {
            return formedString.toString().trim();
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        scanner.nextLine();
        List<String> substrings = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            substrings.add(scanner.nextLine());
        }

        String mainStr = scanner.nextLine();
        int K = scanner.nextInt();

        String result = solveRitikaTask(substrings, mainStr, K);
        System.out.print(result);

        scanner.close();
    }
}


HELP RITIKA CODE ✅✅✅ Language - Java
30 лист 2024, 00:55

#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;

   polygon using the Shoelace Theorem
int calculateArea(const vector<pair<int, int>>& polygon) {
    int n = polygon.size();
    int area = 0;
    for (int i = 0; i < n; i++) {
        int j = (i + 1) % n;
        area += polygon[i].first * polygon[j].second;
        area -= polygon[j].first * polygon[i].second;
    }
    return abs(area) / 2;
}

 are connected
bool areConnected(pair<int, int> a, pair<int, int> b, pair<int, int>& p1, pair<int, int>& p2) {
    return (p1 == a && p2 == b) || (p1 == b && p2 == a);
}

int main() {
    int N;
    cin >> N;

    vector<pair<int, int>> coordinates;
    vector<vector<pair<int, int>>> segments(N);
    set<pair<int, int>> points;

 store them as pairs
    for (int i = 0; i < N; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        coordinates.push_back({x1, y1});
        coordinates.push_back({x2, y2});
        points.insert({x1, y1});
        points.insert({x2, y2});
    }

    vector<pair<int, int>> polygon;
    int maxArea = 0;

      to form polygons
    for (auto p1 = points.begin(); p1 != points.end(); ++p1) {
        for (auto p2 = next(p1); p2 != points.end(); ++p2) {
            polygon.push_back(*p1);
            polygon.push_back(*p2);
            maxArea = max(maxArea, calculateArea(polygon));
        }
    }

    cout << maxArea << endl;
    return 0;
}
Maximum Area ✅
30 лист 2024, 00:54

More Codes will be uploaded 😇 Share our channel in groups ❤️ https://t.me/codinghelpdesk
30 лист 2024, 00:52

MAXIMUM ROTATION
PYTHON


def rl(layer, pos, dir, ol):
    n = len(layer)
    rot = [None] * n

    if dir == "clockwise":
        for i in range(n):
            rot[(i + pos) % n] = layer[i]
    else:
        for i in range(n):
            rot[(i - pos) % n] = layer[i]

    for i in range(n):
        if ol:
            rot[i] = chr(((ord(rot[i]) - ord('A') - 1) % 26) + ord('A'))
        else:
            rot[i] = chr(((ord(rot[i]) - ord('A') + 1) % 26) + ord('A'))

    return rot


def aq(pl, row, col, size):
    layers = []
    for layer in range(size // 2):
        cl = []
        for j in range(col + layer, col + size - layer):
            cl.append(pl[row + layer][j])
        for i in range(row + layer + 1, row + size - layer - 1):
            cl.append(pl[i][col + size - layer - 1])
        for j in range(col + size - layer - 1, col + layer - 1, -1):
            cl.append(pl[row + size - layer - 1][j])
        for i in range(row + size - layer - 2, row + layer, -1):
            cl.append(pl[i][col + layer])
        layers.append(cl)

    for lidx, layer in enumerate(layers):
        ol = (lidx + 1) % 2 == 1
        dir = "counterclockwise" if ol else "clockwise"
        pos = lidx + 1
        rotated_layer = rl(layer, pos, dir, ol)

        idx = 0
        for j in range(col + lidx, col + size - lidx):
            pl[row + lidx][j] = rotated_layer[idx]
            idx += 1
        for i in range(row + lidx + 1, row + size - lidx - 1):
            pl[i][col + size - lidx - 1] = rotated_layer[idx]
            idx += 1
        for j in range(col + size - lidx - 1, col + lidx - 1, -1):
            pl[row + size - lidx - 1][j] = rotated_layer[idx]
            idx += 1
        for i in range(row + size - lidx - 2, row + lidx, -1):
            pl[i][col + lidx] = rotated_layer[idx]
            idx += 1

def MAX_ROTATION(n, pl, queries):
    for row, col, size in queries:
        aq(pl, row, col, size)
    result = ''.join(''.join(row) for row in pl)
    return result


n = int(input())
pl = [list(input().strip().split()) for _ in range(n)]
q = int(input().strip())
queries = [tuple(map(int, input().strip().split())) for _ in range(q)]

result = MAX_ROTATION(n, pl, queries)
print(result, end="")
Maximum Rotation - Codevita ✅
30 лист 2024, 00:51

Plague 2050 
PYTHON


from collections import deque

def infected_neighbors_count(grid, a, b):
    n = len(grid)
    count = 0
    directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]
    for i in range(len(directions)):
        dx, dy = directions[i]
        nx, ny = a + dx, b + dy
        if 0 <= nx < n and 0 <= ny < n and grid[nx][ny] == 1:
            count += 1
    return count

def infection_process(grid):
    n = len(grid)
    new_grid = [[grid[i][j] for j in range(n)] for i in range(n)]
    
    for i in range(n):
        for j in range(n):
            neighbors = infected_neighbors_count(grid, i, j)
            if grid[i][j] == 0 and neighbors == 3:
                new_grid[i][j] = 1
            elif grid[i][j] == 1 and (neighbors < 2 or neighbors > 3):
                new_grid[i][j] = 0
                
    return new_grid

def find_path(size, initial_grid):
    grid = [[1 if cell == '1' else 0 for cell in row] for row in initial_grid]
    start_x, start_y, end_x, end_y = -1, -1, -1, -1
    
    def set_positions():
        nonlocal start_x, start_y, end_x, end_y
        for i in range(size):
            for j in range(size):
                if initial_grid[i][j] == 's':
                    start_x, start_y = i, j
                    grid[i][j] = 0
                if initial_grid[i][j] == 'd':
                    end_x, end_y = i, j
                    grid[i][j] = 0
    
    set_positions()
    
    queue = deque([(start_x, start_y, grid, 0)])
    seen_states = set()
    
    while queue:
        x, y, current_grid, days = queue.popleft()
        
        if (x, y) == (end_x, end_y):
            return days
        
        state = (x, y, tuple(map(tuple, current_grid)))
        if state in seen_states:
            continue
        seen_states.add(state)
        
        next_grid = infection_process(current_grid)
        
        moves = [(0, 0), (-1, 0), (1, 0), (0, -1), (0, 1)]
        for dx, dy in moves:
            nx, ny = x + dx, y + dy
            if 0 <= nx < size and 0 <= ny < size and next_grid[nx][ny] == 0:
                queue.append((nx, ny, next_grid, days + 1))
    
    return -1

if name == "__main__":
    n = int(input())
    pollution_map = [input().strip() for _ in range(n)]
    print(find_path(n, pollution_map) + 1)


Plague 2050 - Codevita ✅
30 лист 2024, 00:49

Ми використовуємо файли cookie для покращення вашого досвіду перегляду.
Натиснувши «Прийняти все», ви погоджуєтеся на політику використання файлів cookie.