AmitDiwan has Published 10744 Articles

Counting specific digits used in squares of numbers using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:06:36

359 Views

ProblemWe are required to write a JavaScript function that takes in an integer n (n >= 0) and a digit d (0

Expanding binomial expression using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:06:16

337 Views

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

Obtaining maximum number via rotating digits in JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:05:55

103 Views

ProblemWe are required to write a JavaScript function that takes in a positive integer n and returns the maximum number we got doing only left rotations to the digits of the number.ExampleFollowing is the code − Live Democonst num = 56789; const findMaximum = (num = 1) => {    let ... Read More

Sum of perimeter of all the squares in a rectangle using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:05:35

315 Views

Problem Suppose there are 5 squares embedded inside a rectangle like this −Their perimeter will be −4 + 4 + 8 + 12 + 20 = 48 unitsWe are required to write a JavaScript function that takes in a number n and return the sum of the perimeter if there ... Read More

Moving every alphabet forward by 10 places in JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:05:17

239 Views

ProblemWe are required to write a JavaScript function that takes in a string of English alphabets. Our function should push every alphabet forward by 10 places. And if it goes past 'z', we should start again at 'a'.ExampleFollowing is the code − Live Democonst str = 'sample string'; const moveStrBy = ... Read More

Extract digits from Tuple list Python

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:04:43

670 Views

When it is required to extract digits from a list of tuple, list comprehension can be used.Below is the demonstration of the same −Example Live Demomy_list = [(67, 2), (34, 65), (212, 23), (17, 67), (18, )] print("The list is : ") print(my_list) N = 2 print("The value of ... Read More

Join Tuples if similar initial element in Python

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:04:17

515 Views

When it is required to join tuples if they contain a similar initial element, a simple ‘for’ loop and an ‘of’ condition can be used. To store elements to one list, the ‘extend’ method can be used.Below is the demonstration of the same −Example Live Demomy_list = [(43, 15), (66, 98), ... Read More

Transforming array of numbers to array of alphabets using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 13:00:00

273 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers. Our function should return a string made of four parts −a four character 'word', made up of the characters derived from the first two and last two numbers in the array. order should be as ... Read More

Moving vowels and consonants using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 12:58:15

261 Views

ProblemWe are required to write a JavaScript function that takes in a string of English alphabets. Our function should construct a new string and every consonant should be pushed forward 9 places through the alphabet. If they pass 'z', start again at 'a'. And every vowel should be pushed by ... Read More

Encrypting censored words using JavaScript

AmitDiwan

AmitDiwan

Updated on 17-Apr-2021 12:57:55

282 Views

ProblemWe are required to write a JavaScript function that takes in a string. Our function should convert the string according to following rules −The words should be Caps, Every word should end with '!!!!', Any letter 'a' or 'A' should become '@', Any other vowel should become '*'.ExampleFollowing is the ... Read More

Advertisements