#2024 Day 16 Discussion Thread

20 messages · Page 1 of 1 (latest)

uncut hemlock
#

Talk day 16 in here when it goes live! 1️⃣ 6️⃣ ☃️

spring island
#

I hated this one because of what is used.

sacred bone
#

I had it so quickly, but kept getting the function was returning N/A. Just re-ran it a few times and it went through.

obtuse flume
#

I can't seem to make this one work. Output keeps being N/A but console.logs show 5. Anyone found a solution?

spring island
obtuse flume
#

I've also tried like that. It would look like this, no?

|| function countSnowReports(paths) {
const regex = //snow_report.txt$/;
const matches = paths.filter(file => regex.test(file));
console.log(matches.length)
return matches.length;
} ||

obtuse flume
#

I don't know what's wrong anymore haha

||function countSnowReports(paths) {
const regex = //snow_report.txt$/;
const matches = paths.filter(file => regex.test(file));
return matches.length;
}||

spring island
obtuse flume
#

I surrender 😦

spring island
# obtuse flume I surrender 😦

||It's a two step fix, first we need to escape the dot \. and make sure we test that is ends with this string $.

/\/snow_report\.txt$/
```||
obtuse flume
#

Thank you!

🤔 I think I had that before. I'm trying it and it doesn't work:

||function countSnowReports(paths) {
// Regex to match only "snow_report.txt" at the end of any path
const regex = //snow_report.txt$/;

// Count how many files match the regex
const matches = paths.filter(file => regex.test(file));
return matches.length;

}||

Am I missing something?

spring island
obtuse flume
#

Sorry, that's when copy pasting

this is the code:

obtuse flume
#

Found the problem!!! Thank you so much, @spring island
I was returning matches.length instead of matches

sacred loom
#

done! (before looking at this channel)

#

am I allowed to blame the yeti for thinking ||regexes are better than .endsWith()||?

spring island
spring island