Person Details
given an object person containing a person details, write a JS program to log the name, address and nicknames count.
input1
output2
input1
{ 'name':'Pranay', 'address':{'city':'Mumbai','state':'maharastra'}, 'nicknames':['nani','chanti']}
output2
pranay is from mumbai,maharastra
pranay has 2 nicknames
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
//////
/////
/////
function main() {
let person = JSON.parse(readLine().replace(/'/g, '"'));
/* Please do not modify anything above this line */
/* Write your code here and log the output */
}
Magical Indices
Given an array of integers and a number
Write a JS program to determine the number of valid indices.
For example, an array A = [10, 20, 30] and a value x = 25.
We have values 10, 20, 30 at indices 0,1,2 respectively.
So there are 2 valid indices.
Sample Input 1
[1, 2, 3, 5, 7]
13
Sample Output 1
3
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
/////
////
function main() {
let integers = JSON.parse(readLine());
let value = JSON.parse(readLine());
/* Write your code here and log the output */
}
Product of array Items
given an array integers, write JS program to get the product of the integers in the given array.
input
the input will be containing single line integers.
output
the output should be single line containing the product as shown in sample outputs.
input1
[1,2,3]
output1
[1 * 2 * 3 = 6]
input2
[-1, -2, -3]
output2
[-1*-2*-3 = -6]
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString
.trim()
.split("\n")
.map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
let integers = JSON.parse(readLine());
/* Please do not modify anything above this line */
/* Write your code here and log the output */
}
create a program that will ask the user to give a number for the divided and the divisor and then program will compute and display the quotient and its remainder on the screen
// quotient.cpp
// Author: Mr jake R. pomperada, BSCS, MAED- IT
// Date: august 14, 2018 Tuesday
// Location: Bacolod City, Negros occidental
// Website: http://www.jakerpompereda.com
squares of Array items
input
output
input1
[[1,2],[3,4],[5,6]]
output1
[ [ 1,4],[9,16],[25,36]]
input2
[12,[24],36,[48,60]]
output2
[144,[576],1296,[2304,3600]]
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString
.trim()
.split("\n")
.map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
let myArray = JSON.parse(readLine())
/* Write your code here and log the output */
}
Find the First Value
Given an array myArray of positive integers, write a JS program to find the smallest integer divisible by 2 and 3.
input
the input will be a single line containing an myArray
output
the output should be a single line containing a number divisible by 2 and 3 or undefined.
input1
[51,18,15,12]
output1
12
input2
[41,29,17,19,31]
output2
undefined
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString
.trim()
.split("\n")
.map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
let myArray = JSON.parse(readLine());
/* Write your code here and log the output */
}
Given a string of numbers S, the task is to find the maximum value from the string S, you can add a ‘+’ or ‘*’ sign between any two numbers.
For example, S=891. As 8*9*1 = 72 and 8*9+1 = 73. So, 73 is maximum.
Write a python module MaxValue.py for solve the above task. You need to import this module in your file which takes a string and return maximum value or error message as shown in example by calling the appropriate function implemented in MaxValue.py module. Also handle the possible exceptions and display the exception message in form of string.
Example-1
Input:
01231
Output:
10
example 2
Input:
891
Output:
73
example 3
Input:
0000
Output:
example 4
Input:
45f
Output:
Invalid Number
Write a program to print the area and parimeter of a triangle having side of 3,4 and 5 unit by creating a class named 'triangle' with the constructor having the three sides as it's parameters.
create a program that will ask the user to give a number for the divided and the divisor and then program will compute and display the quotient and its remainder on the screen
// quotient.cpp
// Author: Mr jake R. pomperada, BSCS, MAED- IT
// Date: august 14, 2018 Tuesday
// Location: Bacolod City, Negros occidental
// Website: http://www.jakerpompereda.com
create a program that will ask the user to give a number for the divided and the divisor and then program will compute and display the quotient and its remainder on the screen
// quotient.cpp
// Author: Mr jake R. pomperada, BSCS, MAED- IT
// Date: august 14, 2018 Tuesday
// Location: Bacolod City, Negros occidental
// Website: http://www.jakerpompereda.com