Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const getGets = (arr) => {
  2.   let index = 0;
  3.  
  4.   return () => {
  5.     const toReturn = arr[index];
  6.     index += 1;
  7.     return toReturn;
  8.   };
  9. };
  10.  
  11. // This is the place where you must place your test data
  12. const test = [
  13.   '5 2 1 1 6 3'
  14. ];
  15.  
  16. const gets = this.gets || getGets(test);
  17. const print = this.print || console.log;
  18.  
  19. let n = gets();
  20. let sumEven = 0;
  21. let sumOdd = 0;
  22. let split_Test = n.split(' ');
  23.  
  24. for (i = 1; i <= split_Test.length; i++) {
  25. if (i % 2 === 0) {
  26. let number = split_Test[i];
  27. sumEven = sumEven + number;
  28. }
  29. if (i % 2 === 1) {
  30. let number = split_Test[i];
  31. sumOdd = sumOdd + number;
  32. }
  33. }
  34. if (sumEven === sumOdd) {
  35. print(`yes ${sumOdd}`);
  36. }
  37. if (sumEven != sumOdd) {
  38. print(`no ${sumOdd} ${sumEven}`)
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement