def all_together(start_x, start_y, end_x, end_y, coordinates_directory, number_of_zeros, temp_filepath='temporary'): """ Takes the files in the coordinates directory and creates a map. Then given start and end coordinates it outputs the shortest path from the start to end points on the map. This map is then saved to a file location. The function will then take the string of the path taken, find the hash collisions with the number of zeros input and return the hash result. Args: start_x (int): The x coordinate of the start position. start_y (int): The y coordinate of the start position. end_x (int): The x coordinate of the end position. end_y (int): The y coordinate of the end position. coordinates_directory (string): Directory containing the files to parse. number_of_zeros (int): The number of zeros to be searching for at the start of the hash. Returns: The collisions string the function has built. """ the_map = parse_and_create_map(coordinates_directory) with open(temp_filepath, mode='w') as fp: fp.write(the_map) path = \ _path_between_points(start_x=start_x, start_y=start_y, end_x=end_x, end_y=end_y, map_file_location=temp_filepath)[1] # path_str = "".join(['x{}y{}'.format(elem[0], elem[1]) for elem in path]) # TODO not sure if the hash function should take the above input or the below, sorry confused from description in pdf file path_str = "".join( ['{:02d}{:02d}'.format(elem[0], elem[1]) for elem in path]) collision_output = find_zero_collision_from_salt( salt=path_str, number_of_zeros=number_of_zeros) import os os.remove(temp_filepath) return collision_output
def test_artificialintelligence_5(self): expected_hash_collision = '610d370320' self.failUnless( hashiterator.find_zero_collision_from_salt( 'artificial-intelligence', 5) == expected_hash_collision)
def test_codequality_3(self): expected_hash_collision = '09e97089ae' self.failUnless( hashiterator.find_zero_collision_from_salt('code-quality', 3) == expected_hash_collision)
def test_machinelearning_4(self): expected_hash_collision = 'f320e001d1' self.failUnless( hashiterator.find_zero_collision_from_salt('machine-learning', 4) == expected_hash_collision)