hnOsmium0001

bad balancer code js

Dec 11th, 2019
189
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const out = document.getElementById('out');
  2.  
  3. const arr = [1, 4, 2, 5];
  4. function sovle(arr) {
  5. const sum = arr.reduce((v, i) => v + i);
  6. precondition:
  7. if(sum % 2 === 1) {
  8. if(arr % 2 === 0) {
  9. return null;
  10. }
  11. for(let i = 0; i < arr.length; ++i) {
  12. if(arr[i] % 2 === 1) {
  13. arr.splice(i, 1);
  14. break precondition;
  15. }
  16. }
  17. return null;
  18. }
  19.  
  20. const halfSum = sum / 2;
  21. const left = [];
  22. const right = [];
  23. for(let i = 0; i < arr.length; ++i) {
  24. for(let j = 0; j < arr.length; ++j) {
  25. if(i === j) {
  26. continue;
  27. }
  28.  
  29.  
  30. }
  31. }
  32. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×