[Question]
      [
## Challenge
Given two numbers, output their quotient. In other words, integer divide one number by another.
Both divisor/dividend will be under 10001. Division must be performed using integer division, rounding down.
Here are some example inputs and outputs:
```
5       1       5
-4      2       -2
4       -2      -2
6       2       3
16      4       4
36      9       4
15      2       7
17      3       5
43      5       8
500     5       100
500     100     5
10000   2       5000
```
Or as CSV:
```
5,1,5
-4,2,-2
4,-2,-2
6,2,3
16,4,4
36,9,4
15,2,7
17,3,5
43,5,8
500,5,100
500,100,5
10000,2,5000
```
## Rules
* Standard loopholes not allowed
* You must use integer division, not floating point division
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"). Shortest answer wins, but will not be selected.
* The second input (denominator) will never be equal to `0`.
## Why?
I'm interested in seeing answers in esoteric languages, like Brainfuck and Retina. Answers in regular languages will be trivial, however I would really like to see answers in these languages.
I will be giving a bounty of **+50** reputation to a Retina answer.

[Answer]
# Mathematica, 8 bytes
```
Quotient
```
Thanks to @JungHwanMin for reminding me there's a builtin.
[Answer]
# JavaScript, 11 bytes
JavaScript doesn't have integers but using a [bitwise or](http://ecma262-5.com/ELS5_HTML.htm#Section_11.10) parses a float as a signed 32 bit integer.
```
a=>b=>a/b|0
```
# Try it online
```
const f = a=>b=>a/b|0
alert(f(prompt())(prompt()))
```
[Answer]
# C (GCC), 13 bytes
Doesn't work on *all* implementations, but that's OK.
```
f(a,b){a/=b;}
```
[Try it on TIO!](https://tio.run/nexus/c-gcc#@5@mkaiTpFmdqG@bZF37PzcxM09Ds7qgKDOvJE1DSTVFSSdNw9BUx0hTEygLAA "C (gcc) ‚Äì TIO Nexus")
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 4 bytes
```
a//b
```
[Try it online!](https://tio.run/nexus/pip#@5@or5/0//9/Q/P/xgA "Pip ‚Äì TIO Nexus")
Explanation:
```
      A and B are read implicitly from the cmd line
a//b  Calculate the int div of a and b (double slash == int div)
      Results of the last expression are printed implicitly.
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 3 bytes
```
q~/
```
[Try it online!](https://tio.run/nexus/cjam#@19Yp///v7GZgiUA "CJam ‚Äì TIO Nexus")
[Answer]
# [ÏïÑÌù¨(Aheui)](http://esolangs.org/wiki/Aheui), 15 bytes
```
Î∞©Î∞©ÎÇòÎßùÌù¨
```
[Try it here! (please copy and paste the code manually)](http://jinoh.3owl.com/aheui/jsaheui_en.html)
[Answer]
# Python 2, ~~14~~ 11 bytes
```
int.__div__
```
[**Try it online**](https://tio.run/nexus/python2#S7ON@Z@ZV6IXH5@SWRYf/7@gCMhTSNMwMdax0PwPAA)
[Answer]
# Bash, ~~25~~ ~~22~~ 15 bytes
```
echo $(($1/$2))
```
Save to script, input numbers given at command line
Saved 3 bytes thanks to @betseg
[Answer]
# [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), 8 bytes
```
::?a'\`b
```
# Explanation:
```
::    get a and b from the cmd line
?     Print
a \ b the backslash does integer division, (opposed to the forward slash / for float div)
  ' ` however, the same symbol is used for ELSE. We need to escape it with ' and `
```
---
Note that the latest version of QBIC allows for an inline use of the `:` function, saving two bytes:
```
?:'\`:
```
[Answer]
# [Aceto](https://github.com/aceto/aceto), 6 bytes
```
riri/p
```
```
ri takes input as integer
/ does integer division
p prints it
```
[Try it online!](https://tio.run/##S0xOLcn//78osyhTv@D/f0NzLmMA "Aceto ‚Äì Try It Online")
[Answer]
# PHP, 23 Bytes
```
<?=$argv[1]/$argv[2]^0;
```
or
```
<?=$argv[1]/$argv[2]|0;
```
and for 29 Bytes
```
<?=intdiv($argv[1],$argv[2]);
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 1 byte
```
:
```
[Try it online!](https://tio.run/nexus/jelly#@2/1//9/Q/P/xgA "Jelly ‚Äì TIO Nexus")
[Answer]
# 05AB1E, 3 bytes
`II√∑`
[Try online](https://tio.run/nexus/05ab1e#@@/peXj7//@GBiDAZQQA)
If you can reverse the input, it would work in 1 byte: `√∑`
[Answer]
# [Triangular](https://github.com/aaronryank/triangular), 6 bytes
```
$.$%_<
```
[Try it online!](https://tio.run/##KynKTMxLL81JLPr/X0VPRTXe5v9/CwVdo/8A "Triangular ‚Äì Try It Online")
Formats into this triangle:
```
  $
 . $
% _ <
```
Without directionals and no-ops, the code looks like this: `$$_%`
* `$` - read input as integer
* `_` - divide
* `%` - print
[Answer]
# [Decimal](//git.io/Decimal), 12 bytes
```
81D81D44D301
```
Ungolfed:
```
81D   ; builtin 1 - read INT to stack
81D   ; builtin 1 - read INT to stack
44D   ; math divide (postfix /)
301   ; print from stack to output
```
[Try it online!](https://tio.run/##S0lNzsxNzPn/38LQBYhMTFyMDQz//7dUMAYA)
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 28 bytes
```
\d+
*
~`(_+) (_+)
K`$1$nC`$2
```
[Try it online!](https://tio.run/##K0otycxLNPz/PyZFm0uLqy5BI15bUwFEcHknqBiq5DknqBj9/29ppmAOAA "Retina ‚Äì Try It Online")
I'm quite new to Retina; I probably could have golfed this more.
**Explanation:**
Let's start with an input: `38 4`
```
\d+
*
```
This turns the numbers into unary, so 4 is represented as \_\_\_\_, and 38 with 38 underscores.
```
~`...
```
This marks a stage that generates code to run afterwards
```
(_+) (_+)
K`$1$nC`$2
```
This is a replace stage to generate the division code; Firstly, it splits the string into the dividend (referenced as $1) and divisor (referenced as $2). Then, it returns the string:
```
K`{dividend as unary}
C`{divisor as unary}
```
The returned string is evaluated and the answer implicitly printed. It sets the working string to the dividend, and counts the matches of the divisor in it.
[Answer]
## [Keg](https://github.com/JonoCode9374/Keg/), 3 bytes
```
¬ø¬ø/
```
Simply 2 nice inputs and then divides them.
[TIO](https://tio.run/##y05N////0P5D@/X//zfkMgYA)
[Answer]
## Batch, 16 bytes
```
@cmd/cset/a%1/%2
```
`set/a` doesn't print its output inside a batch script, so we have to fake it out by starting a new copy of the command processor.
[Answer]
# GML, 30 bytes
```
return argument0 div argument1
```
[Answer]
# TI-Basic, 6 bytes
```
Input :iPart(X/Y
```
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki), ~~40~~ 38 bytes
```
\d+
*
(-?)(_+);(-?)(\2)*_*
$1$3$#4
--
```
Takes input in the format `denominator;numerator`. Also works for negative integers after the specs got changed, unlike the existing Retina answer.
-2 bytes thanks to *@FryAmTheEggman* thanks to a golf suggested in [another Retina answer of mine](https://codegolf.stackexchange.com/a/190623/52210).
[Try it online.](https://tio.run/##JYk7CsMwEET7uYYVkGQWdvXFbJHSlzA4gaRIkyLk/sqiTPHmDfN5fl/vu4yL32/jeKyI8HQN/lyDTjlSiGeEE5fdUkCEMUQrkpKtpMWsoag0bJqbLanIKh1VSzZUZgjzbDvZgq5bA012pb9b/QA)
**Explanation:**
Convert all numbers in the input to unary, replacing them with that amount of underscores:
```
\d+
*
```
Integer divide the two unary numbers (but with a decimal numbers as result), and filter all `-` to the front at the same time:
```
(-?)(_+);(-?)(\2)*_*
$1$3$#4
```
Remove any `--` if present:
```
--
```
[Answer]
# [J-uby](https://github.com/cyoce/J-uby), 2 bytes
ü´§
```
:/
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m700K740qXLBIjfbpaUlaboWi6z0IYwVBQpu0RY6xrEQ7oIFEBoA)
[Answer]
## Ruby, 10 bytes
```
->i,j{i/j}
```
Extremely simple. Lambda function that returns the value `i/j`.
]


[Question]
      [
How many of you that still use your own knuckle to determine whether a month is having a full 31 days or less?
You job is to write a program to count how many months, in a month range, are having a full 31 days and how many are having less than 31 days by "counting the knuckles".
[![Counting days of month by knuckles](https://i.stack.imgur.com/QtCaU.png)](https://i.stack.imgur.com/QtCaU.png)
*Courtesy: amsi.org.au*
---
## Input
A pair of months, the first of which doesn't have to come chronologically before the second, given in any suitable format. For instance: `201703 201902` — March 2017 to February 2019. Please describe the input format you choose. Note that the input must be able to include all years from 1 to 9999. The range of months specified includes both the starting and ending months.
## Output
Two integers: the number of months in the given range with 31 days and the number of months in the range with less than 31 days.
Example: `14 10` — 14 knuckles, 10 grooves (it means that in that month range we have 14 months that have a full 31 days, and 10 months that have less than 31 days).
For an input where the second month in the range comes chronologically before the first, for example `201612 201611`, you have to output a pair of zero.
## Examples of input and output
```
| Input         | Output      |
|---------------|-------------|
| 201703 201902 | 14 10       |
| 201701 202008 | 26 18       |
| 000101 999912 | 69993 49995 |
| 201802 201803 | 1 1         |
| 201601 201601 | 1 0         |
| 201612 201611 | 0 0         |
```
## Rules
* You may choose any language you like
* One input per line
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest code in bytes wins!
* The winner will be chosen in April 9
* Standard loopholes apply
* PS: this is my first question in PCG, it might have some inconsistencies. Feel free to edit and confirm what's unclear for you.

[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 21 bytes
```
ḅ12r/ị7RḂṁ12¤żC$S×⁼Ṣ$
```
Takes input like `[[y, m], [y, m]]`.
[Try it online!](https://tio.run/nexus/jelly#@/9wR6uhUZH@w93d5kEPdzQ93NloaHRoydE9zirBh6c/atzzcOcilf@H2x81rXH//z86OtrIwNBcR0HBOFZHAcS2BLKNYmN1uBTgUoYQKSMDINsCKqUAFIZJWQKBjoIhki4LsCEQAy3AhsOlzBAGQtnIUoZGCClDoFQsAA "Jelly – TIO Nexus")
### How it works
```
ḅ12r/ị7RḂṁ12¤żC$S×⁼Ṣ$  Main link. Argument: [[a, b], [c, d]]
ḅ12                    Unbase 12; yield [x, y] := [ 12a + b, 12c + d].
   r/                  Reduce by range; yield [x, ..., y].
           ¤           Combine the five links to the left into a niladic chain.
      7                  Set the return value to 7.
       R                 Range; yield [1, 2, 3, 4, 5, 6, 7].
        Ḃ                Bit; yield [1, 0, 1, 0, 1, 0, 1].
         ṁ12             Mold 12; repeat the Booleans to create an array of length
                         12. Yields [1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1].
     ị                 At-index; yield the elements of the array to the right at
                       the indices (1-based and modular) of the array to the left.
               $       Combine the two links to the left into a monadic chain.
              C          Complement; map t -> 1-t over the array.
             ż           Zip the original array with the complements.
                S      Take the sum of each column.
                    $  Combine the two links to the left into a monadic chain.
                  Ṣ      Sort [[a, b], [c, d]].
                   ⁼     Compare the result with [[a, b], [c, d]], yielding 1 if
                         the input is sorted, 0 if not.
                 ×     Multiply the results to both sides.
```
[Answer]
## JavaScript (ES6), ~~70~~ ~~68~~ ~~67~~ 64 bytes
Takes input as two integers in `yyyymm` format, in currying syntax `(a)(b)`. Outputs an array of two integers `[knuckles, grooves]`.
```
a=>g=(b,c=d=0)=>a>b?[c,d-c]:g(--b,c+!((b%=100)>11||b/.87&!!++d))
```
### Formatted and commented
```
a =>                        // main function: takes start date (a) as input / returns g
  g = (                     // recursive function g, which takes:
        b,                  //   - b = end date
        c = d = 0           //   - c = number of knuckles
      ) =>                  // and also keeps track of: d = total number of months
    a > b ?                 // if a is greater than b:
      [ c, d - c ]          //   stop recursion and return the final result
    :                       // else:
      g(                    //   do a recursive call to g():
        --b,                //   - decrement the end date
        c +                 //   - increment the # of knuckles if
        !(                  //     both of these conditions are false:
          (b %= 100)        //     - the end month (now stored in b in 0-based indexing)
          > 11 ||           //       is greater than 11
          b / 0.87 & !!++d  //     - the number of days in this month is not 31
        )                   //       (at the same time, d is incremented if the first
      )                     //       condition is false)
```
### Test cases
**NB**: The third test case is not included in this snippet, because it won't work unless your browser has Tail Call Optimization enabled.
```
let f =
a=>g=(b,c=d=0)=>a>b?[c,d-c]:g(--b,c+!((b%=100)>11||b/.87&!!++d))
console.log(f(201703)(201902)); // 14 10
console.log(f(201701)(202008)); // 26 18
console.log(f(201802)(201803)); // 1 1
console.log(f(201601)(201601)); // 1 0
console.log(f(201612)(201611)); // 0 0
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~92~~ ~~90~~ ~~86~~ 80 bytes
```
lambda a,b,c,d:[(bin(2741)[2:]*(c+1-a))[b-1:-12+d or None].count(x)for x in'10']
```
[Try it online!](https://tio.run/nexus/python2#DchLCsIwEADQq8yuM3YiThDEgFfwAjGLfAwEdFJKhd4@9i1ffbzGJ35TiRA5cebiPKamaG9XIW9dOGGexUQin4w4I3Yu0Fd4dn2Hc@4/3XCneswOTSe5TGEsa9MNKgoL3w8slsYf "Python 2 – TIO Nexus")
6 more by converting to a lambda, with thanks to @math\_junkie for the idea. Now outputs a list containing the two numbers.
Previous non-lambda version (86 bytes)
```
a,b,c,d=input()
for x in'10':print(bin(2741)[2:]*(c+1-a))[b-1:-12+d or None].count(x),
```
[Try it online old!](https://tio.run/nexus/python2#DctBCoAgEEDRfadwl1NjNBJEQlfoAuIircDNGGHQ7c2/fr/s6DHgsUa@3yyhudIjPhG5pbE19xM5Sx9Z6nkisNq4Toae1A5gvSKjSPeHqMuW@HRDSG/1H2AphIRLDUn/ "Python 2 – TIO Nexus")
2 saved with thanks to @ovs for helping me get rid of the `len(k)`. I hadn't thought about using `None`.
Input is a list of integers in the format `y1,m1,y2,m2`
Some credit due to @KeerthanaPrabhakaran who got `bin(2741)[2:]` before I did which saves 1 byte over hard coding the binary string.
[Answer]
# [PHP](https://php.net/), ~~259~~ ~~256~~ ~~249~~ ~~248~~ ~~237~~ 221 bytes
Outgolfed by [aross](https://codegolf.stackexchange.com/users/38392/aross): <https://codegolf.stackexchange.com/a/114512/38505>
Input Format: `yyyymm,yyyymm`
```
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";foreach(new DatePeriod($_(Ym,$i[0]),new DateInterval(P1M),$_(Ym,$i[1])) as$f)date(t,mktime(0,0,0,$f->format(m),1,$f->format(y)))>30?++$x:++$y;
echo $x.' '.++$y;
```
[Try it online!](https://tio.run/nexus/php#TY1Bi8JADIXv/opSBkwwK1M9LNvaehHBgyKsF5Eipc3Yso5TxmG3/vruKCgSeEne@@DN5m3d9qJJuWvPpmIIKSR1YneF791itUFMxDENF4XjXaM5jkvL/l5ao5fG6sKFiTLeKmu48F9w57ZsG1OBOMJek2gOMkd6ZquLY/tbnGEbrZFeSJQjBsVVKKw8BI70j/NtIOk@Qn1k6lEGGil6/2@ImE3lfDQSXezllgy4rE0guvEwGI4fTt9PZPQpp@TXl5z8Aw)
---
### Older versions
```
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";$y=1;foreach(new DatePeriod($_("Ym",$i[0]),new DateInterval('P1M'),$_("Ym",$i[1])) as$f)date("t",mktime(0,0,0,$f->format("m"),1,$f->format("y")))==31?++$x:++$y;
echo $x.' '.$y;
```
[Try it online!](https://tio.run/nexus/php#VY5Na8MwDIbv@xVGGGJRr9jtYSyZ10sp9DIG7WWMUkIiN2F1HFyzJb8@c3bqEOjj0Svxvmz6pp94a2jor74mARKkvVC8icNxu39DLPjZwLaMdGwd5XkVKPW74N3OB1dGKPhodGF94lUjOvphs/idQutrwc8CPhxI3n6qE8p5s@8ihe/yev9q5ocY2u4iMs2c72KTobw71idEVt64xTpJBUSQ7ismQ0LJObh9fLV/fgQ4QKn/kREQ0Zi13iwWfMhTGosHqhrP@LDMWLZM8zStlH5Sa5nKs1r9Ag "PHP – TIO Nexus")
```
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";$y=1;foreach(new DatePeriod($_(Ym,$i[0]),DateInterval::createFromDateString('1 month'),$_(Ym,$i[1])) as$f)date(t,mktime(0,0,0,$f->format(m),1,$f->format(y)))>30?++$x:++$y;
echo $x.' '.$y;
```
[Try it online!](https://tio.run/nexus/php#VY5Na8MwDIbv@xVGGGJRr9jtYSyZ10sp9DIG7WWMUkIiN2F1HFyzJb8@c3bqEOjj0Svxvmz6pp94a2jor74mARKkvVC8icNxu39DLPjZwLaMdGwd5XkVKPW74N3OB1dGKPhodGF94lUjOvphs/idQutrwc8CPhxI3n6qE8p5s@8ihe/yev9q5ocY2u4iMs2c72KTobw71idEVt64xTpJBUSQ7ismQ0LJObh9fLV/fgQ4QKn/kREQ0Zi13iwWfMhTGosHqhrP@LDMWLZM8zStlH5Sa5nKs1r9Ag "PHP – TIO Nexus")
```
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";$y=1;foreach(new DatePeriod($_(Ym,$i[0]),DateInterval::createFromDateString('1 month'),$_(Ym,$i[1])) as$f)date(t,mktime(0,0,0,$f->format(m),1,$f->format(y)))==31?++$x:++$y;
echo $x.' '.$y;
```
[Try it online!](https://tio.run/nexus/php#VY5Na8MwDIbv@xVGGGJRr9jtYSyZ10sp9DIG7WWMUkIiN2F1HFyzJb8@c3bqEOjj0Svxvmz6pp94a2jor74mARKkvVC8icNxu39DLPjZwLaMdGwd5XkVKPW74N3OB1dGKPhodGF94lUjOvphs/idQutrwc8CPhxI3n6qE8p5s@8ihe/yev9q5ocY2u4iMs2c72KTobw71idEVt64xTpJBUSQ7ismQ0LJObh9fLV/fgQ4QKn/kREQ0Zi13iwWfMhTGosHqhrP@LDMWLZM8zStlH5Sa5nKs1r9Ag "PHP – TIO Nexus")
```
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";foreach(new DatePeriod($_("Ym",$i[0]),DateInterval::createFromDateString('1 month'),$_("Ym",$i[1])) as$f)date("t",mktime(0,0,0,$f->format("m"),1,$f->format("y")))==31?++$x:++$y;
echo $x.' '.++$y;
```
[Try it online!](https://tio.run/nexus/php#VY5Na8MwDIbv@xVGGGJRr9jtYSyZ10sp9DIG7WWMUkIiN2F1HFyzJb8@c3bqEOjj0Svxvmz6pp94a2jor74mARKkvVC8icNxu39DLPjZwLaMdGwd5XkVKPW74N3OB1dGKPhodGF94lUjOvphs/idQutrwc8CPhxI3n6qE8p5s@8ihe/yev9q5ocY2u4iMs2c72KTobw71idEVt64xTpJBUSQ7ismQ0LJObh9fLV/fgQ4QKn/kREQ0Zi13iwWfMhTGosHqhrP@LDMWLZM8zStlH5Sa5nKs1r9Ag "PHP – TIO Nexus")
```
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";$y=1;foreach(new DatePeriod($_("Ym",$i[0]),DateInterval::createFromDateString('1 month'),$_("Ym",$i[1])) as$f)date("t",mktime(0,0,0,$f->format("m"),1,$f->format("y")))==31?++$x:++$y;
echo $x.' '.$y;
```
[Try it online!](https://tio.run/nexus/php#VY5Na8MwDIbv@xVGGGJRr9jtYSyZ10sp9DIG7WWMUkIiN2F1HFyzJb8@c3bqEOjj0Svxvmz6pp94a2jor74mARKkvVC8icNxu39DLPjZwLaMdGwd5XkVKPW74N3OB1dGKPhodGF94lUjOvphs/idQutrwc8CPhxI3n6qE8p5s@8ihe/yev9q5ocY2u4iMs2c72KTobw71idEVt64xTpJBUSQ7ismQ0LJObh9fLV/fgQ4QKn/kREQ0Zi13iwWfMhTGosHqhrP@LDMWLZM8zStlH5Sa5nKs1r9Ag "PHP – TIO Nexus")
[Answer]
## Batch, 93 bytes
```
@set/ag=(y=%2/100-%1/100)*5+(x=%2%%100+6)*5/12-(w=%1%%100+5)*5/12,k=y*12+x-w-g
@echo %k% %g%
```
Accepts two parameters in ymm format (i.e. 101 - 999912). Previous 129-byte loop-based solution:
```
@set/al=%1-%1/100*88,u=%2-%2/100*88,k=g=0
@for /l %%i in (%l%,1,%u%)do @set/a"m=%%i%%12,k+=1451>>m&1,g+=2644>>m&1
@echo %k% %g%
```
[Answer]
# Python 3.5 (164 162 154 152 150 148 140 137 bytes)
```
n=int;a,b=input().split();t=k=0
for r in range(n(a[4:]),(n(b[:4])-n(a[:4]))*12+n(b[4:])+1):t+=1;k+=n('101010110101'[r%12-1])
print(k,t-k)
```
## [repl.it](https://repl.it/GmAM/2)
### takes input in the form of *yyyymm yyyymm*
### prints output as *number\_of\_knuckles number\_of\_grooves*
* **saved 2 bytes:** Thanks to [Cole](https://codegolf.stackexchange.com/users/42833/cole)
* **saved 8 bytes:** removed unwanted variables
* **saved 2 bytes:** reduced t=0;k=0 as t=k=0
* **saved 2 bytes:** Thanks to Cole (I had missed this before)
* **saved 2 bytes:** Thanks to  [Keerthana](https://codegolf.stackexchange.com/users/67429/keerthana-prabhakaran)
* **saved 8 bytes:** removed unwanted variables
* **saved 3 bytes:** Thanks to [math\_junkie](https://codegolf.stackexchange.com/users/65425/math-junkie) ( split(' ') to split() )
[Answer]
# [Python 2](https://docs.python.org/2/), ~~147~~ ~~146~~ 142 bytes
```
def s(a,b):y=100;r=bin(2741)[2:];x=b/y-a/y;i=r*(x-1);return((0,0),map((i+r[a%y-1:]+r[:b%y]if i or x else r[a%y-1:b%y]).count,('1','0')))[a<=b]
```
[Try it online!](https://tio.run/nexus/python2#bY5BCsIwEEX3niIbaUZTnQlisTUnKV0kNWJA0xIrNAd3XaPiQnE27/P@X8x0sEd25VoYKKMixCoo4zyXxYaglmVTjcqsY67XsXIqLPiYE1TBDrfgOUeBIC6659wtQ63nMaeySak089i4I3OsC2xk9ny17NM/K1i13c0PgmeUiQwzAKj1Xplm6oPzQ3oIEQlJ7NKRhNlHS6QtSZFQIP1oFC986@KtE/6ucQfT3Xd5q9uTfQA "Python 2 – TIO Nexus")
* Saved 4 bytes - Thanks to @math\_junkie for suggesting the if-else clause with array lookup!
Breaking down the code,
```
def s(a,b):
 y=100
 r=bin(2741)[2:] #'101010110101'
 x=b/y-a/y #to get the difference between the two years
 i=r*(x-1)
 return((0,0),map((i+r[a%y-1:]+r[:b%y]if i or x else r[a%y-1:b%y]).count,('1','0')))[a<=b]
```
[Answer]
# PHP, ~~120~~ ~~103~~ ~~97~~ 96 bytes
```
for($f=strtotime;$f($argv[2])>=$n=$f($argv[1].+$x++.month);)$k+=date(t,$n)>30;echo+$k,_,$x-1-$k;
```
Run like this:
```
php -nr 'for($f=strtotime;$f($argv[2])>=$n=$f($argv[1].+$x++.month);)$k+=date(t,$n)>30;echo+$k,_,$x-1-$k;' 0001-01 9999-12;echo
> 69993_49995
```
# Explanation
```
for(
  $f=strtotime;          # Alias strtotime function which is called twice.
  $f($argv[2]) >=        # Create end date timestamp. Iterate until the end
                         # date is reached.
  $n=$f(
    $argv[1].+$x++.month # Create timestamp from start date + X months.
  );
)
  $k+=date(t,$n) > 30;   # If "t" of current date (days in month) is 31
                         # increment $k (knuckles).
echo+$k,_,$x-1-$k;       # Compute grooves (iterations - $k) and output,
                         # implicit cast to int to account for 0 count.
```
# Tweaks
* Saved 17 bytes by using timestamp style instead of DateTime object style
* Saved 6 bytes by not assigning end date timestamp to variable `$e`, just compare directly
* Saved 1 byte by not keeping count of grooves, but just computing it after the loop
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 96 bytes
```
for($a,$b=[datetime[]]$args;$a-le$b;$a=$a.AddMonths(1)){$x++;$z+=$a.Month-in2,4,6,9,11};$x-$z;$z
```
[Try it online!](https://tio.run/nexus/powershell#@5@WX6ShkqijkmQbnZJYklqSmZsaHRurkliUXmytkqibk6qSBKRtVRL1HFNSfPPzSjKKNQw1NatVKrS1rVWqtEEyYGHdzDwjHRMdMx1LHUPDWmuVCl2VKqCC////GxgYGOoaGP63BAJdQyMA "PowerShell – TIO Nexus")
Takes input as form `2017-03`. Uses the built-in .NET date libraries and loops through from inputs `$a` to `$b`, each iteration incrementing `$x++` and adding to `$z` if the current `.Month` is `-in` `2,4,6,9,11` (i.e., a non-31-day month). Then we output our total months minus the non-31-day months `$x-$z`, and the non-31-day months `$z`.
Tosses an error on the `0001-01` to `9999-12` test case, because .NET only supports years up to `9999`, so the final `.AddMonths(1)` causes an overflow. Still outputs the correct values, though, because it's a non-terminating error; it just causes the loop to exit.
Probably would be shorter to do this arithmetically, like the Python or JavaScript answers, but I wanted to show an approach using the .NET built-ins.
[Answer]
# [Bash](https://www.gnu.org/software/bash/), 113 bytes
```
s="$1-1";e="$2-1";sort <(while [ "$s" \< "$e" ];do s=$(date +%F -d"$s+1month");date +%d -d"$s-1day";done)|uniq -c
```
[Try it online!](https://tio.run/nexus/bash#LYtBCsIwEEWvMgwRWspAphQU0m69hLoonYEWNEETEcG7x5R29R6P/3Mc0DAxOi3SrhLDK0FffeblrnABNBHh2hcqws1JgDiYSsak0BzOQFIGDT@CTzPWbu@ydWIZv1g@Xuvf2y9PoCnn3Fo@ku1WnojtHw "Bash – TIO Nexus")
needs golfing...
takes input as `2016-03` `2018-10`
outputs:
```
  1 28
  7 30
 12 31
```
ungolfed:
```
s="$1-1"
e="$2-1"                     # adds first day of month to the dates
sort <(
while [ "$s" \< "$e" ]; do   #iterates over dates
s=$(date +%F -d"$s+1month")  #adds one month to start date
date +%d -d"$s-1day"         #outputs last day of previous month
done) | uniq -c              #counts ocurrences of day number prevously sorted
```
[Answer]
# Swift, 151 bytes
```
let f={(m:[Int])->[Int] in var k=[0,0]
(m.min()!...m.max()!).map{$0%100}.filter{$0>0&&$0<13}.forEach{m in let n = m>7 ?m-7:m
k[(n%2+1)%2]+=1}
return k}
```
input is an array of two integers in the format as per the example
]


[Question]
      [
Usually, it is said that "Doing X without Y" can be a trap to beginners writing challenges ([source](http://meta.codegolf.stackexchange.com/questions/8047/things-to-avoid-when-writing-challenges/8079#8079)). However, I am cocky and think that I can *definitely* make an X without any Ys. Randomly. Oh yes, this will be good.
**Challenge:** Given an odd integer `n` greater than or equal to 1, output an ex of side length `n` made of random printable ascii characters sans "y" and "Y", and the space. All allowed characters must have a nonzero chance of occurring, but not necessarily uniform. This is a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so the shortest code in bytes wins. You should, however, randomize each char--that is, the struts of the ex shouldn't be equal, unless if by chance.
## The chars to appear
```
!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXZ[\]^_`abcdefghijklmnopqrstuvwxz{|}~"
```
## Constructing the ex
Side length 1:
```
x
```
Side length 3:
```
x x
 x
x x
```
Side length 5:
```
x   x
 x x
  x
 x x
x   x
```
etc.
## Example outputs
```
input
output
empty line
3
h 2
 ^
9 5
1
:
5
D   1
 W z
  W
 q j
W   1
```
## Example implementation
You do not need to handle invalid inputs.
```
function generate(sideLength){
    var result = "";
    var INNER = "@"
    for(var i = 0; i < sideLength; i++){
        var p = i < sideLength / 2 ? i : sideLength - i - 1;
        result += " ".repeat(p) + ((sideLength / 2 | 0) == p ? "" : INNER) + " ".repeat(Math.max(sideLength - p * 2 - 2, 0)) + INNER + "\n";
    }

    return result.replace(RegExp(INNER, "g"), function(e){
        let c = "y";
        while(c === "y" || c === "Y"){
            c = String.fromCharCode((Math.random() * 94) + 33 | 0);
        }
        return c;
    });
}
function print(v){
    output.innerHTML = "";
    output.appendChild(document.createTextNode(v));
}
function update(){
    var n = Number(input.value);
    if(n !== Math.floor(n)) print("error: " + n + " is not an integer.");
    else if(n % 2 === 0)    print("error: " + n + " is not odd.");
    else if(n < 1)          print("error: " + n + "is less than one.");
    else                    print(generate(n));
}
input.onchange = update;
update();
```
```
* {
  font-family: Consolas, monospace;
}
#output {
  white-space: pre;
}
```
```
<input id="input" min=1 value=1 type=Number>
<div id="output"></div>
```

[Answer]
# Ruby, 102 bytes
`Array#sample` doesn't do repetitions for sampling from the character set, but that's OK because the character distribution don't have to be perfectly uniform! Recursive function, returns an array of lines.
[Try it online!](https://repl.it/CgUD)
```
f=->l{w,x,y,z=([*?!..?~]-%w"y Y").sample 4
l<2?[w]:[w+(s=' '*(l-2))+x,*f[l-2].map{|e|" #{e} "},y+s+z]}
```
[Answer]
# Mathematica, 146 bytes
```
a:=RandomChoice[33~CharacterRange~126~Complement~{"Y","y"}];StringRiffle[Normal@SparseArray[{{b_, b_}:>a,{b_,c_}/;c-1==#-b:>a},{#,#}," "],"
",""]&
```
Anonymous function. Takes a number as input, and returns a string as output.
[Answer]
## Actually, 62 bytes
```
"!⌂"♂┘ix♂c"Yy"@-╗½≈u;r2@∙`i=`M╪k`;dXR@+`M;dXR@+`"╜J' aI"£MΣ`Mi
```
This is one of the longest Actually programs I've ever written.
[Try it online!](http://actually.tryitonline.net/#code=IiHijIIi4pmC4pSYaXjimYJjIll5IkAt4pWXwr3iiYh1O3IyQOKImWBpPWBN4pWqa2A7ZFhSQCtgTTtkWFJAK2Ai4pWcSicgYUkiwqNNzqNgTWk&input=NQ)
### Explanation:
**Part 1**: setting up the character list
```
"!⌂"♂┘ix♂c"Yy"@-
"!⌂"              push the string "!⌂"
    ♂┘            CP437 ordinal of each character ([21, 127])
      ix          range(21, 127)
        ♂c        character at each ordinal (list of printable ASCII characters)
          "Yy"@-  set difference with ["Y", "y"] (printable ASCII except "Y" and "y")
```
[Try it online!](http://actually.tryitonline.net/#code=IiHijIIi4pmC4pSYaXjimYJjIll5IkAt&input=)
**Part 2**: constructing the boolean array for an X
```
½≈u;r2@∙`i=`M╪k`;dXR@+`M;dXR@+
½≈u;                            two copies of int(input/2)+1
    r                           range
     2@∙                        Cartesian product with itself
        `i=`M                   for each sublist: push 1 if both elements are equal, else 0
             ╪k                 split into int(input/2)+1-length chunks
                                (at this point, we have one quarter of the X)
               `;dXR@+`M        mirror each sublist (one half of the X)
                        ;dXR@+  mirror the entire list (the whole X)
```
[Try it online!](http://actually.tryitonline.net/#code=wr3iiYh1O3IyQOKImWBpPWBN4pWqa2A7ZFhSQCtgTTtkWFJAKw&input=NQ)
**Part 3**: picking random characters
```
`"╜J' aI"£MΣ`Mi
`"╜J' aI"£MΣ`M   for each row:
 "╜J' aI"£M        for each column:
  ╜J                 push a random value from the character list
    '                push a space
      a              invert the stack
       I             take the character if the value is 1, else take the space
           Σ       concatenate the strings
              i  flatten the list and let implicit output take care of the rest
```
[Try it online!](http://actually.tryitonline.net/#code=IiHijIIi4pmC4pSYaXjimYJjIll5IkAt4pWXYCLilZxKJyBhSSLCo03Oo2BNaQ&input=W1sxLDAsMCwwLDFdLFswLDEsMCwxLDBdLFswLDAsMSwwLDBdLFswLDEsMCwxLDBdLFsxLDAsMCwwLDFdXQ)
[Answer]
# Python, ~~142~~ ~~139~~ 135 bytes
This is a straight forward implementation create the square character by character. If the character is *on a diagonal*: use a random char, *else*: use a space. This also uses a regex substitution and random int to generate non-`Y` characters:
```
import re,random
lambda x:''.join('\n'*(i%x<1)+re.sub("y|Y","t",chr(random.randint(33,126))+' ')[i%x!=i/x!=x-i%x-1]for i in range(x*x))
```
---
## Explanation [ Old ]
```
"\n".join( ... for i in range(x)) # Create 'x' lines
''.join( ... for j in range(x))   # Create 'x' chars on each line
(...)[j!=i!=x-j-1]                # Not on diagonals? 2nd char in "? "; Else, choose the 1st
j!=i                              # Not on downward diagonal
i!=x-j-1                          # Not on upward diagonal
re.sub("y|Y","t", ... )           # Replace y or Y for t
chr(random.randint(33,126))+' '   # Random char + a space
```
**Update**
* **-4** [16-07-30] Shortened newline conditional
* **-3** [16-07-30] Changed to single for-loop
* **-6** [16-07-29] Exchanged if statement for ternary op. Thanks to @RootTwo
* **-11** [16-07-27] Removed extra brackets/spaces and flipped if statement
* **-49** [16-07-27] Absorded @squeamishossifrage's method by creating the square step-by-step, Thanks!
* **-10** [16-07-27] Shorten random char lambda + math stuff from @ConorO'Brien
* **-22** [16-07-26] Squeaze in a lambda + misc golfing
* **-6** [16-07-26] `import*` - Thanks to @KevinLau
[Answer]
# Python 2, 171 bytes
```
from random import*
def x(n):
 w=range(-n/2+1,n/2+1)
 for i in w:
  o=''
  for j in w:c=randint(33,124);c+=(c>88)+(c>119);c=[c,32][bool(i^j and i^-j)];o+=chr(c)
  print o
```
Guaranteed to choose random characters with uniform probability.
Try it out here: [ideone link](http://ideone.com/AUKacR)
**EDIT: Thanks to Morgan Thrapp for the corrections.**
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 35 [bytes](http://meta.codegolf.stackexchange.com/a/9429/43319)
```
⎕UCS 32+(⊢+∊∘57 89)⌊?95×(⊢∨⌽)∘.=⍨⍳⎕
```
`⎕` prompt for number
`⍳` 1 through that number
`∘.=⍨` equality table (i.e. the diagonal has 1s)
`(⊢∨⌽)` itself OR its mirror image (gives both diagonals)
`95×` multiply by 95
`?` rand int between 1 and 95 for the diagonals, rand float between 0 and 1 for the rest
`⌊` floor to get rid of the floats
`(⊢+∊∘57 89)` add one to the elements that are a member of {57,89} (Yy – 32)
`32+` add 32 to make the 0s into spaces, and other numbers into the proper range
`⎕UCS` convert to text
[TryAPL](http://tryapl.org/?a=%u2395UCS%2032+%28%u22A2+%u220A%u221857%2089%29%u230A%3F95%D7%28%u22A2%u2228%u233D%29%u2218.%3D%u2368%u237325&run)!
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~28~~ ~~27~~ ~~26~~ 25 bytes
```
~~jmuXGHO-rF"!~""Yy"{,d-tQd\*;Q~~
~~VQuXGHO-rF"!~""Yy"{,N-tQN\*d~~
~~VQuXGHO-r\!\~"Yy"{,N-tQN\*d~~
~~VQuXGHO-r\!\~"Yy",N-tQN\*d~~
VQuXGHO-r\!\[DEL];"Yy",N-tQN*d
```
[Try it online!](https://tio.run/##K6gsyfj/PyywNMLdw1@3KEYxpl4pslJJx0@3JNBPK@X/f1MA "Pyth – Try It Online")
[Answer]
# x86 machine code, 70 bytes
```
60 89 d7 31 db 43 88 ce b2 fe 49 d1 e1 87 da 0f
c7 f0 24 7f 3c 22 72 f7 48 3c 79 74 f2 3c 59 74
ee aa 49 7c 1c 00 df 79 06 86 f7 42 43 eb f6 f6
c3 01 74 03 b0 0a aa 51 88 f9 b0 20 f3 aa 59 eb
cc c6 07 00 61 c3
```
My executable code, disassembled:
```
0000003d <myheh>:
  3d:   60                      pusha
  3e:   89 d7                   mov    %edx,%edi
  40:   31 db                   xor    %ebx,%ebx
  42:   43                      inc    %ebx
  43:   88 ce                   mov    %cl,%dh
  45:   b2 fe                   mov    $0xfe,%dl
  47:   49                      dec    %ecx
  48:   d1 e1                   shl    %ecx
0000004a <myloop>:
  4a:   87 da                   xchg   %ebx,%edx
0000004c <myrand>:
  4c:   0f c7 f0                rdrand %eax
  4f:   24 7f                   and    $0x7f,%al
  51:   3c 22                   cmp    $0x22,%al
  53:   72 f7                   jb     4c <myrand>
  55:   48                      dec    %eax
  56:   3c 79                   cmp    $0x79,%al
  58:   74 f2                   je     4c <myrand>
  5a:   3c 59                   cmp    $0x59,%al
  5c:   74 ee                   je     4c <myrand>
  5e:   aa                      stos   %al,%es:(%edi)
  5f:   49                      dec    %ecx
  60:   7c 1c                   jl     7e <mydone>
00000062 <mylab>:
  62:   00 df                   add    %bl,%bh
  64:   79 06                   jns    6c <myprint>
  66:   86 f7                   xchg   %dh,%bh
  68:   42                      inc    %edx
  69:   43                      inc    %ebx
  6a:   eb f6                   jmp    62 <mylab>
0000006c <myprint>:
  6c:   f6 c3 01                test   $0x1,%bl
  6f:   74 03                   je     74 <myprint1>
  71:   b0 0a                   mov    $0xa,%al
  73:   aa                      stos   %al,%es:(%edi)
00000074 <myprint1>:
  74:   51                      push   %ecx
  75:   88 f9                   mov    %bh,%cl
  77:   b0 20                   mov    $0x20,%al
  79:   f3 aa                   rep stos %al,%es:(%edi)
  7b:   59                      pop    %ecx
  7c:   eb cc                   jmp    4a <myloop>
0000007e <mydone>:
  7e:   c6 07 00                movb   $0x0,(%edi)
  81:   61                      popa
  82:   c3                      ret
```
It is a function that receives the size of the X in ecx, and a pointer to the output buffer in edx.
It fills the output buffer sequentially with bytes. There are `2 * n - 1` iterations (equal to the number of non-space characters to output). At each iteration, it does the following:
* Generate a random number
* Fiddle with the number to fit it into range; if it's bad, go back and generate anew
* Print the random character
* Print a newline (every other iteration)
* Print the proper number of spaces
Conversion from a random number to a random character is not remarkable:
```
myrand:
    rdrand eax;
    and al, 7fh;
    cmp al, 22h;
    jb myrand;
    dec eax;
    cmp al, 'y';
    je myrand;
    cmp al, 'Y';
    je myrand;
```
The interesting part is the calculation of the number of spaces. It must generate the following numbers (example for N=9):
```
7    1
5    2
3    3
1    4
     3
1    2
3    1
5    0
7
```
The numbers are taken alternatingly from two arithmetic progressions. The first one goes down with step -2, and the second one goes up with step 1. When the first progression arrives at -1 (in the middle of the X), there is a glitch (-1 is removed), and then the progressions change direction.
The progressions are stored in registers `ebx` and `edx` - the high parts `bh` and `dh` store the current number, and the low parts `bl` and `dl` store the step. To alternate between the progressions, the code swaps the registers with `xchg`.
When the progression arrives at -1 (around the `mylab` label), it increases both registers, switching the steps from `-2, 1` to `-1, 2`. This also changes the roles of the registers, so then it swaps the high parts of the registers.
At the end of the function, it stores a zero byte to indicate an end of string.
[Answer]
# Python 2.7, 205 bytes:
```
from random import*;C=input()/2;S=' ';R=range;Z=lambda:chr(choice(R(33,89)+R(90,121)+R(122,128)));T=lambda*G:''.join([S*i+Z()+S*(2*(~-C-i)+1)+Z()+S*i+'\n'for i in R(*G)]);print T(C)+S*C+Z()+'\n'+T(~-C,-1,-1)
```
[Try It Online! (Ideone)](http://ideone.com/hhB4qm)
[Answer]
# [MATL](https://github.com/lmendo/MATL), 28 bytes
```
6Y2'Yy 'X-iZr1MZrXdwXdP2$X>c
```
[**Try it online!**](http://matl.tryitonline.net/#code=NlkyJ1l5ICdYLWlacjFNWnJYZHdYZFAyJFg-Yw&input=OQ)
All the allowed characters have the same probability of appearing. Works for even input too.
```
6Y2     % Predefined literal of ASCII chars from 32 to 126
'Yy '   % Not allowed chars
X-      % Set difference. Produces the set of allowed chars
i       % Input number, n
Zr      % Random sample without replacement. Gives a string with n chars taken from
        % the allowed set
1MZr    % Do the same
Xd      % Diagonal matrix. Zeros will be displayed as spaces
wXd     % Diagonal matrix with the other string
P       % Flip vertically
2$X>    % Maximum of the two matrices
c       % Convert to char. Implicitly display
```
[Answer]
# C, 154 bytes (or 119 without the boiler-plate)
```
o(w,c){c=rand()%94+33;printf("%*c",w,w?c+!(c&95^89):10);}main(h){scanf("%d",&h);srand(time(0));for(int n=h,p;n--;)p=abs(h/2-n),o(h/2-p+1),p&&o(p*2),o(0);}
```
Or 119 bytes as a function `X(h)` with `srand(time(0))` taken care of elsewhere:
```
o(w,c){c=rand()%94+33;printf("%*c",w,w?c+!(c&95^89):10);}X(h,n,p){for(n=h;n--;)p=abs(h/2-n),o(h/2-p+1),p&&o(p*2),o(0);}
```
Breakdown:
```
o(w,c){                         // "Output" function, for all printing
    c=rand()%94+33;             // Generate random char, whether we need it or not
    printf("%*c",               // Print a char with some number of leading spaces
           w,                   // Use "w" (width) - 1 leading spaces
           w?                   // Either print the random char...
             c+!(c&95^89)       // (exclude "y" and "Y" by incrementing to "z"/"Z")
                         :10    // ...or print a newline if called with w = 0
    );
}
main(h){                        // Main function; repurpose argc to store grid size
    scanf("%d",&h);             // Get grid size from stdin
    srand(time(0));             // Boiler-plate for random number seeding
    for(int n=h,p;n--;)         // Loop over all lines (count down to save chars)
        p=abs(h/2-n),           // Calculate half-distance between "X" bars
        o(h/2-p+1),             // Output the first half of the "X" (">")
        p&&                     // If we are not in the centre:
           o(p*2),              //   output the second half of the "X" ("<")
        o(0);                   // Output a newline
}
```
[Answer]
## Lua, 277 Bytes
Well... Lua is sooooo good at manipulating strings :D. First time I had to use `local` in a statement! I could save some bytes by using Lua 5.1 instead of 5.3 because they moved the global function `unpack` into the object `table` at Lua 5.2. But I prefer to stick with the latest version I have :).
Defines a function that should be called with a single parameter (the second one is used for recursion purpose) and returns a string.
```
function f(n,N)N=N or n e=" "p="\n"r=math.random C=e.char
R={}for i=1,4 do x=r(33,126)R[i]=x~=89 and x~=121 and x or r(33,88)end
local s,S,a,b,c,d=e:rep((N-n)/2),e:rep(n-2),table.unpack(R)return
n<2 and s..C(a)..p or s..C(a)..S..C(b)..s..p..f(n-2,N)..s..C(c)..S..C(d)..s..p
end
```
### Ungolfed
```
function f(n,N)
  N=N or n                          -- N is equal to the n we had on the first call
  e=" "                             -- shorthand for the space
  p="\n"                            -- shorthand for the newline
  r=math.random                     -- shorthand for math.random
  C=e.char                          -- uses the string e to obtain the function string.char
  R={}                              -- define an array for our random values
  for i=1,4                         -- iterate 4 times (for the random characters)
  do
    x=r(33,126)                     -- random between ASCII "!" and "~"
    R[i]=x~=89 and x~=121           -- if we didn't pick y or Y
           and x                    -- keep this number
         or r(33,88)                -- or roll for a character between "!" and "X"
  end
  local s,S                         -- these variables have to be local
          ,a,b,c,d                  -- or the recursion would change them
         =e:rep((N-n)/2),e:rep(n-2) -- s and S are the number of spaces for the X
           ,table.unpack(R)         -- a,b,c and d are the 4 random characters
  return n<2                        -- if n==1
           and s..C(a)..p           -- we're at the center of the X, time to end recursion
         or                         -- else
           s..C(a)..S..C(b)..s..p   -- concatenate the topmost line for n
           ..f(n-2,N)               -- with the inner X
           ..s..C(c)..S..C(d)..s..p -- and the bottom line
end
```
[Answer]
## JavaScript (ES6), ~~137~~ ~~131~~ 125 bytes
```
n=>[...Array(n)].map((_,i,a)=>String.fromCharCode(...a.map((r=Math.random()*94,j)=>i-j&&i+j+1-n?32:(r+72&95&&r)+33))).join`\n`
```
Where `\n` represents the literal newline character. Edit: Saved 1 byte by moving the `' '` inside the `String.fromCharCode` expression. Saved 5 bytes by making my random character generation non-uniform; the expression `r+72&95` is zero for the values that map to `Y` and `y` and an `!` is generated in their place. Saved 4 bytes when I realised that spreading over `String.fromCharCode` avoids having to `join`. Saved 2 bytes by stealing a trick from @edc65.
[Answer]
# PowerShell v2+, 112 bytes
```
Param($i)function f{Random(33..126-ne121-ne89|%{[char]$_})};1..$i|%{$a=,' '*$i;$a[$_-1]=f;$a[$i-$_]=f;$a-join''}
```
Reads input off the command line.
For each line, an array of spaces is created, the correct indices filled in with characters pulled from function `f`, then the char array is joined to output as one line.
[Answer]
# [Matricks](https://github.com/jediguy13/Matricks/tree/master), 79 bytes (non-competing)
Matricks **excels** as the beginning of making the x and all the random values, but flops when it comes to conditionals...
I marked this as noncompeting because I had to fix a few bugs and get all the new features working after this challenge was posted.
```
m:n;:1;mr=c:L:L;k({}|{X;})*{m_?33:126;;:L:l;miC<121,89>:gr:c;;:49:gr:c;;:L:l;};
```
Run with `python matricks.py x.txt [[]] <input> --asciiprint`
Explanation:
```
m:n;:1;mr=c:L:L;                   #Initialize matrix to be a square with
                                   #a diagonal of 1s
k...;                              #Set the output to...
({}|{X;})*                         #The boolean x matrix multiplied by...
{m_?33:126;;:L:l;                  #A bunch of random characters
miC<121,89>:gr:c;;:49:gr:c;;:L:l;} #But make sure they are not y or Y
```
This also supports even numbers.
[Answer]
## MATLAB, 86 bytes
```
a=@(n)(char(changem(randi(92,n),33+[0:55 57:87 89:93],1:92).*(eye(n)|fliplr(eye(n)))))
```
Some examples:
```
>> a(1)
ans =
i
>> a(3)
ans =
~ {
 Z
* ^
>>a(5)
ans =
k   E
 | M
  }
 ] s
b   t
>> a(10)
ans =
Q        k
 +      a
  j    w
   X  [
    rO
    %3
   P  d
  K    q
 r      &
?        v
```
[Answer]
# SmileBASIC, 97 bytes
```
INPUT S
FOR X=1TO S
FOR Y=1TO S
Q=RND(93)+33?CHR$((Q+!(Q-121&&Q-89))*(X==Y||X+Y==S+1));
NEXT?NEXT
```
Instead of having to calculate the number of spaces between each character or something, I decided to just print in all locations where `X==Y` or `X+Y==Size+1`.
The random character generator just adds 1 if it generates `y` or `Y`, so `z` and `Z` are slightly more common than usual.
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 33 bytes
32 bytes of code, +1 for `-l` flag. Strangely enough, the code begins with `Y` and ends with `y`...
```
Ya{$=a|$+a=y-1?RCPARM-`y`s}MMCGy
```
Takes input as a command-line argument. [Try it online!](https://tio.run/nexus/pip#@x@ZWK1im1ijop1oW6lraB/kHOAY5KubUJlQXOvr6@xe@f//f92c/0amX/PydZMTkzNSAQ "Pip – TIO Nexus")
### Explanation
Constructs a grid of the appropriate size; replaces elements on the diagonals with a random non-y character, and all other elements with space.
```
                                  a is 1st cmdline arg; PA is printable ASCII characters;
                                  s is space (implicit)
Ya                                Yank a into y (global var, accessible within functions)
                             CGy  y by y coordinate grid
  {                       }MM     To each coordinate pair, map this function:
   $=a                             Fold on equality (true if both elements are equal)
      |                            Logical OR
       $+a                         Fold on +
          =y-1                     and test if equal to size - 1
              ?                    If the preceding expression is true, then:
                 PARM               From printable ASCII chars, remove
                     -`y`           regex matching y, case-insensitive
               RC                   Take a random choice from the resulting string
                         s         Else, space
                                  The whole expression returns a nested list, which is
                                  autoprinted as lines of concatenated items (-l flag)
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-R`](https://codegolf.meta.stackexchange.com/a/14339/), ~~25~~ 22 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
A much messier approach that somehow worked out shorter than the original. The need for the `j1` is annoying me but [this](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LVI&code=O8YyxkXFa9X2w8f5tFVhWMOsw/s&input=NQ) is the closest I can get otherwise, without tanking my score (the middle line is wrong).
```
;Æ2ÆEÅkÕöÃqSp´UaX¹j1Ãû
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LVI&code=O8YyxkXFa9X2w3FTcLRVYVi5ajHD%2bw&input=NQ)
```
;Æ2ÆEÅkÕöÃqSp´UaX¹j1Ãû     :Implicit input of integer U
 Æ                         :Map each X in the range [0,U)
  2Æ                       :  Map the range [0,2)
;   E                      :    ASCII
     Å                     :    Slice off the first character (space)
      k                    :    Case insensitively remove
       Õ                   :      "y"
        ö                  :    Random character
         Ã                 :  End map
          q                :  Join with
           S               :    Space
            p              :    Repeat
             ´U            :      Prefix decrement U
               aX          :      Absolute difference with X
                 ¹         :  End join
                  j1       :  Remove character at 0-based index 1
                    Ã      :End map
                     û     :Centre pad each element with spaces to the length of the longest
                           :Implicit output joined with newlines
```
## Original (w/o flag), 25 bytes
```
;z ôÈç iÕêÃÔê û ·ry@EÅkÕö
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=O3og9MjnIGnV6sPU6iD7ILdyeUBFxWvV9g&input=NQ)
```
;z ôÈç iÕêÃÔê û ·ry@EÅkÕö     :Implicit input of integer
 z                            :Floor divide by 2
   ô                          :Range [0,result]
    È                         :Map each X
     ç                        :  X spaces
       i                      :  Prepend
        Õ                     :    "y"
         ê                    :  Palindromise
          Ã                   :End map
           Ô                  :Reverse
            ê                 :Palindromise
              û               :Centre pad each element with spaces to the length of the longest
                ·             :Join with newlines
                 ry           :Replace "y"s
                   @          :  Pass each match through the following function
;                   EÅkÕö     :    As above
```
[Answer]
# Zsh, 115 ~~122~~ ~~130~~ bytes
```
for i ({1..$1}){for j ({1..$1}){x=$[(i==j)|(j+i==$1+1)?RANDOM%93+33:32]
echo -n ${${(#)x==45?89:x}/[yY]/\-}};echo}
```
* `i` & `j` iterate over the rows & columns.
* If we're on the **X**, set `x` to to a random ascii-value in the valid range, otherwise `32` [space].
* Convert ascii-value to text. Switch "-" character (45) to a "Y" (89) if found (necessary to avoid a bug). Change "y" or "Y" to hyphen char "-", and print
[try it online!](https://tio.run/##qyrO@J@moVnNlZqcka@QZ6tiaPU/Lb9IIVNBo9pQT0/FsFazGsTPQuJX2KpEa2Ta2mZp1mhkaQMZKobahpr2QY5@Lv6@qpbG2sbGVsZGsRAjdfMUVKpVqjWUNStsbU1M7S0srSpq9aMrI2P1Y3Tra2utQapq/4NIrlquNAVjIDYEYTBh/h8A)

~~[122 bytes](https://tio.run/##qyrO@J@moVnNlZqcka@QZ6tiaPU/Lb9IIVNBo9pQT0/FsFazGsTPQuJX2qpEBzn6ufj7qloaaxsbx3JVAEU0Mm1tszRrNLK0gQwVQ21DTftKW1sTU3sLS6tKK2OjWIgVunkKKtUq1RrKmhW1@tGVkbH6Mbr1tbXWIMna/yCSq5YrTcEYiA1BGEyY/wcA)~~
~~[130 bytes](https://tio.run/##TY2xCsIwGIT3PEXACAnBwt9Y2kbSILiq4CqdxNBmaEGXxphnj4kuDt9x9y33eg7RUObR/TbMeFIEZDTzA4@YeigKAoH5vO3fdopcL/vT4Xxct8CF6NGSDB2VsuxNLU@FAAemXQfQasdL6bqmSQWkU2pbaagr6aQo@9/tZsLE0xVbQthlEWJOFJDBIgGZb9TxAw)~~
[Answer]
# php, 135 bytes
```
<?php for(;$i<$n=$argv[1];){$s=str_pad('',$n);$s[$i?:0]=chr(rand(33,126));$s[$n-++$i]=chr(rand(33,126));echo str_ireplace(Y,X,"$s
");}
```
Fairly straightforward approach uses str\_pad to make a string of spaces of the required length, replaces the necessary characters with random ones then replaces any Ys (case insensitive) with Xs and echos the line.
Generates 2n+3 notices but, as usual, that's fine.
[Answer]
## Emacs Lisp, 269 bytes
```
(defalias'n'number-sequence)(set'c(mapcar'string(delq 89(delq 121(n 33 126)))))(defun c()(nth(random(length c))c))(defun s(x)" ")(defun x(l)(let((s(mapcar's(n 1 l))))(dotimes(i l)(set'x(copy-seq s))(setf(nth i x)(c)(nth(-(length x)i 1)x)(c))(message(apply'concat x)))))
```
Ungolfed and slightly modified:
```
(defvar c (mapcar 'string (delq 89 (delq 121 (number-sequence 33 126)))))
(defun c() (nth (random (length c)) c))
(defun s(x)" ")
(defun x(l)
  (let ((s(mapcar's(n 1 l)))
        x)
    (dotimes (i l)
      (set 'x (copy-seq s))
      (setf (nth i x) (c)
            (nth (- (length x) i 1) x) (c))
      (message (apply 'concat x)))))
```
[Answer]
# JavaScript (ES6), 128 ~~131~~
**Edit** 3 bytes saved thx @Neil
So bulky, probably not the best approach. Bonus - it works with odd or even input.
```
n=>[...Array(n)].map((_,i,z)=>String.fromCharCode(...z.map((r=1+Math.random()*94,j)=>32+(j==i|j==n+~i&&(r+7&31?r:25))))).join`
`
```
```
F=n=>[...Array(n)].map((_,i,z)=>String.fromCharCode(...z.map((r=1+Math.random()*94,j)=>32+(j==i|j==n+~i&&(r+7&31?r:25))))).join`\n`
Z=_=>{
    o=F(+S.value),O.textContent=o,/y/i.test(o)||setTimeout(Z,100)
}
setTimeout(Z,100)
```
```
<input id=S value=15 type=number>
<pre id=O></pre>
```
[Answer]
# C, 268 bytes
```
V(c){for(c=89;c==89||c==121;c=rand()%95+33);return c;}p(n,s){n^1?s-n?printf("%*.c",s-n,32):0,printf("%c%*.c%c\n",V(),n*2-3,32,V()),p(n-1,s),s-n?printf("%*.c",s-n,32):0,printf("%c%*.c%c\n",V(),2*n-3,32,V()):printf("%*.c%c\n",s-n,32,V());}f(n){srand(time(NULL));p(n,n);}
```
Call `f()` with the size of the `x` to draw.
[Answer]
# Python 2, ~~204~~ ~~191~~ 183 bytes
Okay, Python competition here is getting fierce. Here's my attempt on shaving as many bytes as possible. ~~By now I'm stuck~~ (Ok, stuck again).
Credits to @NonlinearFruit for the way random characters are selected.
**183 byte version:**
```
import re,random
s=i=input();t=lambda:re.sub("y|Y","t",chr(random.randint(33,126)))
while i>-s:i-=2;u=abs(i);z=(s-u)/2-1;print('',' '*-~z+t()+'\n')[-1==i]+(' '*z+t()+' '*u+t())*(i>-s)
```
[Try It Online! (Ideone)](http://ideone.com/lwLInO)
Main change is to rewrite the conditional
```
(" "*(z+1)+t()+"\n"if -1==i else"")
```
as
```
(""," "*-~z+t()+'\n')[-1==i]
```
which saves 7 bytes.
**191 byte version:**
```
import re,random
s=i=input();t=lambda:re.sub("y|Y","t",chr(random.randint(33,126)))
while i>-s:
 i-=2;u=abs(i);z=(s-u)/2-1;print(' '*(z+1)+t()+'\n'if -1==i else'')+(' '*z+t()+' '*u+t())*(i>-s)
```
[Try It Online! (Ideone)](http://ideone.com/Qf2DNS)
Main changes are the way random characters are selected and some code rearrangement such as `s=input();i=s;` becoming `s=i=input();`, removing the `r=range` assignment as it is no longer needed and calling `abs` directly as it results in less bytes of code.
~~Beating the previous shortest answer in Python by 1 byte!~~ @R. Kap 's approach is used for generating the random characters.
Each iteration of the while loop a row of the ex is printed.
**204 byte version**:
```
from random import*
s=input();i=s;a=abs;r=range;t=lambda:chr(choice(r(33,89)+r(90,121)+r(122,128)))
while i>-s:
 i-=2;z=(s-a(i))/2-1;print(' '*(z+1)+t()+'\n'if -1==i else'')+(' '*z+t()+' '*a(i)+t())*(i>-s)
```
[Try It Online! (Ideone)](http://ideone.com/Xcx268)
Ungolfed version to get an idea of how it works:
```
from random import *
random_character = lambda : chr(choice(range(33,89)+range(90,121)+range(122,128)))
size = input()
current_row = size
while current_row > -size:
    current_row-=2
    n_leading_spaces = (size-abs(current_row)/2)-1
    row_to_print = ''
    if current_row == -1:
        row_to_print = ' ' * (n_leading_spaces+1) + random_chr() + '\n'
    if current_row > -size:
        row_to_print += ' ' * n_leading_spaces + random_chr()+' '*abs(current_row)+random_chr()
    print row_to_print
```
It was hard to handle the 1-character case!
[Answer]
# PHP, 100 bytes
```
for(;($x%=$n=$argv[1])?:$y++<$n&print"\n";)echo strtr(chr($y+$x++-$n&&$x-$y?32:rand(33,126)),yY,zZ);
```
takes input from command line argument; run with `-nr`.
combined loop prints characters depending on position
**breakdown**
```
for(;
    ($x%=$n=$argv[1])       // inner loop
        ?
        :$y++<$n&print"\n"  // outer loop; print newline
;)
    echo strtr(chr(             // 2. replace Y with Z; print
        $y+$x++-$n&&$x-$y       // 1: if position is not on diagonals
            ?32                 // then space
            :rand(33,126)       // else random printable
    ),yY,zZ);
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `mM`, 34 bytes
```
‹½ƛ\%꘍⁰↲øm;øm⁋?‹4*›ƛ‛yY95ɾ31+CF℅;%
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=mM&code=%E2%80%B9%C2%BD%C6%9B%5C%25%EA%98%8D%E2%81%B0%E2%86%B2%C3%B8m%3B%C3%B8m%E2%81%8B%3F%E2%80%B94*%E2%80%BA%C6%9B%E2%80%9ByY95%C9%BE31%2BCF%E2%84%85%3B%25&inputs=3&header=&footer=)
```
‹½ƛ       ;                        # Map 0...(n-1)/2...
   \%꘍                             # That many spaces before a %
      ⁰↲                           # Left-padded to correct width
        øm                         # Palindromise
           øm                      # Palindromise
             ⁋                     # Join by newlines
              ?‹4*›                # 4(n-1)+1
                   ƛ            ;  # Map 0...n...
                       95ɾ31+C     # Printable ASCII
                    ‛yY            # Push ys
                              F    # Remove ys
                               ℅   # Choose a random element from this
                                 % # Format the cross by this
```
[Answer]
# [Vyxal 2.6](https://github.com/Vyxal/Vyxal), 22 bytes
```
½⌈:ʁ\%꘍↲∞v∞⁋?dkP‛yYFƈ%
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLCveKMiDrKgVxcJeqYjeKGsuKInnbiiJ7igYs/ZGtQ4oCbeVlGxoglIiwiIiwiNSJd)
```
½⌈:                    # Push ⌈x/2⌉ twice
   ʁ                   # For each 0...^-1
    \%꘍                # Prepend that many spaces to a %
½⌈     ↲               # Pad to length ⌈x/2⌉ with spaces
        ∞v∞            # Quad palindromise
           ⁋           # Join by newlines
                    ƈ  # Choose...
            ?d         # Input * 2
                    ƈ  # Random items from...
              kP       # Printable ASCII
                ‛yYF   # Without Y
                     % # Replace % in the first bit with the random chars
```
]


[Question]
      [
This is a Code Golf challenge.
[Flood](http://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/flood.html) is a game in which the player is presented with a game board such as this:
[![Initial Game Board](https://i.stack.imgur.com/RWaO2m.png)](https://i.stack.imgur.com/RWaO2m.png)
On each turn, you choose a colour (on the link above, by clicking a square containing that colour), and the cell in the top-left corner is filled with that colour - this colour will absorb all adjacent cells with the same colour. So, for example, the first turn might be Blue, which will cause the yellow cell in the top corner to turn blue, and merge with the existing blue cell. The next turn might be Purple, which will fill both of the first two cells purple, merging them with the two-cell purple area attached to them. Then you might go Red, then Orange. With this sequence, the board will end up as:
[![After going Blue, Purple, Red, Orange](https://i.stack.imgur.com/hMfVFm.png)](https://i.stack.imgur.com/hMfVFm.png)
Your task is to write a code that simulates the game, taking in an array or other data format containing the current state of the game, in a suitable format (picture, numbers in a square array, string with numbers indicating the dimensions, anything that can be identified with the game), along with one or more input commands (colours, cells that contain colours, etc - your choice of how to implement the sequence, but you need to explain it).
If (and only if) the input solves the board (causes all cells to be the same colour), then your code should print a message in some format informing the player that the board is cleared or completed. It is up to you how this is done, but it must be clear to any English speaker using the code without requiring separate documentation (so outputting "1" isn't good enough). Note that displaying a completed board is not sufficient.
Some example options for completion output include `win`, `done`, `complete`, or `clear`. If your language doesn't have a nice way to output a longer message, I recommend using `win`.
Whether the input solves the board or not, the code should output (either as function output or as a displayed output) the final state of the board.
The code may take input of moves interactively (from STDIN, to simulate the actual game) or as a code input.
## Scoring
Your goal is to minimise the number of bytes in the function or code.
## Rules and Assumptions
[Standard Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
Code must be able to handle non-square boards, with each dimension being anywhere between 6 and 30 cells (more is fine, it must handle this range). It must be able to handle between 3 and 9 distinct colours or "colour" labels (numbers are fine).
You may assume that input is in simplest form - that is, if there are four colours, they will be labelled 1-4, or a-d, or any other similar system as appropriate. You will not need to handle situations such as incorrect inputs, unsimplified inputs (you won't have the numbers 1, 3, 6, and 9, without the others in between, unless it suits your code).
Your answer should include a description of formats, etc.
**Request**: If you believe you have identified a non-standard loophole, and it's definitely a loophole and not in the spirit of the question, please comment to have the loophole closed, rather than posting an answer using it. This is not a rule, *per se*, but an effort to keep the challenge interesting.

[Answer]
# Octave, ~~68~~ ~~64~~ ~~94~~ ~~92~~ 83 bytes
```
a=f(a,s)m=a;for k=s;[~,x]=bwfill(a~=k&m,1,1,4);m(x)=0;a(x)=k;end;~m&&puts("win\n");
```
A function that takes as input a matrix `a` and a vector `s` as the sequence of commands and outputs the final state of the board.
Explanation:
```
function a=Flood(a,s)
    m=a;
    for k=s
        [~,x]=bwfill(a~=k&m,1,1,4);
        m(x)=0;
        a(x)=k;
    end
    ~m&&puts("Game Completed\n");
end
```
Usage:
```
num_colors = 4;
a = randi(num_colors, 5 ,7)
s = randi(num_colors, 1 , 15);
Flood(a,s)
```
Use `m` as a mask representing the filled region so far. Repeatedly run commands and flood fill the masked grid from the top left corner.
]


[Question]
      [
A simple FizzBuzz using strings.
**Given**
* 1 word or phrase (string)
* 2 unique characters
**Output**
The word or phrase with each occurrence of the first character replaced with fizz and each of the second character replaced with buzz
**Rules**
* The first letter in both Fizz and Buzz must remain capitalized
* For the rest of the words fizz and buzz, you must match the case of the replaced character (if no case then keep lowercase)
* If given characters are not in the phrase, output the original phrase
**Test Cases**
```
Given: Hello, h, l
Output: FIZZeBuzzBuzzo
Given: test, a, b
Output: test
Given: PCG rocks!,  , !
PCGFizzrocksBuzz
Given: This
Is
SPARTA!,
, S
Output: ThiBuzzFizzIBuzzFizzBUZZPARTA!
Given: FizzBuzz, a, b
Output: FizzBUZZuzz
```
This is code-golf so the shortest code, in bytes, wins!
**Note**
Technically handling the newline case (This Is SPARTA!) is a part of the challenge. However, I will not void an answer for not including it, as it is very challenging or even impossible in some languages.

[Answer]
## [Python 3](https://docs.python.org/3.6/), ~~180~~ ~~174~~ ~~168~~ ~~160~~ 152 bytes
```
from sys import*
J=''.join
L=str.lower
s,a,b=J(stdin).split(', ')
print(J('FBFBiuIUzzZZzzZZ'[L(k)==L(b)::2][k!=L(k)::2]*(L(k)in L(a+b))or k for k in s))
```
This is just a more golfed version of [Stephen](https://codegolf.stackexchange.com/a/113295/39211)'s answer, in Python 3. This chips away 42% of his bytes. Python 2 would save one byte on the print, but such is the price of progress. This handles newlines properly.
Thanks to Blckknight for saving 8 bytes on input.
[Answer]
# Python, 109 bytes
```
lambda s,w:"".join([c,"Fizz","Buzz","BUZZ","FIZZ"][-~w.lower().find(c.lower())*-~(-2*c.isupper())]for c in s)
```
[Try it online!](https://tio.run/nexus/python3#PY47D4JAEIT7@xXLVnvkoLA0sVATlcSC@GhECjwhniJHOAyJhX8dj/NR7E5mstlvismxL7P76ZyBEd0YMbxqVVEiBS7U84kCZ4@P7A8HK4vISpoEry4sdZc3xMNCVWeSP8v94EXByJehMo@6dlFa6AYkqAoM79vctAYmkBCu8rLU9ulljVwQxvMlNFrejIcCEDwbArka3w7Zyd0h7i7KsMiwbTzd7KaeTYQdtrWLp2ygDZQB6GhjBnWjqpYGx3@mIN/5f8D7Nw "Python 3 – TIO Nexus")
---
Takes the two characters as a single string
*Edit:
Added testcase to TIO link, newline works too*
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 34 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
Œl=€⁹Œl¤ȧ€"“¡Ṭ4“Ụp»o"/ȯ"Œu⁹Œln$T¤¦
```
**[Try it online!](https://tio.run/nexus/jelly#@390Uo7to6Y1jxp3AlmHlpxYDuQoPWqYc2jhw51rTICMh7uXFBzana@kf2K90tFJpRCFeSohh5YcWvb//3@u4P8hGZnFXJ7FXMEBjkEhjooA "Jelly – TIO Nexus")**
### How?
```
Œl=€⁹Œl¤ȧ€"“¡Ṭ4“Ụp»o"/ȯ"Œu⁹Œln$T¤¦ - Main link: characters, string
Œl                                 - lowercase the characters
       ¤                           - nilad followed by link(s) as a nilad:
    ⁹                              -     right argument, the string
     Œl                            -     lowercase
  =€                               - equals (vectorises) for €ach (a list of 2 lists that identify the indexes of the string matching the characters regardless of case)
           “¡Ṭ4“Ụp»                - dictionary strings ["Fizz", "Buzz"]
          "                        - zip with
        ȧ€                         -     logical and (non-vectorising) for €ach (replace the 1s with the words)
                     /             - reduce with:
                    "              -     zip with:
                   o               -         logical or (vectorises) (make one list of zeros and the words)
                                   - implicit right argument, string
                       "           - zip with:
                      ȯ            -     logical or (non-vectorising) (replace the zeros with the original characters from the string)
                                 ¦ - apply...
                        Œu         -     uppercase
                                   - ...to the indexes (the words at indexes):
                                ¤  -     nilad followed by link(s) as a nilad:
                          ⁹        -         right argument, the string
                              $    -         last two links as a monad (i.e. the string on both sides):
                           Œl      -             lowercase
                             n     -             not equals (vectorises)
                               T   -         truthy indexes (the indexes of the capital letters in the string)

```
[Answer]
# [Python 2](https://docs.python.org/2/), 271, 261 bytes
```
import fileinput as f
a=''
for m in f.input():a+=m
a=a.split(', ')
l=L=list(a[0])
for i in range(0,len(a[0])):
 j,k=l[i].lower(),l[i].istitle()
 if j==a[1].lower():
  L[i]='FIZZ'if k else'Fizz'
 elif j==a[2].lower():
  L[i]='BUZZ'if k else'Buzz'
print''.join(L)
```
[Try it online!](https://tio.run/nexus/python2#bcwxC8IwEIbhPb/itkswlOooZHEQhK4uLQ4RErl6TUuaIvjna1pRENxyvN@Tmbqhjwk8saMwTAnsCF5Ygyh8H6EDCuCLNUm1txvT5WiLcWBKEjWgEmwqwzQmaZvyolZGC4s23JwsNbvwTmovoNV3ww1dCu4fLkql1yNrSuykEkAeWmNss/1OsoIqrwweT3WNeXAHx6PDIz2fKPL7Y3Z/zOH8Yw7TYoZIISEWbU9BVmqel6@WpMFquL4A "Python 2 – TIO Nexus")
Wow this one was a doozie! It turns out python won't accept multi-line inputs so `fileinput` must be used.
edit: should pass all cases now :)
[Answer]
# MATLAB/[Octave](https://www.gnu.org/software/octave/), ~~106~~ ~~102~~ 111 bytes
```
@(a,b,c)regexprep(a,num2cell([lower([b c]) upper([b c]) '1234']),{'2','4','1','3','FIZZ','Fizz','BUZZ','Buzz'})
```
This could probably be optimised further.
It uses a simple Regex replacement. However an intermediate step is required by replacing the input characters with numbers first. This is so that if the second input replace letter was contained in `Fizz` that the `Fizz` doesn't then get replaced when the next regex is performed.
This of course assumes there are no numbers in the input. However given the question says the input is a word or phrase I feel that this is an acceptable assumption.
The code will handle new lines in the input correctly.
You can [Try it online!](https://tio.run/nexus/octave#RY2xCsIwFEV/5W0vgQwm7QdIB1FwdWnIkMaHFmIbUoJS8dvjq4vD4XKGe2/dC68GFWSmG71SpsQ@lYcJFKOwcX5SFnaA4CSUlP6C2jQtOqneaFBhy2imYQ6nvt9iXFeO7vKzrrB9ZPXTIiweeX1G0DvA8zjRAj4T@LjdXdEpvHMjoqxf "Octave – TIO Nexus")
[Answer]
# Bash 4.4 + GNU sed, ~~70~~ ~~228~~ ~~222~~ 227 bytes
```
IFS=;alias e=echo;K=`sed $([[ $2 != '
' ]]&&e "s/${2,}/Fizz/g;s/${2^}/FIZZ/g"||:)$([[ $3 != '
' ]]&&e ";s/${3,}/Buzz/g;s/${3^}/BUZZ/g"||:)<<<"$1"`;[[ $2 = '
'||$3 = '
' ]]&&e ${K//$'\n'/`[[ $2 = '
' ]]&&e Fizz||e Buzz`}||e "$K"
```
Apparently `alias e=echo` throws an error if referenced in Bash 4.3 or below, the version TIO is apparently using. Therefore, the longer and equivalent Bash 4.3 code is given in the below TIO test suite for the sake of testing. This passes all of the test cases, so that is nice.
[Try it online!](https://tio.run/nexus/bash#Zc69CoMwFAXgPU8RQzAttITqqA46COJSql20SooVddEhdNH42J3TqP3DjgfO/c6VgR85VugwXt4g3qQpxAbUHEgAgVmm62VRdxBxigdjN1K/6XtaWXPMVQyShFZIiKWFtgtg/gPziakE7/4RTCV455Vg2zbCB8Ss5ZPZEUKRKxEPIaWYXFpC2U/1W5hefbHTJhvfGzhEUsq4bjgIOIiO7il2NQlk9Gi7fXEt6vIJ "Bash – TIO Nexus")
[Answer]
## JavaScript (ES6), 92 bytes
Takes input as a string and an array of two characters. Supports newlines.
```
f=(s,[a,b],r='Fizz')=>a?f(s.replace(RegExp(a,'gi'),m=>m<'a'?r.toUpperCase():r),[b],'Buzz'):s
```
### Test cases
```
f=(s,[a,b],r='Fizz')=>a?f(s.replace(RegExp(a,'gi'),m=>m<'a'?r.toUpperCase():r),[b],'Buzz'):s
console.log(f("Hello", ['h', 'l']))
console.log(f("test", ['a', 'b']))
console.log(f("PCG rocks!", [' ', '!']))
console.log(f(`This
Is
SPARTA!`, [`
`, 'S']))
console.log(f("FizzBuzz", ['a', 'b']))
```
[Answer]
## [GNU sed](https://www.gnu.org/software/sed/), 135 + 1(r flag) = 136 bytes
By default, a sed script is executed as many times as there are input lines. To handle multi-line input, I use a loop to append all possible remaining lines to the first, without starting a new cycle.
```
:r
$!N
$!br
s:, (.), (.):;\u\1FIZZ;\l\1Fizz;\u\2BUZZ;\l\2Buzz:
s:^:,:
:
s:,(.)(.*;\1)(...)(.):\3,\4\2\3\4:
s:,(.):\1,:
/,;.F/!t
s:,.*::
```
**[Try it online!](https://tio.run/nexus/sed#NYuxCoMwEED3fEWEDirXSKLTZdJBcCml2kWODp0MlFoSXfLxTZOWDnf3eNwLaNkhO8W5W@YQeC6K70JNO8l@mGdNjwjG@2RUd/0Z1e3eY0xuCMgSQKxyUWqS8YjEBVIN1JCimpr/C5KMQQVa9FW2JSlKxBCmxTg2ODae28vUZsAZ8PG9vjazPl042g8)**
The replacement table used on line 4, needs to be in that exact order, i.e. 'Fizz' and 'Buzz' after their upper-case forms. This is because the sed regex `.*`, used during the table lookup, is greedy. If the current char needed to be replaced is not a letter (no case), then the lowercase string is needed (matched last).
Since sed has no data types, I use a character delimiter to iterate a string. It will mark my current position and in a loop I shift it from left to right. Fortunately, I can use `,` for this, since it is the input data delimiter.
**Explanation:**
```
:r                                                 # reading loop
$!N                                                # append next input line
$!br                                               # repeat till EOF
s:, (.), (.):;\u\1FIZZ;\l\1Fizz;\u\2BUZZ;\l\2Buzz: # create replacement table
s:^:,:                                             # append my string delimiter
:                                                  # main loop
s:,(.)(.*;\1)(...)(.):\3,\4\2\3\4:                 # apply char replacement, if any
s:,(.):\1,:                                        # shift delimiter to right
/,;.F/!t                                           # repeat till end of string
s:,.*::                                            # print only the final string
```
[Answer]
# Pyth - 25 bytes
```
sXzsrBQ1scL2rB"FizzBuzz"1
```
[Test Suite](http://pyth.herokuapp.com/?code=sXzsrBQ1scL2rB%22FizzBuzz%221&test_suite=1&test_suite_input=%22hl%22%0AHello%0A%22ab%22%0Atest%0A%22+%21%22%0APCG+rocks%21%0A%22ab%22%0AFizzBuzz&debug=0&input_size=2).
[Answer]
# Haskell, 114 bytes
```
u=Data.Char.toUpper
p[f,b]x|f==u x="Fizz"|b==u x="Buzz"|2>1=[x]
q x y|u y<y=x|2>1=u<$>x
r x=concatMap$q=<<p(u<$>x)
```
`r` takes the fizz and buzz characters as a 2 element list as the first argument, and the input string as the second argument. Newlines and unicode should be handled appropriately, although the function is unfortunately not total (allowing for invalid inputs saved 5 bytes).
[Answer]
# Mathematica, 94 bytes
```
a=ToLowerCase;b=ToUpperCase;StringReplace@{a@#->"Fizz",b@#->"FIZZ",a@#2->"Buzz",b@#2->"BUZZ"}&
```
Anonymous function. Takes two strings as input and returns a function which takes a string as input and returns a string as output as output. It must be called in the format `prog["c1", "c2"]["s"]`, where `"s"` is the target string and `"c1"` and `"c2"` are the two characters. Could probably be golfed further.
]


[Question]
      [
In this exercise, you have to analyze records of temperature to find the closest to zero.
Write a program that prints the temperature closest to 0 among input data.
## Input
* N, the number of temperatures to analyse (optional). This will be nonzero.
* The N temperatures expressed as integers ranging from *-273 to 5526*.
## Output
Output the temperature closest to 0. If two temperatures are equally close, take the positive one. For instance, if the temperatures are -5 and 5, output 5.
## Example
```
Input
    5
    1 -2 -8 4 5
Output
    1
```
[This challenge is similar to this one on CodinGame, you can view the problem statement source here.](https://github.com/GlenDC/Codingame/blob/master/descriptions/temperatures.md)
Some modifications have been made to the text.

[Answer]
# [Python](https://docs.python.org/2/), 35 bytes
```
lambda l:max((-x*x,x)for x in l)[1]
```
[Try it online!](https://tio.run/nexus/python2#S7ON@Z@TmJuUkqiQY5WbWKGhoVuhVaFToZmWX6RQoZCZp5CjGW0Y@7@gKDOvRCFNI1rXSMdQR9cwVpMLWchIxyRW8z8A "Python 2 – TIO Nexus")
Narrowly beats:
```
lambda l:min(l,key=lambda x:2*x*x-x)
lambda l:min(sorted(l)[::-1],key=abs)
```
[Answer]
## JavaScript (ES6), 33 bytes
```
a=>a.reduce((m,n)=>n*n-n<m*m?n:m)
```
### Demo
```
let f =
a=>a.reduce((m,n)=>n*n-n<m*m?n:m)
console.log(f([1, -2, -8, 4, 5]))
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
```
AÐṂṀ
```
[Try it online!](https://tio.run/nexus/jelly#@@94eMLDnU0Pdzb8P9z@qGmN@///0YY6CrpGQGyho2Cio2Aaq6MQDcKmQCHTWAA "Jelly – TIO Nexus")
### How it works
```
AÐṂṀ  Main link. Argument: A (array)
AÐṂ   Take all elements with minimal absolute value.
   Ṁ  Take the maximum. Yields 0 for an empty list.
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog) (2), 5 or 2 bytes
```
~{≜∈}
```
[Try it online!](https://tio.run/nexus/brachylog2#@19X/ahzzqOOjtr//6N1TXVMdcx0dA2NYv9HAQA "Brachylog – TIO Nexus")
It wouldn't surprise me if there were a shorter solution along the lines of the Jelly or Pyke, but I like this one because it's so weird.
This is simply Brachylog's "find a list containing the input" operator `∈`, with an evaluation strategy `≜` that simply tries explicit values for integers until it finds one that works (and it happens to try in the order 0, 1, -1, 2, -2, 3, etc., which is surprisingly handy for this problem!), and inverted `~` (so that instead of trying to find an output list containing the input, it's trying to find an output contained in the input list). Unfortunately, inverting an evaluation strategy along with the value itself costs 2 bytes, so this doesn't beat the Jelly or Pyke solutions.
There's also a dubious 2-byte solution `≜∈`. All Brachylog predicates take exactly two arguments, which can each be inputs or outputs; by convention, the first is used as an input and the second is used as an output, but nothing actually enforces this, as the caller has complete control over the argument pattern used (and in Prolog, which Brachylog compiles to, there's no real convention about argument order). If a solution which takes input through its second argument and produces output through its first argument is acceptable, there's no requirement to do the inversion.
[Answer]
# [R](https://www.r-project.org/), 31 bytes
```
(l=scan())[order(abs(l),-l)][1]
```
[Try it online!](https://tio.run/##K/r/XyPHtjg5MU9DUzM6vygltUgjMalYI0dTRzdHMzbaMPa/rqmC6X8A "R – Try It Online")
[Answer]
## Pyke, 4 bytes
```
S_0^
```
[Try it online!](https://tio.run/nexus/pyke#@x8cbxD3/7@uoY4CEOkaAbGFjoKJjoIpAA "Pyke – TIO Nexus")
```
S_   - reversed(sorted(input))
  0^ - closest_to(^, 0)
```
[Answer]
# Mathematica, ~~21~~ 19 bytes
```
Max@*MinimalBy[Abs]
```
Composition of functions. Takes a list of integers as input and returns an integer as output.
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~9~~ 6 bytes
```
0iSPYk
```
[Try it online!](https://tio.run/nexus/matl#@@@fGRwQmf3/f7SuqYJpLAA "MATL – TIO Nexus")
Thanks to Luis Mendo for pointing out there's actually a built-in for this in MATL, which is not present in MATLAB.
```
 i     % Take input
  S    % Sort
   P   % Reverse to have largest value first.
0   Yk % Closest value to zero, prioritizing the first match found
```
If you wish to follow the spec and also provide the number of temperatures to be read, this should be given as the second input, and will be silently discarded.
[Answer]
# C++14, 64 bytes
As unnamed lambda, expecting first argument to be like `vector<int>` and returing via reference parameter.
```
[](auto L,int&r){r=L[0];for(int x:L)r=x*x<=r*r?r+x?x:x>r?x:r:r;}
```
Ungolfed and usage:
```
#include<iostream>
#include<vector>
auto f=
[](auto L,int&r){
  r=L[0];
  for(int x:L)
    r = x*x<=r*r ?   //x is absolute less or equal
      r+x ?          //r==-x?
        x :          //no, just take x
        x>r ?        //take the positive one
          x :
          r      :
      r              //x was absolute greater, so keep r
    ;
}
;
int main(){
 std::vector<int> v = {5, 2, -2, -8, 4, -1, 1};
 int r;
 f(v,r);
 std::cout << r << std::endl;
}
```
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 21 bytes
Added `+1` for `-p` since this challenge precedes "options don't count"
```
$G[abs]=$_}{$_+="@G"
```
[Try it online!](https://tio.run/##K0gtyjH9/1/FPToxqTjWViW@tlolXttWycFd6f9/Cy4TYy5dEy5TIPyXX1CSmZ9X/F@3AAA "Perl 5 – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt) `-g`, 3 bytes
```
ña¼
```
[Try it online!](https://tio.run/##y0osKPn///DGxEN7/v@PNlUwVNA1UtC1UDBRMI3l4tJNBwA "Japt – Try It Online")
# [Japt](https://github.com/ETHproductions/japt), 5 bytes
```
ña¼ v
```
[Try it online!](https://tio.run/##y0osKPn///DGxEN7FMr@/4/WNVUwjQUA "Japt – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 16 bytes
```
Îåà_Di¹{RDÄßs\kè
```
Explanation:
```
Î                 Push 0 and [implicit] input array
 å                For each element in the array, is it a 0?
  à               Find the greatest value (1 if there was a 0 in it, 0 otherwise)
   _              Negate boolean (0 -> 1, 1 -> 0)
    D             Duplicate
     i            If true, continue
      ¹           Push input
       R          Reversed
        D         Duplicated
         Ä        Absolute value
          ß       Greatest element
           s      Swap top two values in stack
            \     Delete topmost value in stack
             k    Index of greatest element in the array
              è   Value of the index in the input array
```
[Try it online!](https://tio.run/nexus/05ab1e#@3@47/DSwwviXTIP7awOcjnccnh@cUz24RX//0frmugo6BoBsYWOApBpCmQBKSMw0jWMBQA "05AB1E – TIO Nexus")
Not at short as I'd like, but at least it works.
[Answer]
## Haskell, 29 bytes
```
snd.maximum.map(\x->(-x^2,x))
```
Usage example: `snd.maximum.map(\x->(-x^2,x)) $ [1,-2,-8,4,5]`-> `1`.
Map each element `x` to a pair `(-x^2,x)`. Find the maximum and pick the 2nd element from the pair.
[Answer]
# PHP, 81 bytes
two solutions: the first one requires an upper bound; both require all temperatures nonzero.
```
for($r=9e9;$t=$argv[++$i];)abs($t)>abs($r)|abs($t)==abs($r)&&$t<$r?:$r=$t;echo$r;
for(;$t=$argv[++$i];)$r&&(abs($t)>abs($r)|abs($t)==abs($r)&&$t<$r)?:$r=$t;echo$r;
```
Run with `-r`, provide temperatures as command line arguments.
A lazy solution for **92 bytes**:
```
$a=array_slice($argv,1);usort($a,function($a,$b){return abs($a)-abs($b)?:$b-$a;});echo$a[0];
```
defines a callback function for [`usort`](http://php.net/usort) and uses it on a slice of `$argv`.
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 15 bytes
```
*.min:{.²,-$_}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPtfSy83M8@qWu/QJh1dlfja/9ZcxYmVCmkaKvGaCmn5RVwahjq6Rjq6FjomOqaaOlwaRgiujq4hSEQXSYWOoab1fwA "Perl 6 – Try It Online")
[Answer]
# Java 8, ~~63~~ 39 bytes
```
s->s.reduce(1<<15,(r,i)->r*r-r<i*i?r:i)
```
Port from [*@Arnauld's* JavaScript answer](https://codegolf.stackexchange.com/a/112039/52210). I couldn't find anything shorter..
-10 bytes converting Java 7 to 8,
and another -24 bytes thanks to *@OlivierGrégoire*.
**Explanation:**
[Try it online.](https://tio.run/##rY/BbsIwDEDv/QofE5RE6zakCTqmHXcYF46IQ5YG5K4NyEmZEOq3d25BaPdxcBQn9vNzZY9WV@V372obI3xaDOcMAEPytLXOw3JIxwdwouJq0yasTUzkbWM@QlqNN4hyzoVdxkdMNqGDJQR4hT7qRTTky9Z5kRdFPlWCFEq9oAlpKnCCbzRD2c@H1kP7VXPrlXDcYwkNKwkegmG33lh50VmdYvKN2bfJHPgn1UEE89fvncie4lVTBP8zbLDenCFXoB85XhQ8K5hCJ@Vo/h/mALw7k0UfFOR3E3y6kbqs638B)
```
s->                   // Method with IntStream parameter and int return-type
  s.reduce(1<<15,     //  Start `r` at 32768 (`32768^2` still fits inside a 32-bit integer)
     (r,i)->r*r-r<i*i?//  If `r^2 - r` is smaller than `i^2`:
       r              //   Leave `r` the same
      :               //  Else:
       i)             //   Replace the current `r` with `i`
                      //  Implicitly return the resulting `r`
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 30 bytes
```
a=>a.sort((a,b)=>a*a-a>b*b)[0]
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z@TWqKQpmD7P9HWLlGvOL@oREMjUSdJE8jTStRNtEvSStKMNoj9n5yfV5yfk6qXk5@ukaYRbaijoGsExBY6CiY6CqaxmppcaCp0jcyNgZLGWKRMgRpNsGkxxW4USD1I/D8A "JavaScript (Node.js) – Try It Online")
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 28 bytes
```
@(x)max(x(min(a=abs(x))==a))
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bo0IzN7FCo0IjNzNPI9E2MakYKKJpa5uoqfk/TSNawVBB10hB10LBRME0VvM/AA "Octave – Try It Online")
Finds the smallest absolute value (`min(a=abs(x))`), then maps it back to which elements have that smallest absolute value in case of a tie (`x(...==a)`). Finally takes the maximum value of the results (`max(...)`) to ensure that in the event of a tie we get one result which is the positive one.
[Answer]
## PHP, 209 Bytes
**Not really golfed**, but wanted to try to use mostly array functions, avoiding loops
[Try it Online!!](https://tio.run/##VY9BCoMwEEWv0kWQhEbQUjeN4kFCKGk6QVGMTEyhFM9u09guuhn@f/NgmLmbt7qd47RhMkvvpoOlRLMX0VI1hfAOl08XZGg0on5ePWg0HS14ou5Hx95AFDkZjmXk4csRHoAe6N7uvbVJcoyJPsYgS5VlxMlCxZPYUH3zO2V1imnD2oQuqYkVRg9J3sX/JcIScCIo1g1M5@I3Mq94fuJ5yc@84pViYnsD)
**Code**
`function f($a){$a[]=0;sort($a);$k=array_search(0,$a);$o=array_slice($a,$k+1);$u=array_reverse(array_diff($a,$o));if($u[1]&&$o[0]){$r=(abs($u[1])<abs($o[0]))?$u[1]:$o[0];}else{$r=($u[1])?$u[1]:$o[0];}return$r;}`
**Explanation**
```
function f($a){
$a[]=0;                                #As all nonzero values, 0 is pushed
sort($a);                              #Sorting the array
$k=array_search(0,$a);                 #Search where zero is
$o=array_slice($a,$k+1);               #Array with all values >0
$u=array_reverse(array_diff($a,$o));   #Array with all smaller than zero values
                                       #Array has ascending order so it gets reversed
if($u[1]&&$o[0]){                      #if both are set we just compare the abs value
    $r=(abs($u[1])<abs($o[0]))?$u[1]:$o[0];
}else{
    $r=($u[1])?$u[1]:$o[0];            #al least one of them will allways be set
                                       #the first value is always returned
                                       #the 0 value on $u is not usetted that why $u[1]
}
return $r;
}
```
[Answer]
# [Julia 0.6](http://julialang.org/), 29 bytes
```
x->sort(x,by=x->abs(x-.1))[1]
```
Sort by the absolute value of the temperature, but subtract .1 first to ensure positive temperatures always win.
[Try it online!](https://tio.run/##yyrNyUw0@59mm5Sanpn3v0LXrji/qESjQiep0hbISUwq1qjQ1TPU1Iw2jP2fmpfC5VCckV@ukKYRbaRjrGMSq4kmoKNrhCwGE/kPAA "Julia 0.6 – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 5 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
{R0.x
```
[Try it online.](https://tio.run/##yy9OTMpM/f@/OshAr@L//2hDHV0jHV0LHRMd01gA)
Or alternatively:
```
ÄWQÏà
```
[Try it online.](https://tio.run/##yy9OTMpM/f//cEt44OH@wwv@/4821NE10tG10DHRMY0FAA)
**Explanation:**
```
{      # Sort the (implicit) input-list lowest-to-highest
 R     # Reverse it to highest-to-lowest
  0.x  # Pop and push the item closest to 0
       # (after which the result is output implicitly)
Ä      # Get the absolute value of each in the (implicit) input-list
 W     # Push the minimum (without popping the list)
  Q    # Check which are equal to this minimum
   Ï   # Only keep the values in the (implicit) input-list at the truthy indices
    à  # Pop and push the maximum of the remaining values
       # (after which the result is output implicitly)
```
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `h`, 4 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
ṠrþA
```
[Try it online!](https://Not-Thonnu.github.io/run#aGVhZGVyPSZjb2RlPSVFMSVCOSVBMHIlQzMlQkVBJmZvb3Rlcj0maW5wdXQ9MSUyQy0yJTJDLTglMkM0JTJDNSZmbGFncz1o)
#### Explanation
```
ṠrþA  # Implicit input
Ṡr    # Reverse-sort
  þA  # Sort by |x|
      # Take the first item
      # Implicit output
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `G`, 20 [bitsv2](https://github.com/Vyxal/Vyncode/blob/main/README.md), 2.5 bytes
```
⁽ȧP
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyJHPSIsIiIsIuKBvcinUCIsIiIsIls3LDIsLTIsOTEsNV0iXQ==)
Finds the minimum in the list by absolute value
[Answer]
# Python, 62 bytes
```
def f(n):
    r=min(map(abs,n))
    return r if r in n else -r
```
It feels like there is a much simpler/shorter solution.
[Answer]
# [C (clang)](http://clang.llvm.org/), 74 bytes
```
k,m;f(*i,n){for(k=*i;--n>0;k=(k*k>m*m||(k==-m&&k<m))?m:k)m=i[n];return k;}
```
[Try it online!](https://tio.run/##RY5RS8QwEITf8yuWOzyyJdF6KIi51B9S@xDaRJc0W8n1HrTX314jiMI8zCwfO9PrfnT8tu2J@/EyeDid54Gm2/dmiyqZICtSjEuYsoy2IqM1N7WJVsYqNqlK12u5W50Oh3hKiC/pOWKy1HJnsp8vmSGadRP7wQdiDy5n9zl6lg5ByjN9@SkUj3d/vq07RBSCeIbkiCXCIgT8RGo7sLDoewVF@qigSD8peFDwuJpCfeTCBbm7GV55pyBIUv@VVP4W6HdWbcS6fQM "C (clang) – Try It Online")
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 6 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
¢M║⌠§☺
```
[Run and debug it at staxlang.xyz!](https://staxlang.xyz/#p=9b4dbaf41501&i=[-4+5+4+-1+6+-8+1]&a=1)
### Unpacked (6 bytes) and explanation
```
{|a}eoH
{  }e      Get all elements of array producing the minimum value from a block.
 |a          Absolute value.
     o     Sort ascending.
      H    Take last. Implicit print.
```
[Answer]
# Pyth, 4 bytes
```
.m.a
```
[Try it online!](https://tio.run/##K6gsyfj/Xy9XL/H//2hDHV0jHV0LHVMdk1gA)
Explanation:
```
.m.a   #Code
.m.abQ #With implicit variables
.m   Q #Filter input list for values b with minimal value of the following:
  .ab  #Absolute value of b
```
[Answer]
# [Python 3](https://docs.python.org/3/), 31 bytes
```
a=lambda q:sorted(q,key=abs)[0]
```
[Try it online!](https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRodCqOL@oJDVFo1AnO7XSNjGpWDPaIPb/fwA "Python 3 – Try It Online")
Sorts items by absolute value and prints the first element.
[Answer]
# [Avail](http://www.availlang.org/), 88 bytes
```
Method"f_«_»"is[c:[1..∞),t:integer*|quicksort a,b in t[1..c] by[|a-0.1|<|b-0.1|][1]]
```
Approximate deobfuscation:
```
Method "nearest to zero among first _ of «_»" is
[
    count : natural number,
    temps : integer*
|
    (quicksort a, b in temps[1..count] by [|a-0.1| < |b-0.1|])[1]
]
```
The [pattern syntax](http://www.availlang.org/about-avail/learn/quick-start.html#methods-message-pattern-language) in the method's name, `f_«_»`, will read the initial count as a natural number (whose type is abbreviated above as the range type `[1..∞)`) separate from the collected tuple of subsequent integers.
All that remains for the body is to [sort by a custom comparator](http://www.availlang.org/about-avail/documentation/stacks/library-documentation/avail/Avail/Foundation/Tuples/2169357673.html). Here we escape the need for a second-level comparison between `x` and `-x` by shifting the values slightly towards -∞.
[Answer]
# [dc](https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html), 53 bytes
```
Fd^sr[d*v]sA[ddlr+0=Asr]sR[dlAxlrlAx!<Rs_z0<M]dsMxlrp
```
[Try it online!](https://tio.run/##DcihDoAgEIDhVzmrFkAR2TBQbBQqQ4IXCY7bnPPl8cq3fz9efdFQFgVlkyClBU4zg1QzXyEYC1qbFfqBJ7WE45PJJ8TaJrF7apliwurf2pjBRSqfcCEjBV537z8 "dc – Try It Online")
We're going to use the register `r` to hold our final result, so the first thing we need to do is put a too-big number in there so that our first comparison always succeeds. I think the largest number we can push in two bytes is 165 (which is less than the required 5526), but `Fd^` gives us 15^15 which is plenty large. Macro `A`, `[d*v]sA` just does the square root of the square to give us absolute value.
Macro `R` handles putting a value into register `r`; we'll come back to it in a second. Macro `M`, `[dlAxlrlAx!<Rs_z0<M]dsMx` is our main macro. Duplicates the value on the stack, runs `A` to get ABS, then pushes the value in `r` and does the same. `!<R` checks to see if ABS(`r`) is ~~greater than or equal to~~ not less than ABS(top of stack), and if so it runs `R`. Since we had to leave behind a copy of the original top of stack for `R` to potentially use, we store to a useless register (`s_`) to pop it. `z0<M` just loops `M` until the stack is empty.
Macro `R`, `[ddlr+0=Asr]sR` duplicates the top of stack twice (we need to leave something behind for `M` to gobble up when we return). At this point we know that of the two absolute values, our new value is less than or equal to our old value. If they're equal, and one is positive and the other is negative, we always need the positive. Fortunately, knowing this we can easily check for the case of one being the inverse of the other by simply adding them and comparing to 0. If so, we run `A`, and no matter what else happened we know we're storing whatever is left in `r`.
After `M` has gone through the whole stack, we `l`oad `r` and `p`rint it.
]