16 lines
290 B
Dart
Raw Permalink Normal View History

2024-10-14 11:37:17 +02:00
import 'dart:math' as math;
class Darts {
int score(double x, double y) {
double distance = math.sqrt(x * x + y * y);
if (distance <= 1) {
return 10;
} else if (distance <= 5) {
return 5;
} else if (distance <= 10) {
return 1;
}
return 0;
}
}