This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
An email address such as "John.Smith@example.com" is made up of a local part ("John.Smith"), an "@" symbol, then a domain part ("example.com"). | |
The domain name part of an email address may only consist of letters, digits, hyphens and dots. The local part, however, also allows a lot of different special characters. Here you can look at several examples of correct and incorrect email addresses. | |
Given a valid email address, find its domain part. | |
Example | |
For address = "prettyandsimple@example.com", the output should be |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Caring for a plant can be hard work, but since you tend to it regularly, you have a plant that grows consistently. Each day, its height increases by a fixed amount represented by the integer upSpeed. But due to lack of sunlight, the plant decreases in height every night, by an amount represented by downSpeed. | |
Since you grew the plant from a seed, it started at height 0 initially. Given an integer desiredHeight, your task is to find how many days it'll take for the plant to reach this height. | |
Example | |
For upSpeed = 100, downSpeed = 10, and desiredHeight = 910, the output should be | |
growingPlant(upSpeed, downSpeed, desiredHeight) = 10. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Given a string, find the number of different characters in it. | |
Example | |
For s = "cabca", the output should be | |
differentSymbolsNaive(s) = 3. | |
There are 3 different characters a, b and c. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Find the leftmost digit that occurs in a given string. | |
Example | |
For inputString = "var_1__Int", the output should be | |
firstDigit(inputString) = '1'; | |
For inputString = "q2q-q", the output should be | |
firstDigit(inputString) = '2'; | |
For inputString = "0ss", the output should be |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Consider integer numbers from 0 to n - 1 written down along the circle in such a way that the distance between any two neighboring numbers is equal (note that 0 and n - 1 are neighboring, too). | |
Given n and firstNumber, find the number which is written in the radially opposite position to firstNumber. | |
Example | |
For n = 10 and firstNumber = 2, the output should be | |
circleOfNumbers(n, firstNumber) = 7. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Given a string, your task is to replace each of its characters by the next one in the English alphabet; i.e. replace a with b, replace b with c, etc (z would be replaced by a). | |
Example | |
For inputString = "crazy", the output should be alphabeticShift(inputString) = "dsbaz". | |
*/ | |
function alphabeticShift(inputString) { | |
let newStr = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Check if all digits of the given integer are even. | |
Example | |
For n = 248622, the output should be | |
evenDigitsOnly(n) = true; | |
For n = 642386, the output should be | |
evenDigitsOnly(n) = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Check if all digits of the given integer are even. | |
Example | |
For n = 248622, the output should be | |
evenDigitsOnly(n) = true; | |
For n = 642386, the output should be | |
evenDigitsOnly(n) = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Given an array of integers, replace all the occurrences of elemToReplace with substitutionElem. | |
Example | |
For inputArray = [1, 2, 1], elemToReplace = 1, and substitutionElem = 3, the output should be | |
arrayReplace(inputArray, elemToReplace, substitutionElem) = [3, 2, 3]. | |
*/ | |
function arrayReplace(inputArray, elemToReplace, substitutionElem) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Given an array of integers, find the maximal absolute difference between any two of its adjacent elements. | |
Example | |
For inputArray = [2, 4, 1, 0], the output should be | |
arrayMaximalAdjacentDifference(inputArray) = 3. | |
*/ | |
function arrayMaximalAdjacentDifference(inputArray) { |