[Question]
      [
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](/questions/tagged/code-golf "show questions tagged 'code-golf'")

[Answer]
# [Brachylog](https://github.com/JCumin/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
```
≤ᵐ --> projects each value to a value bigger/equal then input
⊆  --> input is a ordered subsequence of output
p  --> permutes the list so it becomes a unordered subsequence
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r/v@BR55KHWyc86mr7/z/aUMdIxzgWRENYAA "Brachylog – Try It Online")
[Answer]
# Pyth, 11 bytes
```
.AgM.t_DMQ0
```
Takes input as a list of lists, classroom sizes first, group sizes second. Try it online [here](https://pyth.herokuapp.com/?code=.AgM.t_DMQ0&input=%5B%5B31%2C%202%2C%2021%2C%201%5D%2C%5B10%2C%2020%2C%2030%5D%5D&debug=0), or verify all the test cases at once [here](https://pyth.herokuapp.com/?code=.AgM.t_DMQ0&test_suite=1&test_suite_input=%5B%5B31%2C%2012%2C%2020%5D%2C%5B10%2C%2020%2C%2030%5D%5D%0A%5B%5B100%2C%20200%5D%2C%5B10%2C%2020%2C%2030%5D%5D%0A%5B%5B20%2C%2020%2C%2050%2C%2040%5D%2C%5B20%2C%2010%2C%2030%5D%5D%0A%5B%5B40%2C%2020%2C%2050%2C%2040%2C%2099%2C%2099%5D%2C%5B30%2C%2010%2C%2030%2C%205%2C%20100%2C%2099%5D%5D%0A%5B%5B10%2C%2010%2C%2010%5D%2C%5B%5D%5D%0A%5B%5B%5D%2C%5B10%2C%2010%2C%2010%5D%5D%0A%5B%5B%5D%2C%5B%5D%5D%0A%5B%5B100%5D%2C%5B10%2C%201%5D%5D%0A%5B%5B100%2C%20100%5D%2C%5B10%5D%5D%0A%5B%5B1%2C1%2C2%2C3%5D%2C%5B1%2C2%2C3%5D%5D&debug=0).
```
.AgM.t_DMQ0   Implicit: Q=eval(input())
      _DMQ    Sort each element of Q in reverse
    .t    0   Transpose, padding the shorter with zeroes
  gM          Element wise test if first number >= second number
.A            Are all elements truthy? Implicit print
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
Takes the classrooms as first argument and the groups as second argument.
```
Œ!~+Ṡ‘ḌẠ¬
```
[Try it online!](https://tio.run/##y0rNyan8///oJMU67Yc7FzxqmPFwR8/DXQsOrfn//3@0oY6hjpGOcSyIBaIB "Jelly – Try It Online")
### Commented
*NB: This `Ṡ‘ḌẠ¬` is far too long. But I suspect that this is not the right approach anyway.*
```
Œ!~+Ṡ‘ḌẠ¬  - main link taking the classrooms and the groups e.g. [1,1,2,3], [1,2,3]
Œ!         - computes all permutations of the classrooms    -->  [..., [1,2,3,1], ...]
  ~        - bitwise NOT                                    -->  [..., [-2,-3,-4,-2], ...]
   +       - add the groups to each list; the groups fits   -->  [..., [-1,-1,-1,-2], ...]
             in a given permutation if all resulting values
             are negative
    Ṡ      - take the signs                                 -->  [..., [-1,-1,-1,-1], ...]
     ‘     - increment                                      -->  [..., [0,0,0,0], ...]
      Ḍ    - convert from decimal to integer                -->  [..., 0, ...]
       Ạ   - all truthy?                                    -->  0
        ¬  - logical NOT                                    -->  1
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 9 bytes
```
ñÍí§Vñn)e
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.6&code=8c3tp1bxbill&input=WzEsMiwzXQpbMSwxLDIsM10=) or [run all test cases on TIO](https://tio.run/##y0osKPnvl35oQwgXmPx/eOPh3sNrDy0PO7wxTzP1/39DA65oQwMdIwMdY4NYnWhjQx1DIyAvFkXU0ADEBgkCRQyhgkZgeVMDHROQhDFUQsdUB6Ta0hKowgShAigAEuOKBpumA0YQOyBMnWiIHFQMYieYA7UeytUx0jEGiehAWFy6uUEA)
```
ñÍí§Vñn)e     :Implicit input of arrays U=students, V=classrooms
ñ             :Sort U by
 Í            :  Subtracting each integer from 2
  í           :Interleave with
    Vñn       :  V sorted by negating each integer
   §          :  Reduce each pair by checking if the first is <= the second
       )      :End interleaving
        e     :All true?
```
---
```
ñÍeÈ§Vn o
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.6&code=8c1lyKdWbiBv&input=WzEsMiwzXQpbMSwxLDIsM10=) or [run all test cases on TIO](https://tio.run/##y0osKPnvl35oQwgXmPx/eOPh3tTDHYeWh@Up5P//b2jAFW1ooGNkoGNsEKsTbWyoY2gE5MWiiBoagNggQaCIIVTQCCxvaqBjApIwhkromOqAVFtaAlWYIFQABUBiXNFg03TACGIHhKkTDZGDikHsBHOg1kO5OkY6xiARHQiLSzc3CAA)
```
ñÍeÈ§Vn o     :Implicit input of arrays U=students, V=classrooms
ñ             :Sort U by
 Í            :  Subtracting each integer from 2
  e           :Does every element return true
   È          :When passed through the following function
    §         :  Less than or equal to
     Vn       :  Sort V
        o     :  Pop the last element
```
[Answer]
# [Python 2](https://docs.python.org/2/), 49 bytes
Outputs by exit code, fails for falsy input.
```
g,r=map(sorted,input())
while g:g.pop()>r.pop()>y
```
[Try it online!](https://tio.run/##XY4xj4MwDIX3/AqLCaToREJvKFK7lfWWbqgDRy2K2pLIDbry67k4pKh3g/Xi9z3HtpO7mEHPrTkj7CBJkrmTtLs3Nn0YcniW/WBHl2aZ@Ln0N4Su7D6ssWm2p6jT7KciPdKIpQBwNLEA4BNb4M9DZ6kfXAgJRi1aB4ev6kBkaMl/EzbXNxikN0P5Nl81twfOtcolaF9FfpJQF0qC0uycxD@k8tAyYFOtQMfYp68N42LF3uSn1@2Wo5s/UXYDEfWyYBlTr92x8SgmXn48J7TradGQWhbBk8vzFw "Python 2 – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), 10 bytes
```
yn&Y@>~!Aa
```
[Try it online!](https://tio.run/##y00syfn/vzJPLdLBrk7RMfH//2gjAx0FQyA2NojlAnNA2BSITQxiAQ) Or [verify all test cases](https://tio.run/##y00syfmf8L8yTy3Swa5O0THxv0vI/2hDAx0FIyA2NojlijY21FEwNAIJADkoMoYGYB6ICRIzhIkbQRWZArEJ2Ai4LFAQxATSlpZACRMUlSBBqATUKghG58ARWATiEDAJcxOUr2OkYwymISwA).
### Explanation
Consider inputs `[20, 10, 30]`, `[20, 20, 50, 40]` as an example. Stack is shown bottom to top.
```
y     % Implicit inputs. Duplicate from below
      % STACK: [20 10 30]
               [20 20 50 40]
               [20 10 30]
n     % Number of elements
      % STACK: [20 10 30]
               [20 20 50 40]
               3
&Y@   % Variations. Gives a matrix, each row is a variation
      % STACK: [20 10 30]
               [20 10 30
                20 20 40
                20 20 40
                ···
                50 40 20]
>~    % Less than? Element-wise with broadcast
      % STACK: [1 1 1
                1 1 1
                1 1 1
                ···
                1 1 0]
!     % Transpose
      % STACK: [1 1 1 ··· 0
                1 1 1 ··· 1
                1 1 1 ··· 1]
A     % All. True for columns that only contain nonzeros
      % STACK: [1 1 1 ··· 0]
a     % Any. True if the row vector contains at least a nonzero. Implicit display
      % STACK: 1
```
[Answer]
# [Haskell](https://www.haskell.org/), 40 bytes
```
c%l=[1|x<-l,x>=c]
s#g=and[c%s<=c%g|c<-s]
```
[Try it online!](https://tio.run/##dY/BCoMwEETvfsWCFVpYIYl6UIyH3voNIQeJxUpTLdWDB/89TVQQqoUcJjNvNtlH2T/vWhujAs0FncY81DgWXEmv92tetpVQQZ9zFdSTysNemrN/gSwDcWsHCWGxiWvXae9VNi1wqDoP3p@mHeAEriAoQUYwIhJERJEye5P/EUqc3hE2pivBZjghGO@oaKUwQTcnTS0eb7g1nPdTmh/F@Rz8a/EttW8d0csG@2Td7ChDhpGLcVHmCw "Haskell – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~14~~ ~~12~~ 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
€{í0ζÆdP
```
Port of [*@Sok*'s Pyth answer](https://codegolf.stackexchange.com/a/179562/52210), so make sure to upvote him as well!
Takes the input as a list of lists, with the classroom-list as first item and group-list as second item.
[Try it online](https://tio.run/##yy9OTMpM/f//UdOa6sNrDc5tO9yWEvD/f3S0oY6hjpGOcaxONISOBQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/R01rqg@vNTi37XBbSsB/nf/R0dHGhjoKhkY6CkYGsTrRhgYgho6CsUFsrI5CNJAPFjAAcdDljKB8UyA2AasA8QyRVJigqNBRsLQEYaA1xnCFQEkQEywJsxIiZwg2EiIGsx4qDheDOxKuAMnZcGGomI6hjpGOMVgIzIiNBQA).
**Explanation:**
```
€{         # Sort each inner list
  í        # Reverse each inner list
   0ζ      # Zip/transpose; swapping rows/columns, with 0 as filler
     Æ     # For each pair: subtract the group from the classroom
      d    # Check if its non-negative (1 if truthy; 0 if falsey)
       P   # Check if all are truthy by taking the product
           # (and output implicitly)
```
---
**Old 12-byte answer:**
```
æε{I{0ζÆdP}à
```
Takes the classroom-list first, and then the group-list.
[Try it online](https://tio.run/##yy9OTMpM/f//8LJzW6s9qw3ObTvclhJQe3jB///RhjqGOkY6xrFc0RAaAA) or [verify all test cases](https://tio.run/##yy9OTMpM/W9o4ObpYq@kkJiXoqBk73l4QiiQ86htEpBT/P/wsnNbqyOqDc5tO9yWElB7eMF/nf/RxoY6CoZGOgpGBrFc0YYGIIaOgjGEA@ZhiBtBOaZAbAITMITJmqDI6ihYWoIwUMIYrgooCWIaQCUMoRKGIO0QhFUI5hBDmNtgQiBCx1DHSMcYzALRAA).
**Explanation:**
```
æ             # Take the powerset of the (implicit) classroom-list,
              # resulting in a list of all possible sublists of the classrooms
 ε            # Map each classroom sublist to:
  {           #  Sort the sublist
   I{         #  Take the group-list input, and sort it as well
     0ζ       #  Transpose/zip; swapping rows/columns, with 0 as filler
       Æ      #  For each pair: subtract the group from the classroom
        d     #  Check for everything if it's non-negative (1 if truthy; 0 if falsey)
         P    #  Check if all are truthy by taking the product
          }à  # After the map: check if any are truthy by getting the maximum
              # (and output the result implicitly)
```
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~77~~ 74 bytes
```
a=>b=>a.Count==a.OrderBy(x=>-x).Zip(b.OrderBy(x=>-x),(x,y)=>x>y?0:1).Sum()
```
[Try it online!](https://tio.run/##jZJRa4MwEMff/RR5TCCVRLuHrk0KGwwGgw32tuJDdMqEVUcSN6Xss7tLLaKW1aIhuf/d/xc8LzGLxOTtQ1Ukm8en3NhNXlhJp3Fclp9SZqJVQsZCKv@@rAorhPKf9Xuq7xpcC7moif@Wf@F4IlJc04YIWctmy2458V@rPSbt2vOAvYvcg2xqrEECFekP6tWDNwgHwYEzigJYIfulAznkFPHApUAeZq5yc3bUL3udj597gxPyBtbyMiHsCVDujrCvViPackRz6VPJ/9TJl3RX8Pk@9GUj1JX3zNOnDZ5xnP@PWQ90Cno5NoKtl90Lk5aVOlXJB/5W@jhrUNrNHPEQetFgxBl2wo5FpDvwiJB1@wc "C# (Visual C# Interactive Compiler) – Try It Online")
Commented code:
```
// a: student group counts
// b: classroom capacities
a=>b=>
  // compare the number of student
  // groups to...
  a.Count==
  // sort student groups descending
  a.OrderBy(x=>-x)
     // combine with classroom
     // capacities sorted descending
     .Zip(
        b.OrderBy(x=>-x),
        // the result selector 1 when
        // the classroom has enough
        // capacity, 0 when it doesn't
        (x,y)=>x<y?0:1
     )
     // add up the 1's to get the number
     // of student groups who can fit
     // in a classroom
     .Sum()
```
[Answer]
## Haskell, 66 bytes
```
import Data.List
q=sortOn(0-)
x#y=and$zipWith(<=)(q x)$q y++(0<$x)
```
[Try it online!](https://tio.run/##dY89C4MwEIZ3f8WBDgm9lsToIJitY6FjB3EIWDDUbzNo/7yNH1CoFm64e9/nvnLVv55FMU26bOrOwFUZdbnp3jit7K1wrwg7U2dwR6mqzHvr5qFNTmJJSQsD9VoYTyfCYm@gU6l0BRKy2oGm05UBD4hLIeEMfYaCpZAIjty3Vfof4WzOd4S1@Ub4CxwyDHaU2CgMcZ4TRRYPvrgVZu2naVmKSxzcteqW2ncd0esHe2f77MhDH8Vs45pNHw "Haskell – Try It Online")
[Answer]
# Bash + GNU tools, 68 bytes
```
(sort -nr<<<$2|paste -d- - <(sort -nr<<<$1)|bc|grep -- -)&>/dev/null
```
69 bytes
```
(paste -d- <(sort -nr<<<$2) <(sort -nr<<<$1)|bc|grep -- -)&>/dev/null
```
[TIO](https://tio.run/##VY1JCoMwGIX3/ykeRbQuQgZ1IZX2It3YJtSCqCQdFrVnt4mWDhCS7w28HGrXTPfm3BpYU2s4xPFCdgPdkzMXMIZV9HCcg0fJvkueq6Dtj6Zp7Xrrm52tqipS41C7iwHTDAzVXybT8XAcT9YMYZel8ZZrc@PdtW0nc2x6RDvSfWdokgJKIBOUSUjlmT6OFIEEeSVnQ81JIZD7@ttEgdArS8q/qZfBCVPz@QItZtgmuXwxIxQyfy/vCw)
takes student rooms as first and second argument as string numbers delimited by newline
returns exit status 1 for true or 0 for false
[Answer]
# [Perl 5](https://www.perl.org/) `-pal`, ~~67~~ 62 bytes
*@NahuelFouilleul saved 5 bytes with a rearrangement and a grep*
```
$_=!grep$_>0,map$_-(sort{$b-$a}@F)[$x++],sort{$b-$a}<>=~/\d+/g
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lYxvSi1QCXezkAnNxFI62oU5xeVVKsk6aok1jq4aUarVGhrx@ogCdrY2dbpx6Ro66f//29ooGBkoGBswGVsoGBopGBo8C@/oCQzP6/4v66vqZ6BocF/3YLEHAA "Perl 5 – Try It Online")
[67 bytes version](https://tio.run/##K0gtyjH9/9@hyDY3saBaozi/qKRaJUlXJbHWwU0zWltbRbkkVlclvhZJwsbOtk4/JkVbP91aJd5WyaFISbFOX1f//39DAwUjAwVjAy5jAwVDIwVDg3/5BSWZ@XnF/3V9TfUMDA3@6xYk5gAA "Perl 5 – Try It Online")
Takes the space separated list of class sizes on the first line and the space separated list of room sizes on the next.
[Answer]
# Common Lisp, 74 bytes
`(defun c(s r)(or(not(sort s'>))(and(sort r'>)(<=(pop s)(pop r))(c s r))))`
## Non-minified
```
(defun can-students-relocate (students rooms)
  (or (not (sort students #'>))
      (and (sort rooms #'>)
           (<= (pop students)
               (pop rooms))
           (can-students-relocate students rooms))))
```
[Test it](https://rextester.com/NMOUG17878)
Note that sort permanently mutates the list, and pop rebinds the variable to the next element.
In effect this just recursively checks that the largest student group can fit in the largest room. There are 3 base-cases:
1. No students - return T
2. Students, but no rooms - return NIL
3. Students and rooms, but largest student group larger than largest room - return NIL
[Answer]
# [Python 2](https://docs.python.org/2/), ~~71~~ ~~67~~ 64 bytes
```
lambda g,c:s(g)==s(map(min,zip(s(g)[::-1],s(c)[::-1])))
s=sorted
```
[Try it online!](https://tio.run/##dZA5DoMwEEV7TmEpjS1NJMaQAiS3OUE6QkHYgsQmTIrk8sQGQxbhYuRZ3v/2uH@O967lUyGuU500tywhJaShpCUTQtIm6WlTtfCqeqp7URgeMQZJU5MyxhwpZDeMeTb1Q9WOpKARukC4Cs@NgUQeAkGuOzEjB3IZHrnjWFh053Ihz0ktv1GN4YZyIzyp8HetvY1XlE7VGQRa6/9odXee7F26vGoxQusGZqpYq4lVavbeFeLnV1bk3wI4eDMES7oy0xs "Python 2 – Try It Online")
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 50 bytes
```
\d+
$*
%O^`1+
%`$
,
^((1*,)(?=.*¶((?>\3?)1*\2)))*¶
```
[Try it online!](https://tio.run/##RY5NCgIxDIX3OccU0k6QpJ1ZDEV7BBduy1BBF25cyJzNA3ixmhZ/4EG@vBeSPK7b7X6uBk8l1nwZYXBgjmuREUwZgGBFFEcW037nXk/EdMghWXHZW2vVqVWYPFPgGITEK8PPEW7EoJ10w/dkZpoYwsekmdrcssTpn2qrAt1AXfCFCLFz263QT3QkTyHqB62@AQ "Retina 0.8.2 – Try It Online") Link includes test suite. Takes two lists of groups and rooms (test suite uses `;` as list separator). Explanation:
```
\d+
$*
```
Convert to unary.
```
%O^`1+
```
Reverse sort each list separately.
```
%`$
,
```
Append a comma to each list.
```
^((1*,)(?=.*¶((?>\3?)1*\2)))*¶
```
Check that each of the numbers in the first list can be matched to the appropriate number in the second list. Each time `\3` contains the previously matched rooms and the next group `\2` therefore needs to be able to fit into the next room. The `(?>\3?)` handles the case of the first room when there are no previous rooms yet.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 28 bytes
```
Ｗ∧⌊θ¬›⌈§θ¹⌈§θ⁰ＵＭθΦκ⁻ν⌕κ⌈κ¬⊟θ
```
[Try it online!](https://tio.run/##bY47C8MwDIT3/gqPMrjg9DF1CoWWDinZgweTGGLiR@I6bf69K3vpUsEt3@lO6kcZei9NSp9RG0WgdgM02mm7WlgoI08f4R6UjCpAI7fC6/hwg9pgYaSiuPOHc1oGrfnqrZXYivSmTe6ZMKLd@gKXEVrTr2MqucuuDdpFyNdbP@MnyFLquu7AGck6o05cMFJIhTpyIUTav80X "Charcoal – Try It Online") Link is to verbose version of code. Takes a list of lists of rooms and groups and outputs `-` if the rooms can accommodate the groups. Explanation:
```
Ｗ∧⌊θ¬›⌈§θ¹⌈§θ⁰
```
Repeat while a group can be assigned to a room.
```
ＵＭθΦκ⁻ν⌕κ⌈κ
```
Remove the largest room and group from their lists.
```
¬⊟θ
```
Check that there are no unallocated groups remaining.
[Answer]
# JavaScript, 56 bytes
```
s=>c=>s.sort(g=(x,y)=>y-x).every((x,y)=>c.sort(g)[y]>=x)
```
[Try it](https://tio.run/##ZZBBDoIwEEX3nMJlm4y1BVy4KEtP4K42kWAhGqSGIqGnxxaoRkm6mP7/5nc697zPTdHent220Vc1lnw0PCt4ZojRbYcqjgawmGd2O2CietVatCjFQmBhZcYHPBa6MbpWpNYVElEkBKMQU0ioBJEwYLG7SQmb3W5zal/qF2DU18E/5rXxgHPZAsQTu6eQ/oUkCwN78CGHg4PTL@wEr00tIXZ6D6YzG995ZhHEqmEFzkP/cix85eOEBogh8R7MlQxWJMkjfyIk3FKl22qJBowsxuSub83l3Fzw@AY)
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 34 bytes
```
{none [Z>] $_>>.sort(-*)>>[^.[0]]}
```
[Try it online!](https://tio.run/##rZBRa4MwFIWf56@4FFm1pGq0G3Rgyh42GAz6MvYw60Z0OgpqxOiDtP3tzmQyKnWrjD1cEsg53zk3eVQk101aw2UMLjS7jGUReC/EB/WNEIOzotTmM50Q79XwLN8/NDErQEu2WcR1mBNQKQI1aCd0JxPYKRec1rCKNZUaIUsDzdx4xmy18c2WYdw93z7qCKbCOEV7Neg0T0UV7e9pwiNTVw7NQ5ZX5Q18FKzKObAYeFm9R1nJwSXgYQuB3Y5j@QjChHJeMJZyCGlOw21ZS5GDEWBbCH1lXZWSJ1IU5R/g2JKqI7Tsfo4tuPgc2@4KXLWzOFNeLvoNbT3i2p7LZT9A6BY9rtBI3e8bCOMpCneReES9I@0J50/hIyOHWlsjAod6yj/t2X@MRjZyBgDo66Hn/wQ "Perl 6 – Try It Online")
Takes input as a list of two lists, the groups and the classrooms, and returns a None Junction that can be boolified to true/false.
### Explanation:
```
{                                }   # Anonymous code block
           $_>>.sort(-*)             # Sort both lists from largest to smallest
                        >>[^.[0]]    # Pad both lists to the length of the first list
 none                                # Are none of
      [Z>]                           # The groups larger than the assigned classroom
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), 57 bytes
```
->c,r{r.permutation.any?{|p|c.zip(p).all?{|a,b|b&&a<=b}}}
```
[Try it online!](https://tio.run/##ZZBBCoMwEEX3nsJVaWEaTGIXQm0PErKIolSwNogurPHsdhJTtXQxzMz7f8gnbZ8Nc5nO51sO7dgSXbTPvlNd9WqIaob7aLTJybvSR30iqq4RKMhMdjioa5pN0zSLQAgaQciweCQhFJxCSJklUsKfSiO3es1yumrMOy9YsXfw1YHcjtiTxLrjH7elTnFXy0vLJd3l8Duqm2@n@oBfsubdGDDgDsMyykCSQuWP0eAHGh2WAruc5g8 "Ruby – Try It Online")
Takes `c` for classes, `r` for rooms. Checks all permutations of rooms instead of using sort, because reverse sorting costs too many bytes. Still looks rather long though...
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~105~~ ~~93~~ ~~91~~ ~~82~~ ~~81~~ ~~79~~ ~~77~~ ~~76~~ 74 bytes
Now matches dana's score!
```
n=>m=>{n.Sort();m.Sort();int i=m.Count-n.Count;i/=n.Any(b=>m[i++]<b)?0:1;}
```
Throws an error if false, nothing if true.
-12 bytes thanks to @Destrogio!
[Try it online!](https://tio.run/##pZBNi4MwEIbv/gqPSq012h7amJRS2FNve9jDsoc2KB2oI@hIKZLfbpN@sq0syB6GGeZ9M89MVD1WNXQfDap0AzWlgCSDlSIo8dmQMhcdClkI2WL4WVbk@by4F8bhgijCddkgjfGaOUwEhis8eTvz7htGo5905y@jBeO64w5Vp9bJPcyO7oPSsihwYxNJpP0XKWGBy2Ira587XxVQtgHMPKqazDS0o7ak9u1TyLeH2ih6MIlFF62X8wfmwnnFWATrx8S3DWYmphY2gNWHSh4oM9OWJs/nb9jpL6y1XG38v6f2/KPdYtDk7gw "C# (Visual C# Interactive Compiler) – Try It Online")
# Explanation
```
//Function taking in a list, and returning another function
//that takes in a list and doesn't return
n=>m=>{
  //Sort the student groups from smallest to largest
  n.Sort();
  //Sort the classrooms fom smallest capacity to largest
  m.Sort();
  //Initialize a variable that will function as a sort of index
  int i=m.Count-n.Count;
  //And divide that by...
  i/=
    //0 if any of the student groups...
    n.Any(b=>
      //Don't fit into the corresponding classroom and incrementing i in the process
      /*(In the case that a the amount of classrooms are less than the amount of
      student groups, an IndexOutOfRangeException is thrown)*/
      m[i++]<b)?0
    //Else divide by 1
    :1;
}
```
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), 183 bytes
```
a->{int b=a[0].length;Arrays.sort(a[0]);Arrays.sort(a[1]);if(b>a[1].length){return false;}for(int i=0;i<b;i++){if(a[0][i]>a[1][i]){return false;}}return true;}
```
[Try it online!](https://tio.run/##tVBNa8MwDL33V@gYUzc4/TgUr4X9gPXSY8jBaZ3OXWoHx@koxr89k7PAoNDt0oFB0pPfe5LO4ipmppH6fPzo1aUx1sEZsbRzqk5frRW3lk8OtWhbeBNK@wmA0k7aShwk7HxpTC2FBpsgmhd5AYLwgJ9aJ5w6wA70Bnox23rsQ7kROSvSWuqTe@ff6mmLnknEyR2SIaKqpNzGdCQRb6XrrIZK1K3koTKDM6gN4@ql5Go6JR5JUS9XxUDFeE8LY@lsh1XPceCmK2sceJz7atQRLrhwsndW6VNeCBJ3B9jfWicvqelc2mDH1TrRqU20/ITxBN5njM4ZXbBAPcZsThdZCITwRwKPO79JZyzm7B@U50O6YnT5NPUF3iGq0xWNc6/XaLP8sUEgYk8yG45Dh/e3ZJiE/gs "Java (OpenJDK 8) – Try It Online")
With a little helpful advice from [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen/%22Kevin%20Cruijssen%22) and simply another glance over my code myself, I can decrease my score by a whole 9% just by replacing three English words!
# [Java (OpenJDK 8)](http://openjdk.java.net/), 166 bytes
```
a->{int b=a[0].length;Arrays.sort(a[0]);Arrays.sort(a[1]);if(b>a[1].length){return 0;}for(int i=0;i<b;){if(a[0][i]>a[1][i++]){return 0;}}return 1;}
```
[Try it online!](https://tio.run/##tVDLasMwELznK/ZoNYqQ8zgENYF@QHPJ0fggJ0oq15GNLKcEoW93V8bQUkh7SUFIw@zuzKxKeZWzulGmPL73@tLU1kGJHOucrtiTmBwq2bbwKrXxEwBtnLIneVCw84jBJnhneZaDJCJgQ@uk0wfYgdlAL2fboavYyIznrFLm7N7Ei7Xy1rIWrZLIkx9Miow@JcU2wnGIeKtcZw1wEU714Ap6w4V@LgTx2B2FMp0PM5meTvPvE2GEqQi9wJBNV1QYcsx6rfURLrhgsndWm3OWSxJ3BdjfWqcurO4ca7DiKpMYZhOjPmBc2/uU0zmnCx6oxzed00UaAiHinsD9ym/SKY@Y/4PyfIArTpcPU1/gP0R1uqIx93qNNssvGyQi9yCz4XPocP6WDJPQfwI "Java (OpenJDK 8) – Try It Online")
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 80 bytes
```
param($s,$c)!($s|sort -d|?{$_-gt($r=$c|?{$_-notin$o}|sort|select -l 1);$o+=,$r})
```
[Try it online!](https://tio.run/##dZJda4MwFIbv/RVZORsJi2C0u@iGzKv9gt0X0XQbpMYlkQ2qv90d48faYgMhOec875vPWv9IYz@lUj0cSEpOfZ2b/EjBcijYHY6t1caRsGxfT7APPxwFk0IxRpV2XxXozjOtlUoWiCoi2Avox5SD6VjfBUFGA4KN04yKiJMYexIxTjKaCE5EPKQwBGcayW6hIvKxB99yZc/IgRL/ZDwJn7BvPf9@YZwsODLDFMfdzku3F9IhPZWul5y2NBqJlUUuap5ftbghnE@8IhNn1zERVwY85snI8Hk@IYy05J6cPArWNaWsnMVqoXJrjdbHIZC/Nb6jLPE7wH5EjbSNcph4wF@yCM91ntsAndBQfi8@7Hk22ARd/wc "PowerShell – Try It Online")
Less golfed test script:
```
$f = {
param($students,$classrooms)
$x=$students|sort -Descending|where{
    $freeRoomWithMaxCapacity = $classrooms|where{$_ -notin $occupied}|sort|select -Last 1
    $occupied += ,$freeRoomWithMaxCapacity    # append to the array
    $_ -gt $freeRoomWithMaxCapacity           # -gt means 'greater than'. It's a predicate for the 'where'
}                                             # $x contains student groups not assigned to a relevant classroom
!$x                                           # this function returns a true if $x is empty
}
@(
    ,(@(10, 20, 30), @(31, 12, 20), $true)
    ,(@(10, 20, 30), @(100, 200), $False)
    ,(@(20, 10, 30), @(20, 20, 50, 40), $True)
    ,(@(30, 10, 30, 5, 100, 99), @(40, 20, 50, 40, 99, 99), $False)
    ,(@(), @(10, 10, 10), $True)
    ,(@(10, 10, 10), @(), $False)
    ,(@(), @(), $True)
    ,(@(10, 1), @(100), $False)
    ,(@(10), @(100, 100), $True)
    ,(@(1,2,3), @(1,1,2,3), $True)
) | % {
    $students, $classrooms, $expected = $_
    $result = &$f $students $classrooms
    "$($result-eq$expected): $result"
}
```
[Answer]
# [R](https://www.r-project.org/), 65 bytes
```
function(g,r)isTRUE(all(Map(`-`,sort(-g),sort(-r)[seq(a=g)])>=0))
```
[Try it online!](https://tio.run/##bVC9DoIwEN59ChKXu@RM2oIDAyYOOuniz2RMIAQaEgJa8PmR0gKCDJd@ve@nd1VNGjTpp4jrrCxAksKsul3uB4jyHM7RC8JNSFWpathItEDho0reEAUSn7gLGGKTQgyckSPachlSDC4nhwvdQXTWjs5c/as4665Gc9yfrkakBXwQCWvZtuXN4txB2fIatqfva5c3celux/w@lBV1IhMFZhITxBfmtX0a9MshE3oaYHedrcnHP@jJ0UaC3I4mA3u2@QI "R – Try It Online")
]


[Question]
      [
**Problem:**
Find the number of leading zeroes in a 64-bit signed integer
**Rules:**
* The input cannot be treated as string; it can be anything where math and bitwise operations drive the algorithm
* The output should be validated against the 64-bit signed integer representation of the number, regardless of language
* [Default code golf rules apply](https://codegolf.stackexchange.com/tags/code-golf/info)
* Shortest code in bytes wins
**Test cases:**
These tests assume two's complement signed integers. If your language/solution lacks or uses a different representation of signed integers, please call that out and provide additional test cases that may be relevant. I've included some test cases that address double precision, but please feel free to suggest any others that should be listed.
```
input                output   64-bit binary representation of input (2's complement)
-1                   0        1111111111111111111111111111111111111111111111111111111111111111
-9223372036854775808 0        1000000000000000000000000000000000000000000000000000000000000000
9223372036854775807  1        0111111111111111111111111111111111111111111111111111111111111111
4611686018427387903  2        0011111111111111111111111111111111111111111111111111111111111111
1224979098644774911  3        0001000011111111111111111111111111111111111111111111111111111111
9007199254740992     10       0000000000100000000000000000000000000000000000000000000000000000
4503599627370496     11       0000000000010000000000000000000000000000000000000000000000000000
4503599627370495     12       0000000000001111111111111111111111111111111111111111111111111111
2147483648           32       0000000000000000000000000000000010000000000000000000000000000000
2147483647           33       0000000000000000000000000000000001111111111111111111111111111111
2                    62       0000000000000000000000000000000000000000000000000000000000000010
1                    63       0000000000000000000000000000000000000000000000000000000000000001
0                    64       0000000000000000000000000000000000000000000000000000000000000000
```

[Answer]
# x86\_64 machine language on Linux, 6 bytes
```
0:       f3 48 0f bd c7          lzcnt  %rdi,%rax
5:       c3                      ret
```
Requires Haswell or K10 or higher processor with `lzcnt` instruction.
[Try it online!](https://tio.run/##S9ZNT07@/19DK01TQ9NWKabCzTimwsQipsLALabCySWmwtkciI2VrLlyEzPzNDSruQqKMvNK0jSUVFNi8pR00jQMfTQ1rTFEDcCitf///0tOy0lML/6vW5VakZpcXJKYnA0A "C (gcc) ‚Äì Try It Online")
[Answer]
# [Hexagony](https://github.com/m-ender/hexagony), ~~78~~ 70 bytes
```
2"1"\.}/{}A=<\?>(<$\*}[_(A\".{}."&.'\&=/.."!=\2'%<..(@.>._.\=\{}:"<><$
```
[Try it online!](https://tio.run/##BcFBDkAwEAXQs5jQNha/WMq09BwmaSyEFVvSzNnrvet49/O5v1onGkmgvmgKLEt03EqvW3ZJCEVBBlZM8AA1QSbbMeBWRGRIkKIzceS21uEH "Hexagony ‚Äì Try It Online")
Isn't this challenge too trivial for a practical language? ;)
side length 6. I can't fit it in a side length 5 hexagon.
### Explanation
[![](https://i.stack.imgur.com/3azaW.png)](https://i.stack.imgur.com/3azaW.png)
[Answer]
# [Python](https://docs.python.org/2/), 31 bytes
```
lambda n:67-len(bin(-n))&~n>>64
```
[Try it online!](https://tio.run/##ZYu7CsJAEEX7@YpUkhSBmdnZeQj6JTaKioG4BomIjb8etxO0uofDudNrvtwKL@fNbhn318Nx35S1Wj@eSnsYStuXrlu9y3arsjwvw3hqaD3dhzI353Yo02Nuu27pCfpgTskYk3oWs@zo8O8MRInUFcmFLbkFJiBmiUrhKrWTIIJANIrgehSsC5Ix5QitL0MJ/RUZmGrrScW/aMBAgB8 "Python 2 ‚Äì Try It Online")
The expresson is the bitwise `&` of two parts:
```
67-len(bin(-n)) & ~n>>64
```
The `67-len(bin(-n))` gives the correct answer for non-negative inputs. It takes the bit length, and subtracts from 67, which is 3 more than 64 to compensate for the `-0b` prefix. The negation is a trick to adjust for `n==0` using that negating it doesn't produce a `-` sign in front.
The `& ~n>>64` makes the answer instead be `0` for negative `n`. When `n<0`, `~n>>64` equals 0 (on 64-bit integers), so and-ing with it gives `0`. When `n>=0`, the `~n>>64` evaluates to `-1`, and doing `&-1` has no effect.
---
**[Python 2](https://docs.python.org/2/), 36 bytes**
```
f=lambda n:n>0and~-f(n/2)or(n==0)*64
```
[Try it online!](https://tio.run/##ZYtLasNAEAX3fQotpYBId09PfwzyXWQUIYEzFkYheOOry7MLxKtXFPW2x77cCh/HPFzH78s0NuVUzjiW6dnPbfnk7nZvyzBg96Fy/C7r9auh03Zfy97M7Vq2n73tuqMn6IM5JWNM6lnMsqPDuzMQJVJXJBe25BaYgJglKoWr1E6CCALRKILrUbAuSMaUI7S@DCX0v8jAVFtPKv6HBgwE@AI "Python 2 ‚Äì Try It Online")
Arithmetical alternative.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 14 bytes
```
__builtin_clzl
```
Works fine on tio
# [C (gcc)](https://gcc.gnu.org/), ~~35~~ 29 bytes
```
f(long n){n=n<0?0:f(n-~n)+1;}
```
[Try it online!](https://tio.run/##S9ZNT07@/z9NIyc/L10hT7M6zzbPxsDewCpNI0@3Lk9T29C69n9uYmaehmZ1QVFmXkmahpJqioKSTpqGhaamNUIIJGIAFKn9DwA "C (gcc) ‚Äì Try It Online")
Than Dennis for 6 bytes
# [C (gcc)](https://gcc.gnu.org/) compiler flags, 29 bytes by David Foerster
```
-Df(n)=n?__builtin_clzl(n):64
```
[Try it online!](https://tio.run/##ZYzLTsMwEADv@YpVEVJMG@RX/KAtXPgLqKLUIakl46A05QDi11mWXhBw2tHs7IZqCAEvYg7p1D3B5jh3Ke6vD7fFLxdHUogxz/Dcxlx@QzsNYQXh0E5wRfz6sGPFewHQjxOcgwhbEGsam3NLtFwyCgBeJtr35eKye8yLFfRlO4@pPD@JO8bYuvhArARWXkqlrOTKuFpbWzvu8L@zqI0QxhkunJZWOeu5QiGl9kTeGU2d9kKg59wK7yUdak4Tdc1V7b2hK8u1N39FjVJQ65TR7gctShTIP0Of2uGI1X1fZrbNd02zP8U0x9yE9JbI3Rj9BQ "C (gcc) ‚Äì Try It Online")
[Answer]
# Java 8, ~~32~~ 26 bytes.
`Long::numberOfLeadingZeros`
Builtins FTW.
-6 bytes thanks to Kevin Cruijssen
[Try it online!](https://tio.run/##bZDBboMwDIbP5Sl8BGlFCQSSlHXHSZO67dDbph1SGmg6CAhCu2rqs7Mg0Wpq8cX2b3@2k704iPl@@92rsq4aA3ub@51Rhb9OhdaySZy7Stbp1KhK@89jkDhO3W0KlUJaiLaFV6E0/DpgbdRbI4x1h0ptobRVd20apfPPLxBN3npj83@7zH5cVTp/gBdtZC6bJ8hg2Q/SYqG7ciOb92wlxdbO@pBN1fa3YxJnNhtfAu3ol6DlEUbVXZ9aI0tfac8@4xY/7lQhwR1JfyfaN/ljhv2uN3X1YIWtgrZbLpS@IskkMF5Qdcav7a@YQruZL@q6OLnam2DOznR27ucY5jwIwpAGKIxZRCiNGGJwr1EgMcYxixFmJKAhoxyFgIOAcBtxFhPbRzjGwBGimPPAggRZDyRCYcR5bCmKCI/hVokgwLaZhTFhw13XjNoYMKA/ "Java (JDK) ‚Äì Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 25 bytes
Takes input as a BigInt literal.
```
f=x=>x<0?0:x?f(x/2n)-1:64
```
[Try it online!](https://tio.run/##fdFLbsIwEAbgfU@RZbJIMy@PZ1ApZ0GUVK2QgwBVuX3qBQjkQLzx5tP88/jd/m3Pu9PP8dKm4Ws/Tf16XH@OH7CB1bjp67Gj1LS4Upl2QzoPh/37Yfiu@7rFVM1e01RdV8FbQZ2IORKwWpAYg4Gl53QuY7pWxYKKIqopoAlFtujAN0oFRSLxDNxUclVxxBvlsgGAiO6U0wXyn@5jYdmsBODgrjk@grg@Wly24dGW7RLmcGMVS@Vq@aWNc1vORk8udrU6W9mCLevCgpXpHw "JavaScript (Node.js) ‚Äì Try It Online")
Or [**24 bytes**](https://tio.run/##fdHNbsIwDAfw@56iJ9QeutqO49iTgGdBjE6bUIoATX37LgfQkAvNJZef/PfHz@53d9mfv0/XNg@fh2nq1@N6M27HDaxWfT12lJsWP4Sn/ZAvw/Hwfhy@6r5uMVez1zRV11Xw5qgRhZAIgmjklKKC5ud0LlO@VUVHWRBFBVCZUtBkEO6UHEUitgJMhUtVNsQ7Db4BgIRmVNIZyp//x0LfLEcI0UxKfAI2ebS4bOOj9e0SlnANwpr9asNLm@bWz0ZPLnazMlvZgvV1YcHy9Ac) by returning *false* instead of \$0\$.
[Answer]
# [Python 3](https://docs.python.org/3/), 34 bytes
```
f=lambda n:-1<n<2**63and-~f(2*n|1)
```
[Try it online!](https://tio.run/##ZYtLasNAEAX3OcUsJdGC/k1/jHMYGSMscMbGeGMIuboyu0C8ekVR7/56Xm5N9n39vC5fp/NS2mGmYzvyNJks7Tz/rANP7ZvGfb09yla2VmaCOZlFnFEsqrrXwIB356BGZGFIoewSnihAzJqdMkx7p0kEieiUyf2o2Be0otRM6y9HTfsvKjD1NsQ0/tCBgQAPH6XcH1t7DuuwjeP@Cw "Python 3 ‚Äì Try It Online")
[Answer]
# [J](http://jsoftware.com/), 18 bytes
```
0{[:I.1,~(64$2)#:]
```
[Try it online!](https://tio.run/##dY5BCsJADEX3PUVQoRZqSTKZTFLoATyDuBKLuHHRpejVx9l0NsVVwvvk/TzzvEwDIIyAGd@X8TxQ/z2qHLjbj9fcNbsB2nkaWujhM8K8NM399njBDCeqmzOHkBiDWpSUoqGt2TZKayRKpKZIJpyCJcewRsQsXoCbSrkSp1rmiIncudgEy6y2iCG6a1ElFNc/PK6cqQgsqNiG1A@rvLZj/gE "J ‚Äì Try It Online")
# [J](http://jsoftware.com/), 19 bytes
```
1#.[:*/\0=(64$2)#:]
```
[Try it online!](https://tio.run/##dY4xDsIwDEX3nsKiSKUIiu04jl2pJwEmRIVYGDpz9pClWSomW@/L7/ud52UaAGEEzNQO1/F4ueF0UNlz34733De7Abp5Gjo4wXeEeWma5@P1gRnOVDdnDiExBrUoKUVDW7NtlNZIlEhNkUw4BUuOYY2IWbwAN5VyJU61zBETuXOxCZZZbRFDdNeiSiiuf3hcOVMRWFCxDakfVnltx/wD "J ‚Äì Try It Online")
## Explanation:
```
                #:  - convert
                  ] - the input to
          (64$2)    - 64 binary digits
         =          - check if each digit equals
        0           - zero
   [:*/\            - find the running product
1#.                 - sum
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 18 bytes
*-2 bytes thanks to Jo King*
```
64-(*%2**64*2).msb
```
[Try it online!](https://tio.run/##rdNRb4IwEAfw936Ke9kEFL22x7WNWeb3mD7opomJzkWezLLPzi4bEzJIMOC9FNLml7s/5WN7PnBxvMDjDp6gYEqj5MEkCVNi4ukx3xRztTudITrs37d5DJ8KQE4v1nJ6@no6bqLZMn1evo1n8VzJXr6@wC5arF9wFU9GsM9hNBnLq16pryLV0Cz8e9ADS6XBGGudQcs@I@cyj77G47BSTd2Jeh1jaPfEWrNn1J6Ms94FtADmyg/0lTaGgqDBM0n3FLS0bisef/LpzQdEp0MwkgyhrGXkFV9Wv6@gKEObhcCSjEMKXF6YBt/P/89nv7xp8r0CUkZLKt4y@dq9t218W3WNVPGuztsbeezsvuWnBb61@67ZlG7l7V141ApbeboPj98 "Perl 6 ‚Äì Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 22 bytes
```
->n{/[^0]/=~"%064b"%n}
```
[Try it online!](https://tio.run/##bY69CsJAEIR7n0ICKUP27/aniC8SYpEiZRDBQkRf/Ty8q9RqmB3mm73e1nvepjyc9sc4n2EZp1fXg8ra9fszX47bPOBy@GgQMRsBqycxSw5ek9/AaiCKqK6ALmTsFsA1QCKJYsNVSkMC20gAGEZQ4QgUbZwEnCK0QAwk9O811SthqTqr@JdvPzVk24MlvwE "Ruby ‚Äì Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~10~~ 9 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
¬∑bg65Œ±sd*
```
I/O are both integers
[Try it online](https://tio.run/##yy9OTMpM/f//0PakdDPTcxuLU7T@/zcxMzQ0szAzMLQwMTI3tjC3NDAGAA) or [verify all test cases](https://tio.run/##ZYu7CQJREEXzqWLZUFyY35tPtImNuChiZLAgLBhbgJ0YmVuARdjI82WCRvdwOPc0b6fjvl7Oy9h37@ut68dlU5@P6WDldZ93q7quA8GQzCLOKBZF3UtgwL9zUCOyMKRQdglPFCBmzUYZpq3TJIJEdMrkdlRsC1pQSqa1l6Om/YoCTK0NMY0vOjAQ4Ac).
**Explanation:**
```
¬∑         # Double the (implicit) input
          #  i.e. -1 ‚Üí -2
          #  i.e. 4503599627370496 ‚Üí 9007199254740992
 b        # Convert it to binary
          #  i.e. -2 ‚Üí "√ø0"
          #  i.e. 9007199254740992 ‚Üí 100000000000000000000000000000000000000000000000000000
  g       # Take its length
          #  i.e. "√ø0" ‚Üí 2
          #  i.e. 100000000000000000000000000000000000000000000000000000 ‚Üí 54
   65Œ±    # Take the absolute different with 65
          #  i.e. 65 and 2 ‚Üí 63
          #  i.e. 65 and 54 ‚Üí 11
      s   # Swap to take the (implicit) input again
       d  # Check if it's non-negative (>= 0): 0 if negative; 1 if 0 or positive
          #  i.e. -1 ‚Üí 0
          #  i.e. 4503599627370496 ‚Üí 1
        * # Multiply them (and output implicitly)
          #  i.e. 63 and 0 ‚Üí 0
          #  i.e. 11 and 1 ‚Üí 11
```
[Answer]
# [Haskell](https://www.haskell.org/), 56 bytes
Thanks [xnor](https://codegolf.stackexchange.com/users/20260/xnor) for spotting a mistake!
```
f n|n<0=0|1>0=sum.fst.span(>0)$mapM(pure[1,0])[1..64]!!n
```
Might allocate quite a lot of memory, [try it online!](https://tio.run/##JcqxDoMgFIXhvU9xTTpgouQCKjQpvkGfgDAwaGoqhIhuvju1dPnOcP63S59pXXOeIZzhiRpPNqJOh6dz2mmKLpAR67t38UXisU2GNWhrwygdOltVIXu3BNDwC4DEbQk7nesbgIGWXdNA@@BcCMlRDKrvpOwVqnIMRV78p3hp8xc "Haskell ‚Äì Try It Online")
Maybe you want to test it with a smaller constant: [Try 8-bit!](https://tio.run/##y0gszk7Nyfn/P00hrybPxsDWoMbQzsC2uDRXL624RK@4IDFPw85AUyU3scBXo6C0KDXaUMcgVjPaUE/PIlZRMe9/bmJmnoKtAkheQaOgKDOvRC9Nk0tBIVpB1xhI6SjoGoIpAzAJYRuBSTOIiJE5kI79DwA "Haskell ‚Äì Try It Online")
## Explanation
Instead of using `mapM(pure[0,1])[1..64]` to convert the input to binary, we'll use `mapM(pure[1,0])[1..64]` which essentially generates the inverted strings \$\lbrace0,1\rbrace^{64}\$ in lexicographic order. So we can just sum the \$1\$s-prefix by using `sum.fst.span(>0)`.
[Answer]
# Powershell, 51 bytes
```
param([long]$n)for(;$n-shl$i++-gt0){}($i,65)[!$n]-1
```
Test script:
```
$f = {
param([long]$n)for(;$n-shl$i++-gt0){}($i,65)[!$n]-1
}
@(
    ,(-1                   ,0 )
    ,(-9223372036854775808 ,0 )
    ,(9223372036854775807  ,1 )
    ,(4611686018427387903  ,2 )
    ,(1224979098644774911  ,3 )
    ,(9007199254740992     ,10)
    ,(4503599627370496     ,11)
    ,(4503599627370495     ,12)
    ,(2147483648           ,32)
    ,(2147483647           ,33)
    ,(2                    ,62)
    ,(1                    ,63)
    ,(0                    ,64)
) | % {
    $n,$expected = $_
    $result = &$f $n
    "$($result-eq$expected): $result"
}
```
Output:
```
True: 0
True: 0
True: 1
True: 2
True: 3
True: 10
True: 11
True: 12
True: 32
True: 33
True: 62
True: 63
True: 64
```
[Answer]
# Java 8, 38 bytes
```
int f(long n){return n<0?0:f(n-~n)+1;}
```
Input as `long` (64-bit integer), output as `int` (32-bit integer).
Port of [*@l4m2*'s C (gcc) answer](https://codegolf.stackexchange.com/a/177291/52210).
[Try it online.](https://tio.run/##fZFNTsMwEIX3PcWoK0dRqvFP/EORuACsukQsQptULqlTJU4lVIUlB@CIXCSYEAksECtr5vl9Hr85FOciO@yexm1ddB3cFdZdFgCdL7zdwmidh4rUjduDSy5t6fvWgbvGG7yqiMteXJLS9TAGx6l/rINjNp4bu4NjgJGNb63b3z9AkXyCAXzZeZLR22T9ozSMca4YcqlzoVSuUUcXfusq0oWkVGqJVAumuFYGeaRTxoQJXaOlCH5haDyAQVTUGBbgAsMZw3PkuTEykBUKI/8T80hkNPA0l0L/3Y4/Eb8aD4hf1bD4Xs6U8SRO@7FzvpvnzpfHVdP71SlE72tHbLqE99c3WKYVsckMGsYP)
**Explanation:**
```
 int f(long n){       // Recursive method with long parameter and integer return-type
   return n<0?        //  If the input is negative:
           0          //   Return 0
          :           //  Else:
           f(n-~n)    //   Do a recursive call with n+n+1
                  +1  //   And add 1
```
---
EDIT: Can be **26 bytes** by using the builtin `Long::numberOfLeadingZeros` as displayed in [*@lukeg*'s Java 8 answer](https://codegolf.stackexchange.com/a/177304/52210).
[Answer]
# APL+WIN, 34 bytes
```
+/√ó\0=(0>n),(63‚ç¥2)‚ä§((2*63)√ó√ón)+n‚Üê‚éï
```
Explanation:
```
n‚Üê‚éï Prompts for input of number as integer
((2*63)√ó√ón) If n is negative add 2 to power 63
(63‚ç¥2)‚ä§ Convert to 63 bit binary
(0>n), Concatinate 1 to front of binary vector if n negative, 0 if positive
+/√ó\0= Identify zeros, isolate first contiguous group and sum if first element is zero
```
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 42 bytes
```
x=>x!=0?64-Convert.ToString(x,2).Length:64
```
[Try it online!](https://tio.run/##ZVA9T8MwFJzxr3C3RHIif8UfLSkDElO3IjEghsoyqaXiSLapghC/PTgNAQRveffu3t1wJlYmuvHu1ZvrU@875HzaQgNbOA7tdli1@Ebw6rb3ZxtSfd/vU3C@KwZEy3pnfZeOa8HHDQCT@fEJJhuTDTH73yuCQKUpZUxSzIRquJSNwgrBrwH/RQkXFXBBiFACE8WpZEpqzCAChFKuM9ZK8GzhmhD4KxBjSbSmOY3jvCcSTVkNZo3WIgdJzLWY@b90s7xTkv2KCa7mXPTDyPmEi0C@Ef7ILTz3wR7MsTgfwqWKCJ1fOinB1f4to5c61xn7k60fgkt257wtTHH5LsvN@Ak "C# (Visual C# Interactive Compiler) ‚Äì Try It Online")
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 31 bytes
```
int c(long x)=>x<0?0:c(x-~x)+1;
```
Even shorter, based off of [@l4m2's C (gcc) answer.](https://codegolf.stackexchange.com/a/177291/52210)
Never knew that you could declare functions like that, thanks @Dana!
[Try it online!](https://tio.run/##ZZA/T8QwDMVn8ik8tqI92UmaP1cOBlY2BgbEcIoCRLpLpaZCRQi@ekmvFBB48fN79m@wS7VLYZpCHMAVhy4@wVjuLscLvMKtK8b6YyzPqZ0Ym7P7Bxh8GnyfYAdvNVWstpwLoTkKZRqpdWPQVPBV7H@oYU2ZVETKKCQjuRZGWxRQMeJc2qytUTKfSEsEv4CImqzlmSYx99msZlaDorFWZZBGadXi/7WbdZ1TvjdCSbNwqx9HLyOsAX0rfG8Ze@x6v3fPxcu@P70iQYjrT0p2dvua1XFz3cXUHfzmrg@DvwnRF644bZdlO30C "C# (Visual C# Interactive Compiler) ‚Äì Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~¬†10¬†~~ 9 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
-1 thanks to a neat trick by Erik the Outgolfer (is-non-negative is now simply `A∆ë`)
```
·∏§BL65_√óA∆ë
```
A monadic Link accepting an integer (within range) which yields an integer.
**[Try it online!](https://tio.run/##y0rNyan8///hjiVOPmam8YenOx6b@P//fxNTA2NTS0szI3NjcwMTSzMA "Jelly ‚Äì Try It Online")** Or see the [test-suite](https://tio.run/##ddA7TgNBDAbg3qeIlHYi@TV@lEmdGyBERYNyAVoaaiouQJkDpF8p90guMhmxQgvLZhpL88m/bL88Hw6vrV1OX7u91afhc3v@aMP79e3Y2gNsqKwW3nqFsElmEWcUi6ruNTDKSP/Fy3cXgRqRhSGFskt4oozEQMya/SPDtHdpEo0kkIhOmdzTFHstP2MQglaUmmk9zlHTJqO51ckYmHpYiGmUv6vJL/O5CfDiRbpZX@GuCeBdU3i8AQ "Jelly ‚Äì Try It Online").
---
The 10 was `·∏§BL65_…ì>-√ó`
Here is another 10 byte solution, which I like since it says it is "BOSS"...
```
Bo·π†S¬ª-~%65
```
[Test-suite here](https://tio.run/##ddA9akJBEAfwfk4hhHT7YL52PtpcwVIsbUSwTpMiTa6RA@QCwS45SbzIuuQh6tO3zcD@mD8zs93sdq@tvez/vj@XP4fh7dlq@/04vn@1toKByuLBe1ogDMks4oxiUdW9BkYZ6V68/HcRqBFZGFIou4QnykgMxKzZPzJMe5cm0UgCieiUyT1NsddyHoMQtKLUTOtxjpp2MZpavRgDUw8LMY1yu5pcmU9NgB9epJv1FWZNAGdNYX0C "Jelly ‚Äì Try It Online")
...`Bo·π†S63r0¬§i`, `Bo·π†S63≈ª·πö¬§i`, or `Bo·π†S64·∏∂·πö¬§i` would also work.
---
Another 10 byter (from Dennis) is `√¶¬ª64·∏∂·πö¬§√Ñƒã0` (again `√¶¬ª63r0¬§√Ñƒã0` and `√¶¬ª63≈ª·πö¬§√Ñƒã0` will also work)
[Answer]
# [Perl 5](https://www.perl.org/), 37 bytes
```
sub{sprintf("%064b",@_)=~/^0*/;$+[0]}
```
[Try it online!](https://tio.run/##rZPrTsJAEIX/71NMNouhUmH20r1Yq7yHFyJSCJFLpSWRGH11XAoKkSYY4PxpMzv55szpNktno2g5XrB@sszn3Y88mw0nRb9Oa6hVl4btTpB8tZ7wshWzxj0@fi7j8QLaRZoXyfg5g/s8Gw2L1kPeaD2GN7cx6U9n9fI4@CDgNV7U2TBkaZC0WSfelIANkgvW9yfBurSeCpQ26yyF9M033FF6TSfTAmjQpNNX3zScZPPiGmoiyiGB0iBA@p6lL0XaW9V7AINp2dF7mNBwNXc1OmSDmHwurzjsC39e@IkiV04IKY1AqW2kjIks2h08niayTzee@rvGqe6V5lxbjdwqYaQ1DiWA@MWfyCdcCOU81FmtvHvluLcut3gs8zka7xANd074ZBT65ybyLX6j474CURHKyDntkzGonN5cmD38cfy/@GiNF/v4owIigvtUrNTK7tx7WYWv0qGVtnizi5f/xONB9xU/Lej/uj@0G@GVeHkWPHKClXh1Hjx@Aw "Perl 5 ‚Äì Try It Online")
Or this 46 bytes if the "stringification" is not allowed: sub z
```
sub{my$i=0;$_[0]>>64-$_?last:$i++for 1..64;$i}
```
[Answer]
# Swift (on a 64-bit platform), 41 bytes
Declares a closure called `f` which accepts and returns an `Int`. This solution only works correctly 64-bit platforms, where `Int` is `typealias`ed to `Int64`. (On a 32-bit platform, `Int64` can be used explicitly for the closure‚Äôs parameter type, adding 2 bytes.)
```
let f:(Int)->Int={$0.leadingZeroBitCount}
```
In Swift, even the fundamental integer type is an ordinary object declared in the standard library. This means `Int` can have methods and properties, such as [`leadingZeroBitCount`](https://developer.apple.com/documentation/swift/int/2884587-leadingzerobitcount) (which is required on all types conforming to the standard library‚Äôs [`FixedWidthInteger`](https://developer.apple.com/documentation/swift/fixedwidthinteger) protocol).
[Answer]
# [Haskell](https://www.haskell.org/), 24 bytes
```
f n|n<0=0
f n=1+f(2*n+1)
```
[Try it online!](https://tio.run/##ZY2xDsIwDET3foXHllJkO2niVOQDGPgCxJCBioo2qqAj/x6idGQ5n9@ddM/weT3mOaUR4jee0WOVnad2rPkQW2rSEqYIHpawXqFe31PcTmNTAdygo3yO0DlmpSyjMtJra3tBKcE/t4VrQ2TEIIlmq8Q6VIUTs3b5c2J07mtH@4ApynunKA7DJW7Z3tMP "Haskell ‚Äì Try It Online")
This is basically the same as Kevin Cruijssen's Java solution, but I found it independently.
The argument should have type `Int` for a 64-bit build, or `Int64` for anything.
## Explanation
If the argument is negative, the result is immediately 0. Otherwise, we shift left, *filling in with ones*, until we reach a negative number. That filling lets us avoid a special case for 0.
Just for reference, here's the obvious/efficient way:
# 34 bytes
```
import Data.Bits
countLeadingZeros
```
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), 103 bytes
Uses the same *"builtin"* as ceilingcat's answer.
```
f::!Int->Int
f _=code {
instruction 243
instruction 72
instruction 15
instruction 189
instruction 192
}
```
[Try it online!](https://tio.run/##S85JTcz7n5ufUpqTqpCbmJn3P83KStEzr0TXDkhwpSnE2ybnp6QqVHNl5hWXFJUml2Tm5ykYmRij8M2NULiGpqhcC0tUvqURV@3/4JLEohIFW4U0BYP/AA "Clean ‚Äì Try It Online")
# [Clean](https://github.com/Ourous/curated-clean-linux), 58 bytes
```
import StdEnv
$0=64
$i=until(\e=(2^63>>e)bitand i<>0)inc 0
```
[Try it online!](https://tio.run/##S85JTcz7n5ufUpqTqpCbmJn3PzO3IL@oRCG4JMU1r4xLxcDWzIRLJdO2NK8kM0cjJtVWwyjOzNjOLlUzKbMkMS9FIdPGzkAzMy9ZweB/cEkiUKetgoqCgQIc/P@XnJaTmF78X9fT579LZV5ibmZyMQA "Clean ‚Äì Try It Online")
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 10 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
√Æn¬ª‚ïß3(‚àû‚îº‚å†g
```
[Run and debug it](https://staxlang.xyz/#p=8c6eafcf3328ecc5f467&i=-1%0A-9223372036854775808%0A9223372036854775807%0A4611686018427387903%0A1224979098644774911%0A9007199254740992%0A4503599627370496%0A4503599627370495%0A2147483648%0A2147483647%0A2%0A1%0A0&a=1&m=2)
It's a port of Kevin's 05AB1E solution.
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 42 bytes
```
1while$_>0&&2**++$a-1<$_;$_=0|$_>=0&&64-$a
```
[Try it online!](https://tio.run/##rdPNaoQwEAfwe54i0LCHXSwz@Q7WvkGfQTxYarEqftAe@uxNQ7tdpQouunOJGPgx83ds8rZU3uP7S1HmLH2Ew4Efj6cTyyJ8YGnM0gQ@w/skXGgZsczHLEsgpnf5R9H1HX0dup4@1y19G8q@aMqc9m2Rd7SoaF3ltB0qHyGdF/w94M4ikeNcCMNBaKukMcqCnfCwr8hcN0G9jLG3e6kRtdWAVnIjrHEgKOUXfqdPkHPpAuqslqF76TC0LkYefvLZzDsAg87xkIyEcJ4jH/lzbfsKRCoQyjkdkjEgnT4vzIzf5v/n1S/P5/ymgAjHkIoVWtrJ3oslfqnWRhp5M@XFlTysLiYRhC/8uFRfO8HafAQXeXETHpDAIi9vw8NX3fRFXXU@elL3YRofNeU3 "Perl 5 ‚Äì Try It Online")
Longer than a bitstring based solution, but a decent math based solution.
[Answer]
# APL(NARS), 15 chars, 30 bytes
```
{¬Ø1+1‚ç≥‚ç®‚çµ‚ä§‚ç®64‚ç¥2}
```
test for few numbers for see how to use:
```
  f‚Üê{¬Ø1+1‚ç≥‚ç®‚çµ‚ä§‚ç®64‚ç¥2}
  f ¬Ø9223372036854775808
0
  f 9223372036854775807
1
```
[Answer]
# Rust, 18 bytes
```
i64::leading_zeros
```
[Try it online!](https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=71da8c48aa4f1edd0fb85db20d7281d4)
[Answer]
# PHP, ~~50~~ 46 bytes
```
for(;0<$n=&$argn;$n>>=1)$i++;echo$n<0?0:64-$i;
```
Run as pipe with `-R` or [try it online](http://sandbox.onlinephpfunctions.com/code/7d03c08accfe0eaa3e19c42efec9c7bca8b40ae6),
`<?=$argn<0?0:0|64-log($argn+1,2);` has rounding issues; so I took the long way.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 41 bytes
The formula for positive numbers is just `63-Floor@Log2@#&`. Replacement rules are used for the special cases of zero and negative input.
The input need not be a 64-bit signed integer. This will effectively take the floor of the input to turn it into an integer. If you input a number outside of the normal bounds for a 64-bit integer, it will tell return a negative number indicating how many more bits would be needed to store this integer.
```
63-Floor@Log2[#/.{_?(#<0&):>2^63,0:>.5}]&
```
[Try it online!](https://tio.run/##ZY9NawJBEER/jCARerW/pnvaROMppxxyFyOLrImgWXDnJv72zZwSSE5VPOod6tKWz@7SltOhHUs3lEM7dMPq1hA0wSzijGI5qXvKmOE/c1AjsmxIWdkle6AAMWvUFtm07jSIIBCdIriKijVBE0qKsGo5athfkICpbrOY5t/qwECA98fjajRpXs59f9289h@8nSzmt/3zw@QJp7Plmt9NAJfrebrvpuPb9fRVtsfF5ufkbvwG "Wolfram Language (Mathematica) ‚Äì Try It Online")
@LegionMammal978's solution is quite a bit shorter at 28 bytes. The input must be an integer. Per the documentation: "`BitLength[n]` is effectively an efficient version of `Floor[Log[2,n]]+1`. " It automatically handles the case of zero correctly reporting `0` rather than `-‚àû`.
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 28 bytes
```
Boole[#>=0](64-BitLength@#)&
```
[Try it online!](https://tio.run/##ZY@7asNAEEU/xhAcGOGZ2dl5YBSM6xTujQth1pbAD4i2C/l2ZasEkupeDvcU9z7UsdyHOp2HpZa5noe5zP1nR9AFc0rGmNSzmGVHh//MQJRIXZFc2JJbYAJilmgtXKXtJIggEI0iuImCLUEyphyhzTKU0L8gA1PbelLx32rAQIBf20u/7J/PWzmu3no8rVW6/VTfy@Nax93q9WU5fEyPerxsdj@/Tss3 "Wolfram Language (Mathematica) ‚Äì Try It Online")
[Answer]
bitNumber - math.ceil (math.log(number) / math.log(2))
e.g
64 bit
NUMBER : 9223372036854775807
math.ceil (math.log(9223372036854775807) / math.log(2))
ANS: 63
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 12 bytes
```
+/&\~(64#2)\
```
[Try it online!](https://ngn.codeberg.page/k#eJxljstqAlEMhvfzFEJFlCLN7eQy51E0oJuB0kJBXCjiPHvPmZ24Cv+X5Eum8fNrc5y3Kh+0Ow7DdXysD/f5Mk6rWz39/dTtaTp//9ZbvdfLLp/D9bDHhF6CiNkIWL2IWXHwpfHOLbFxUUR1BXQhY7cATmociSRaCldp8xKIyd0DYBhBTSLQamK3SwEuEdoUBhKaiO+0JHYzYVt1VvHkl2zJ/QKlLg+k9gSp8g/x20FX)
`(64#2)\` encode the argument as 64 bits
`~` bitwise not
`&\` cumulative boolean and
`+/` sum
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 15 bytes
```
Ôº©‚Åª‚Å∂‚Å¥Ôº¨‚Ü®Ôπ™ÔºÆÔº∏¬≤¬¶‚Å∂‚Å¥¬¶¬≤
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEwzczr7RYw8xER8EnNS@9JEPDKbE4VcM3P6U0J1/DM6@gtMSvNDcptUhDU0chIL8cyDDSUTAz0QRyjTTBwPr/f4P/umU5AA "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Explanation:
```
    Ôº¨           Length of
       ÔºÆ        Input as a number
      Ôπ™         Modulo
         ¬≤      Literal 2
        Ôº∏       To the power
           ‚Å∂‚Å¥   Literal 64
     ‚Ü®          Converted to base
              ¬≤ Literal 2
 ‚Åª              Subtracted from
  ‚Å∂‚Å¥            Literal 64
Ôº©               Cast to string
                Implicitly print
```
The `¬¶`s serve to separate adjacent integer literals. Conveniently, Charcoal's arbitrary numeric base conversion converts `0` into an empty list, however for negative numbers it simply inverts the sign of each digit, so the number is converted to the equivalent unsigned 64-bit integer first.
]


[Question]
      [
My two kids like to play with the following toy:
[![Turtle](https://i.stack.imgur.com/BYhak.jpg)](https://i.stack.imgur.com/BYhak.jpg)
The colored areas with the shapes inside can be touched and the turtle then lights the area and plays a sound or says the name of the color or the shape inside. The middle button changes the mode. There is one mode in which the areas play different musical notes when touched, with a twist: if the kid touches three consecutive areas clockwise, a special melody 1 is played. If the three consecutive areas touched are placed counterclockwise, a special melody 2 is played.
### The challenge
Let's simulate the internal logic of the toy. Given a string with 3 presses of the kid, return two distinct, coherent values if the three presses are for consecutive areas (clockwise or counterclockwise) and a third distinct value if they are not.
### Details
* The input areas will be named with a character each, which can be their color: `ROYGB` for red, orange, yellow, green and blue; or their shape: `HSRTC` for heart, square, star (`R`), triangle and circle. Case does not matter, you can choose to work with input and output just in uppercase or in lowercase.
* The program will receive a string (or char array or anything equivalent) with three presses. Examples (using the colors): `RBO`, `GYO`, `BBR`, `YRG`, `YGB`, `ORB`...
* The program will output three distinct, coherent values to represent the three possible outcomes: a first value if the combination does not trigger a special melody, a second value if the combination triggers the clockwise special melody, and a third value if the combination triggers the counterclockwise special melody. Example: `0` for no special combination, `1` for the melody triggered by a clockwise combination and `-1` for the melody triggered by a counterclockwise combination.
* You do not need to worry about handling wrong input.
### Test cases
```
Input   Output      // Input based on colors
--------------
RBO     0           // No special combination
GYO     -1          // Counterclockwise melody triggered
BBR     0           // No special combination
YRG     0           // No special combination
YGB     1           // Clockwise melody triggered
ORB     -1          // Counterclockwise melody triggered
OOO     0           // No special combination
BRO     1           // Clockwise melody triggered
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so may the shortest code for each language win!

[Answer]
# Java 8, ~~48~~ ~~39~~ 33 bytes
```
s->"ROYGBRO BGYORBG".indexOf(s)|7
```
-6 bytes thanks to *@RickHitchcock*, so make sure [to upvote him as well](https://codegolf.stackexchange.com/a/174590/52210)!
Takes uppercase color as input-String. Outputs `-1` for none, `7` for clockwise, and `15` for counterclockwise.
[Try it online.](https://tio.run/##jVE9j8IwDN37K6xO7UAZke4EQxgy0Uhhqk4MIQ0oUBJEUg4E/e3FLTBCukSy/Zz34Z04i9Gu3LeyEs7BQmhziwC08eq0EVJB3pV9A2Sy9CdttuDSX2w2ET7OC68l5GBgCq0bzWLOCko4A0ILxgmNM21KdWGbxKX3SdstHut1hTuv1bPVJRyQ9/X73wpE@iQdjyG3Rv30xfLqvDpktvbZEXG@MonJZBJzwuK0F/QZQwgPYgpOgxjGvnLh5K17Xlm5/9cuIB6jCovnYYMY@lBhtu5uK4fpwxuGQ@EDPNAi7IG8D9BETfsA)
**Explanation:**
```
s->      // Method with String parameter and integer return-type
   "ROYGBRO BGYORBG".indexOf(s)
         //  Get the index of the input in the String "ROYGBRO BGYORBG",
         //  which will result in -1 if the input is not a substring of this String
    |7   //  Then take a bitwise-OR 7 of this index, and return it as result
```
---
**Old 39 bytes answer:**
```
s->(char)"ROYGBRO BGYORBG".indexOf(s)/7
```
Takes uppercase color as input-String. Outputs `9362` for none, `0` for clockwise, and `1` for counterclockwise.
[Try it online.](https://tio.run/##jZGxbsMgEIZ3P8XJEwyxx0qp2oEMTDUSmawqA8UkwXEgMjhpFfnZXey6Y4IXpLv7j@@/u1pcxaquToNshHPwIbS5JwDaeNXuhVRQjOGUAIm2vtXmAA6/hmSfhMd54bWEAgy8weBW70geRYtTzkpKOANCS8YJTTNtKvXN9sjh/GUY2y/dVxM65w@uVldwDvSZ8bkDgf/QeQ6FNWo9Bdsf59U5s53PLkHnG4NMJlHKCUvxZOuxhhAe1ZScRjWMPWWFyr/vTWPl6aZdxHxYVdw8Xwy13Xg9uYwd7hMfmC/wR8tZ0yf98As)
**Explanation:**
```
s->      // Method with String parameter and integer return-type
   (char)"ROYGBRO BGYORBG".indexOf(s)
         //  Get the index of the input in the String "ROYGBRO BGYORBG",
         //  which will result in -1 if the input is not a substring of this String
         //  And cast it to a char (-1 becomes character with unicode value 65535)
    /7   //  Integer-divide it by 7 (the char is implicitly converted to int doing so)
```
[Answer]
# JavaScript (ES6), 41 bytes
Takes color initials as input. Returns `2` for none, `true` for clockwise or `false` for counterclockwise.
```
s=>~(x='ROYGBRO_ORBGYOR'.search(s))?x<5:2
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@7/Y1q5Oo8JWPcg/0t0pyD/eP8jJPdI/SF2vODWxKDlDo1hT077CxtTK6H9yfl5xfk6qXk5@ukaahnqQk7@6pqaCvr6CEReaFNAAqFRaYk5xKrq0k1MQLp2RQe44pdydoFIlRaUYZgKdjc9Kf3@cjgV6Gsnc/wA "JavaScript (Node.js) – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 36 bytes
```
lambda i:'ROYGBRO ORBGYOR'.find(i)/7
```
`-1` - None
`0` - Clockwise
`1` - Counterclockwise
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHTSj3IP9LdKchfwT/IyT3SP0hdLy0zL0UjU1Pf/H9BUWZeiUKahnqQk7@6JhecC1SHzHVyCkLmRga5o3DdnZC5QGtQuP6oRgUBuf8B "Python 2 – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~15~~ 11 bytes
Saved 4 bytes thanks to *Kevin Cruijssen* and *Magic Octopus Urn*.
Uses shapes.
Output `[0, 0]` for *none*, `[1, 0]` for *clockwise* and `[0, 1]` for *counter-clockwise*
```
Â‚.•ÌöJη•så
```
[Try it online!](https://tio.run/##yy9OTMpM/f//cNOjhll6jxoWHe45vM3r3HYgq/jw0v//i0qSAQ "05AB1E – Try It Online")
or as a [Test suite](https://tio.run/##yy9OTMpM/V9TVln5/3DTo4ZZeo8aFh3uObzN69x2IKv48NL/lUqH9yvo2iko2ev8z0gu5iopKuZKTs7gKsoo4SoqSeYqzgDiYqBYRjEA)
**Explanation**
```
Â‚            # pair the input with its reverse
  .•ÌöJη•     # push the string "hsrtchs"
         så   # check if the input or its reverse is in this string
```
[Answer]
## Excel, 29 bytes
```
=FIND(A1,"ROYGBRO_RBGYORB")<6
```
Uppercase colours as input.
Returns `#VALUE!` for no pattern, `TRUE` for clockwise, `FALSE` for anti-clockwise.
Can wrap in `IFERROR( ,0)` for `+11 bytes` to handle exception , and return '0' for no-pattern cases instead.
[Answer]
# JavaScript (ES6), 32 bytes
```
s=>'ROYGBRO_ORBGYOR'.search(s)|7
```
Returns -1 if no combination, 15 if counterclockwise, 7 if clockwise.
```
let f =
s=>'ROYGBRO_ORBGYOR'.search(s)|7
console.log(f('RBO')) // -1
console.log(f('GYO')) // 15
console.log(f('BBR')) // -1
console.log(f('YRG')) // -1
console.log(f('YGB')) // 7
console.log(f('ORB')) // 15
console.log(f('OOO')) // -1
console.log(f('BRO')) // 7
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~42~~ 36 bytes
```
{"ROYGBRO","ORBGYOR"}~StringCount~#&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78H1CUmVcS/b9aKcg/0t0pyF9JR8k/yMk90j9IqbYuuAQom@6cX5pXUqes9l/fQQGozslfSUFHQQmoBEwDdYFpoC4I7Q8RB5mlUBv7HwA "Wolfram Language (Mathematica) – Try It Online")
Counts the number of times the input appears in both `"ROYGBRO"` and `"ORBGYOR"`. Returns `{1,0}` for clockwise, `{0,1}` for counterclockwise, and `{0,0}` for no special combination.
At the cost of only one more byte, we can get outputs of `0` for nothing, `1` for clockwise, and `2` for counterclockwise with `"ROYGBRO.ORBGYORBGYOR"~StringCount~#&`.
[Answer]
# x86 machine code, ~~39~~ 36 bytes
```
00000000: f30f 6f29 b815 0000 0066 0f3a 6328 0c89  ..o).....f.:c(..
00000010: c883 c807 c352 4f59 4742 524f 2042 4759  .....ROYGBRO BGY
00000020: 4f52 4247                                ORBG
```
Assembly:
```
section .text
	global func
func:					;the function uses fastcall conventions
					;no stack setup needed because we don't need to use stack
	movdqu xmm5,[ecx]		;Move DQword (16 bytes) from 1st arg to func(ecx) to SSE reg
	mov eax, msg			;Load address of constant str 'msg' into eax
	PcmpIstrI xmm5, [eax], 1100b	;Packed Compare String Return Index, get idx of [eax] in xmm5
	mov eax, ecx			;Move returned result into reg eax
	or eax, 7			;Bitwise OR eax with 7 to get consistent values
	ret				;return to caller, eax is the return register
	msg db 'ROYGBRO BGYORBG'
```
[Try it online!](https://tio.run/##bVNRT9swEH6Of8WpEmtTGtaCNiQKPGSwDmkoLDwhqCrHdtKwxM5spw1C/PbunKyi1cjDKT5/33ff@eyEmuWGUQvn59fRd7iEz7asPtMjasqNEczmSsKRFY0lXlaohBaQ1pIRF848903tUrS5FlobYSClxjJaFMCUXAnpNgzpwFKBsZT9BiNsXYEUggsOiWAUmbAWwJXs2zYPVjm5Dk@8Uq34nxqasvwyehSsmaParVoJuPq1VprDYPIVkhcrjA@pViVMjAWqM6fi3A2Q4rvF/f01aJG1giBoM4LSZM7aT0U5UM61MAZU6sxjaWnRgIY@gvqQSxRADvHuWFnd4MZNZwgeMTsfwWQyHife9A4dYwPfVFlRLeDe6lxmEGPLWsKN5AKrZsJCzhtXqSWjeKu1Ywwte9sudUtGUbRXF7azgn10dpTuGKcOH@Z2nePBRbFLwjq3Szh1rbuSrqvcWJwKrGhRCxwMSrez6Uo4oBue0KOWnhtwE/63iRUdW6NLkwFPoB9HD7MwjiCcPURxOOtv8BoR8t@NMrZOjhjBiyRQBt3DYkEtHkxSW7FYDAbbS@P73bzYkuqhPwXisCXN5cB/JV6bxSFb8zi/eO3FYdQb9bAyxjCMMT7EMxdnIUb042LU7sYYx29T4qVKD5xmfjGedkr5fJofHjp5r8JJ2XTQOzBncMCfZG@0hYxaV9uV76PSG3kjbbcSXwsEqSjSk@OdBwSB6lZMcXGkSMbYfgoJu6ezC4ZAqqDKBQTlyTFRyTNT1QsEESS5pBr/nrtnucd5/0cUcSxelxUEVxDcujMXxR788tMxEWyJtQT0nuRwOAzxAeEVqaU9w1WvRazRNIPzffEPuD9E46q9E5uGf0Aie@1v/gI "Try It Online")
Output is `23` for none, `7` for clockwise, and `15` for counter-clockwise. Based on @RickHitchcock 's answer.
Edit 1: Saved 3 bytes by using an SSE string comparison instruction instead of using libc.
Edit 2: Use proper calling convention for SSE (use XMM5 instead of XMM2) and improve formatting on Bash.
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 30 bytes
```
$_=ROYGBRO=~/$_/-ORBGYOR=~/$_/
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3jbIP9LdKcjftk5fJV5f1z/IyT3SPwjC@/8fKPEvv6AkMz@v@L@ur6megaHBf90CAA "Perl 5 – Try It Online")
[Answer]
# APL(Dyalog), ~~22~~ 18 bytes
```
+/(⍷-⍷∘⌽)∘'ROYGBRO'
```
*-4 bytes thanks to @ngn*
Takes a string of color initials. Outputs 0 for no special pattern, -1 for counterclockwise, 1 for clockwise.
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///X1tf41Hvdl0gftQx41HPXk0gpR7kH@nuFOSv/j/tUduER719j/qmevo/6mo@tN74UdtEIC84yBlIhnh4Bv9PUw9y8lfnSlN3jwRTTk5BICoyyB1MuTuBKP8gCOUPUQI0GgA)
[Answer]
# [Python 2](https://docs.python.org/2/), ~~45~~ 43 bytes
```
lambda i,a='ROYGBRO':(i in a)-(i[::-1]in a)
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSFTJ9FWPcg/0t0pyF/dSiNTITNPIVFTVyMz2spK1zAWzPtfUJSZV6KQpqEe5OSvrskF57pHonCdnIKQuZFB7ihcdydkrn8QKtcf1SigazT/AwA "Python 2 – Try It Online")
With ideas from and serious credit to @DeadPossum
-2 with thanks to @JoKing. Now outputs -1 = counterclockwise, 0 = none, 1 = clockwise.
My original effort is below for historical purposes.
# [Python 2](https://docs.python.org/2/), ~~52~~ 51 bytes
```
lambda i,a='ROYGBRO':((0,1)[i[::-1]in a],2)[i in a]
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSFTJ9FWPcg/0t0pyF/dSkPDQMdQMzoz2spK1zA2M08hMVbHCMhXADP/FxRl5pUopGmoBzn5q2tywbnukShcJ6cgZG5kkDsK190JmesfhMr1RzUK6CrN/wA "Python 2 – Try It Online")
0 = none, 1 = counterclockwise, 2 = clockwise
[Answer]
# [Python 2](https://docs.python.org/2/), ~~35~~ 36 bytes
+1 - for some reason I thought all buttons would be distinct >\_<
*Developed independently from [what I have just seen](https://codegolf.stackexchange.com/a/174582/53748) (and now up-voted) by Dead Possum*
```
lambda s:'ORBGYO.BROYGBR'.find(s)/7
```
**[Try it online!](https://tio.run/##lZBRS8NADMff@ynylha6CvogDCqsRcpQLFRBhvOha6/stL077lLET19znQ6GOPAeApf88/snMZ@01@py6tLt1NfDrq3BLbGssmJTVklWlZsiqzDppGpDF11cT/l9md89rx9vIYUX5DrGyCKOrOTo5TFyI74Gq4en9amewVxlutcUvpd9fG9ZsT4wVioCzHvdvH9IJ5YYdNoCCUcgFRxZywD4HdS@GAMubjCGLvS/6IeDR@JKkVw0f2BPxvw3uqS9sGC0c3LXC@aZkRwbWD2AJGFJ696BHIy2xFzdjg3N9sZ7fydCnC/NPlYYUVN6FR0GmWdM2S9501KFJpqzsvt9Ezi/kX@N5jOoUZxfcfoC "Python 2 – Try It Online")**
[Answer]
# [Stax](https://github.com/tomtheisen/stax), ~~14~~ 13 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
ù♀e▌d─█£F'♦O▬
```
[Run and debug it](https://staxlang.xyz/#p=970c65dd64c4db9c4627044f16&i=RBO%0AGYO%0ABBR%0AYRG%0AYGB%0AORB%0AOOO%0ABRO&a=1&m=2)
The output is
* 1 for no special combination
* 2 for counter-clockwise melody
* 3 for clockwise melody
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 19 bytes
```
Y"ROYGBRO"OaNyaNRVy
```
Outputs `10` for clockwise, `01` for counterclockwise, `00` for neither. [Try it online!](https://tio.run/##K8gs@P8/UinIP9LdKchfyT/RrzLRLyis8v///0AxAA "Pip – Try It Online")
### Explanation
```
                     a is 1st cmdline argument
Y"ROYGBRO"           Yank that string into y variable
           aNy       Count of occurrences of a in y
          O          Output without newline
                RVy  y reversed
              aN     Count of occurrences of a in that string
                     Print (implicit)
```
[Answer]
# [J](http://jsoftware.com/), 21 bytes
```
-&(OR@E.&'ROYGBRO')|.
```
[Try it online!](https://tio.run/##y/qvpKegnqZga6WuoKNQa6VgoADE/3XVNPyDHFz11NSD/CPdnYL81TVr9P5rcqUmZ@QrANXYKqQpqAc5@atDROINISLukTARmBonpyA0kcggd5gIVBfQAjRz/IOc0HT5@/uj6QI56j8A "J – Try It Online")
### How it works
```
-&(OR@E.&'ROYGBRO')|.  Monadic 2-verb hook. Input: a string.
                   |.  Map over [input string, input string reversed]:
      E.&'ROYGBRO'     Find exact matches of input in 'ROYGBRO'
  (OR@            )    Reduce with OR; is it a substring of 'ROYGBRO'?
-&                     Reduce with -; result is 1 for CW, -1 for CCW, 0 otherwise
```
Achieves maximum amount of function reuse.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes
```
,Ṛẇ€“¤ƈẎṬ%Ȥ»
```
[Try it online!](https://tio.run/##ASkA1v9qZWxsef//LOG5muG6h@KCrOKAnMKkxojhuo7huawlyKTCu////2d5bw "Jelly – Try It Online")
-4 thanks to [Jonathan Allan](https://codegolf.stackexchange.com/questions/174564/playing-with-the-musical-turtle/174588?noredirect=1#comment420882_174588).
Clockwise: `[1, 0]`
Counter-clockwise: `[0, 1]`
Other: `[0, 0]`
[Answer]
# [R](https://www.r-project.org/), 38 bytes
```
grep(scan(,''),c('ROYGBRO','ORBGYOR'))
```
[Try it online!](https://tio.run/##pZJBb4MgFMfvfoqX9IAkatYem20HdvA2Em4eKT4dqaJBjGuWfXYHtWt6WbpNTgT@P/i9B3bewGRl36MF1wG2YyMdwuBKbfrRwaTdG0ioRqOc7gzEg2wRDiefUd1oHI2qp@/N@J1@DEqax/S6kmUZtehGGzbn2mIfh0ScEEITFRPBi5wJThLCBcsLLgil82cUbUCcqQH2fg4pvHYw9Ki0bPy97UEbeda5GXvQxmGNNn6gsEAvwRCtajp1nPSA0GLTlSdwVtc@iKWHdpfoz5nr@dsoqrwy44QCbH6h5Ef6fKMVcF/kgt@XW/BdoBgTay4tRL4Kz9nF@W6XFnwbKP@i/6iU81XtDZ/pb6rzFw "R – Try It Online")
Returns :
* No special combination : `integer(0)`
* Counterclockwise melody triggered : `2`
* Clockwise melody triggered : `1`
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 18 bytes
```
≔ROYGBROηＩ⁻№ηθ№⮌ηθ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/9@xuDgzPU9DKcg/0t0pyF9JRyFD05oroCgzr0TDObG4RMM3M6@0WMM5vxQokKGjUKipowDhBKWWpRYVp2pkaIJEgcD6/3//IKf/umU5AA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
 ROYGBRO            Literal string
≔       η           Assign to variable
            η   η   Value of variable
               ⮌    Reversed
             θ   θ  Input string
           №  №     Count matches
          ⁻         Subtract
         Ｉ          Cast to string
                    Implicitly print
```
[Answer]
# [Common Lisp](http://www.clisp.org/), 68 bytes
```
(defun x(s)(cond((search s "ROYGBRO")1)((search s "BGYORBG")-1)(0)))
```
[Try it online!](https://tio.run/##Zc0xCsMwDIXhvacQnvSGQnMFLR4N2jwGJyWB4Ia4hdzeEZkSd/349ZSWuay18jC@f5l2LuD0yQNzGfstTVTIaYheNDh0uLL4GFS8w9P8BaDyus35S7zbjViPx0WsbkREG4lqcyC6mZemsq@thL9tPaUe "Common Lisp – Try It Online")
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), 63 bytes
```
import StdEnv,Text
$s=map((>)0o indexOf s)["ROYGBRO","BGYORBG"]
```
[Try it online!](https://tio.run/##S85JTcz7n5ufUpqTqpCbmJn3PzO3IL@oRCG4JMU1r0wnJLWihEul2DY3sUBDw07TIF8hMy8ltcI/TaFYM1opyD/S3SnIX0lHyck90j/IyV0p9n9wSSJQu62CioISUE7p/7/ktJzE9OL/up4@/10q8xJzM5MhnICcxJK0/KJcAA "Clean – Try It Online")
`[True, True]` for no special noises, `[True, False]` for counterclockwise, `[False, True]` for clockwise.
[Answer]
# Japt, ~~17~~ 14 bytes
Takes the colours as input, in lowercase. Returns `0` for clockwise, `1` for counterclockwise or `-1` if there's no combo.
```
`ygß`ê qÔbøU
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.6&code=YJ55Z9+WYOogcdRi+FU=&input=InJibyI=)
---
## Expanation
```
`...`            :Compressed string "roygbrow"
     ê           :Palindromise
       qÔ        :Split on "w"
         b       :Index of the first element
          ø      : That contains
           U     :  The input string
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~53~~ 36 bytes
```
->n{"\a\fDch+".index(""<<n%111)&./3}
```
[Try it online!](https://tio.run/##DclBDoIwEAXQq5gmEolDzZ8ZdujKW5QuUGx0QUOakEiAsxe276XpNedwz9UjLqbt2vB8f6/G/mL/@V@MaZp4BlAW9iZbdmClWphUQSJCYCGWw8CEWkmPE4a3Qzcua1rHk0sUXPJ@yzs "Ruby – Try It Online")
Input: a 3-digit integer, where the digits represent colors:
* 1 - red
* 2 - orange
* 3 - yellow
* 4 - green
* 5 - blue
Output:0 for clockwise, 1 for counterclockwise, `nil` otherwise.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 55 bytes
Returns 0 for none, -1 for CCW and 1 for CW.
```
f(char*s){s=!strstr("ORBGYOR",s)-!strstr("ROYGBRO",s);}
```
[Try it online!](https://tio.run/##PY6xCsMwDET3foVqCNiJM3ROs3jJKNAW2g7BJamHpsUOWUK@XZVLKQh09ySO8/XkPfOo/WOIZTJbao9piTJaIbmuR1I2mfoPCfvOEWbY7BzmBZ5DmHUWQ5y8hRwEZSlmNbAdAMZX/J5De2ognPOX7Koy8I7CR62KBC0U9@usbA5ZL@FmYdQ/aUxz2JnJIUsddo64p46lBktDRhRG@AE "C (gcc) – Try It Online")
]


[Question]
      [
Use any programming language to display "AWSALILAND" in such a way, so that each letter is in a new line and repeated as many times as its position in the English alphabet. For example letter, (A) should be displayed just once because it is the first letter of the alphabet. Letter D should be displayed 4 times because it is the 4th letter of the alphabet.
So, the output should be this:
```
A
WWWWWWWWWWWWWWWWWWWWWWW
SSSSSSSSSSSSSSSSSSS
A
LLLLLLLLLLLL
IIIIIIIII
LLLLLLLLLLLL
A
NNNNNNNNNNNNNN
DDDD
```

[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~61~~ 59 bytes
```
foreach(var s in"AWSALILAND")WriteLine(new string(s,s-64));
```
[Try it online!](https://tio.run/##Sy7WTS7O/P8/Lb8oNTE5Q6MssUihWCEzT8kxPNjRx9PH0c9FSTO8KLMk1SczL1UjL7VcobikKDMvXaNYp1jXzERT0/r/fwA "C# (Visual C# Interactive Compiler) – Try It Online")
@Kevin Cruijssen Thanks, 2 bytes saved by removing { }
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~18~~ 17 bytes
*-1 byte from @Shaggy*
```
`awÑ¢Ó€`u ¬®pIaZc
```
---
```
`awÑ¢Ó€`u ¬®pIaZc   Full program
`awÑ¢Ó€`            Compressed "awasiland"
        u           uppercase
          ¬®        split and map each letter
            p         repeat the letter this many times:
              a         absolute difference of
               Zc         get charcode
             I            and 64
```
[Try it online!](https://tio.run/##ASEA3v9qYXB0//9gYXfDkcKiw5PCgGB1IMKswq5wSWFaY///LVI "Japt – Try It Online")
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 20 bytes
```
jm*d-Cd64"AWSALILAND
```
Try it online [here](https://pyth.herokuapp.com/?code=jm%2Ad-Cd64%22AWSALILAND&debug=0).
```
jm*d-Cd64"AWSALILAND
         "AWSALILAND   String literal "AWSALILAND"
 m                     Map each character of the above, as d, using:
     Cd                  Get character code of d
    -  64                Subtract 64
  *d                     Repeat d that many times
j                      Join on newlines, implicit print
```
**19 byte** alternative, which outputs lower case: `jm*dhxGd"awsaliland` - [link](https://pyth.herokuapp.com/?code=jm%2AdhxGd%22awsaliland&debug=0)
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 112 bytes
```
+++++++[->++>>++>+>++>>+++>+++[<<<]<<]++++>>+>-->++>-->+>-->++>+[[->+>+<<]----[>+<----]>+>[-<.>]++++++++++.<,<<]
```
[Try it online!](https://tio.run/##PYvRCYBADEMHir0JShcp96GCIIIfgvPXRA9D24Twulzzfm73elThU1oAocUIcqS7d44QlmEvpjsiUp8BMkYlk7yzS/MWHb@aT6SqHg "brainfuck – Try It Online")
The actual word generation can probably be optimised further.
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 34 bytes
```
"AWSALILAND"|% t*y|%{"$_"*($_-64)}
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/X8kxPNjRx9PH0c9FqUZVoUSrska1WkklXklLQyVe18xEs/b/fwA "PowerShell – Try It Online")
Takes the string `t`oCharArra`y`, then multiplies each letter out the corresponding number of times. Implicit `Write-Output` gives us newlines for free.
Ho-hum.
[Answer]
# Python 3,41 bytes
```
for i in'AWSALILAND':print(i*(ord(i)-64))
```
# Python 2,40 bytes
```
for i in'AWSALILAND':print i*(ord(i)-64)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 17 bytes
```
.•DθîRI§•ʒAyk>×u,
```
[Try it online!](https://tio.run/##yy9OTMpM/f9f71HDIpdzOw6vC/I8tBzIPjXJsTLb7vD0Up3//wE "05AB1E – Try It Online")
**Explanation**
```
.•DθîRI§•           # push compressed string "awsaliland"
         ʒ          # filter
          Ayk       # get the index of the current letter in the alphabet
             >      # increment
              ×     # repeat it that many times
               u    # upper-case
                ,   # print
```
We only use filter here to save a byte over other loops due to ac implicit copy of the element on the stack. Filter works here since we print in the loop and don't care about the result of the filter.
[Answer]
# [Stax](https://github.com/tomtheisen/stax),  ~~16~~  15 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
êôM▄╬æ♠ª+ç█○==.
```
[Run and debug it](https://staxlang.xyz/#p=88934ddcce9106a62b87db093d3d2e&i=)
**Explanation**
```
`'YHu~{YX#`m64-_]*      #Full program, unpacked,
`'YHu~{YX#`             #Compressed "AWSALILAND"
           m            #Use the rest of the program as the block. Print each mapped element with a new-line.
            64          #Put 64 on stack
              -         #Subtract current element by 64
               _        #Get current index
                ]       #Make a 1 element array
                 *      #Duplicate that many times
```
Saved one byte by figuring out that the "\*" command works with [arr int] and [int arr].
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 17 bytes
```
ＥAWSALILAND×ι⊕⌕αι
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM3sUBDyTE82NHH08fRz0VJRyEkMze1WCNTR8EzL7koNTc1ryQ1RcMtMy9FI1FHIVMTBKz///@vW5YDAA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
 AWSALILAND         Literal string
Ｅ                   Map over characters
                ι   Current character
               α    Uppercase alphabet
              ⌕     Find
             ⊕      Increment
            ι       Current character
           ×        Repeat
                    Implicitly print each entry on its own line
```
[Answer]
# [R](https://www.r-project.org/), ~~64~~ 61 bytes
R's clunky string handling characteristics on full display...
-3 thanks to @Giuseppe, who noticed it's actually shorter to *convert a string from utf8 to int and back again* than using R's native string splitting function...
```
write(strrep(intToUtf8(s<-utf8ToInt("AWSALILAND"),T),s-64),1)
```
[Try it online!](https://tio.run/##K/r/v7wosyRVo7ikqCi1QCMzryQkP7QkzUKj2Ea3FEiH5HvmlWgoOYYHO/p4@jj6uShp6oRo6hTrmplo6hhq/v8PAA "R – Try It Online")
[Answer]
# [Scala](https://www.scala-lang.org/) (51 bytes):
```
"AWSALILAND"map(c=>s"$c"*(c-64)mkString)map println
```
# [Scala](https://www.scala-lang.org/) (41 bytes):
```
for(c<-"AWSALILAND")println(s"$c"*(c-64))
```
[Try it online](https://tio.run/##K05OzEn8n5@UlZpcouCbmJmnkFpRkpqXUqzgWFCgUP0/Lb9II9lGV8kxPNjRx9PH0c9FSbOgKDOvJCdPo1hJJVlJSyNZ18xEU/N/7X8A)
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 22 bytes
A more elegant, tacit solution thanks to Adám!
```
(↑⎕A∘⍳⍴¨⊢)'AWSALILAND'
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v//Ud/UR20TNB61TQSyHB91zHjUu/lR75ZDKx51LdJUdwwPdvTx9HH0c1H//x8A "APL (Dyalog Classic) – Try It Online")
Initial solution:
```
↑a⍴¨⍨⎕A⍳a←'AWSALILAND'
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v//Ud/UR20THrVNTHzUu@XQike9K4Aijo96NycChdUdw4MdfTx9HP1c1P//BwA "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Perl 5](https://www.perl.org/), 35 bytes
```
say$_ x(31&ord)for AWSALILAND=~/./g
```
[Try it online!](https://tio.run/##K0gtyjH9/784sVIlXqFCw9hQLb8oRTMtv0jBMTzY0cfTx9HPxbZOX08//f//f/kFJZn5ecX/dX1N9QwMDQA "Perl 5 – Try It Online")
[Answer]
# [K (ngn/k)](https://gitlab.com/n9n/k), 23 22 bytes
```
(32!r)#'r:"AWSALILAND"
```
[Try it online!](https://tio.run/##y9bNS8/7/1/D2EixSFNZvchKyTE82NHH08fRz0Xp/38A)
```
         r:"AWSALILAND"  // set variable r to the string
(32!r)                   // mod 32 each string in r, the operation will use ASCII number
       #'                // for each value in the array, take that amount of the corresponding character in the string
```
[Answer]
# Java 11, ~~89~~ ~~83~~ ~~82~~ 81 bytes
```
v->"AWSALILAND".chars().forEach(c->System.out.println(((char)c+"").repeat(c-64)))
```
-1 byte thanks to *@OlivierGrégoire*.
[Try it online.](https://tio.run/##LY7BCoJAEIbvPsXgaZdwT9FFEoQ6BOZFqEN0mKYttXWV3VWI8NltLS8zzM/PfF@NA0b1/TWRQmvhiJX@BACVdtI8kCTk8wkwtNUdiJ3mNfDYZ2Pgh3XoKoIcNGynIUrC9Fyk2SFL810oqERjGReP1uyRSkZRUrytk41oeyc64yFKM8bmHqdVGHJhZCfR@eZmzTmf4pnR9TflGQvqJ9J4TVY4/@F5uQLyv6MWxHSv1KI3Tl8)
**Explanation:**
```
v->                      // Method with empty unused parameter and no return-type
  "AWSALILAND".chars().forEach(c->
                         //  Loop over the characters as integer unicode values
    System.out.println(  //   Print with trailing newline:
      ((char)c+"")       //    The current character converted to char and then String
       .repeat(c-64)))   //    repeated the unicode value minus 64 amount of times
```
[Answer]
# [J](http://jsoftware.com/), 31 bytes
```
echo(#&>~_64+a.i.])'AWSALILAND'
```
[Try it online!](https://tio.run/##y/r/PzU5I19DWc2uLt7MRDtRL1MvVlPdMTzY0cfTx9HPRf3/fwA "J – Try It Online")
## Explanation:
```
echo(#&>~_64+a.i.])'AWSALILAND' - print
     #  ~                       - copy (arguments reversed)
      &>                        - each character (can be "0)
               i.               - the index of
                 ]              - the characters in
             a.                 - the alphabet
         _64+                   - minus 64 (times)
```
[Answer]
# [SNOBOL4 (CSNOBOL4)](http://www.snobol4.org/csnobol4/), 88 bytes
```
	S ='AWSALILAND'
L	S LEN(1) . X REM . S :F(END)
	&UCASE X @Y
	OUTPUT =DUPL(X,Y)	:(L)
END
```
[Try it online!](https://tio.run/##DYqxCoAgFABn/Yo3pUIEQZMgJGkQvExSydbmqKH/x5wO7u573uu9h1JIAMX0ETQuqJ1hFKtB63gvoIMMu10rA8iZW2cEJU2adLC1jCclW4o@RVAmeeS5PQWRHAWtZyk/ "SNOBOL4 (CSNOBOL4) – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), 20 bytes
```
'AWSALILAND'"@@64-Y"
```
[Try it online!](https://tio.run/##y00syfn/X90xPNjRx9PH0c9FXcnBwcxEN1Lp/38A "MATL – Try It Online")
### Explanation
```
'AWSALILAND'   % Push this string
"              % For each character in this string
  @            %   Push current character
  @            %   Push current character
  64-          %   Implicitly convert to codepoint and subtract 64
  Y"           %   Repeat that many times. Gives a string with the repeated character
               % Implicit end
               % Implicit display
```
[Answer]
# [Red](http://www.red-lang.org), 59 bytes
```
foreach c"AWSALILAND"[print pad/with c to-integer c - 64 c]
```
[Try it online!](https://tio.run/##K0pN@R@UmhId@z8tvyg1MTlDIVnJMTzY0cfTx9HPRSm6oCgzr0ShIDFFvzyzBCipUJKvCxRJTU8tAnJ0FcxMFJJj//8HAA "Red – Try It Online")
[Answer]
## Haskell, 43 bytes
```
mapM(putStrLn. \c->c<$['A'..c])"AWSALILAND"
```
[Try it online!](https://tio.run/##y0gszk7Nyfmfm5iZZxsDpAp8NQpKS4JLinzy9BRiknXtkm1UotUd1fX0kmM1lRzDgx19PH0c/VyU/v//l5yWk5he/F83uaAAAA "Haskell – Try It Online")
[Answer]
# [SOGL V0.12](https://github.com/dzaima/SOGLOnline), 16 [bytes](https://github.com/dzaima/SOGL/blob/master/chartable.md)
```
i|╚┌ž′ø¹‘U{Z⁴W*P
```
[Try it Here!](https://dzaima.github.io/SOGLOnline/?code=aSU3QyV1MjU1QSV1MjUwQyV1MDE3RSV1MjAzMiVGOCVCOSV1MjAxOFUlN0JaJXUyMDc0VypQ,v=0.12)
[Answer]
# T-SQL, 83 bytes
```
SELECT REPLICATE(value,ASCII(value)-64)FROM STRING_SPLIT('A-W-S-A-L-I-L-A-N-D','-')
```
`STRING_SPLIT` is supported by [SQL 2016 and later](https://docs.microsoft.com/en-us/sql/t-sql/functions/string-split-transact-sql).
[Answer]
# [Pip](https://github.com/dloscutoff/pip) `-l`, 21 bytes
```
_X A_-64M"AWSALILAND"
```
[Try it online!](https://tio.run/##K8gs@P8/PkLBMV7XzMRXyTE82NHH08fRz0Xp////ujkA "Pip – Try It Online")
```
         "AWSALILAND"  Literal string
        M              to the characters of which we map this function:
   A_                   ASCII value of character
     -64                minus 64 (= 1-based index in alphabet)
_X                      String-repeat character that many times
                       Autoprint, with each item on its own line (-l flag)
```
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~96~~ ~~95~~ ~~77~~ 73 bytes
```
*s=L" AWSALILAND";main(i){for(;*++s;puts(""))for(i=*s-63;--i;printf(s));}
```
[Try it online!](https://tio.run/##S9ZNT07@/1@r2NZHScExPNjRx9PH0c9FyTo3MTNPI1OzOi2/SMNaS1u72LqgtKRYQ0lJUxMklGmrVaxrZmytq5tpXVCUmVeSplGsqWld@/8/AA "C (gcc) – Try It Online")
-18 bytes thanks to @ErikF
-5 bytes thanks to @ceilingcat
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~65~~ 63 bytes
```
i=>[...'AWSALILAND'].map(c=>c.repeat(parseInt(c,36)-9)).join`
`
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9mm2lrF62np6fuGB7s6OPp4@jnoh6rl5tYoJFsa5esV5RakJpYolGQWFSc6plXopGsY2ymqWupqamXlZ@Zl8CV8D85P684PydVLyc/XSNNQ1Pz/38A "JavaScript (Node.js) – Try It Online")
**Explanation:**
```
i=>                         // Prints the result of this function
  [...'AWSALILAND'].map(c=> // Loop over the characters
    c.repeat(               // Repeat the current character
      parseInt(c,36)-9)))   // Character to alphabetical position
        .join`
        `                   // Prints a newline after every new char
```
**Edit:** -2 bytes thanks to @BrianH.
[Answer]
# Julia, 41 bytes
```
[println(l^(l-'@')) for l∈"AWSALILAND"]
```
[Try it online!](https://tio.run/##yyrNyUw0rPj/P7qgKDOvJCdPIydOI0dX3UFdU1MhLb9IIedRR4eSY3iwo4@nj6Ofi1Ls//8A "Julia 1.0 – Try It Online")
[Answer]
# [Swift](https://swift.org), 95 bytes
```
"AWSALILAND".unicodeScalars.forEach{print(String(repeating:String($0),count:Int($0.value)-64))}
```
**[Try it online!](http://jdoodle.com/a/JPk)**
**How?**
```
"AWSALILAND"                             // Starting string
    .unicodeScalars                      // Convert into a list of unicode values
    .forEach {                           // Loop over each number
        print(String(                    // Create a string
            repeating: String($0),       //   that repeats each character
            count: Int($0.value) - 64))  //   the unicode value minus 64 (the offset)
}
```
[Answer]
# [Z80Golf](https://github.com/lynn/z80golf), 30 bytes
```
00000000: 2114 007e d640 477e ff10 fd23 3e0a ff7e  !..~.@G~...#>..~
00000010: b720 f076 4157 5341 4c49 4c41 4e44       . .vAWSALILAND
```
[Try it online!](https://tio.run/##LYyxCsJAEER7v2LEftm922TVQjwQRAg2FtZq7tIIdilS5NfPlTjF8GYYZtry8HmXWvmvPYKIgtky@lYZak6lCKP0ISJmfnj0DmuimY7nmYg2B@fV8iD@8bTge7YWKo2hiSrQl@5@5pRVsYhAY7rfUnfp0vVU6xc "Z80Golf – Try It Online")
Assembly:
```
ld hl,str			;load address of str
start:
	ld a,(hl)		;get current char
	sub 64 		;get letter num in alphabet
	ld b,a			;store in b
	ld a,(hl)		;get current char
	print_char:
		rst 38h 	;print letter
		djnz print_char	;repeat print loop b times
	inc hl			;increment index of str, to get next char
	ld a,10
	rst 38h 		;print newline
	ld a,(hl)		;get current char
	or a
	jr nz, start		;if current char!=0, keep looping
end:
	halt			;end program (if current char==0)
str:
	db 'AWSALILAND'
```
[Try it online!](https://tio.run/##hZIxT8MwEIVn51ccU4uUKpFgqGg7RAIkpAoGBkZk19fGxbEj@wqh4r@Hc5SqgqVDFNv3fO97lygZ634jCZbLh5dH@IHCt1TIGLFR9nt2nJcFPzI2UGj8LCJp42DmYcbSrtO91VDbPFIQQiyslxqk1gFjBL8FPs4iyUB3mWChzKe1vWbdDgk2hxDQ8buWIRPxoKDsbsuxaJEIA7hDA2wnbVtLhTQ0UblMVpF8wFRUl1q3wTh6T2umECESG93MxWI4H524oPfuCGetWARskecyyrxvQQGZBmMmjNtw6oTBq4BNMjNOYzeGzoE8JBKH3QljgCy7KjsjnBgcflnj8FIQH0BmYs9jOeYwjDUBbP@orlZlDh@I7UBs3C5Dpzl3LS0lXt5xIr8LsoHpv7urVXnNnyuNSSuYVG@v1fppXT3fT3r@Nfpf "Bash – Try It Online")
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 40 bytes
```
"DNALILASWA"v
 oa~~<v-*88:<
-:0=?^>$:o$1
```
[Try it online!](https://tio.run/##S8sszvj/X8nFz9HH08cxONxRqYxLIT@xrs6mTFfLwsLKhkvXysDWPs5OxSpfxfD/fwA "><> – Try It Online")
[Answer]
# JavaScript, ~~74~~ 68 bytes
```
for(i in s="AWSALILAND")console.log(s[i].repeat(s.charCodeAt(i)-64))
```
* 74->68, -6B for changing `for` loop to `for...in`, saving bytes on loop statement, removed increment, and removing statement to save the character.
]