mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: findClosestNumber
Closes #120 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -798,6 +798,9 @@ class Utils {
|
||||
0 => target,
|
||||
1 => numbers.first,
|
||||
_ => numbers.reduce((a, b) {
|
||||
if (b > target) {
|
||||
return a;
|
||||
}
|
||||
int diff1 = (a - target).abs();
|
||||
int diff2 = (b - target).abs();
|
||||
return diff1 == diff2
|
||||
|
||||
Reference in New Issue
Block a user