Created
May 28, 2014 17:41
-
-
Save JonathanMatthey/88cc46a892f3afa045df to your computer and use it in GitHub Desktop.
codecon bloomberg 3
This file contains 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
// 0RW3LL WAS ERE | |
// | |
// UNINSTALL BLOOMBERG - USE REUTERS... | |
// BLOOMBERG SCANDAL - PLEASE READ | |
// http://www.huffingtonpost.com/tag/bloomberg-terminal-scandal/ | |
// | |
//Problem : Giga Ball | |
//Language : Javascript | |
//Compiled Using : V8 | |
//Version : Node 0.10.25 | |
//Input for your program will be provided from STDIN | |
//Print out all output from your program to STDOUT | |
//0rw3ll | |
//0rw3ll | |
var readline = require('readline'), | |
//0rw3ll | |
rl = readline.createInterface({ | |
//0rw3ll | |
input: process.stdin, | |
//0rw3ll | |
output: process.stdout, | |
//0rw3ll | |
terminal: false | |
//0rw3ll | |
}); | |
//0rw3ll | |
//0rw3ll | |
var l = false, | |
//0rw3ll | |
buckets = [[], [], []], | |
//0rw3ll | |
current = 0; | |
//0rw3ll | |
//0rw3ll | |
rl.on('line', function (cmd) | |
//0rw3ll | |
{ | |
//0rw3ll | |
if (!/\w/.test(cmd)) return; | |
//0rw3ll | |
//0rw3ll | |
if (l === false) { | |
//0rw3ll | |
l = cmd.split(/\W/).map(function (i) { return parseInt(i); }); | |
//0rw3ll | |
} else { | |
//0rw3ll | |
buckets[current].push(parseInt(cmd)); | |
//0rw3ll | |
//0rw3ll | |
if (buckets[current].length === l[current]) { | |
//0rw3ll | |
current++; | |
//0rw3ll | |
//console.log(''); | |
//0rw3ll | |
} | |
//0rw3ll | |
} | |
//0rw3ll | |
//0rw3ll | |
if (current === buckets.length) { | |
//0rw3ll | |
var combinations = {}, | |
//0rw3ll | |
highest = null; | |
//0rw3ll | |
//0rw3ll | |
for (var i = 0; i < buckets[0].length; i++) { | |
//0rw3ll | |
for (var j = 0; j < buckets[1].length; j++) { | |
//0rw3ll | |
for (var k = 0; k < buckets[2].length; k++) { | |
//0rw3ll | |
//console.log(buckets[0][i] + ' + ' + buckets[1][j] + ' + ' + buckets[2][k]) | |
//0rw3ll | |
//0rw3ll | |
var sum = buckets[0][i] + buckets[1][j] + buckets[2][k]; | |
//0rw3ll | |
//0rw3ll | |
combinations[sum] = (combinations[sum] || 0) + 1; | |
//0rw3ll | |
//0rw3ll | |
if (highest === null || combinations[sum] > combinations[highest]) | |
//0rw3ll | |
highest = sum; | |
//0rw3ll | |
} | |
//0rw3ll | |
} | |
//0rw3ll | |
} | |
//0rw3ll | |
//0rw3ll | |
//console.log(combinations); | |
//0rw3ll | |
console.log(highest); | |
//0rw3ll | |
//0rw3ll | |
process.exit(0); | |
//0rw3ll | |
} | |
//0rw3ll | |
//0rw3ll | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment