async function main() {
    performance.mark("all-start");
    await setup();
    // writeFileExt('./allWords.txt', allWords.join('\n'));

    const stats = {
        solver: solverName,
        date: fileNameDate,
        minGuesses: allWords.length,
        maxGuesses: 0,
        fails: 0,
        guessesDetails: {},
        totalGuesses: 0,
    };
    function formatReport(stats) {
        return [
            `Summary:`,
            `Solver: ${stats.solver}`,
            `Date: ${stats.date}`,
            `Total Guesses: ${stats.totalGuesses}`,
            `Avg Guesses: ${(stats.totalGuesses / answers.length).toFixed(4)}`,
            `Shortest Guesses: ${stats.minGuesses}`,
            `Longest Guesses: ${stats.maxGuesses}`,
            `Fails: ${stats.fails}`,
            `Guess Limit Exceeded: ${Object.entries(stats.guessesDetails).filter(([k, v]) => Number(k) > 6).map(([k, v]) => v).reduce(sum)}`,
            `Guess Histogram:`,
            ...Object.entries(stats.guessesDetails).map(([k, v]) => `  ${k}: ${v}`)
        ].join('\n');
    }

    console.log(`Mode: ${process.env.MODE}`);
    if (process.env.MODE === 'all') {
        for (let i = 0; i < answers.length; i++) {
            const answer = answers[i];
            if ((i + 1) % 100 === 0) console.log(`${i + 1}/${answers.length}`);
            solve(answer, outPath, stats);
        }
    } else if (process.env.MODE.length === 5) {
        solve(process.env.MODE, outPath, stats);
    } else {
        const count = parseInt(process.env.MODE, 10);
        for (let i = 0; answers.length > 0 && i < count; i++) {
            const answer = answers.splice(Math.floor(Math.random() * answers.length), 1)[0];
            solve(answer, outPath, stats);
        }
    }


    console.log(formatReport(stats));
    appendFile(outPath, `\n\n${formatReport(stats)}\n`);

    console.log(`Result written to ${outPath}`);
    performance.mark("all-end");
    performance.measure('all', "all-start", "all-end");
}
// allowed guesses and answers mixed, sorted
allowed guesses and answers mixed, sorted
allowed guesses and answers mixed sorted
async function main() {
    performance.mark("all-start");
    await setup();
    const stats = {
        solver: solverName,
        date: fileNameDate,
        minGuesses: allWords.length,
        maxGuesses: 0,
        fails: 0,
        guessesDetails: {},
        totalGuesses: 0,
    };
    function formatReport(stats) {
        return [
            `Summary:`,
            `Solver: ${stats.solver}`,
            `Date: ${stats.date}`,
            `Total Guesses: ${stats.totalGuesses}`,
            `Avg Guesses: ${(stats.totalGuesses / answers.length).toFixed(4)}`,
            `Shortest Guesses: ${stats.minGuesses}`,
            `Longest Guesses: ${stats.maxGuesses}`,
            `Fails: ${stats.fails}`,
            `Guess Limit Exceeded: ${Object.entries(stats.guessesDetails).filter(([k, v]) => Number(k) > 6).map(([k, v]) => v).reduce(sum)}`,
            `Guess Histogram:`,
            ...Object.entries(stats.guessesDetails).map(([k, v]) => `  ${k}: ${v}`)
        ].join('\n');
    }
    console.log(`Mode: ${process.env.MODE}`);
    if (process.env.MODE === 'all') {
        for (let i = 0; i < answers.length; i++) {
            const answer = answers[i];
            if ((i + 1) % 100 === 0) console.log(`${i + 1}/${answers.length}`);
            solve(answer, outPath, stats);
        }
    } else if (process.env.MODE.length === 5) {
        solve(process.env.MODE, outPath, stats);
    } else {
        const count = parseInt(process.env.MODE, 10);
        for (let i = 0; answers.length > 0 && i < count; i++) {
            const answer = answers.splice(Math.floor(Math.random() * answers.length), 1)[0];
            solve(answer, outPath, stats);
        }
    }
    console.log(formatReport(stats));
    appendFile(outPath, `\n\n${formatReport(stats)}\n`);
    console.log(`Result written to ${outPath}`);
    performance.mark("all-end");
    performance.measure('all', "all-start", "all-end");
}
async function main ( ) { performance . mark ( "all-start" ) ; await setup ( ) ; const stats = { solver : solverName , date : fileNameDate , minGuesses : allWords . length , maxGuesses : 0 , fails : 0 , guessesDetails : { } , totalGuesses : 0 , } ; function formatReport ( stats ) { return [ ` ` , ` ${ stats . solver } ` , ` ${ stats . date } ` , ` ${ stats . totalGuesses } ` , ` ${ ( stats . totalGuesses / answers . length ) . toFixed ( 4 ) } ` , ` ${ stats . minGuesses } ` , ` ${ stats . maxGuesses } ` , ` ${ stats . fails } ` , ` ${ Object . entries ( stats . guessesDetails ) . filter ( ( [ k , v ] ) => Number ( k ) > 6 ) . map ( ( [ k , v ] ) => v ) . reduce ( sum ) } ` , ` ` , ... Object . entries ( stats . guessesDetails ) . map ( ( [ k , v ] ) => ` ${ k } ${ v } ` ) ] . join ( '\n' ) ; } console . log ( ` ${ process . env . MODE } ` ) ; if ( process . env . MODE === 'all' ) { for ( let i = 0 ; i < answers . length ; i ++ ) { const answer = answers [ i ] ; if ( ( i + 1 ) % 100 === 0 ) console . log ( ` ${ i + 1 } ${ answers . length } ` ) ; solve ( answer , outPath , stats ) ; } } else if ( process . env . MODE . length === 5 ) { solve ( process . env . MODE , outPath , stats ) ; } else { const count = parseInt ( process . env . MODE , 10 ) ; for ( let i = 0 ; answers . length > 0 && i < count ; i ++ ) { const answer = answers . splice ( Math . floor ( Math . random ( ) * answers . length ) , 1 ) [ 0 ] ; solve ( answer , outPath , stats ) ; } } console . log ( formatReport ( stats ) ) ; appendFile ( outPath , ` \n \n ${ formatReport ( stats ) } \n ` ) ; console . log ( ` ${ outPath } ` ) ; performance . mark ( "all-end" ) ; performance . measure ( 'all' , "all-start" , "all-end" ) ; }
allowed guesses and answers mixed, sorted
allowed guesses and answers mixed sorted
// writeFileExt('./allWords.txt', allWords.join('\n'));