Socks Draws.
PrepBuddy is getting late for college. She is looking for a matching pair of socks from a drawer full of socks. In the worst-case scenario, how many socks should PrepBuddy remove from her drawer until she finds a matching pair.
Input Format:
Write a program to make a simple calculator using switch statement that takes operator and two numbers from user and print the result after operation.
Square Fit.
PrepBuddy provided you with a rectangular board of m*n
dimension. Also, he provided an unlimited number of small blocks of 2*1
size. You are allowed to rotate the block. You are asked to place as many blocks as
possible on the board to meet the following conditions:
- Each block completely covers two squares.
- No two blocks overlap.
- Each block lies entirely inside the board. It is allowed to touch the edges of the board.
Find the maximum number of blocks, which can be placed under these restrictions.
m*n
dimension. Also, he provided an unlimited number of small blocks of 2*1
size. You are allowed to rotate the block. You are asked to place as many blocks as
possible on the board to meet the following conditions:
const squareFit = (m,n) => {
if((m%2 === 0)||(n%2 === 0)){
var a = (m*n)/2;
}
else{
a= ((m*n)-1)/2;
}
return a
};
Age Calculation.
You are given two integers F , S
, indicating the age of the father and his son. You have to calculate how many years ago the father was twice as old as his son, or in how many years he will be twice as old.
F , S
, indicating the age of the father and his son. You have to calculate how many years ago the father was twice as old as his son, or in how many years he will be twice as old.const ageCalculation = (f,s) => {
let x = f - 2*s;
return (Math.abs(x));
};
Atom Combine.
Atoms combine to form molecules. The base amount of atom = 1 at sec = 1 that is combined into the molecule, and for every second that passes, their base amount doubles. So at sec = 2, there are 2 atoms and now a total of
3 (previous 1 + 2(new)) atoms are present in the molecule. At sec = 3, there are 4 atoms, and now the total is 7 (previous 3 + 4(new)) atoms present in the molecule. Return how many atoms are present in the molecule at a certain second.
Input Format:
You are given a function atomCombine()
, containing an argument denoting the second at which the total count is required.
atomCombine()
, containing an argument denoting the second at which the total count is required.
Discount Value.
Given two values price
and discount
percentage as integers, return the price after the discount.
Input Format:
You are given a function dicountValue()
containing two arguments p
and d
, denoting the price and discount.
price
and discount
percentage as integers, return the price after the discount.dicountValue()
containing two arguments p
and d
, denoting the price and discount.
Range Victory.
Arnab is fighting some enemies. The enemies' power level is a distinct natural number in a range of l
to r
(both inclusive). Arnab can defeat the enemies if he can find the largest number which divides every
number in the given range. Help Arnab find the answer.
Note: Complete the LargestNumber
function. No need to take any input.
l
to r
(both inclusive). Arnab can defeat the enemies if he can find the largest number which divides every
number in the given range. Help Arnab find the answer.
LargestNumber
function. No need to take any input.
Divisibility Test.
You are given a number n
and you are asked to make n
divisible by 10. The only operation you can do on n
is to multiply n
by 2. Given
n
find out how many operations are required to make n
divisible by 10.
Note: Complete the DivTest
function. No need to take any input.
n
and you are asked to make n
divisible by 10. The only operation you can do on n
is to multiply n
by 2. Given
n
find out how many operations are required to make n
divisible by 10.
DivTest
function. No need to take any input.
Building up Ten.
Rohit is one of the brillant student of the school and participated in coding competition on the behalf of his school.Although he was able to solve all the questions but got stuck in one of the question in which he was provided with two integers
A
and B
and have to return true if one of them is 10 or their sum is 10.Rohit wants your help in solving out this question for securing a good rank in competition.
Note: Complete the BuildTen
function. No need to take any input.
A
and B
and have to return true if one of them is 10 or their sum is 10.Rohit wants your help in solving out this question for securing a good rank in competition.
BuildTen
function. No need to take any input.
Play with Boolean.
Recently Gourav learned boolean values and showed off in front of his friends. So one of his friends gave him a task in which he has to return the opposite of the given boolean as a number. Rohit wants your help with solution so that he will not feel insulted in front of
his friends.
Note: Complete the ChangeBool
function. No need to take any input.
ChangeBool
function. No need to take any input.
Checking Range.
Abhishek recently learned about the concepts of ranges and to test his ability he tried to solve the unique problem in which he has a number A
and he wants to check whether A
is within the bounds of
B
and C
. It's also mentioned that if N
isn't an integer return false. so being a friend of Abhishek he wants your help.
Note: Complete the CheckRange
function. No need to take any input.
A
and he wants to check whether A
is within the bounds of
B
and C
. It's also mentioned that if N
isn't an integer return false. so being a friend of Abhishek he wants your help.
CheckRange
function. No need to take any input.
Pattern Puzzle 1.
Given N
, you have to print the spanning N
rows with symbol X
.
Note: Complete the CompletePattern
function. No need to take any input.
N
, you have to print the spanning N
rows with symbol X
.CompletePattern
function. No need to take any input.const CompletePattern = (N) => {
for(let i = 1; i <= N; i++){
let s = " ";
for(let j = 1; j <= i; j++){
s = s + "X";
}
console.log(s)
}
};
XX
XXX
XXXX
XXXXX
Pattern Puzzle 2.
Given N
, you have to print the spanning N
rows in following patterns provided in inputs.
Note: Complete the CompletePattern
function. No need to take any input.
N
, you have to print the spanning N
rows in following patterns provided in inputs.CompletePattern
function. No need to take any input.const CompletePattern = (N) => {
for(let r = 1; r <= N; r++){
let s = "";
for(let c = 1; c <= r; c++){
s = s + c + " ";
}
console.log(s)
}
};
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Pattern Puzzle 3.
Given N
, you have to print the spanning N
rows in following patterns provided in inputs.
Note: Complete the CompletePattern
function. No need to take any input.
N
, you have to print the spanning N
rows in following patterns provided in inputs.CompletePattern
function. No need to take any input.const CompletePattern = (N) => {
for(let r = 1; r <= N; r++){
let s = " ";
for(let c = 1; c <= r; c++){
s = s + r + " ";
}
console.log(s);
}
};
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Pattern Puzzle 4.
Given N
, you have to print the spanning N
rows in following patterns provided in inputs.
Note: Complete the CompletePattern
function. No need to take any input.
N
, you have to print the spanning N
rows in following patterns provided in inputs.CompletePattern
function. No need to take any input.
###2 1
##3 2 1
#4 3 2 1
5 4 3 2 1
Pattern Puzzle 5.
Given N
, you have to print the spanning N
rows in following patterns provided in inputs.
Note: Complete the CompletePattern
function. No need to take any input.
N
, you have to print the spanning N
rows in following patterns provided in inputs.CompletePattern
function. No need to take any input.
0 1
1 0 1
0 1 0 1
1 0 1 0 1
Pattern Puzzle 6.
Given N
, you have to print the spanning N
rows in following patterns provided in inputs.
Note: Complete the CompletePattern
function. No need to take any input.
N
, you have to print the spanning N
rows in following patterns provided in inputs.CompletePattern
function. No need to take any input.
A B
A B C
A B C D
A B C D E
Pattern Puzzle 7.
Given N
, you have to print the spanning N
rows with symbol X
.
Note: Complete the CompletePattern
function. No need to take any input.
N
, you have to print the spanning N
rows with symbol X
.CompletePattern
function. No need to take any input.
# # # X X
# # X X X
# X X X X
X X X X X
Shaped Puzzle.
Given N
, you have to print the spanning N
rows in following patterns provided in inputs.
Note: Complete the CompletePattern
function. No need to take any input.
N
, you have to print the spanning N
rows in following patterns provided in inputs.CompletePattern
function. No need to take any input.
0 1
0 1 0
1 0 1 0
1 0 1 0 1
Shaped Puzzle 2.
Given N
, you have to print the spanning N
rows in following patterns provided in inputs.
Note: Complete the CompletePattern
function. No need to take any input.
N
, you have to print the spanning N
rows in following patterns provided in inputs.CompletePattern
function. No need to take any input.
1 2 3 4
1 2 3
1 2
1
Shaped Puzzle 3.
Given N
, you have to print the spanning N
rows in following patterns provided in inputs.
Note: Complete the CompletePattern
function. No need to take any input.
N
, you have to print the spanning N
rows in following patterns provided in inputs.CompletePattern
function. No need to take any input.
? ? X X X ? ?
? X X X X X ?
X X X X X X X
Divisibility Test.
You are given a number n
and you are asked to make n
divisible by 10. The only operation you can do on n
is to multiply n
by 2. Given
n
find out how many operations are required to make n
divisible by 10.
Note: Complete the DivTest
function. No need to take any input.
n
and you are asked to make n
divisible by 10. The only operation you can do on n
is to multiply n
by 2. Given
n
find out how many operations are required to make n
divisible by 10.
DivTest
function. No need to take any input.
Divisibility Test.
You are given a number n
and you are asked to make n
divisible by 10. The only operation you can do on n
is to multiply n
by 2. Given
n
find out how many operations are required to make n
divisible by 10.
Note: Complete the DivTest
function. No need to take any input.
n
and you are asked to make n
divisible by 10. The only operation you can do on n
is to multiply n
by 2. Given
n
find out how many operations are required to make n
divisible by 10.
DivTest
function. No need to take any input.