<commit_before><?php
function toRoman($int)
{
    $out ="";

    $roman = array("I","V","X","L","C","D","M");
    list($out, $int) = loop($int, $out, 1000, "M");

    list($out, $int) = r2($int, $out, $roman, 4, 100);
    list($out, $int) = r2($int, $out, $roman, 2, 10);
    list($out, $int) = r2($int, $out, $roman, 0, 1);
    return $out;
}

/**
 * @param $int
 * @param $out
 * @param $roman
 * @param $index
 * @param $factor
 * @return array
 */
function r2($int, $out, $roman, $index, $factor): array
{
    $small = $roman[$index++];
    $big = $roman[$index++];
    $bigger = $roman[$index++];

    list($out, $int) = loop($int, $out, 9 * $factor, $small . $bigger);
    list($out, $int) = loop($int, $out, 6 * $factor, $big . $small);
    list($out, $int) = loop($int, $out, 5 * $factor, $big);
    list($out, $int) = loop($int, $out, 4 * $factor, $small . $big);
    list($out, $int) = loop($int, $out, 1 * $factor, $small);<commit_msg>Problem 11: refactor<commit_after><?php
function toRoman($int)
{
    $roman = array("I", "V", "X", "L", "C", "D", "M");
    list($out, $int) = loop($int, "", 1000, "M");
    for ($i = 4, $f = 100; $i >= 0; $i -= 2, $f /= 10)
        list($out, $int) = r2($int, $out, $roman, $i, $f);
    return $out;
}

/**
 * @param $int
 * @param $out
 * @param $roman
 * @param $index
 * @param $factor
 * @return array
 */
function r2($int, $out, $roman, $index, $factor): array
{
    $small = $roman[$index++];
    $big = $roman[$index++];
    $bigger = $roman[$index++];

    list($out, $int) = loop($int, $out, 9 * $factor, $small . $bigger);
    list($out, $int) = loop($int, $out, 6 * $factor, $big . $small);
    list($out, $int) = loop($int, $out, 5 * $factor, $big);
    list($out, $int) = loop($int, $out, 4 * $factor, $small . $big);
    list($out, $int) = loop($int, $out, 1 * $factor, $small);
{'fraction_non_alphanumeric': 0.2740619902120718, 'fraction_numerical': 0.023382272974442633, 'mean_word_length': 3.433734939759036, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6605266', 'n_tokens_mistral': 807, 'n_tokens_neox': 764, 'n_words': 198}