Challenge Taken with permission from my University Code Challenge Contest
For some years now, the number of students in my school has been growing steadily. First the number of students was increased by classroom, but then it was necessary to convert some spaces for some groups to give classes there, such as the gym stands or, this last course, up to the broom room.
Last year the academic authorities got the budget to build a new building and started the works. At last they have finished and the new building can be used already, so we can move (the old building will be rehabilitated and will be used for another function), but it has caught us halfway through the course. The director wants to know if the move will be possible without splitting or joining groups, or that some students have to change groups.
Challenge
Given the amount of students of the current groups and the new classrooms (capacity), output a truthy value if it is possible to assign a different classroom, with sufficient capacity, to each of the current groups, or a falsey value otherwise.
Test Cases
Input: groups of students => [10, 20, 30], classrooms capacity => [31, 12, 20]
Output: True
Input: groups of students => [10, 20, 30], classrooms capacity => [100, 200]
Output: False
Input: groups of students => [20, 10, 30], classrooms capacity => [20, 20, 50, 40]
Output: True
Input: groups => [30, 10, 30, 5, 100, 99], classrooms => [40, 20, 50, 40, 99, 99]
Output: False
Input: groups => [], classrooms => [10, 10, 10]
Output: True
Input: groups => [10, 10, 10], classrooms => []
Output: False
Input: groups => [], classrooms => []
Output: True
Input: groups => [10, 1], classrooms => [100]
Output: False
Input: groups => [10], classrooms => [100, 100]
Output: True
Input: groups => [1,2,3], classrooms => [1,1,2,3]
Output: True
Notes
- You can take the input in any reasonable format
- You can output any Truthy/Falsey value (
1/0
,True/False
, etc...) - code-golf
g=[1,2,3], c=[1,1,2,3]
\$\endgroup\$0
a valid value for groups or classrooms? \$\endgroup\$