fork download
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3.  
  4. // your code goes here
  5. let card;
  6. let cards = [[1,2,3,4],[1,5,6,7],[1,8,9,10],[1,11,12,13],[2,5,8,11],[2,6,9,12],[2,7,10,13],[3,5,9,13],[3,6,10,11],[3,7,8,12],[4,5,10,12],[4,6,8,13],[4,7,9,11]];
  7.  
  8. const num = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
  9. .map(a => [a,Math.random()])
  10. .sort((a,b) => a[1]-b[1])
  11. .map(a => a[0]);
  12.  
  13. for (let index = 0; index < cards.length; index++) {
  14. card = cards[index];
  15. cards[index] = card.map(a => num[a-1])
  16. .map(a => [a,Math.random()])
  17. .sort((a,b) => a[1]-b[1])
  18. .map(a => a[0]);
  19. }
  20. cards = cards.map(a => [a,Math.random()]).sort((a,b) => a[1]-b[1]).map(a => a[0]);
  21.  
  22. for (card of Array.from(cards)) { console.log(card); }
Success #stdin #stdout 0.04s 130432KB
stdin
Standard input is empty
stdout
[ 1, 10, 11, 8 ]
[ 12, 10, 13, 4 ]
[ 3, 1, 6, 4 ]
[ 5, 3, 10, 9 ]
[ 8, 2, 4, 5 ]
[ 11, 3, 12, 2 ]
[ 7, 12, 1, 5 ]
[ 7, 13, 8, 3 ]
[ 10, 2, 7, 6 ]
[ 6, 8, 9, 12 ]
[ 4, 9, 11, 7 ]
[ 13, 5, 11, 6 ]
[ 1, 9, 2, 13 ]