AlexKondov

SoftUni Couples Frequency

Jul 26th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(args) {
  2.     var count = 0;
  3.     var matrix = {};
  4.  
  5.     for (var i = 0; i < args.length - 1 ; i++) {
  6.        
  7.         var couple = args[i] + args[i + 1];
  8.  
  9.         for (var j = 0; j < args.length - 1; j++) {
  10.             var testCouple = args[j] + args[j + 1];
  11.             if (couple === testCouple) {
  12.                 count++;
  13.             }
  14.         }
  15.             matrix[couple] = count;
  16.             count = 0; 
  17.     }
  18.  
  19.     console.log(matrix);
  20. }
  21.  
  22. console.log(solve(['3', '4', '2', '3', '4', '2', '1', '12', '2', '3', '4']));
Advertisement
Add Comment
Please, Sign In to add comment