Skip to content

Instantly share code, notes, and snippets.

@omas
Created December 20, 2014 03:09
Show Gist options
  • Select an option

  • Save omas/d027017767425436f81a to your computer and use it in GitHub Desktop.

Select an option

Save omas/d027017767425436f81a to your computer and use it in GitHub Desktop.
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
var lines = chunk.toString().split('\n')[0].toString().trim().split(' ');
var result = (function(diff) {
var table = [0,1,2,3,2,1,2,3,3,2];
return ~~(diff / 10) + table[diff % 10];
}(Math.abs(lines[1] - lines[0])));
console.log(result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment