<commit_before>"""
Solution to Lowest common ancestor problem on codeeval:
https://www.codeeval.com/open_challenges/11/
Write a program to determine the lowest common ancestor of two nodes in a binary search tree. You may hardcode the following binary search tree in your program:

    30
    |
  ____
  |   |
  8   52
  |
____
|   |
3  20
    |
   ____
  |   |
  10 29
INPUT SAMPLE:

The first argument is a path to a file that contains two values. These values represent two nodes within the tree, one per line. E.g.:

8 52
3 29
OUTPUT SAMPLE:

Print to stdout the lowest common ancestor, one per line. Lowest means the lowest depth in the tree, not the lowest value. E.g.:

30
8
"""
import sys


def find_path_to(node):
    """Given node return path to as list of nodes."""
    pass


def lca(node1, node2):
    path1 = find_path_to(node1)
    path2 = find_path_to(node2)
    last = None
    for x, y in map(None, path1, path2):
        if x == y:
            last = x
        else:
            break
    return last


def main(input_file):
    with open(input_file) as f:
        line = f.readline()
        values = line.split(' ')
        lca(values[0], values[1])


if __name__ == '__main__':
    input_file = sys.argv[1]
    main(input_file)<commit_msg>Add parameter to find_path_to.<commit_after>"""
Solution to Lowest common ancestor problem on codeeval:
https://www.codeeval.com/open_challenges/11/
Write a program to determine the lowest common ancestor of two nodes in a binary search tree. You may hardcode the following binary search tree in your program:

    30
    |
  ____
  |   |
  8   52
  |
____
|   |
3  20
    |
   ____
  |   |
  10 29
INPUT SAMPLE:

The first argument is a path to a file that contains two values. These values represent two nodes within the tree, one per line. E.g.:

8 52
3 29
OUTPUT SAMPLE:

Print to stdout the lowest common ancestor, one per line. Lowest means the lowest depth in the tree, not the lowest value. E.g.:

30
8
"""
import sys


def find_path_to(node, tree=default):
    """Given node return path to as list of nodes."""
    pass


def lca(node1, node2):
    """Compare paths to nodes and return lowest common ancestor."""
    path1 = find_path_to(node1)
    path2 = find_path_to(node2)
    last = None
    for x, y in map(None, path1, path2):
        if x == y:
            last = x
        else:
            break
    return last


def main(input_file):
    with open(input_file) as f:
        line = f.readline()
        values = line.split(' ')
        lca(values[0], values[1])


if __name__ == '__main__':
    input_file = sys.argv[1]
    main(input_file)
{'fraction_non_alphanumeric': 0.08775276611980161, 'fraction_numerical': 0.025944296070202214, 'mean_word_length': 2.591780821917808, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5423469', 'n_tokens_mistral': 896, 'n_tokens_neox': 837, 'n_words': 332}