Ledger Nano X - The secure hardware wallet
SHARE
TWEET

WinningTicket 100/100 Fixed

AreWe Apr 6th, 2020 (edited) 135 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. winningTicket = ([input]) => {
  2.     let patternRepeat = /([@#\$\^])\1{5,9}/g;
  3.     input = input.split(/[\s,]+/).forEach(ticket => {
  4.         if(ticket.length === 20) {
  5.             let left = ticket.substr(0, 10), right = ticket.substr(10);
  6.             let leftRepeat = left.match(patternRepeat), rightRepeat = right.match(patternRepeat);
  7.             if(leftRepeat !== null && rightRepeat !== null && leftRepeat[0][0] === rightRepeat[0][0]) {
  8.                 leftRepeat = leftRepeat[0];
  9.                 rightRepeat = rightRepeat[0];
  10.                 console.log(`ticket "${ticket}" - ${Math.min(rightRepeat.length, leftRepeat.length)}${rightRepeat[0]}${rightRepeat.length === 10 && leftRepeat.length === 10 ? ' Jackpot!': ''}`);
  11.             } else {
  12.                 console.log(`ticket "${ticket}" - no match`);
  13.             }
  14.         } else {
  15.             console.log('invalid ticket');
  16.         }
  17.     });
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top