'Grow the program.'

def grow(self, program_len, input_types):

    var_names = list(reversed(map(chr, range(97, 123))))
    dependencies = dict()
    types_to_vars = dict()
    input_names = []
    for t in input_types:
        var = var_names.pop()
        dependencies[var] = []
        types_to_vars.setdefault(t, []).append(var)
        input_names.append(var)
    statements = []
    for _ in range((program_len - 1)):
        var = var_names.pop()
        statements.append(self.grow_body(var, dependencies, types_to_vars))
    statements.append(self.grow_body('out', dependencies, types_to_vars))
    new_var_names = [c for c in map(chr, range(97, 123)) if (c not in input_names)]
    new_var_names.reverse()
    keep_statements = []
    env = dict()
    for s in statements:
        if (s.output_var in dependencies['out']):
            keep_statements.append(s)
            env[s.output_var] = new_var_names.pop()
        if (s.output_var == 'out'):
            keep_statements.append(s)
    for k in keep_statements:
        k.substitute(env)
    return Program(input_names, input_types, ';'.join([str(k) for k in keep_statements]))
