Using the std map for the difficulty tuning is misleading (and error prone)

The suggested implementation uses std::map to create some pairs: given a word length, gets the number of max tries. Great, it’s defined for 3,4,5,6,7 character-long word. And less? and more? there is no code to manage this. What happens? Try. With the code specified in the lesson, you get 0 as return. Things are a little more complex than this, under the hood, but bottomline is: this code doesn’t think to generic cases.
My suggestion is either to manage the out-of-bounds cases before the map access, or to find a generic formula to express the relationship between characters and tries. Also, map used the way it is is quite overkill, it would make more sense reading from a configuration file the info as data, by the way.

1 Like

Hello @Michele_Caletti,

in which context or minute at the video the “Suggestion” was mentioned? I don’t get it …
What are you talking about and why in this thread?

Cheers
Kevin

Privacy & Terms