Implementation of A* algorithm using Ruby