Skip to content

Conversation

@randomUsernameAndPassword
Copy link
Collaborator

Partial solution (without #3 and #4 optional problems) to assignment 6.

Partial solution (without #3 and #4 optional problems) to assignment 6.
current_empty, start = move_car(start, position, current_empty)
yield start

def print_sequence(start, end):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use crossopts function for this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is far more reasonable though

end_positions = inverse_map(end)

for position in range(len(start)):
# At first, move car, that should be placed in current
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the coherent comments, they really made this function easy to understand:)

# At first, move car, that should be placed in current
# empty space and repeat.
while end_positions[0] != current_empty:
start_positions = inverse_map(start)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this in a cycle N times is way too slow

current_empty, start = move_car(start, position, current_empty)
yield start

def print_sequence(start, end):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is far more reasonable though


class TestCarSequences(unittest.TestCase):
def test(self):
print_sequence([1, 2, 0, 3], [3, 1, 2, 0])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the tests do more than print the output?

That said, it would be awesome if you could add some checks/asserts and merge Laida's test_0 onto them

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we'd better use something like "yield_sequence" and then compare it's output with correct sequences somehow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants