source-academy / modules

Modules that can be imported by programs in Source Academy, an online experiential environment for computational thinking
Apache License 2.0
8 stars 28 forks source link

Refactor scrabble module #276

Closed RichDom2185 closed 6 months ago

RichDom2185 commented 6 months ago

Description

Generates scrabble letters using .map on words to:

Also generates the tiny dataset using .filter every 100 words.

The correctness is guaranteed by the introduction of additional tests, ensuring they stay the (snapshot-checking).

Type of change

Please delete options that are not relevant.

RichDom2185 commented 6 months ago

@martin-henz can I check what exactly qualifies for scrabble_words_tiny? Or is it handpicked? Perhaps we can generate it in a similar way, using array functions on scrabble_words.

martin-henz commented 6 months ago

@martin-henz can I check what exactly qualifies for scrabble_words_tiny? Or is it handpicked? Perhaps we can generate it in a similar way, using array functions on scrabble_words.

I remember playing with the scrabble module in preparation for the PA last semester. There was a concern that the full dataset would be too large for some student's computers, so I came up with scrabble_words_tiny. I think I sampled the full set at intervals of 100:

display(array_length(scrabble_words));          // 172820
display(array_length(scrabble_words_tiny));     // 1729

[We ended up not using the scrabble module for the PA.]

RichDom2185 commented 6 months ago

@martin-henz can I check what exactly qualifies for scrabble_words_tiny? Or is it handpicked? Perhaps we can generate it in a similar way, using array functions on scrabble_words.

I remember playing with the scrabble module in preparation for the PA last semester. There was a concern that the full dataset would be too large for some student's computers, so I came up with scrabble_words_tiny. I think I sampled the full set at intervals of 100:

display(array_length(scrabble_words));          // 172820
display(array_length(scrabble_words_tiny));     // 1729

[We ended up not using the scrabble module for the PA.]

Ok, I've used .filter((_, i) => i % 100 === 0) to generate scrabble_words_tiny and it seems to be an exact match with the snapshot.

This PR is ready now, thank you!