<jupyter_start><jupyter_text>Lattice paths Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.![grid](https://projecteuler.net/project/images/p015.gif)How many such routes are there through a 20×20 grid? ---  Idea A problem of 'combination'From observation:- Each step can either go down *or* right, but cannot go down *and* right- Take totally `2 * grid_len` steps to finish- Must take `grid_len` steps to go down, so is to go right- Among `2 * grid_len` steps, if 'go down' steps is determined, other steps must be 'go right'So this problem is simplified to caculate how many ways to choose `grid_len` steps (down / right) from `2 * grid_len` steps.Solution is $$ C_{steps}^{grid\_len} $$ ---<jupyter_code>from math import factorial
def solve(grid_len):
    steps = grid_len * 2
    return factorial(steps) // (factorial(grid_len) * factorial(steps - grid_len))
solve(2)
solve(20)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10069101678183613, 'fraction_numerical': 0.01678183613030602, 'mean_word_length': 4.664804469273743, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '273590', 'license': 'MIT', 'n_tokens_mistral': 320, 'n_tokens_neox': 307, 'n_words': 135, 'path': '1-25/p15.ipynb', 'repo_name': 'Sorosliu1029/Euler', 'size': '1013'}