From 41ea631bad89efd18ef45f33ab98a37f1c7444e7 Mon Sep 17 00:00:00 2001 From: Luca Ferranti <49938764+lucaferranti@users.noreply.github.com> Date: Tue, 20 Feb 2024 11:09:39 +0200 Subject: [PATCH] fix broken tests (#78) --- .../practice/allergies/.meta/reference.chpl | 2 +- .../practice/dominoes/.meta/reference.chpl | 4 ++-- .../practice/high-scores/.meta/reference.chpl | 9 +++++---- .../resistor-color/.meta/reference.chpl | 2 +- exercises/practice/yacht/.meta/reference.chpl | 18 ++++++++++-------- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/exercises/practice/allergies/.meta/reference.chpl b/exercises/practice/allergies/.meta/reference.chpl index 129eca4..0739ece 100644 --- a/exercises/practice/allergies/.meta/reference.chpl +++ b/exercises/practice/allergies/.meta/reference.chpl @@ -2,7 +2,7 @@ module Allergies { const allergens = ["eggs", "peanuts", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats"]; proc isAllergicTo(score: int, allergen: string) { - var (_, idx) = allergens.find(allergen); + var idx = allergens.find(allergen); return (1 << idx) & score != 0; } diff --git a/exercises/practice/dominoes/.meta/reference.chpl b/exercises/practice/dominoes/.meta/reference.chpl index 7eb89b8..28b2d8d 100644 --- a/exercises/practice/dominoes/.meta/reference.chpl +++ b/exercises/practice/dominoes/.meta/reference.chpl @@ -5,8 +5,8 @@ module Dominoes { var graph: [1..6] list(int), node = edges[0][0]; for edge in edges { - graph[edge[0]].append(edge[1]); - graph[edge[1]].append(edge[0]); + graph[edge[0]].pushBack(edge[1]); + graph[edge[1]].pushBack(edge[0]); } return (graph, node); } diff --git a/exercises/practice/high-scores/.meta/reference.chpl b/exercises/practice/high-scores/.meta/reference.chpl index 99f6c76..b0b0078 100644 --- a/exercises/practice/high-scores/.meta/reference.chpl +++ b/exercises/practice/high-scores/.meta/reference.chpl @@ -1,16 +1,17 @@ module HighScores { + use Sort; proc latest(scores: [] int) { return scores.last; } proc personalBest(scores: [] int) { - var s = scores.sorted(); - return s.last; + sort(scores); + return scores.last; } proc personalTopThree(scores: [] int) { - var s = scores.sorted(); - return [i in 1..min(3, s.size)] s[s.size-i]; + sort(scores); + return [i in 1..min(3, scores.size)] scores[scores.size-i]; } } diff --git a/exercises/practice/resistor-color/.meta/reference.chpl b/exercises/practice/resistor-color/.meta/reference.chpl index b451184..df8f641 100644 --- a/exercises/practice/resistor-color/.meta/reference.chpl +++ b/exercises/practice/resistor-color/.meta/reference.chpl @@ -4,7 +4,7 @@ module ResistorColor { } proc colorCode(color : string) { - var (_, val) = colors().find(color); + var val = colors().find(color); return val; } } diff --git a/exercises/practice/yacht/.meta/reference.chpl b/exercises/practice/yacht/.meta/reference.chpl index 0b85629..32b34e0 100644 --- a/exercises/practice/yacht/.meta/reference.chpl +++ b/exercises/practice/yacht/.meta/reference.chpl @@ -1,15 +1,17 @@ module Yacht { + use Sort; + const name2nums = ["ones" => 1, "twos" => 2, "threes" => 3, "fours" => 4, "fives" => 5, "sixes" => 6]; proc score(nums: [] int, cat: string) { - var sorted = nums.sorted(); - if name2nums.domain.contains(cat) then return getNumber(sorted, name2nums[cat]); - else if cat == "full house" then return getFullHouse(sorted); - else if cat == "four of a kind" then return getFourKind(sorted); - else if cat == "little straight" then return getLittleStraight(sorted); - else if cat == "big straight" then return getBigStraight(sorted); - else if cat == "choice" then return getChoice(sorted); - else return getYacht(sorted); + sort(nums); + if name2nums.domain.contains(cat) then return getNumber(nums, name2nums[cat]); + else if cat == "full house" then return getFullHouse(nums); + else if cat == "four of a kind" then return getFourKind(nums); + else if cat == "little straight" then return getLittleStraight(nums); + else if cat == "big straight" then return getBigStraight(nums); + else if cat == "choice" then return getChoice(nums); + else return getYacht(nums); } proc getNumber(vals: [] int, num: int) {