Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let input = [
- '5',
- '4',
- '3',
- '2',
- '5',
- '2'
- ];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- let n = +gets();
- const oddLines = [];
- const evenLines = [];
- for(i = 1; i <= n; i++){
- if(i % 2 === 0){
- evenLines.push(+gets());
- }else{
- oddLines.push(+gets());
- }
- }
- console.log(evenLines, oddLines)
- function product(array){
- let total = 1;
- for(let i = 0; i <= array.lenght; i++){
- if(isNaN(array[i])){
- continue;
- }else{
- total *= Number(array[i]);
- }
- }
- return total;
- }
- let productOfEven = product(evenLines);
- let productOfOdds = product(oddLines);
- console.log(productOfEven,productOfOdds)
- if(productOfEven === productOfOdds){
- print(`yes ${productOfEven}`)
- }else{
- print(`no ${productOfOdds} ${productOfEven}`)
- }
Advertisement
Add Comment
Please, Sign In to add comment