<commit_before>var prompt = require('prompt');
var readlineSync = require('readline-sync');
var cp = require('child_process');
var variables = 5
var polys = 5
var steps = 5

var properties = [
    {
        name: 'variables',
        validator: /^[1-9]{1}?$/,
        warning: 'variables must be from 1 to 9'
    },
    {
        name: 'polys',
        validator: /^[2-5]{1}?$/,
        warning: 'polys must be from 2 to 5'
    },
    {
        name: 'steps',
        validator: /^[2-5]{1}?$/,
        warning: 'steps must be from 2 to 5'
    },
    {
        name: 'questions',
        validator: /^[1-9]{1}?$/,
        warning: 'questions must be from 1 to 9'
    },
  ];

prompt.start();

prompt.get(properties, function(err, result) {
    if (err) { return onErr(err); }

    if (variables > result.variables)
        variables = result.variables;
    if (polys > result.polys)
        polys = result.polys;
    if (steps > result.steps)
        steps = result.steps;

    for (var q = 0; q < result.questions; q++) {

        var expr = getExpr(steps);
        console.log('\n\n' + (q + 1) + '] ' +
            expr
        );

        expr = expr.replace(/\+/g, '%2B');
        expr = expr.replace(/\(/g, '%5Cleft(');
        expr = expr.replace(/\)/g, '%5Cright)');

        readlineSync.question('Press [Enter] to check the answer!');

        if(require('os').type() == 'Windows_NT')
            cp.exec('start https://www.symbolab.com/solver/polynomial-calculator/' + expr);
        else if(require('os').type() == 'Darwin')
            cp.exec('open "https://www.symbolab.com/solver/polynomial-calculator/' + expr + '"', (err, stdout, stderr) => {
  if (err) {
    console.error(err);
    return;
  }
  console.log(stdout);
});
    }

});

function onErr(err) {
    console.log(err);
    return 1;
}



var vars = 'abcdefghijkl';


function getSign() {
    return Math.random() > .5 ? '+' : '-';
}

function getCoeff() {
    var c = Math.round(Math.random() * 10 + 1);
    if (c == 1)
        return '';
    else
        return c;
}

function getExpr(step) {
    if (step == 1)
        return vars[(Math.round(Math.random() * 10) % variables)]
    else {
        var exp = step == steps ? '' : '(';
        for (var i = 0; i < polys; i++) {
            var sign = getSign();
            if (sign == '+' && i == 0)
                sign = '';
            exp += (
                sign + getCoeff() + getExpr(step - 1)
            );
        }
        exp += step == steps ? '' : ')';
        return exp;
    }
}<commit_msg>simplify arguments, add quadratic choice<commit_after>var prompt = require('prompt');
prompt.message = '';
prompt.delimiter = '><'
var readlineSync = require('readline-sync');
var cp = require('child_process');
var nestings = 3
var degrees = 1
var properties = [
    {
        name: 'degrees',
        validator: /^[1-2]{1}?$/,
        default: 1,
        warning: 'degrees must be from 1 to 2'
    },
    {
        name: 'questions',
        validator: /^[1-9]{1}?$/,
        default: 5,
        warning: 'questions must be from 1 to 9'
    },
];

prompt.start();

prompt.get(properties, function (err, result) {
    if (err) { return onErr(err); }
    degrees = result.degrees;

    for (var q = 0; q < result.questions; q++) {

        var expr = '';
        if (degrees == 1)
            expr = getLinear(nestings);
        else
            expr = getHighDegreePoly(degrees);
        console.log('\n\n' + (q + 1) + '] ' +
            expr
        );

        expr = expr.replace(/\+/g, '%2B');
        expr = expr.replace(/\(/g, '%5Cleft(');
        expr = expr.replace(/\)/g, '%5Cright)');

        readlineSync.question('Press [Enter] to check the answer!');

        if (require('os').type() == 'Windows_NT')
            cp.exec('start https://www.symbolab.com/solver/polynomial-calculator/' + expr);
        else if (require('os').type() == 'Darwin')
            cp.exec('open "https://www.symbolab.com/solver/polynomial-calculator/' + expr + '"', (err, stdout, stderr) => {
                if (err) {
                    console.error(err);
                    return;
                }
                console.log(stdout);
            });
    }
});

function onErr(err) {
    console.log(err);
    return 1;
}

var vars = 'abcdefghijkl';

function getSign() {
    return Math.random() > .5 ? '+' : '-';
}

function getCoeff() {
    var c = Math.round(Math.random() * 10 + 1);
    if (c == 1)
        return '';
    else
        return c;
}

function getLinear(nesting, idx) {
    if (nesting == 1)
        return vars[idx]
    else {
        var exp = nesting == nestings ? '' : '(';
        var term = Math.ceil(Math.random() * 3) + 1;
        for (var i = 0; i < term; i++) {
            var sign = getSign();
            if (sign == '+' && i == 0)
                sign = '';
            exp += (
                sign + getCoeff() + getLinear(nesting - 1, i)
            );
        }
        exp += nesting == nestings ? '' : ')';
        return exp;
    }
}

function getHighDegreePoly(degree) {
    var ret = '';
    for (var i = 0; i < degree; i++)
        ret += getLinear(2);
    return ret;
}
{'fraction_non_alphanumeric': 0.17911318553092181, 'fraction_numerical': 0.014391287436795021, 'mean_word_length': 1.8273776800439803, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4760699', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1682, 'n_words': 410}