<commit_before>! Copyright (c) 2007 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: io io.files kernel math.parser namespaces sequences strings
    vocabs vocabs.loader system project-euler.ave-time
    project-euler.001 project-euler.002 project-euler.003 project-euler.004
    project-euler.005 project-euler.006 project-euler.007 project-euler.008
    project-euler.009 project-euler.010 project-euler.011 project-euler.012
    project-euler.013 project-euler.014 project-euler.015 project-euler.016 ;
IN: project-euler

<PRIVATE

: problem-prompt ( -- n )
    "Which problem number from Project Euler would you like to solve?"
    print readln string>number ;

: number>euler ( n -- str )
    number>string string>digits 3 0 pad-left [ number>string ] map concat ;

: solution-path ( n -- str )
    number>euler dup [
        "project-euler" vocab-root ?resource-path %
        os "windows" = [
            "\\project-euler\\" % % "\\" % % ".factor" %
        ] [
            "/project-euler/" % % "/" % % ".factor" %
        ] if
    ] "" make ;

PRIVATE>

: problem-solved? ( n -- ? )
    solution-path exists? ;

: run-project-euler ( -- )
    problem-prompt dup problem-solved? [
        dup number>euler "project-euler." swap append run<commit_msg>Update problems list and simplify code<commit_after>! Copyright (c) 2007 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: definitions io io.files kernel math.parser sequences strings
    vocabs vocabs.loader
    project-euler.001 project-euler.002 project-euler.003 project-euler.004
    project-euler.005 project-euler.006 project-euler.007 project-euler.008
    project-euler.009 project-euler.010 project-euler.011 project-euler.012
    project-euler.013 project-euler.014 project-euler.015 project-euler.016
    project-euler.017 project-euler.018 project-euler.019
    project-euler.067
    project-euler.134 ;
IN: project-euler

<PRIVATE

: problem-prompt ( -- n )
    "Which problem number from Project Euler would you like to solve?"
    print readln string>number ;

: number>euler ( n -- str )
    number>string 3 CHAR: 0 pad-left ;

: solution-path ( n -- str/f )
    number>euler "project-euler." swap append vocab where
    dup [ first ?resource-path ] when ;

PRIVATE>

: problem-solved? ( n -- ? )
    solution-path ;

: run-project-euler ( -- )
    problem-prompt dup problem-solved? [
        dup number>euler "project-euler." swap append run
{'fraction_non_alphanumeric': 0.12383272431993504, 'fraction_numerical': 0.049939098660170524, 'mean_word_length': 2.8864353312302837, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '4925801', 'n_tokens_mistral': 891, 'n_tokens_neox': 797, 'n_words': 198}