Tuesday, August 24, 2021

US city, cardinal number, ordinal number (Preview)

After giving us the last week off, Will Shortz is back with this week with a new Sunday Puzzle from NPR:

This week's challenge comes from listener Ben Austin, of Dobbs Ferry, N.Y. Take the name of a major American city. Move one of its letters three spaces later in the alphabet. Embedded in the resulting string of letters, reading left to right, is a cardinal number. Remove that number, and the remaining letters, reading left to right, spell an ordinal number. What city is it, and what are the numbers?

What do we need to solve this puzzle?
  • M: a list of major American cities;
    • Does "American" mean "USA" here? Maybe this list needs major cities from throughout North and South America;
  • C: a list of cardinal numbers spelled out in letters; probably 0-100 should be enough;
  • O: a list of ordinal numbers spelled out in letters; probably 1-100 should be enough;
  • shift_letter_3: a function that shifts a letter 3 places later in the alphabet;
First, for M, C, and O, we'll want to clean up the text:
  1. lowercase
  2. remove spaces
  3. remove non-letters
  4. convert accented characters to simple ASCII
Next, the processing is pretty simple:

  • for city in M:
    • for letter in city:
      • shifted_city = shift_letter_3(city)
      • for cardinal in C:
        • if cardinal in shifted_city:
          • short_city = shifted_city.replace(cardinal, "")
          • for ordinal in O:
            • if ordinal in short_city:
              • print("Solution: ", city, cardinal, ordinal)
That should do it. Good luck, and I'll be back after the Thursday NPR submission deadline to present my solution.

--Levi

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...