Saturday, June 26, 2021

Car Makes and Girl Names (Solution)

Welcome back, Puzzlers. I'm back to share my solution to the latest Sunday Puzzle from NPR. Scroll to the bottom to see it. Here's the puzzle again:

This week's challenge comes from listener Iva Allen in Canada. Name a make of car. Write it in all capital letters. Rotate one of the letters 90 degrees and another letter 180 degrees to make a woman's name. What is it?

In the preview post, I shared this breakdown:


    What do we need in order to solve this?

    • C: A list of car "makes"; let's assume this means "brands" or "manufacturers";
    • G: A list of girl names;
    • R90: A dictionary mapping of capital letters that can be rotated 90 degrees to form a new letter;
      • {'C': 'U', ...}
    • R180: A dictionary mapping of capital letters that can be rotated 180 degrees to form a new letter;
      • {'M': 'W', ...}
    Now, we iterate through each car maker. Then we'll need to iterate through the letters and determine which ones are in R90 and R180---we make a list of all indices in the string where the letter at that index can be rotated 90 degrees, and another list of indices for 180 degrees. Then we use something like "itertools.product()" to generate all pairs of one 90-degree position and one 180-degree position (where the two positions are not the same---we want to rotate two different letters (indices) in the string). Then we take this "agenda" of pair rotations and apply the rotation mappings to the original string, so we have all possible strings generated from the car maker string. For example:

    ACURA --> ['VUURA', 'AUARA', 'VCCRA']

    Then, we simply iterate through each of these variants and compare it against G, the list of girls' names and print out the car maker and the girl name when find a match.


      And that's how I solved it! If you'd like to see my approach in detail, I've shared my solver script here, and you'll also need my list of car makes and my list of girls' names.

      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .

      MAZDA --> WANDA

      Did you get this solution too?

      See you next week!
      --Levi King

        No comments:

        Post a Comment

        Director, anagram, film award

        Welcome back to Natural Language Puzzling, the blog where we use natural language processing and linguistics to solve the Sunday Puzzle from...