Skip to content

Commit

Permalink
fix broken tests (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaferranti authored Feb 20, 2024
1 parent ce4a100 commit 41ea631
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion exercises/practice/allergies/.meta/reference.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/dominoes/.meta/reference.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
9 changes: 5 additions & 4 deletions exercises/practice/high-scores/.meta/reference.chpl
Original file line number Diff line number Diff line change
@@ -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];
}
}
2 changes: 1 addition & 1 deletion exercises/practice/resistor-color/.meta/reference.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module ResistorColor {
}

proc colorCode(color : string) {
var (_, val) = colors().find(color);
var val = colors().find(color);
return val;
}
}
18 changes: 10 additions & 8 deletions exercises/practice/yacht/.meta/reference.chpl
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit 41ea631

Please sign in to comment.