liveBook · Manning

Clue

As explained in Learn C++ by Example

A clue is a feedback string that marks guessed digits as correctly placed, misplaced, or absent from a hidden number.

A clue is a feedback string for a five-digit guess: * marks a correctly placed digit, ^ marks a present but misplaced digit, and . marks an absent digit. section 3.3.4

Build a clue in two passes:

  • Format both numbers as five-character strings, including leading zeroes, and initialize the result with dots. section 3.3.4

Example feedback

For hidden number 78737 and guess 87739, the clue is "^^**.": the second 7 and 3 are correctly placed, the opening 7 and 8 are misplaced, and 9 is absent. section 3.3.4

How Learn C++ by Example covers it

How deep it goes
Explains formatting, exact matches, misplaced matches, and duplicate consumption through a two-pass algorithm.
Examples
Uses 12347 versus 23471, 78737 versus 87739, and 11779 to expose placement and duplicate rules.
What it assumes
Assumes basic C++ functions, loops, strings, and formatted output while teaching digit comparison from first principles.
What you can do after
Build it from scratch as a C++ feedback function and integrate it into a playable guessing loop.
How it connects
Connects string formatting, std::string, loops, functions, and number-guessing games.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn C++ by Example. The section links point to the parts of the book it draws on.