curriculum/challenges/english/blocks/daily-coding-challenges-python/697a49e9860d24853adef67c.md
Given an array representing the weights of the athletes on a bobsled team and a number representing the weight of the bobsled, determine whether the team is eligible to race.
The bobsled (sled by itself) must have a minimum weight of:
The total weight of the bobsled (athletes plus sled) must not exceed:
Return "Eligible" if the team meets all the requirements, or "Not Eligible" if the team fails to meet one or more of the requirements.
check_eligibility([78], 165) should return "Eligible".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(check_eligibility([78], 165), "Eligible")`)
}})
check_eligibility([80], 160) should return "Not Eligible".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(check_eligibility([80], 160), "Not Eligible")`)
}})
check_eligibility([80], 170) should return "Not Eligible".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(check_eligibility([80], 170), "Not Eligible")`)
}})
check_eligibility([85, 90], 170) should return "Eligible".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(check_eligibility([85, 90], 170), "Eligible")`)
}})
check_eligibility([85, 95], 168) should return "Not Eligible".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(check_eligibility([85, 95], 168), "Not Eligible")`)
}})
check_eligibility([112, 97], 185) should return "Not Eligible".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(check_eligibility([112, 97], 185), "Not Eligible")`)
}})
check_eligibility([110, 102, 90, 106], 222) should return "Eligible".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(check_eligibility([110, 102, 90, 106], 222), "Eligible")`)
}})
check_eligibility([106, 99, 90, 88], 205) should return "Not Eligible".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(check_eligibility([106, 99, 90, 88], 205), "Not Eligible")`)
}})
check_eligibility([106, 99, 103, 96], 227) should return "Not Eligible".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(check_eligibility([106, 99, 103, 96], 227), "Not Eligible")`)
}})
def check_eligibility(athlete_weights, sled_weight):
return athlete_weights
def check_eligibility(athlete_weights, sled_weight):
team_size = len(athlete_weights)
rules = {
1: {"min_sled": 162, "max_total": 247},
2: {"min_sled": 170, "max_total": 390},
4: {"min_sled": 210, "max_total": 630}
}
min_sled = rules[team_size]["min_sled"]
max_total = rules[team_size]["max_total"]
total_weight = sum(athlete_weights) + sled_weight
if sled_weight < min_sled:
return "Not Eligible"
if total_weight > max_total:
return "Not Eligible"
return "Eligible"