xxxxxxxxxx
function plusMinus(num) {
let a = num.toString().split('').map(int => parseInt(int))
if (a.length < 2) {
return "not possible"
}
return recursiveFunc(a.slice(1), a[0])
function recursiveFunc(updatedArray, updatedSum) {
if (updatedArray.length == 1) {
if (updatedSum + updatedArray[0] === 0) {
return 'plus'
} else if (updatedSum - updatedArray[0] === 0) {
return 'minus'
} else {
return 'not possible'
}
}
let string2 = recursiveFunc(updatedArray.slice(1), updatedSum - updatedArray[0])
if (string2 != 'not possible') {
return '-' + string2
}
let string1 = recursiveFunc(updatedArray.slice(1), updatedSum + updatedArray[0])
if (string1 != 'not possible') {
return '+' + string1
}
return 'not possible'
}
}
xxxxxxxxxx
public static void Selectdatefromcalendar() throws InterruptedException {
WebElement DateBox=driver.findElement(By.xpath("//input[@formcontrolname='categoryDateRange']"));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].value='01Sep2021-30Sep2021';", DateBox);
}
xxxxxxxxxx
public static void Selectdatefromcalendar() throws InterruptedException {
WebElement DateBox=driver.findElement(By.xpath("//input[@formcontrolname='categoryDateRange']"));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].value='01Sep2021-30Sep2021';", DateBox);
xxxxxxxxxx
function StringChallenge(str) {
let newString = str.slice(0)
let dictionary = [
['zero', '0'],
['zero', '1'],
['zero', '2'],
['zero', '3'],
['zero', '4'],
['zero', '5'],
['zero', '6'],
['zero', '7'],
['zero', '8'],
['zero', '9'],
['zero', '-'],
['zero', '+']
]
dictionary.forEach(val => {
let regEx = new RegEx (val[0], 'g');
newString = newString.replace(regEx, val[1]);
});
let resString = eval(newString).toString();
dictionary.slice(0,10).forEach(val => {
let regEx = new RegEx (val[1], 'g');
newString = newString.replace(regEx, val[0]);
});
// code goes here
return resString.replace('-', 'minus');
}
xxxxxxxxxx
function plusMinus(num) {
let a = num.toString().split('').map(int => parseInt(int))
if (a.length < 2) {
return "not possible"
}
return recursiveFunc(a.slice(1), a[0])
function recursiveFunc(updatedArray, updatedSum) {
if (updatedArray.length == 1) {
if (updatedSum + updatedArray[0] === 0) {
return 'plus'
} else if (updatedSum - updatedArray[0] === 0) {
return 'minus'
} else {
return 'not possible'
}
}
let string2 = recursiveFunc(updatedArray.slice(1), updatedSum - updatedArray[0])
if (string2 != 'not possible') {
return '-' + string2
}
let string1 = recursiveFunc(updatedArray.slice(1), updatedSum + updatedArray[0])
if (string1 != 'not possible') {
return '+' + string1
}
return 'not possible'
}
}
xxxxxxxxxx
function plusMinus(num) {
let a = num.toString().split('').map(int => parseInt(int))
if (a.length < 2) {
return "not possible"
}
return recursiveFunc(a.slice(1), a[0])
function recursiveFunc(updatedArray, updatedSum) {
if (updatedArray.length == 1) {
if (updatedSum + updatedArray[0] === 0) {
return 'plus'
} else if (updatedSum - updatedArray[0] === 0) {
return 'minus'
} else {
return 'not possible'
}
}
let string2 = recursiveFunc(updatedArray.slice(1), updatedSum - updatedArray[0])
if (string2 != 'not possible') {
return '-' + string2
}
let string1 = recursiveFunc(updatedArray.slice(1), updatedSum + updatedArray[0])
if (string1 != 'not possible') {
return '+' + string1
}
return 'not possible'
}
}
xxxxxxxxxx
var seats=[];
for(var i=0;i<array.length;i++)
seats.push(Array(array[i][0]).fill().map(()=>Array(array[i][1]).fill("M")));
for(var i=0;i<seats.length;i++){
for(var j=0;j<seats[i].length;j++){
seats[i][j][0]="A";
seats[i][j][seats[i][j].length-1]="A";
}
}
for(var i=0;i<seats[0].length;i++)
seats[0][i][0]="W";
for(var i=0;i<seats[seats.length-1].length;i++)
seats[seats.length-1][i][(seats[seats.length-1][i].length)-1]="W";
return seats;
xxxxxxxxxx
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
xxxxxxxxxx
let wineNumber = gets();
let wineTesters = gets().split(' ');
let correctAnswers = 0;
let correctAnswersList = wineTesters.filter(correctAnswers => correctAnswers.includes(wineNumber));
correctAnswers = correctAnswersList.length;
console.log(correctAnswers);
xxxxxxxxxx
function numberSearch(str) {
var separatedString = str.split(”);
var letters = [];
var numbers = [];
var sum = 0;
for (var i=0; i<str.length; i++) {
var currentItem = separatedString[i];
if (isNaN(parseInt(currentItem))) {
letters.push(currentItem);
} else {
numbers.push(currentItem);
};
};
for (var i=0; i<numbers.length; i++) {
currentNumber = Number(numbers[i]);
sum = sum + currentNumber;
};
return (Math.round(sum/letters.length));
};