diff --git a/exercises/practice/resistor-color-trio/.meta/example.gd b/exercises/practice/resistor-color-trio/.meta/example.gd index 94c570c..bcc81b5 100644 --- a/exercises/practice/resistor-color-trio/.meta/example.gd +++ b/exercises/practice/resistor-color-trio/.meta/example.gd @@ -1,18 +1,18 @@ func color_code(colors): - var colors_code = ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"] + var colors_code = ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"] - var units = { + var units = { 1e9: "gigaohms", 1e6: "megaohms", 1e3: "kiloohms" } - var base_value = colors_code.find(colors[0]) * 10 + colors_code.find(colors[1]) - var magnitude = 10 ** colors_code.find(colors[2]) - var total = base_value * magnitude + var base_value = colors_code.find(colors[0]) * 10 + colors_code.find(colors[1]) + var magnitude = 10 ** colors_code.find(colors[2]) + var total = base_value * magnitude - for key in units.keys(): - if total >= key: - return str(total / key) + " " + units[key] + for key in units.keys(): + if total >= key: + return str(total / key) + " " + units[key] - return str(total) + " ohms" \ No newline at end of file + return str(total) + " ohms" \ No newline at end of file diff --git a/exercises/practice/resistor-color-trio/resistor_color_trio.gd b/exercises/practice/resistor-color-trio/resistor_color_trio.gd index 2c5d051..0956b0e 100644 --- a/exercises/practice/resistor-color-trio/resistor_color_trio.gd +++ b/exercises/practice/resistor-color-trio/resistor_color_trio.gd @@ -1,2 +1,2 @@ func color_code(colors): - pass \ No newline at end of file + pass \ No newline at end of file diff --git a/exercises/practice/resistor-color-trio/resistor_color_trio_test.gd b/exercises/practice/resistor-color-trio/resistor_color_trio_test.gd index 19766a9..b4e479e 100644 --- a/exercises/practice/resistor-color-trio/resistor_color_trio_test.gd +++ b/exercises/practice/resistor-color-trio/resistor_color_trio_test.gd @@ -1,58 +1,59 @@ func test_orange_and_orange_and_black(solution_script): - var colors = ["orange", "orange", "black"] - var expected = "33 ohms" - return [expected, solution_script.color_code(colors)] + var colors = ["orange", "orange", "black"] + var expected = "33 ohms" + return [expected, solution_script.color_code(colors)] func test_blue_and_grey_and_brown(solution_script): - var colors = ["blue", "grey", "brown"] - var expected = "680 ohms" - return [expected, solution_script.color_code(colors)] + var colors = ["blue", "grey", "brown"] + var expected = "680 ohms" + return [expected, solution_script.color_code(colors)] func test_red_and_black_and_red(solution_script): - var colors = ["red", "black", "red"] - var expected = "2 kiloohms" - return [expected, solution_script.color_code(colors)] + var colors = ["red", "black", "red"] + var expected = "2 kiloohms" + return [expected, solution_script.color_code(colors)] func test_green_and_brown_and_orange(solution_script): - var colors = ["green", "brown", "orange"] - var expected = "51 kiloohms" - return [expected, solution_script.color_code(colors)] + var colors = ["green", "brown", "orange"] + var expected = "51 kiloohms" + return [expected, solution_script.color_code(colors)] func test_yellow_and_violet_and_yellow(solution_script): - var colors = ["yellow", "violet", "yellow"] - var expected = "470 kiloohms" - return [expected, solution_script.color_code(colors)] + var colors = ["yellow", "violet", "yellow"] + var expected = "470 kiloohms" + return [expected, solution_script.color_code(colors)] func test_blue_and_violet_and_blue(solution_script): - var colors = ["blue", "violet", "blue"] - var expected = "67 megaohms" - return [expected, solution_script.color_code(colors)] + var colors = ["blue", "violet", "blue"] + var expected = "67 megaohms" + return [expected, solution_script.color_code(colors)] func test_minimum_possible_value(solution_script): - var colors = ["black", "black", "black"] - var expected = "0 ohms" - return [expected, solution_script.color_code(colors)] + var colors = ["black", "black", "black"] + var expected = "0 ohms" + return [expected, solution_script.color_code(colors)] func test_maximum_possible_value(solution_script): - var colors = ["white", "white", "white"] - var expected = "99 gigaohms" - return [expected, solution_script.color_code(colors)] + var colors = ["white", "white", "white"] + var expected = "99 gigaohms" + return [expected, solution_script.color_code(colors)] func test_first_two_colors_make_an_invalid_octal_number(solution_script): - var colors = ["black", "grey", "black"] - var expected = "8 ohms" - return [expected, solution_script.color_code(colors)] + var colors = ["black", "grey", "black"] + var expected = "8 ohms" + return [expected, solution_script.color_code(colors)] func test_ignore_extra_colors(solution_script): - var colors = ["blue", "green", "yellow", "orange"] - var expected = "650 kiloohms" - return [expected, solution_script.color_code(colors)] \ No newline at end of file + var colors = ["blue", "green", "yellow", "orange"] + var expected = "650 kiloohms" + return [expected, solution_script.color_code(colors)] +