From a72672190a072e8d2c6ad3a5422c022dc8f53789 Mon Sep 17 00:00:00 2001 From: Kevin Bloch Date: Wed, 16 Apr 2025 14:53:11 +0200 Subject: [PATCH] Update `resistor-color-expert` example to pass on Godot Engine v4.4.1.stable.official.49a5bc7b6 (cf. https://github.com/exercism/gdscript/issues/38) --- exercises/practice/resistor-color-expert/.meta/example.gd | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/exercises/practice/resistor-color-expert/.meta/example.gd b/exercises/practice/resistor-color-expert/.meta/example.gd index 2cb90c8..c588911 100644 --- a/exercises/practice/resistor-color-expert/.meta/example.gd +++ b/exercises/practice/resistor-color-expert/.meta/example.gd @@ -30,5 +30,8 @@ func color_code(colors): var tolerance = tolerances[colors[-1]] #work for key in units.keys(): if total >= key: - return "%s %s ±%s%%" % [(total / key), units[key], tolerance] - return "%s ohms ±%s%%" % [total, tolerance] + return "%s %s ±%s%%" % [format_number(total / key), units[key], tolerance] + return "%s ohms ±%s%%" % [format_number(total), tolerance] + +func format_number(n): + return str(int(n)) if n == int(n) else str(n) \ No newline at end of file