IBM Coding Exam Answers
2.45K subscribers
13 photos
70 links
Download Telegram
def max_points(chocolates,initial):
  chocolates=sorted(chocolates)
  points=1
  l=[1]
  i=0
  while i < len(chocolates):
    if chocolates[i]<=initial:
      initial=initial-chocolates[i]
      points+=1
      i+=1
    else:
      points-=1
      initial+=chocolates[-1]
      chocolates.pop()
    l.append(points)
  return max(l)
# Example usage:
chocolates_list = list(map(int, input().split()))  # Input list of chocolates
initial_chocolates = int(input())  # Initial chocolates Bittu has
result = max_points(chocolates_list, initial_chocolates)
print(result,end="")


Chocolate Code

Pls share

https://t.me/TCS_Codevita_Exam_Help
JOIN FAST.... Only after that i will share more codes
This media is not supported in your browser
VIEW IN TELEGRAM
Make it 75.. and i will upload No More Symbol Code
def pfix(exq):
ta = []
ops = set(['+', '-', '*', '/', '%', '^'])


to = exq.split()


for t1 in reversed(to):
if t1.isdigit():

ta.append(int(t1))
elif t1 in ops:

if t1 == '^':

if len(ta) < 2:
return "expression is not complete or invalid"
ex1 = ta.pop()
be = ta.pop()
ta.append(ex1**be)
elif t1 == '/':

if len(ta) < 2 or ta[-1] == 0:
return "expression is not complete or invalid"
op2 = ta.pop()
op1 = ta.pop()
ta.append(op1 // op2)
elif t1 == '%':

if len(ta) < 2 or ta[-1] == 0:
return "expression is not complete or invalid"
op2 = ta.pop()
op1 = ta.pop()
ta.append(op2 % op1)
else:

if len(ta) < 2:
return "expression is not complete or invalid"
op1 = ta.pop()
op2 = ta.pop()

if t1 == '+':
ta.append(op1 + op2)
elif t1 == '-':
ta.append(op1 - op2)
elif t1 == '*':
ta.append(op1 * op2)
else:
return "expression is not complete or invalid"


if len(ta) == 1:
return ta[0]
else:
return "expression is not complete or invalid"

dn2 = {
"one":1,
"two":2,
"three":3,
"four":4,
"five":5,
"six":6,
"seven":7,
"eight":8,
"nine":9,
"zero":0
}

do1 = {
"add":'+',
"sub":'-',
"mul":'*',
"rem":'%',
"pow":'^'
}

def conv(s):
a1= s.split('c')
nx= 0
for i in a1:
if i in dn2:
nx = nx*10 + dn2[i]
else:
return "-1"
return str(nx)

s= input()
lee = s.split()
st = ""
flag = False
for i in lee:
if i not in do1:
jik = conv(i)
if jik=="-1":
flag = True
print("expression evaluation stopped invalid words present",end='')
break
st = st + jik + ' '
else:
st = st + do1[i] + ' '
if flag != True:
print(pfix(st),end='')

No more symbols Code

Pls share

https://t.me/TCS_Codevita_Exam_Help
This media is not supported in your browser
VIEW IN TELEGRAM
MAKE 100 SUBSCRIBERS.. THEN I CAN SHARE MORE CODE
This media is not supported in your browser
VIEW IN TELEGRAM
#include<bits/stdc++.h>
using namespace std;

void mark(int xa, int ya, int ha, vector<vector<int>> &matrix, vector<vector<int>> &visited) {
int rows = matrix.size(), cols = matrix[0].size();
visited[xa][ya] = 1;
int delta[5] = {-1, 0, +1, 0, -1};
for(int i = 0; i < 4; i++) {
int ax = xa + delta[i];
int ay = ya + delta[i+1];
if(min(ax, ay) >= 0 && ax < rows && ay < cols && matrix[ax][ay] <= ha && !visited[ax][ay]) {
mark(ax, ay, ha, matrix, visited);
}
}
}

void go2(int x, int y, int cell, vector<vector<int>> &matrix, vector<vector<int>> &visited) {
int rows = matrix.size(), cols = matrix[0].size();
int delta[5] = {-1, 0, +1, 0, -1};
visited[x][y] = 0;
for(int i = 0; i < 4; i++) {
int nx = x + delta[i];
int ny = y + delta[i+1];
if(min(nx, ny) >= 0 && nx < rows && ny < cols && matrix[nx][ny] == cell && visited[nx][ny]) {
go2(nx, ny, cell, matrix, visited);
}
}
}

int main() {
int rows, cols;
cin >> rows >> cols;
vector<vector<int>> matrix(rows, vector<int>(cols)), visited(rows, vector<int>(cols, 0));
for(int i = 0; i < rows; i++)
for(int j = 0; j < cols; j++)
cin >> matrix[i][j];

int x, y, h;
cin >> x >> y >> h;

if(matrix[x][y] == 0) mark(x, y, h, matrix, visited);

int count = 0;
for(int i = 0; i < rows; i++) {
for(int j = 0; j < cols; j++) {
if(visited[i][j]) {
count += matrix[i][j] != 0;
go2(i, j, matrix[i][j], matrix, visited);
}
}
}

if (count == 0) cout << "NONE";
else cout << count;

return 0;
}

BlackBeard Code

Pls share

https://t.me/TCS_Codevita_Exam_Help
This media is not supported in your browser
VIEW IN TELEGRAM
SUBSCRIBE FAST... I AM ALREADY UPLOADING ALOT OF CODE
This media is not supported in your browser
VIEW IN TELEGRAM
100 SUBS DONE.. which new code you want?
Decide fast