

▲ 37 r/YourAISlopBoresMe
Preordering the best meme of 2027 before it ends up being AI Slop
The interaction and the full thing on the second slide
u/Minimum_Trick_8415 — 1 day ago


The interaction and the full thing on the second slide
Doing the 4th July puzzle today, My current code simply compares 2 values in each array in the array 'roads' and records the smallest amount. Or at least it's supposed to. Below is my code, and the Testcase for the Puzzle which ended up not working for it. Any reasons why this particular testcase doesn't apply?
Code:
var minScore = function(n, roads) {
var Path = 0;
var Pathlog = roads[1][2];
for (i = 0 ;i < roads.length;i++){
Path = roads[i][2];
if (Path < Pathlog) {
Pathlog = Path;
return Pathlog;
}
}
};
Testcase:
n =
20
roads =
[[18,20,9207],[14,12,1024],[11,9,3056],[8,19,416],[3,18,5898],[17,3,6779],[13,15,3539],[15,11,1451],[19,2,3805],[9,8,2238],[1,16,618],[16,14,55],[17,7,6903],[12,13,1559],[2,17,3693]]
Output
416
Expected
55