This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function calcMemberInvoices(opts) { | |
| var invoices = {}, | |
| members = opts.members, | |
| overpays = opts.overpays, | |
| avgSum = opts.invoice / members.length; | |
| // Рассчитаем средний платеж на каждого | |
| for (var i = 0; i < members.length; i++) { | |
| invoices[members[i]] = avgSum; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function isValidPasspharse(phrase) { | |
| var usedWords = {}; | |
| var words = phrase.split(' '); | |
| for (var i = 0; i < words.length; i++) { | |
| var word = words[i].split('').sort().join(''); | |
| if (word in words) { | |
| return false; | |
| } | |
| words[word] = 1; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function isValidPasspharse(phrase) { | |
| var usedWords = {}; | |
| var words = phrase.split(' '); | |
| for (var i = 0; i < words.length; i++) { | |
| var word = words[i]; | |
| if (word in words) { | |
| return false; | |
| } | |
| words[word] = 1; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | calc(265149); | |
| function calc(inputNum) { | |
| var map = {}; | |
| var sum = 1; | |
| setAt(map, 0, 0, sum); | |
| for (var i = 1; i; i++) { | |
| sum = 0; | |
| var coord = spiralCoord(i, -1, true); | |
| for (var x = coord.x - 1; x <= coord.x + 1; x++) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function getProperty(obj, props, def) { | |
| while (obj && props.length) { | |
| obj = obj[props.shift()]; | |
| } | |
| return (obj !== undefined) ? obj : def; | |
| } | |
| // Example | |
| var state = { authenticationModel: { UserData: {} } }; | |
| var roles = getProperty(state, ['authenticationModel', 'UserData', 'tokenData', 'payload', 'realmAccess', 'roles'], []); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| function swapBits($num, $map) { | |
| $layer = 0; | |
| $rest = $num; | |
| foreach ($map as $from => $to) { | |
| $layer |= getBitAt($num, $from) << $to; | |
| $rest = setBitAt($rest, $to, 0); | |
| } | |
| return $rest | $layer; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| function build_promocode($index, $charTable) { | |
| $code = ''; | |
| $max = 1; | |
| foreach ($charTable as $chars) { | |
| $max *= count($chars); | |
| } | |
| $rest = $index % $max; | |
| $i = count($charTable); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import gzip | |
| import time | |
| import pprint | |
| def main(): | |
| tm_parsing = time.time() | |
| data = parse_log("nginx-access-ui.log-20170630.gz") | |
| tm_parsing = time.time() - tm_parsing | |
| tm_stats = time.time() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import random | |
| def pairs_of(items: list) -> list: | |
| size = len(items) | |
| return [[items[i], items[(i + 1) % size]] for i in range(size)] | |
| def pairs_group_rand(pairs: list) -> None: | |
| rest = len(pairs) - 1 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function shuffle(items) { | |
| return items | |
| .map(item => [item, Math.random()]) | |
| .sort((a, b) => (a[1] > b[1]) - (a[1] < b[1])) | |
| .map(item => item[0]); | |
| } | |
| function pairs(items) { | |
| return items | |
| .map((item, index, items) => [item, items[(index + 1) % items.length]]); |