Finding the Longest Consonant Cluster


/ Published in: Groovy
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def words = [
  2. berndschiffer: 'Angstschweiss', // ß -> ss
  3. mittie: 'Herbstschnee',
  4. mittie: 'rontgst', // ö -> o
  5. mittie: 'Durststrecke',
  6. mittie: 'Kunstspringen',
  7. mittie: 'Borschtschschmand',
  8. ipreuss: 'Borschtschschussel', // ü -> u
  9. ]
  10. println words.collect{ user, word ->
  11. def cluster = word.toLowerCase().split(/[aeiou]/).sort{ it.size() }.toList().last()
  12. [cluster] << "@$user found the longest consonant cluster '$cluster' in the word '$word'."
  13. }.sort{ it.first().size() }.last().last()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.