[48in24 Exercise] [05-28] Pig Latin

This issue is a discussion for contributors to collaborate in getting ready to be featured in 48in24. Please refer to this forum topic for more info.

We will be featuring Pig Latin from May 28 onwards.

Staff jobs

These are things for Erik/Jeremy to do:

  • ☐ Check/update exercise in Problem Specifications
  • ☐ Create + schedule video

Community jobs

For each track:

  • Implement Pig Latin
  • Add approaches (and an approaches introduction!) for each idiomatic or interesting/educational approach.
  • Add video walkthroughs (record yourself solving and digging deeper into the exercise).
  • Highlight up to 16 different featured exercises (coming soon)

Existing Approaches

You can use these as the basis for approaches on your own tracks. Feel free to copy/paste/reuse/rewrite/etc as you see fit! Maybe ask ChatGPT to translate to your programming language.

  • charat-substring (java)
  • hashset-lookup (kotlin)
  • map-lookups (go)
  • map-lookups-with-generics (go)
  • map-recursion-mkstring (scala)
  • regular-expressions (csharp)
  • sets-and-slices (python)
  • strchr-strstr-strtok (c)

Track Statuses

You can see an overview of which tracks have implemented the exercise at the #48in24 implementation status page.

I’ve currently gathered the following solutions to feature:

  1. Go: for loops and maps
    Use for loops and maps

  2. Kotlin: rotate using special cases
    Add special cases to vowels and consonants and drop and take

  3. Scala: rotate using pattern matching
    Use pattern matching to find out how many chars to rotate

  4. Prolog: define relations and use unification
    Define the relations and use unification

  5. AWK: regex matches
    Use regular expressions to match the words

  6. JS: regex matches using pig latinified functions
    Use regular expressions to match the words and define pig latinified versions of base functions

  7. C#: conditional regex replace
    Use regular expressions to match and replace the words

  8. Python: single regex replace
    Use a single regex replace

If anyone has more suggestions, do let us know!

I never actually did this exercise so I’ll port to Euphoria. If it goes well, I’ll work on Coffeescript and Emacs Lisp. Most tracks already have Space Age the following week so I’ll probably backfill more tracks that need this exercise.

1 Like
1 Like

Added for jq. I have to say, jq is so pretty (even if regular expressions are very ugly)


I was implementing this in jq, and I thought of a new test case: words with no vowels. There are some in

grep -i -v '[aeiouy]' /etc/dictionaries-common/words

test case: given “xkcd” expect “xkcday”

Worth adding to problem-specs?

Is xkcd a word? I thought it’s an arbitrary collection of letters used as a website name.

“The translation is defined using four rules, which look at the pattern of vowels and consonants at the beginning of a word“

Is a complete lack of vowels a valid pattern? Rule three indicates a valid pattern is the lack of consonants at the beginning but consonants can still occur at the end.

As an aside, I noticed a typo in the instructions for rule 2. “ If a word begins with a one or more consonants” should be “If a word begins with one or more consonants”.

1 Like

Are there other words @glennj that make sense?

How would you say “why” in Pig Latin?

Edit: Nevermind. That’s explicitly covered by rule 4.

Let’s see.

there are acronyms like RSVP that are commonly used.

“nth” seems to be a real word. It is even pronounced like it starts with a vowel, so “nthay” would be the appropriate pigification.

Contraindicating that would be something like “pwned” which I assume would be pigified like “wnedpay”, but a rule for that would be very hard to compose.

I’m not really strongly advocating for this new test case, but the discussion is worthwhile.

“Hmm” is a valid english word that doesn’t sound like anything vowely, so it’s maybe a good one to potentially add.

Fix typo in pig-latin instructions by BNAndras · Pull Request #2452 · exercism/problem-specifications · GitHub for the typo I mentioned.

Someone noticed that the Elixir track had some extra (no-canonical) tests with some that actually break the official rules.
I opened a PR to remove those tests, but that means that all current Elixir solutions pass all the tests but still break the general rules. If we ever want to add some tests, those might be good ones to look at.