<commit_before><commit_msg>problem 15 solution - Lattice Paths<commit_after>/*
    Copyright (c) 2015 - <EMAIL>
    ----------------------------------------
    Compute number of routes in NxN grid where you
    can move either Right or Down from the top left 
    corner to the bottom right corner.
*/


#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <map>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <sstream>
#include <cstdint>


#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)



using namespace std;


// important trick in the equation is to first multiply 
// res by n+i and then divide by i, which prevents fractions.
uint64_t calc(uint64_t n) {
    uint64_t  res = 1;
    for(uint64_t i=1; i<=n; ++i) {
        res = (res * (n+i)) / i;
    }
    return res;
}


int main(int argc, char* argv[]) 
{
    ios_base::sync_with_stdio(0);

    int N;
    cin >> N;
            
    cout << "computed number of different routes: " << calc(N) << endl;

    return 0;
}







{'fraction_non_alphanumeric': 0.16393442622950818, 'fraction_numerical': 0.017357762777242044, 'mean_word_length': 2.5547945205479454, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 16, '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': '7176088', 'n_tokens_mistral': 389, 'n_tokens_neox': 356, 'n_words': 119}