diff --git a/march-2026/3-19-march-madness/march_madness.js b/march-2026/3-19-march-madness/march_madness.js new file mode 100644 index 0000000..2e1ae14 --- /dev/null +++ b/march-2026/3-19-march-madness/march_madness.js @@ -0,0 +1,22 @@ +// March Madness 🏀 +// shercodes + +function upsetProbability(matchups) { + // Defines the array for upset. + let upset = []; + + for (let i = 0; i < matchups.length; i++) { + let match = matchups[i]; + + // Determines the higher seed (seedA) and lower seed (seedB). + const seedA = match[1]; + const seedB = match[3]; + + // Calculates the upset probability for each matchup. + const prob = seedA / (seedA + seedB); + const result = Number(prob.toFixed(2)); + upset.push(result); + } + + return upset; +}; \ No newline at end of file diff --git a/march-2026/3-20-cherry-blossoms/cherry_blossoms.js b/march-2026/3-20-cherry-blossoms/cherry_blossoms.js new file mode 100644 index 0000000..6d037aa --- /dev/null +++ b/march-2026/3-20-cherry-blossoms/cherry_blossoms.js @@ -0,0 +1,27 @@ +// Cherry Blossoms 🌸 +// shercodes + +function cherryBlossoms(temps) { + // Defines the variable for bloomDay. + let bloomDay = -1; // -1 when there's no bloom day. + + for (let i = 4; i < temps.length; i++) { + + // Adds the current number plus the 4 before it. + let sum = 0; + for (let j = i - 4; j <= i; j++) { + sum += temps[j]; + } + + // Calculates the 5-day average. + let avg = sum / 5; + + // Compares if the average is greater or equal to 15. + if (avg >= 15) { + bloomDay = i + 1; // i + 1 when there's a bloom day. + return bloomDay; + } + } + + return bloomDay; +}; \ No newline at end of file