Deduping the Deck
removing duplicate cards
Part of: Flashcard Maker
Chunk your notes into ten pieces and the same fact often turns up in three of them, so your deck ends up with three near-identical cards for "What is the powerhouse of the cell?". Studying the same card three times wastes your time, and a deck full of repeats feels sloppy. This lesson strips the repeats before export. Why exact matching isn't enough You can't just check if two question strings are identical. The model phrases the same fact slightly differently each time: - "What is the powerhouse of the cell?" - "What is the powerhouse of the cell" (no question mark) - "what is the POWERHOUSE of the cell?" (different casing) These are the same card to a human but three different strings to ==. The fix is to compare a normalized form of each question, not the raw text. Normalize, then dedup Normalizing means squashing away the differences that don't matter, so equivalent questions collapse to one key: The pattern is the classic seen-set dedup : walk the deck once, compute each card's normalized key, and keep a card only the first time its key appears. Using a set makes the "have I seen this?" check instant even for a big deck. Keeping the first occurrence preserves the order the car
Challenge: Count Unique Cards