Created
March 3, 2017 13:41
-
-
Save darkaico/e37ea58cf47f69d51793dcaa38a1931e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def assign_marker(people_to_mark, marker_index): | |
result = list(people_to_mark) | |
for idx, i in enumerate(people_to_mark): | |
if marker_index < len(result): | |
marker_index = marker_index + 1 | |
if marker_index < len(result): | |
del result[marker_index] | |
else: | |
del result[0] | |
break | |
else: | |
marker_index = 0 | |
break | |
if len(result) == 1: | |
return result[0] | |
else: | |
return assign_marker(result, marker_index) | |
# Tests 4 Personas | |
# Resultado esperado: 5 | |
people = [i for i in range(1, 5)] | |
result = assign_marker(people, 0) | |
print result == 1 | |
# Tests 10 Personas | |
# Resultado esperado: 5 | |
people = [i for i in range(1, 11)] | |
result = assign_marker(people, 0) | |
print result == 5 | |
# 16 personas | |
# Resultado esperado: 1 | |
people = [i for i in range(1, 17)] | |
result = assign_marker(people, 0) | |
print result == 1 | |
# 100 Personas | |
people = [i for i in range(1, 101)] | |
result = assign_marker(people, 0) | |
print 'Result: %s' % result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment