[Question]
  [
## Background
Numeric Mahjong is a hypothetical variation of Japanese Mahjong, played with nonnegative integers instead of Mahjong tiles. Given a list of nonnegative integers, it is a *winning hand* if it satisfies the following:
* its length is \$3n+2\$ for some nonnegative integer \$n\$, and
* it can be partitioned into \$n\$ triples and a pair so that
	+ each triple consists of three identical numbers \$(x,x,x)\$ or three consecutive numbers \$(x,x+1,x+2)\$, and
	+ the pair consists of two identical numbers \$(x,x)\$.
## Challenge
Write a program or function that tests if a given a list of nonnegative integers is a winning hand in Numeric Mahjong. As this is a [self-validating](/questions/tagged/self-validating "show questions tagged 'self-validating'") challenge, **your source code** (when converted to a list of integers) **must be a winning hand.** For example, `print(1)` is not a valid answer even if it implements the task, but the following may be:
```
print(1)###*11ios
```
whose ASCII values in sorted order is `[35, 35, 35, 40, 41, 42, 49, 49, 49, 105, 105, 110, 111, 112, 114, 115, 116]`, which can be partitioned to five triples `[35, 35, 35], [40, 41, 42], [49, 49, 49], [110, 111, 112], [114, 115, 116]` and a pair `[105, 105]`.
When converting the source code to integers, you may choose between
* Unicode codepoints of each char (when the source code is a sequence of Unicode characters),
* one of your language's fixed-width encodings, or
* a raw byte sequence (when the source code has an integral number of bytes).
If there are other sensible conversions, please leave a comment.
For output, you can choose to
* output truthy/falsy using your language's convention (swapping is allowed), or
* use two distinct, fixed values to represent true (affirmative) or false (negative) respectively.
Standard [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") rules apply. The shortest code in bytes wins.
## Test cases
### Truthy
```
[0, 0]
[999, 999, 999, 1234, 1234]
[1, 2, 2, 2, 3]
[1, 4, 7, 2, 5, 5, 5, 8, 3, 6, 9]
[1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7]
[1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3]
[0, 0, 0, 0, 0, 0, 0, 0]
```
### Falsy
```
[]
[1]
[1, 3, 5, 7, 9]
[1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64]
```
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~47~~ ~~47~~ ~~44~~ ~~41~~ 38 bytes
```
≈ì í3√¥ í¬•J>}gy3√¥ í¬•T>SQ}g+3*Ig>Q}ƒáQ,¬•‚Ä∫HUyy
```
[Try it online!](https://tio.run/##yy9OTMpM/f//6ORTk4wPbzk16dBSL7va9EooO8QuOLA2XdtYyzPdLrD2SHugzqGljxp2eYRWVv7/H22oo2Cko2Cso2Cio2AaCwA), or [try all test cases (this code can handle in under a minute)](https://tio.run/##yy9OTMpM/V9Waa@koGunoGRfeWjl/6OTT00yPrzl1KRDS73satMroewQu@DA2nRtY61D69LtAmuPtAfqHFr6qGGXR2hl5f//0dGxOgrRhiDCQEfBAMzRUTDWUTDVUTDXUbCEChjBkDFIwNLSEigFJwyNjE0gJEI10ASgmGlsLAA).
[See the codepoints](https://tio.run/##yy9OTMpM/a/0/@jkU5OMD285NenQUi@72vRKKDvELjiwNl3bWMsz3S6w9kh7oM6hpY8adnmEVlb@Vzq07cKec1uP7jvSVpxdW11Waa@koGunoGQPEqk8vEKn9j8A)
Returns `0` for true and `[]` for false.
## Explanation
The general approach is this: Test for the existence of a permutation such that if we split it to parts of length 3, and then keep all the valid ones and count them, and multiply by 3, we should get 1 plus the length of the original input.
```
≈ì       # all permutations
 í       # keep those such that:
 3√¥      # split to parts of length 3
  í       # keep parts where:
  ¬•       # their differences
  J       # joined to a string
  >       # plus one
 }       # (is equal to 1)
 g       # find the length
 y       # push the input again
 3√¥      # and split to parts of length 3
  í       # keep parts such that:
  ¬•      # their differences
  T>     # 11
  S      # [1, 1]
  Q      # [1, 1] is equal to the differences
 }
 g       # take their lengths
 +       # sum the lengths of the two types of parts
 3*      # times 3
 I       # input
 g       # length
 >       # plus one
 Q       # is equal to the number of valid parts times 3
}
ƒáQ      # test whether the array is empty, by comparing arr[0] == arr[1:]
,        # output - this suppresses implicit output, so the rest of the code doesn't matter
¬•‚Ä∫HUyy  # filler to satisfy the self validation requirement
```
[Answer]
# JavaScript (ES6), ~~¬†143 122¬†~~ 119 bytes
*-24 bytes thanks to [@tsh](https://codegolf.stackexchange.com/users/44718/tsh)!*
Expects an `Uint32Array`. Returns a Boolean value.
```
n=>(q=([v,...f],e)=>6/v?[e,4,4.5].some(t=>q(f.filter(i=>p>t|v+t%1*p-i||0%[p*=2],p=2),t<p?4>t?4:e:1%0)):e>3)(n.sort(),3)
```
[Try it online!](https://tio.run/##nZDNTsMwDMfvfYpo0qRkZKFNsu6LZOLAnmCcSg/RSFlRabs0FE3au5euYaXAjehnK7Id52@/qlpVe5OWdpoXz7rZiiYXEh4FjGpMCElirJGQ4W29iTTmmJNZTKriTUMr5BEmJEkzqw1MhSylPdc3dhxMyml6PvvjqJwIGuNSUITtXbnh0m74Sq@CsY/QSkuGYN72MhYizFCzL/KqyDTJihc4inbm3R5O8QitvcgDIPIx8GN8uS2XSwy@XUAZd96lAwzoFdaH2pJ5F5pdWbRpDMK2y693rINfcdVhR9ti3lf30OGPDld00fyX2Is9khTmQe0PUAEhwXDyLcz1B3hMc8vovTHqBBVqz9rzfuznKY@2KqsGC/rS1ctjne75cL5eq5ts0RGEzhh1FvKL/U9k8wk "JavaScript (Node.js) ‚Äì Try It Online")
The above function is too slow to validate itself on TIO, so this is using my original answer with an additional optimization:
[Try it online!](https://tio.run/##Xc/PToQwEAbw@z4FbgKZQqlQ0APLlOhh38AT4UCwNRhs@VMxJrw7FuNh4xwnk@/7zXu7tks396ONtXmV@xV3hQImhHqljDHVUIkJQZHer5UseRDUnOb0oWGL@ZBg3a3GlBpUTPWDlTP0KHTIhd36eI2tz0O9bXdRpAn9XQfBBIbKCGyZETeFREwJKJc3WyBkH6T1Okfx0Dvr/xQHeXSQWjpDzm4UE9wCRle/RtZPwzHuty3x6zFE3tAROaG2HKtc2CovZJH6yUEQGQH9J6AZOV9Op87oxQySDeYNrqDll/fSa5vxp3luv@H5UylXdTiPJy77Dw "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 71 bytes
```
oo::{*0-0!=|/{:[&/0=x;1;|/^%x;0;o@@[1_x;!2;-;3!*x]]}'+@[-2*=3+/x;x;1+]}
```
[Try it online!](https://ngn.codeberg.page/k#eJxlUstuhDAMvOcrzGrbSjxEHpAAKRL/QdN2L5V6yhVpd/+9jr2kVNWMrRB7xlZEjNN0LWUji/nWXqf1uZXz5pW/te9Pm5c+LsuqPjZfaN94U5RbCPeXalkbXc6majePzVW4C/E1oTpGSGKZLlqxyhpkEOs4jjX8JqVNxxlrqga90/A3Fh199zsHrNVgUX9UGGK3k1stEfWOWzP1cRAz8Ib/GYRYk5wtDBm7PD2b8dyBqCyH0Ry2S5HX5UX7IN7wpUCCxIyPkSO9BiW8V6AJhs4dODz3hAEMWBhzj0F0hFS1CAeOqgy9OyXw3CNwlQUKmXKtSGbQxj0GsDyZDwhlE41OtB3ysURaoCejz+/zKeLfdKrPMYrXS3GZ/lz9AKoTePc=)
Based on a polynomial-time algorithm with respect to the maximal element, so it can test all test cases and itself in a second.
Let's call `(x,x,x)` an *x-triplet* and `(x,x+1,x+2)` an *x-sequence*.
* Count the occurrence of each number in `[0, 1, 2, ...]` up to the maximal element that appears in the input. Let's call it C.
* For `i` from 0 to the maximum index of C,
	+ Construct a copy of C where `i`-th element is subtracted by 2. (i.e., Assume a pair is `(i,i)`.)
	+ Repeat until one of the halting condition is met:
		- If the remaining array is all zeros, return true.
		- If the remaining array contains a negative value, return false.
		- Otherwise, pop `x` from the front, and subtract `x%3` from the first two elements. (i.e., Maximally create `j`-triplets and try creating `j`-sequences for the remaining `j`s.)
* If any choice of `i` gives true, return true. Otherwise return false.
If a partition exists and it contains three or more `j`-sequences for some `j`, three copies of `j`-sequences can be replaced with `j`-, `j+1`-, and `j+2`-triplets to get another valid partition. Also, when considering all possible partitions where the minimum value is `j`, choosing to have three `j`-sequences (compared to one `j`-triplet) has the effect of fixing a `j+1`- and `j+2`-triplet from the remaining numbers, leaving a strict subset of choices afterwards. Therefore, it suffices to check if a greedy partitioning (favoring triplets) leads to a valid one.
```
{|/{:[&/0=x;1;|/^%x;0;o@@[1_x;!2;-;3!*x]]}'+@[-2*=3+/x;x;1+]}
+@[-2*=3+/x;x;1+]  construct number-count arrays with all choices of pairs
      =3+/x        identity matrix of size `sum of x + 3`
   -2*             change 1s on the diagonal to -2
 @[        ;x;1+]  for each number i in x, add 1 to i-th row of the above
+                  transpose
{:[...]}'  test if each number-count array is partitionable
&/0=x;1;   if all elements are 0, return 1
|/^%x;0;   if any element is negative, return 0
           (monadic % is square root, which gives 0n for negatives;
            monadic ^ is null-check, which gives 1 for 0n)
o@@[1_x;!2;-;3!*x]  otherwise, update the array and do recursive call
    1_x             remove first element k
        !2          and update 0th and 1st elements by
           - 3!*x   subtracting k%3
o@                  recursive call
|/  return 1 if any is true
*0-0!=  filler that preserves truthiness
oo::    globally assign function to the name oo
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~128~~ ~~125~~ ~~122~~ 95 bytes
```
‚âî‚àßŒ∏Ôº•‚åà‚Å∫¬≥Œ∏‚ÑñŒ∏ŒπŒ∏Ôº¶Ôº•Œ∏‚ÆåÔº•Œ∏‚ÅªŒª‚àß‚ÅºŒ∫Œº¬≤¬´Ôº∑‚àß‚Ä∫Ôº¨Œπ¬≤¬¨‚Äπ‚åäŒπ‚Å∞¬´‚âîÔπ™‚äüŒπ¬≥Œ∏Ôº¶¬≤¬ß‚âîŒπ¬±‚äïŒª‚Åª¬ßŒπ¬±‚äïŒªŒ∏¬ªÔº∞‚Üî¬¨‚åà‚ÜîŒπ¬ªÔº∑‚Å∞¬´‚äü‚äü‚åä‚â°‚Üî‚äï¬¨¬ßÔπ™Ôπ™‚Å∫‚Å∫‚Åª‚Å∞¬≥Ôº¶Ôº¨Ôº¨Ôº∞Ôº∞Ôº∑ŒπŒªŒ∏¬ª
```
[Try it online!](https://tio.run/##dVFLTsMwEL0KB2CRUGiSs1RdJE4RCyQkVl02EqraKMvCtmIBkWiEAlk0v5UP4EP4AjlCGM9YtSlCsl6cmTfvvUnYXfjIHsL7cZTbndzkoh76N5ltZNLyStTy6UXUolHVd2hA4TOjZ9KJDvgy6UUrev7ND0N/VIVVO/SFaKBSyFUjs1Q0Min5AfSH5kOme@hVKAiUHKrw/iXTZ5BLOp6f3kTNu6Ev5XoHQhBorYidMkG1dK9OlsrtK7Rgghc8BwPlkbR4OsWsMHmBp8RzhH1QfRxnM2fps8sLZ@m4Cm8R2Y1CN1QYRgqjien6vrkvAmtqamY1808ljHHKcoyogi4LvEdXyESX2LOYC1RjxlczqYt1N7C6jtGhHUNM4kwtzuQ8v9a8NlPEdDFhwEx@2oWY/3H01tiNMU8wNZnpCwdWHs30zvNTZkLa0ffMLDmSJuWhTTVGFsZGmXbXf40ZpJwaPZPt90bz@Q8 "Charcoal ‚Äì Try It Online") Uses the Charcoal code page. Add the `-x` argument to show the hex dump which you can compare against the input. Outputs a Charcoal boolean, i.e. `-` for a winning hand, nothing if not. Explanation: Now a port of @Bubbler's algorithm.
```
‚âîÔº•‚Å∫¬≥‚åàŒ∏‚ÑñŒ∏ŒπŒ∏
```
Count the number of times each integer appears in the array, plus some extra dummy values.
```
Ôº¶Ôº•Œ∏‚ÆåÔº•Œ∏‚ÅªŒª‚àß‚ÅºŒ∫Œº¬≤¬´
```
Try each integer in case it's the pair.
```
Ôº∑‚àß‚Ä∫Ôº¨Œπ¬≤¬¨‚Äπ‚åäŒπ‚Å∞¬´
```
Repeat until a count becomes negative or the length is reduced to `2`.
```
‚âîÔπ™‚äüŒπ¬≥Œ∏
```
Get the number of runs needed to satisfy the next integer.
```
Ôº¶¬≤¬ß‚âîŒπ¬±‚äïŒª‚Åª¬ßŒπ¬±‚äïŒªŒ∏
```
Subtract them from the next two integers.
```
¬ªÔº∞‚Üî¬¨‚åä‚ÜîŒπ
```
Output a `-` if this reduced all the integers to zero (but not negative).
```
¬ªÔº∑‚Å∞¬´‚äü‚äü‚åä‚â°‚Üî‚äï¬¨¬ßÔπ™Ôπ™‚Å∫‚Å∫‚Åª‚Å∞¬≥Ôº¶Ôº¨Ôº¨Ôº∞Ôº∞Ôº∑ŒπŒªŒ∏¬ª
```
Filler bytes to satisfy the source layout, wrapped in a `while` loop whose condition is false.
Original verbose code (without padding): [Try it online!](https://tio.run/##hVFda4MwFH22vyKPERxou1WlTzLGKMxR9lr6EDVtw1Jt/eiE0d/uknvTxXWM@XBI7j3n3nNivmd1XjE5DEnTiF1Jk7KgJ4@k7EhT1otDd6Ar2TV05pGT63rkserKVjOEq68ndzHZVjWhWqCqb/zM64Zfr6kolVZ6RI99OnVMNvTdIwelnLrwkc@J87EXkhNY/Vxz1vKavvBy1@6pAKJHXqtWlZqGqoHgSTf8q94x3tOq6GRFV9UR@jPjz3HA4dQlyEvaZVnwngo1l@/UOros85ofeNnygkodC33/S4QFesNl4qSdbMWxFup1kqypZKfo2vb1Fb@LAnIvJpdhWK/9PspVkt4PNG4B8weNAdPIMo3ZzHajyJ55PFLNrdYwf1VYAarRxgwrsIXDOZsCE7YU4YjJYVpu9xomdqEexKOub@dgRgZO/PmIM7v1b2beWxUyA3AY59Y/ZkHmXxyTGroF@Inn1jO@cDzyY5jhrX/0jIgZo9BqcSPORD@Y1GA2wsJOxuzmr@UW0afB0Hr7mWizGe7O8gs "Charcoal ‚Äì Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 122 bytes
```
f=(A,e,k,n)=>1/n&&!{'1,1':1,'0,0':'B\():'|1}[[e-k,k-n]]?!!0:A+A?A.some((C,j)=>f(A.filter(B=>j--),C,...1/n?[]:[e,k])):e==+k
```
[Try it online!](https://tio.run/##jZBRT4MwEMff@RTdHkabHZXChA3TLWxxn8C3rg9kFjdAMDBNjPrZsaMOUV9Mfndp7q53/7sseUmafX18Ojllda/aLW9TjmNQkENJ@JJdlZPJ6M1mwOyIge2Ca0f2eodJZL@zDyGUk0PulFKuRiM3iqfxKqZN9agw3kCmG6Q4pumxOKkar/kycxwCG6CU6sYrISOhB0lCIsX5NG/3VdlUhaJF9YDH4q5@Ph1e5ZjcWMJCSLiAXAnn12KxAPTtmOfPjDdpBsi74PchXRJ2oesLc50GFOguv/75HbMLpjro0C3CvrrHG040mKKz5r/onLRoWtW3yf6AE8SXaLj6FieE6K2tH/fYlWKbFM3gIF86ejl@pzMc7tNrM5vMO1hgzPeMBbOzyf9oaj8B "JavaScript (Node.js) ‚Äì Try It Online")
Besides tuplets: `&& ++,,-- --..// AABBCC [\] ijjkkl mno rst {|}`
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 50 bytes
```
¬∞√æ√æ&&,@∆ë∆íW√ü¬ª»§
W√ûW+√æ@3‚Äô≈ì&∆ë∆á≈ì-@‚Ç¨∆≤‚Ç¨·∫é$∆¨·∫é≈í…†%¬π∆á…ó‚Ç¨3‚Äò≈ì&∆ë∆á3
```
[Try it online!](https://tio.run/##y0rNyan8///QhsP7Du9TU9NxODbx2KTww/MP7T6xhCv88Lxw7cP7HIwfNcw8OlkNKNV@dLKuw6OmNcc2AYmHu/pUjoHIo5NOLlA9tPNY@8npQGGg6hlQ1cb/D@08PMMr89HGdUAjjnX5H5tof7j94a4dXA937ju0E8S1ftQwR0HXTuFRw1zrw@1cD3dvOTopDGjK4XYgEfn/v5KSUrSBjoJBLFe0paWljgKCMDQyNoGQQDlDHQUjGDKG8IGS5mC@KQxZAOV0FMyA@pF1GIORCQxBlJqBEVC/OUQpHBkhWwRBQBUgF2KiWC4lrAF7aBvlIavEFQ1yGcR1xmA3m8M9BncnxEsWYGRoBsHGRhBsZgLCscAABgA "Jelly ‚Äì Try It Online")
The main part is a monadic link that takes a list of integers and returns an empty list for false and a list containing one or more items for truthy. To meet the challenge rules, the program includes another link above the main one which is just filler.
Completes all test cases including itself in about 17 seconds on TIO. Full explanation to follow. Note the footer turns the falsy and truthy outcomes to 0 and 1 for more compact printing.
General explanation:
* Remove every possible combination of runs of three (including removing none)
* Check the remaining integers are in groups of length 0 mod 3, except for one that is of length 2 mod 3
## Explanation
```
¬∞√æ√æ&&,@∆ë∆íW√ü¬ª»§ | Filler to meet challenge requirements
W√û                                   | Sort (technically with order based on that after wrapping each item in a list, but this doesn't affect sort order)
  W                                  | Wrap in a list
                   $∆¨                | Repeat the following until no changes are made, gathering up intermediate results
                ∆≤‚Ç¨                   | - For each list in the lists of lists (example for e.g. [1, 2, 3, 4, 4])
   +√æ@3                              |   - Outer addition using 1, 2, 3 e.g. [[[2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [5, 6, 7]]
       ‚Äô                             |   - Decrease by 1 e.g. [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [4, 5, 6]]
        ≈ì&∆ë∆á                         |   - Filter, keeping only those lists that were seen in the original list e.g. [[1, 2, 3], [2, 3, 4]]
            ≈ì-@‚Ç¨                     |   - Filter the original list removing each of these in turn [[4, 4], [1, 4]]
                  ·∫é                  | - Join inner lists together, leaving one list of lists
                     ·∫é               | Join all gathered intermediate results into one list of lists
                           …ó‚Ç¨        | For each list within this list:
                      ≈í…†             | - Run lengths
                        %    3       | - Mod 3
                         ¬π∆á          | - Only keep those non-zero (i.e. those lists that were not a multiple of 3 in length)
                              ‚Äò      | Increase by 1
                               ≈ì&∆ë∆á3 | Only keep those that consist of a single 3
```
Some of the code above (e.g. using `W√û` rather than `·π¢`) would be suboptimal in normal code-golf challenges, but here improve length by reducing the amount of filler required.
The runtime is sufficient to complete all the test cases, but as written becomes very inefficient as the number of runs of three consecutive numbers increases. This can be greatly improved by adding a uniquify step ([TIO](https://tio.run/##y0rNyan8///QBp3D@w7vU1NVdTg28dik8MPzD@0@sSQw8FjXsS6u8MPzwrUP73MwftQw8@hkNaCC9qOTdR0eNa05tglIPNzVB1IHoo9OOrlA9dDOY@0npwMlgOpnQNUb/z@08/AMr8xHG9cBDTnW5X9sov3h9oe7dnA93Lnv0E4Q1/pRwxwFXTuFRw1zrQ@3cz3cveXopDCgKYfbgUTk//9KSkrRBjoKBrFc0ZaWljoKCMLQyNgEQgLlDHUUjGDIGMIHSpqD@aYwZAGU01EwA@pH1mEMRiYwBFFqBkZA/eYQpXBkhGwRBAFVgFyIiWK5lPCF8KFt1AhiJa5okBMhzjQGO94c7kO4gyF@swAjQzMINjaCYDMTEI4FhjQA)), reducing the run time for all test cases and my original code down to ~0.3 seconds total).
[Answer]
# [Raku](https://raku.org/), ~~121~~ 116 bytes
```
{sub k(\u){u{*}~~[.2/.1]||?(u{*}:k).grep:{?grep {u (>)$_&&k u (-)$_},^3+$_,[$_,$_,$_]}}(bag |$_)}#%&//:>>?\`aabeqqss
```
[Try it online!](https://tio.run/##ZY7dboMwDIVfxeoYClsGJWGhMBUehDIGEvSCVqMgLqqQvjrLD7SbJn3HsWzn2F3dn9h8voLdwH7mw1hBiw6jw0f@Im63zCWe6@fTlCJViFvHPfZ1F/NUPcBHQIljFbbdgkzfZCrwJ321CpxJaXIhUFUeYbIKRzw9254XJ0l6@CrLqr5chmH@gKG8wsYq3E4egxzYJ8AbkFYbaL57yLYYtjmGLIoiDI/gExqYqJo@BrJCl4Jsh7rwvrKTTQxMOvz5QzXBipllGmkQLrN3yO9dBjWi7vyP6miDxYVq8/Bxwt3QLN9pfGZEiRELlPL5Bw "Perl 6 ‚Äì Try It Online")
The inner subroutine name `k` and its argument `u` were somewhat haphazardly chosen to try to produce more triples and runs.
* `bag |$_` converts the argument list into a `Bag` (a set with multiplicity) which is then given to the inner recursive subroutine `k`.
* The subroutine returns true if `u{*} ~~ [.2/.1]`, that is, if the bag contains a single element with multiplicity 2. This is the pair that a winning mah jong hand must contain.
* Otherwise, for the keys ùë• in the bag (`u{*}:k`), return true if the bag is a superset (`u (>) $_`) of either the run ùë•, ùë• + 1, ùë• + 2 (`^3 + $_`) or the triple ùë•, ùë•, ùë• (`[$_, $_, $_]`), and the bag minus those elements (`u (-) $_`) produces a true result when passed to the inner recursive function `k`. (Normally I prefer using the Unicode characters for superset (`‚äÉ`) and set minus (`‚àñ`), which are the same number of bytes as the equivalent plain ASCII operators (`(>)` and `(-)` respectively), but then I'd have to repeat both of them twice in the trailing comment for a substantial byte penalty.)
Of course, the trailing comment `#%&//:>>?\`aabeqqss` makes the overall code snippet into a winning numerical mah jong hand. The function takes an infeasibly long time to validate itself; I constructed the comment by visual inspection of the function's character distribution.
The pair is: `~~`
The runs are: `#$%`, `()*`, `()*`, `+,-`, `123`, `[\]`, `[\]`, `^_` plus a backtick I can't figure out how to escape, `pqr`, `pqr`
The triples are: , , `$$$`, `$$$`, `&&&`, `(((`, `)))`, `,,,`, `...`, `///`, `:::`, `>>>`, `???`, `___`, `___`, `aaa`, `bbb`, `eee`, `ggg`, `kkk`, `sss`, `uuu`, `uuu`, `{{{`, `{{{`, `|||`, `}}}`, `}}}`
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~116~~ 92 bytes
Brute force solution checking all permutations until it finds one that matches. Times out on medium inputs, so verification was done using the program below since it doesn't time out as easily.
Recursive approach saving 24 bytes by G B.
```
e=->a{a[2]?a.permutation.any?{_,o,z,*i=_1;_-o==(o-=z)&&o**2<2&&e[i]}:a!=a|a}#"')).11@@A[]ass
```
[Attempt This Online!](https://ato.pxeger.com/run?1=tVBLTsMwFBTbbLmA-ZmkOFbsAG0pbss5jBW5YGiktI4aFxQan4RNF-VQcBqSuIVKrJFGI83Mex7rvW8Wy0m5Xn8szVPY-7xXLBzKleRUjCTO1WK2NNKkeo7lvBytEqTRG-qkLCGDJNSM-TpkbwGEutOhtxRCxVNhb-QRk5W0J8fnQYAJGY_vuJBFse3Y5KDtcE8aJrGRWVYOfMMTIkJGgyGLIJS40AuD62i0qlRluBKt7_sRxriRZywOXO4rjNUF3aoqradTwRqCOCTWBtZa_qxMgR-mepbjSWlUIbzXaZop0PgeyIHi6kVmp4nw1PzR_XX9dXD4nxfxeIRAJDze7_cR-CVC40vHdUYQoDvETtdht9VXO_TqDIHret9N_IDubzsIV_sX-6vbssZydtz2dJsGd5xv)
## [Ruby](https://www.ruby-lang.org/), 137 bytes
Count the number of occurrences of each element. Then, for each element, removes a pair from the count (if possible), then checks if everything else is sequences or triplets.
```
->a{a.any?{t=a.tally;(t[_1]-=2)>=0&&a.sort.all?{|e|t[e]>=0&&((0...t[e]%=3).all?{(e..e+2).all?{|i|t[i]=t[i]&.-1}})}}}#$&*++3;;??\\__lmtty|
```
[Attempt This Online!](https://ato.pxeger.com/run?1=zVHRboIwFM1e-xWNcwQmNNA61CjyIdiQ4upkQSVStxDgA5bsD_Zilu2jtq9ZaZWZ7AeWnHuT03PvOTfw9rE_JOXxfRV8HsTKGX-9OHNWMcS2ZViJgCHBsqycmiKKPeoE2JoHrmEwVOz2AkkprGpei4hT9W6aLkKopTcBsbRucoT4AJ9YncrplAZtM5DjNY3VNM1137gdDMh0GoaLRRxnGyHK-nTQJoEBfOCiQMv1bpOjpBS8UPkgh4m-D-QHUUiSbh_5Upi9nlXF3mwW40bOrKKEAvC8TjOufABMpSN_YhnsxwDmMLXlTEoB394DHXr8vnr9N98BRK4NXQqiyWRiw9_mYTLUXWqeDfEZRHMpjhS_O2MsNRv6cv9ygygMz9CjvoLcH-nRDvgySIPqC_9CCu22diDKd9SFd146dqzg-boI1uUP26L6r_wA)
]