Skip to content

Instantly share code, notes, and snippets.

@tyage
Created December 19, 2010 08:03
Show Gist options
  • Save tyage/747194 to your computer and use it in GitHub Desktop.
Save tyage/747194 to your computer and use it in GitHub Desktop.
var fs = require('fs'),
sys = require('sys');
var result = function (file) {
fs.readFile(file, "utf-8", function (err, data) {
err && sys.print(err)
var search = '';
var r = 0;
data.split('\r\n').forEach(function (val, i) {
if (i == 0) {
search = val;
} else if (i >= 2 && (val+val).indexOf(search) != -1) {
r++;
}
})
fs.writeFile(file, r+"");
});
}
result('2011-yo-t2-in_s1.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment