-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lecture "Brute-force argorithms", exercise 3 #19
Comments
Here is my version of enumerate function.
Here is the visualization of how the function works Below is the test code for the above written algorithm -
Here you can see the test code in action note: I don't think this is the most elegant or even the complete method for testing the algorithm, but its the best I could come up with. |
It returns:
|
|
If the code is run, the results |
|
|
Task_3
Returns |
def test_my_enumerate(input_list, expected): my_list = ("a", "b", "c") def my_enumerate(input_list): print(test_my_enumerate(my_list, [(0, "a"), (1, "b"), (2, "c")])) True |
def test_my_enumerate(input_list, expected): def my_enumerate(input_list): return output_list print(my_enumerate_test([1, 2, 3, 4], [(0, 1), (1,2), (2,3), (3,4)])) |
|
Hi all, Just a few general and specific comments:
|
|
Hello, @essepuntato I tried to run my algorithm with the input list At first I thought to delete the item analysed at every iteration, but again, it did not seem to work, as the other elements shifted (changing all the indexes). The output was: I found this solution, that seems to work!
I think it's much easier to understand by looking at the code! I really hope I made no mistakes...
|
OUTPUT:
|
Write in Python the function
def my_enumerate(input_list)
, which behaves like the built-in functionenumerate()
introduced in Section "Linear search" and returns a proper list, and accompany the function with the related test case. It is not possible to use the built-in functionenumerate()
in the implementation.The text was updated successfully, but these errors were encountered: