<commit_before># TODO: docs
import sys
import time
import resource

import nsquare
import bfs
import dfs

def handle_input():
    algos = {"bfs": bfs.Bfs, "dfs": dfs.Dfs}

    if len(sys.argv) != 3:
        print("required args include the search algo and the initial board state")
        print("available search algos include: {}".format(list(algos.keys())))
        print("initial board state must be a valid n-square board or crazy stuff may occur")
        print("initial board state must be a CSV string with no spaces")
        print("example:")
        print("    python3 driver.py bfs 1,2,3,0,5,6,4,7,8")
        exit(2)
    else:
        return algos[sys.argv[1]], [int(n) for n in sys.argv[2].split(",")]

def write_out(results, start_time):
    output_file = open("./output.txt", "w")

    results["time"] = time.time() - start_time
    # TODO is memory working?
    results["memory"] = resource.getrusage(resource.RUSAGE_CHILDREN)[2]

    if results.get("path"):
        output_file.write("Solution found:")
        output_file.write("time: {:.2f} seconds\n".format(results["time"]))
        output_file.write("memory: {:,.2f}KB\n".format(results["memory"]))
        output_file.write("cost: {}\n".format(results["cost"]))
        output_file.write("max_search_depth: {}\n".format(results["max_search_depth"]))
        output_file.write("path: {}\n".format(results["path"]))
    else:
        output_file.write("No solution found!")<commit_msg>added newlines<commit_after># TODO: docs
import sys
import time
import resource

import nsquare
import bfs
import dfs

def handle_input():
    algos = {"bfs": bfs.Bfs, "dfs": dfs.Dfs}

    if len(sys.argv) != 3:
        print("required args include the search algo and the initial board state")
        print("available search algos include: {}".format(list(algos.keys())))
        print("initial board state must be a valid n-square board or crazy stuff may occur")
        print("initial board state must be a CSV string with no spaces")
        print("example:")
        print("    python3 driver.py bfs 1,2,3,0,5,6,4,7,8")
        exit(2)
    else:
        return algos[sys.argv[1]], [int(n) for n in sys.argv[2].split(",")]

def write_out(results, start_time):
    output_file = open("./output.txt", "w")

    results["time"] = time.time() - start_time
    # TODO is memory working?
    results["memory"] = resource.getrusage(resource.RUSAGE_CHILDREN)[2]

    if results.get("path"):
        output_file.write("Solution found:\n")
        output_file.write("time: {:.2f} seconds\n".format(results["time"]))
        output_file.write("memory: {:,.2f}KB\n".format(results["memory"]))
        output_file.write("cost: {}\n".format(results["cost"]))
        output_file.write("max_search_depth: {}\n".format(results["max_search_depth"]))
        output_file.write("path: {}\n".format(results["path"]))
    else:
        output_file.write("No solution found!\n")
{'fraction_non_alphanumeric': 0.1616992120589243, 'fraction_numerical': 0.011647824597464886, 'mean_word_length': 3.4923076923076923, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '61657', 'n_tokens_mistral': 963, 'n_tokens_neox': 940, 'n_words': 230}