<commit_before><commit_msg>Euler 15: The number of lattice paths in a 20x20 grid.<commit_after>      * Author: <NAME>
      * Date: 5 July 2015
      * Purpose: Calculate length of lattice paths in 20x20 grid
      * Tectonics: cobc -x euler0015.cbl
      * Method:
      *   This is combinatorics. Use formula from 1991.
      *   In a grid from (0, 0) to (a, b) the number of lattice paths
      *   are the binomial coefficient (a+b)Ca.
      *   nCk = n!/(n-k)!k!
      *   There is a simpler algorithm for computing it, but
      *   I chose to eliminate manually the common factors.
      *   For 20x20 grid this becomes 40C20
      *   = 40!/20!20!
      *   = 40*39*...*21/20!
      *   = 37 * 33 * 31 * 29 * 26 * 5 * 2 * 23 * 21
      *   Function Product is not implemented yet in OpenCobol 1.1,
      *   nor in GnuCOBOL 2.0+ as far as I can tell.
       identification division.
       program-id. euler0015.
      ******************************************************************
       data division.
       working-storage section.
       01  lattice-path-count             pic 9(18) comp value 1.
       01  i                              pic 9     comp.
       01  binomial-coefficent-remains.
           05  remains                    pic X(27) values
                                          "37 33 31 29 26 23 21 05 02".
           05  factors redefines remains  pic X(3) occurs 9 times.
       01  factor-num                     pic 9(2)  comp.
      ******************************************************************
       procedure division.
       main-procedure.
           perform varying i from 1 by 1 until i > 9
               move function numval(factors(i)) to factor-num
               multiply factor-num by lattice-path-count
           end-perform
           display "The number of lattice paths in a 20x20 grid is "
               lattice-path-count.
           stop run.
       end program euler0015.

{'fraction_non_alphanumeric': 0.13601236476043277, 'fraction_numerical': 0.0633693972179289, 'mean_word_length': 1.613728129205922, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3905400', 'n_tokens_mistral': 634, 'n_tokens_neox': 521, 'n_words': 202}