School moving out (Day 1) 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 =&gt; [10, 20, 30], classrooms capacity =&gt; [31, 12, 20]
Output: True

Input: groups of students =&gt; [10, 20, 30], classrooms capacity =&gt; [100, 200]
Output: False

Input: groups of students =&gt; [20, 10, 30], classrooms capacity =&gt; [20, 20, 50, 40]
Output: True

Input: groups =&gt; [30, 10, 30, 5, 100, 99], classrooms =&gt; [40, 20, 50, 40, 99, 99]
Output: False

Input: groups =&gt; [], classrooms =&gt; [10, 10, 10]
Output: True

Input: groups =&gt; [10, 10, 10], classrooms =&gt; []
Output: False

Input: groups =&gt; [], classrooms =&gt; []
Output: True

Input: groups =&gt; [10, 1], classrooms =&gt; [100]
Output: False

Input: groups =&gt; [10], classrooms =&gt; [100, 100]
Output: True

Input: groups =&gt; [1,2,3], classrooms =&gt; [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
Brachylog, 4 bytes

It's always nice to see a challenge and know brachylog is gonna beat everyone.
Takes current classes as input and new classrooms as output; It will output true if it finds a way to fit the students, false otherwise

p≤ᵐ⊆


Explanation

The code has 3 parts of which the order actually doesn't matter

≤ᵐ --&gt; projects each value to a value bigger/equal then input
⊆  --&gt; input is a ordered subsequence of output
p  --&gt; permutes the list so it becomes a unordered subsequence


Try it online!