Checking for vowels in array of numbers using JavaScript

AmitDiwan
Published on 17-Apr-2021 16:42:54
ProblemWe are required to write a JavaScript function that takes in takes in an array of numbers. If in that array there exists any number which is the char code any vowel in ascii we should switch that number to the corresponding vowel and return the new array.ExampleFollowing is the ... Read More

Sorting string alphabetically and inserting underscores using JavaScript

AmitDiwan
Published on 17-Apr-2021 16:42:12
ProblemWe are required to write a JavaScript function that takes in an array of strings.Our function should return the first string of the array after sorting it alphabetically and each character of that string should be separated by ‘***’.ExampleFollowing is the code − Live Democonst arr = ['this', 'is', 'some', 'string', ... Read More

Finding the date at which money deposited equals a specific amount in JavaScript

AmitDiwan
Published on 17-Apr-2021 16:41:09
ProblemWe have an amount of money amt > 0 and we deposit it with an interest rate of p percent divided by 360 per day on the 1st of January 2021. We want to have an amount total >= a0.Our function should take these three parameters and return the date ... Read More

Finding path to the end of maze using JavaScript

AmitDiwan
Published on 17-Apr-2021 16:40:12
ProblemWe are required to write a JavaScript function that takes in a matrix of N * N order. The walls in the matrix are marked by ‘W’ and empty positions are marked by ‘_’We can move in any of the four directions at any point. Our function should return true ... Read More

Finding length, width and height of the sheet required to cover some area using JavaScript

AmitDiwan
Published on 17-Apr-2021 16:39:00
ProblemWe are required to write a JavaScript function that takes in the length, height and width of a room.Our function should calculate the number of sheets required to cover the whole room given that the width of one single sheet is .52 units and length is 10 units.For the sake ... Read More

Python program to Order Tuples using external List

AmitDiwan
Published on 17-Apr-2021 16:36:03
When it is required to order the tuples using an external list, the list comprehension, and ‘dict’ method can be used.Below is the demonstration of the same −Example Live Demomy_list = [('Mark', 34), ('Will', 91), ('Rob', 23)] print("The list of tuple is : ") print(my_list) ordered_list = ['Will', 'Mark', ... Read More

Counting specific digits used in squares of numbers using JavaScript

AmitDiwan
Published on 17-Apr-2021 16:35:37
ProblemWe are required to write a JavaScript function that takes in an integer n (n >= 0) and a digit d (0 <= d <= 9)Our function should square all numbers k (0 <= k <= n) between 0 and n and count the numbers of digits d used in ... Read More

Remove Tuples of Length K in Python

AmitDiwan
Published on 17-Apr-2021 16:34:58
When it is required to remove the tuples of a specific length ‘K’, list comprehension can be used.Below is the demonstration of the same −Example Live Demomy_list = [(32, 51), (22, 13 ), (94, 65, 77), (70, ), (80, 61, 13, 17)] print("The list is : " ) print(my_list) ... Read More

Expanding binomial expression using JavaScript

AmitDiwan
Published on 17-Apr-2021 16:34:40
ProblemWe are required to write a JavaScript function that takes in an expression in the form (ax+b)^n where a and b are integers which may be positive or negative, x is any single character variable, and n is a natural number. If a = 1, no coefficient will be placed ... Read More

All pair combinations of 2 tuples in Python

AmitDiwan
Published on 17-Apr-2021 16:34:26
When it is required to find all the pair combinations between two tuples, the list comprehension can be used.Below is the demonstration of the same −Example Live Demofrom itertools import product N = 2 print("The value of N has been initialized to ") print(N) my_result = [ele for ele in product(range(1, ... Read More
Advertisements