#JavaScript (ES6), (削除) 41 40 (削除ここまで) 39 bytes
JavaScript (ES6), (削除) 41 40 (削除ここまで) 39 bytes
Takes inputs as (h)(m).
h=>m=>((x=4+h/3-m*.55/9)&2?12-x:x)%4*90
###How?
How?
Instead of working directly in the range \$[0..360]\$, we define a temporary variable \$x\$ in the range \$[0..4]\$:
$$x=\left|\frac{4h}{12}+\frac{4m}{60\times12}-\frac{4m}{60}\right|\bmod 4$$ $$x=\left|\frac{4h}{12}-\frac{44m}{60\times12}\right|\bmod 4$$ $$x=\left|\frac{h}{3}-\frac{11m}{180}\right|\bmod 4$$
The angle in degrees is given by:
$$\min(4-x,x)\times90$$
However, the formula is implemented a bit differently in the JS code, as we definitely want to avoid using the lengthy Math.abs() and Math.min().
Instead of computing the absolute value, we force a positive value in \$[0..12]\$ by computing:
$$x'=4+\frac{h}{3}-\frac{11m}{180}$$
And instead of computing the minimum, we determine in which case we are by simply doing a bitwise AND with \2ドル\$ -- and this is why we chose an interval bounded by a power of \2ドル\$ in the first place.
#JavaScript (ES6), (削除) 41 40 (削除ここまで) 39 bytes
Takes inputs as (h)(m).
h=>m=>((x=4+h/3-m*.55/9)&2?12-x:x)%4*90
###How?
Instead of working directly in the range \$[0..360]\$, we define a temporary variable \$x\$ in the range \$[0..4]\$:
$$x=\left|\frac{4h}{12}+\frac{4m}{60\times12}-\frac{4m}{60}\right|\bmod 4$$ $$x=\left|\frac{4h}{12}-\frac{44m}{60\times12}\right|\bmod 4$$ $$x=\left|\frac{h}{3}-\frac{11m}{180}\right|\bmod 4$$
The angle in degrees is given by:
$$\min(4-x,x)\times90$$
However, the formula is implemented a bit differently in the JS code, as we definitely want to avoid using the lengthy Math.abs() and Math.min().
Instead of computing the absolute value, we force a positive value in \$[0..12]\$ by computing:
$$x'=4+\frac{h}{3}-\frac{11m}{180}$$
And instead of computing the minimum, we determine in which case we are by simply doing a bitwise AND with \2ドル\$ -- and this is why we chose an interval bounded by a power of \2ドル\$ in the first place.
JavaScript (ES6), (削除) 41 40 (削除ここまで) 39 bytes
Takes inputs as (h)(m).
h=>m=>((x=4+h/3-m*.55/9)&2?12-x:x)%4*90
How?
Instead of working directly in the range \$[0..360]\$, we define a temporary variable \$x\$ in the range \$[0..4]\$:
$$x=\left|\frac{4h}{12}+\frac{4m}{60\times12}-\frac{4m}{60}\right|\bmod 4$$ $$x=\left|\frac{4h}{12}-\frac{44m}{60\times12}\right|\bmod 4$$ $$x=\left|\frac{h}{3}-\frac{11m}{180}\right|\bmod 4$$
The angle in degrees is given by:
$$\min(4-x,x)\times90$$
However, the formula is implemented a bit differently in the JS code, as we definitely want to avoid using the lengthy Math.abs() and Math.min().
Instead of computing the absolute value, we force a positive value in \$[0..12]\$ by computing:
$$x'=4+\frac{h}{3}-\frac{11m}{180}$$
And instead of computing the minimum, we determine in which case we are by simply doing a bitwise AND with \2ドル\$ -- and this is why we chose an interval bounded by a power of \2ドル\$ in the first place.
#JavaScript (ES6), (削除) 41 40 (削除ここまで) 39 bytes
Takes inputs as (h)(m).
h=>m=>((x=4+h/3-m*.55/9)&2?12-x:x)%4*90
###How?
Instead of working directly in the range \$[0..360]\$, we define a temporary variable \$x\$ in the range \$[0..4]\$:
$$x=\left|\frac{4h}{12}+\frac{4m}{60\times12}-\frac{4m}{60}\right|\bmod 4$$ $$x=\left|\frac{4h}{12}-\frac{44m}{60\times12}\right|\bmod 4$$ $$x=\left|\frac{h}{3}-\frac{11m}{180}\right|\bmod 4$$
The angle in degrees is given by:
$$\min(4-x,x)\times90$$
However, this is not how the formula is implemented a bit differently in the JS code, as we definitely want to avoid using the lengthy Math.abs() and Math.min().
Instead of computing the absolute value, we force a positive value in \$[0..12]\$ by computing:
$$x'=4+\frac{h}{3}-\frac{11m}{180}$$
And instead of computing the minimum, we determine in which case we are by simply doing a bitwise AND with\2ドル\$ -- and this is why we chose an interval bounded by a power of \2ドル\$ in the first place.
#JavaScript (ES6), (削除) 41 40 (削除ここまで) 39 bytes
Takes inputs as (h)(m).
h=>m=>((x=4+h/3-m*.55/9)&2?12-x:x)%4*90
###How?
Instead of working directly in the range \$[0..360]\$, we define a temporary variable \$x\$ in the range \$[0..4]\$:
$$x=\left|\frac{4h}{12}+\frac{4m}{60\times12}-\frac{4m}{60}\right|\bmod 4$$ $$x=\left|\frac{4h}{12}-\frac{44m}{60\times12}\right|\bmod 4$$ $$x=\left|\frac{h}{3}-\frac{11m}{180}\right|\bmod 4$$
The angle in degrees is given by:
$$\min(4-x,x)\times90$$
However, this is not how the formula is implemented in the JS code.
Instead of computing the absolute value, we force a positive value in \$[0..12]\$ by computing:
$$x'=4+\frac{h}{3}-\frac{11m}{180}$$
And instead of computing the minimum, we determine in which case we are by simply doing a bitwise AND with \2ドル\$.
#JavaScript (ES6), (削除) 41 40 (削除ここまで) 39 bytes
Takes inputs as (h)(m).
h=>m=>((x=4+h/3-m*.55/9)&2?12-x:x)%4*90
###How?
Instead of working directly in the range \$[0..360]\$, we define a temporary variable \$x\$ in the range \$[0..4]\$:
$$x=\left|\frac{4h}{12}+\frac{4m}{60\times12}-\frac{4m}{60}\right|\bmod 4$$ $$x=\left|\frac{4h}{12}-\frac{44m}{60\times12}\right|\bmod 4$$ $$x=\left|\frac{h}{3}-\frac{11m}{180}\right|\bmod 4$$
The angle in degrees is given by:
$$\min(4-x,x)\times90$$
However, the formula is implemented a bit differently in the JS code, as we definitely want to avoid using the lengthy Math.abs() and Math.min().
Instead of computing the absolute value, we force a positive value in \$[0..12]\$ by computing:
$$x'=4+\frac{h}{3}-\frac{11m}{180}$$
And instead of computing the minimum, we determine in which case we are by simply doing a bitwise AND with\2ドル\$ -- and this is why we chose an interval bounded by a power of \2ドル\$ in the first place.
#JavaScript (ES6), (削除) 41 40 (削除ここまで) 39 bytes
Takes inputs as (h)(m).
h=>m=>((x=4+h/3-m*.55/9)&2?12-x:x)%4*90
###How?
Instead of working directly in the range \$[0..360]\$, we define a temporary variable \$x\$ in the range \$[0..4]\$:
$$x=\left|\frac{4h}{12}+\frac{4m}{60\times12}-\frac{4m}{60}\right|\bmod 4$$$$x=\left|\frac{4h}{12}-\frac{44m}{60\times12}\right|\bmod 4$$$$x=\left|\frac{h}{3}-\frac{11m}{180}\right|\bmod 4$$
The angle in degrees is given by:
$$\min(4-x,x)\times90$$
However, this is not how the formula is implemented in the JS code.
Instead of computing the absolute value, we force a positive value in \$[0..12]\$ by computing:
$$x'=4+\frac{h}{3}-\frac{11m}{180}$$
And instead of computing the minimum, we determine in which case we are by simply doing a bitwise AND with \2ドル\$.
#JavaScript (ES6), (削除) 41 40 (削除ここまで) 39 bytes
Takes inputs as (h)(m).
h=>m=>((x=4+h/3-m*.55/9)&2?12-x:x)%4*90
#JavaScript (ES6), (削除) 41 40 (削除ここまで) 39 bytes
Takes inputs as (h)(m).
h=>m=>((x=4+h/3-m*.55/9)&2?12-x:x)%4*90
###How?
Instead of working directly in the range \$[0..360]\$, we define a temporary variable \$x\$ in the range \$[0..4]\$:
$$x=\left|\frac{4h}{12}+\frac{4m}{60\times12}-\frac{4m}{60}\right|\bmod 4$$$$x=\left|\frac{4h}{12}-\frac{44m}{60\times12}\right|\bmod 4$$$$x=\left|\frac{h}{3}-\frac{11m}{180}\right|\bmod 4$$
The angle in degrees is given by:
$$\min(4-x,x)\times90$$
However, this is not how the formula is implemented in the JS code.
Instead of computing the absolute value, we force a positive value in \$[0..12]\$ by computing:
$$x'=4+\frac{h}{3}-\frac{11m}{180}$$
And instead of computing the minimum, we determine in which case we are by simply doing a bitwise AND with \2ドル\$.