Why is my code not accepted for the elevator task problem. [closed]
up vote
0
down vote
favorite
I recently took a Codility test, the objective of the task is to count the number of time an elevator stop. Let us consider the following scenario :
A = [60, 80, 40] is the weight of each person,
B = [2, 3, 5] the floors,
X = 2 (max number of people allowed in the elevator) and
Y = 200 (max number of weight allowed at a time).
For this case, the solution would be N = 5, since the elevator took 60 plus 80 to floors number 2 and 3 (2 stops), then came back to 0 (3 stops), it went to 5 (4 stops) and it returned to 0 ( 5 stops).
My codes compiled and it worked with the example cases given during the test. However, I received a very low grade for this task. I will appreciate it if someone can help me figure out the problem with my code. Thanks in advance.
def solution (A, B, M, X, Y):
original = X
count = 1
N = len(A)
while N > 0:
if sum(A[:X]) <= Y:
count = count + len(B[:X]) + 1
N = N - len(B[:X])
reVal = A
reM = A[:X]
final_list = list(set(reVal).difference(set(reM)))
A = final_list
reVal1 = B
reM1 = A[:X]
final_list2 = list(set(reVal1).difference(set(reM1)))
B = final_list2
X = original
else:
X = X - 1
continue
return(count)
python
migration rejected from stackoverflow.com Nov 16 at 1:55
This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.
closed as unclear what you're asking by Jamal♦ Nov 16 at 1:55
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
comments disabled on deleted / locked posts / reviews |
up vote
0
down vote
favorite
I recently took a Codility test, the objective of the task is to count the number of time an elevator stop. Let us consider the following scenario :
A = [60, 80, 40] is the weight of each person,
B = [2, 3, 5] the floors,
X = 2 (max number of people allowed in the elevator) and
Y = 200 (max number of weight allowed at a time).
For this case, the solution would be N = 5, since the elevator took 60 plus 80 to floors number 2 and 3 (2 stops), then came back to 0 (3 stops), it went to 5 (4 stops) and it returned to 0 ( 5 stops).
My codes compiled and it worked with the example cases given during the test. However, I received a very low grade for this task. I will appreciate it if someone can help me figure out the problem with my code. Thanks in advance.
def solution (A, B, M, X, Y):
original = X
count = 1
N = len(A)
while N > 0:
if sum(A[:X]) <= Y:
count = count + len(B[:X]) + 1
N = N - len(B[:X])
reVal = A
reM = A[:X]
final_list = list(set(reVal).difference(set(reM)))
A = final_list
reVal1 = B
reM1 = A[:X]
final_list2 = list(set(reVal1).difference(set(reM1)))
B = final_list2
X = original
else:
X = X - 1
continue
return(count)
python
migration rejected from stackoverflow.com Nov 16 at 1:55
This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.
closed as unclear what you're asking by Jamal♦ Nov 16 at 1:55
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
The current question title, which states your concerns about the code, is too general to be useful here. Please edit to the site standard, which is for the title to simply state the task accomplished by the code. Please see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
Nov 15 at 16:23
comments disabled on deleted / locked posts / reviews |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I recently took a Codility test, the objective of the task is to count the number of time an elevator stop. Let us consider the following scenario :
A = [60, 80, 40] is the weight of each person,
B = [2, 3, 5] the floors,
X = 2 (max number of people allowed in the elevator) and
Y = 200 (max number of weight allowed at a time).
For this case, the solution would be N = 5, since the elevator took 60 plus 80 to floors number 2 and 3 (2 stops), then came back to 0 (3 stops), it went to 5 (4 stops) and it returned to 0 ( 5 stops).
My codes compiled and it worked with the example cases given during the test. However, I received a very low grade for this task. I will appreciate it if someone can help me figure out the problem with my code. Thanks in advance.
def solution (A, B, M, X, Y):
original = X
count = 1
N = len(A)
while N > 0:
if sum(A[:X]) <= Y:
count = count + len(B[:X]) + 1
N = N - len(B[:X])
reVal = A
reM = A[:X]
final_list = list(set(reVal).difference(set(reM)))
A = final_list
reVal1 = B
reM1 = A[:X]
final_list2 = list(set(reVal1).difference(set(reM1)))
B = final_list2
X = original
else:
X = X - 1
continue
return(count)
python
I recently took a Codility test, the objective of the task is to count the number of time an elevator stop. Let us consider the following scenario :
A = [60, 80, 40] is the weight of each person,
B = [2, 3, 5] the floors,
X = 2 (max number of people allowed in the elevator) and
Y = 200 (max number of weight allowed at a time).
For this case, the solution would be N = 5, since the elevator took 60 plus 80 to floors number 2 and 3 (2 stops), then came back to 0 (3 stops), it went to 5 (4 stops) and it returned to 0 ( 5 stops).
My codes compiled and it worked with the example cases given during the test. However, I received a very low grade for this task. I will appreciate it if someone can help me figure out the problem with my code. Thanks in advance.
def solution (A, B, M, X, Y):
original = X
count = 1
N = len(A)
while N > 0:
if sum(A[:X]) <= Y:
count = count + len(B[:X]) + 1
N = N - len(B[:X])
reVal = A
reM = A[:X]
final_list = list(set(reVal).difference(set(reM)))
A = final_list
reVal1 = B
reM1 = A[:X]
final_list2 = list(set(reVal1).difference(set(reM1)))
B = final_list2
X = original
else:
X = X - 1
continue
return(count)
python
python
asked Nov 14 at 13:00
dawarlord
migration rejected from stackoverflow.com Nov 16 at 1:55
This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.
closed as unclear what you're asking by Jamal♦ Nov 16 at 1:55
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
migration rejected from stackoverflow.com Nov 16 at 1:55
This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.
closed as unclear what you're asking by Jamal♦ Nov 16 at 1:55
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
The current question title, which states your concerns about the code, is too general to be useful here. Please edit to the site standard, which is for the title to simply state the task accomplished by the code. Please see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
Nov 15 at 16:23
comments disabled on deleted / locked posts / reviews |
The current question title, which states your concerns about the code, is too general to be useful here. Please edit to the site standard, which is for the title to simply state the task accomplished by the code. Please see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
Nov 15 at 16:23
The current question title, which states your concerns about the code, is too general to be useful here. Please edit to the site standard, which is for the title to simply state the task accomplished by the code. Please see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
Nov 15 at 16:23
The current question title, which states your concerns about the code, is too general to be useful here. Please edit to the site standard, which is for the title to simply state the task accomplished by the code. Please see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
Nov 15 at 16:23
comments disabled on deleted / locked posts / reviews |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
The current question title, which states your concerns about the code, is too general to be useful here. Please edit to the site standard, which is for the title to simply state the task accomplished by the code. Please see How to get the best value out of Code Review: Asking Questions for guidance on writing good question titles.
– Toby Speight
Nov 15 at 16:23