Skip to content

Instantly share code, notes, and snippets.

@ArupSen
Forked from codeeval/sample.py
Last active August 29, 2015 13:56
Show Gist options
  • Save ArupSen/8903276 to your computer and use it in GitHub Desktop.
Save ArupSen/8903276 to your computer and use it in GitHub Desktop.
// challenge description
// sample input -
// sample output -
function coolFunction (input) {
var dataStruct = []; // or {}
var output = ""; // or 0
dataStruct = input.split(',');
output = dataStruct.join(' ');
return output;
}
var fs = require("fs");
fs.readFileSync(process.argv[2]).toString().split('\n').forEach(function (line) {
if (line !== "") { // ignore empty lines
console.log(coolFunction(line));
}
});
@ArupSen
Copy link
Author

ArupSen commented Feb 9, 2014

I started off using the editor on the codeEval site but I seem to use the same basic pattern and workflow for each challenge. I use the Chrome console to hack and try stuff out. I copy / paste the function that I write in my text editor (TextMate). The pattern is typically breaking each line into an array or object which I then iterate. It uses less memory if I didn't have a function call but the way I've been doing it works well for me. Last year it would have been Python, this year (2014) it's js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment