-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add note in readme to say all solutions exist now #367
Conversation
Wasn't sure what the wording should be so feel free to change, I just wanted something to let people know that there aren't any games that are missing a language implementation |
are we sure this is correct? I clicked through on a random folder,
|
Ah yep this can definitely be closed - I had an async bug causing it to check if an array is empty before anything had a chance to get inserted, and the languages I was spot-checking the most (javascript and python) seem to also be the most implemented. Here's the updated script with the bug fixed and some additional counts by game/language. I'll open a new PR to include this script in the repo, but feel free to reject it too for whatever reason, just seems like it could be useful /**
* Program to find games that are missing solutions in a given language
*
* Scan each game folder, check for a folder for each language, and also make
* sure there's at least one file of the expected extension and not just a
* readme or something
*/
const fs = require('fs');
const glob = require('glob');
// relative path to the repository root
const ROOT_PATH = '.';
const languages = [
{ name: 'csharp', extension: 'cs' },
{ name: 'java', extension: 'java' },
{ name: 'javascript', extension: 'js' },
{ name: 'pascal', extension: 'pas' },
{ name: 'perl', extension: 'pl' },
{ name: 'python', extension: 'py' },
{ name: 'ruby', extension: 'rb' },
{ name: 'vbnet', extension: 'vb' },
];
const getFilesRecursive = async (path, extension) => {
return new Promise((resolve, reject) => {
glob(`${path}/**/*.${extension}`, (err, matches) => {
if (err) {
reject(err);
}
resolve(matches);
});
});
}
const getPuzzleFolders = () => {
return fs.readdirSync(ROOT_PATH, { withFileTypes: true })
.filter(dirEntry => dirEntry.isDirectory())
.filter(dirEntry => !['.git', 'node_modules'].includes(dirEntry.name))
.map(dirEntry => dirEntry.name);
}
(async () => {
let missing = [];
let missingGames = {};
let missingLanguageCounts = {};
const puzzles = getPuzzleFolders();
for (const puzzle of puzzles) {
for (const { name: language, extension } of languages) {
const files = await getFilesRecursive(`${ROOT_PATH}/${puzzle}/${language}`, extension);
if (files.length === 0) {
missing.push(`${puzzle}/${language}`);
if (!missingGames[puzzle]) {
missingGames[puzzle] = [];
}
if (!missingLanguageCounts[language]) {
missingLanguageCounts[language] = 0;
}
missingGames[puzzle].push(language);
missingLanguageCounts[language]++;
}
}
}
if (missing.length === 0) {
console.log('All games have solutions for all languages')
} else {
console.log(`Missing ${missing.length} implementations:`);
console.log(`\nMissing languages by game:`);
for (const [puzzle, languages] of Object.entries(missingGames)) {
console.log(`${puzzle}: ${languages.join(', ')}`);
}
console.log(`\nBy language:`);
for (const [language, count] of Object.entries(missingLanguageCounts)) {
console.log(`${language}: ${count} missing`);
}
}
})();
return; Which has the following output:
|
I was wondering if there was any games that hadn't been implemented yet and it appears there are not. I wrote a little JS script to check (below), but figured there should be a note in the readme so other people don't spent time trying to see what's left to do.