Skip to content

Instantly share code, notes, and snippets.

@JonathanMatthey
Created May 28, 2014 17:40
Show Gist options
  • Save JonathanMatthey/789f4b71ce1800ef7af9 to your computer and use it in GitHub Desktop.
Save JonathanMatthey/789f4b71ce1800ef7af9 to your computer and use it in GitHub Desktop.
codecon bloomberg 2
// 0RW3LL WAS ERE
//
// UNINSTALL BLOOMBERG - USE REUTERS...
// BLOOMBERG SCANDAL - PLEASE READ
// http://www.huffingtonpost.com/tag/bloomberg-terminal-scandal/
//
//Problem : Mug Color
//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
var readline = require('readline');
//0rw3ll
var rl = readline.createInterface({
//0rw3ll
input: process.stdin,
//0rw3ll
output: process.stdout,
//0rw3ll
terminal: false
//0rw3ll
});
//0rw3ll
function isPal(word){
//0rw3ll
return ( word.split("").reverse().join("") == word.split("").join("") );
//0rw3ll
}
//0rw3ll
rl.on('line', function (line)
//0rw3ll
{
//0rw3ll
var length;
//0rw3ll
var word = line;
//0rw3ll
for(i=word.length; i >= 0; i--){
//0rw3ll
if(isPal(word.substr(0,i))){
//0rw3ll
length = (i + (word.length - i) *2);
//0rw3ll
break;
//0rw3ll
}
//0rw3ll
}
//0rw3ll
console.log(length);
//0rw3ll
});
//0rw3ll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment