5
\$\begingroup\$

Why don't you grow up?

In the past week a meme involving the young actor Aaron Bailey became trending in most Brazilian social networks. Entitled "why don't you grow up" it consists in repeating a sentence replacing its vowels with is (it's a bit more complicated than that, I'll explain below). As I want to be a cool guy I decided to write a program that mimimifies a given string.

Challenge

The challenge consists of mimimifying a string, following the rules:

  • ão and õe should be replaced with im.
  • ca, ka, que, ke, qui, ki, co ,ko, cu, and ku should be replaced with ki.
  • ça, ce, çe, ci, çi, ço, and çu should be replaced with ci.
  • ga, gue, gui, go, and gu should be replaced with gui.
  • ja, ge, je, gi, ji, jo, and ju should be replaced with ji
  • You can assume that qua, quo, quu, gua, guo, and guu, will never appear, only a and o can have tildes and if they do they'll be followed by o and e, repsectively (ão, õe).
  • The only time us are allowed in output strings is gui, besides that case all other vowels present should be is.
  • In all other circumstances all vowels must be replaced with is.
  • Other than tilde all other accents may be ignored.
  • Two or more is in a row are not allowed, you should replace them with only one (Piauiense -> Pinsi)

Examples

Input

Por que você só fala assim?

Output

pir ki vici si fili issim?

Input

Que horas são?

Output

ki hiris sim?

Input

Óculos sem lente pode ser armação

Output

ikilis sim linti pidi sir irmicim

Input

Ganha o código com menos bytes

Output

guinhi i kidigui kim minis bytis

Rules

  • The vowels are a, e, i, o, and u.
  • You can see the full list of possible accents here.
  • : the shortest code in bytes wins. Check meta if counting bytes is awkward in your language.
  • Standard loopholes are forbidden
  • Your output must be consistent in case: all upper/all lower.
  • You may assume the input to be in whichever encoding you want but if you do you must specify it.

Happy golfing!/Hippy guilfing!

\$\endgroup\$
  • 3
    \$\begingroup\$ (This phenomenon sounds similar to Ermahgerd in English.) \$\endgroup\$ – Greg Martin Nov 12 '16 at 19:50
  • \$\begingroup\$ What is the list of accented characters? \$\endgroup\$ – Cows quack Nov 13 '16 at 11:24
  • \$\begingroup\$ @Mego why? By ignored I meant there presence is irrelevant (ê == e, ó == o) \$\endgroup\$ – fpg1503 Nov 13 '16 at 12:03
4
\$\begingroup\$

Retina, 150 bytes

[ÀÁÂàáâ]
a
[ÉÊéê]
e
Í|í
i
[ÓÔóô]
o
[ÚÜúü]
u
T`L`l
ão|õe
im
[ck][aou]|qu[ei]|ke
ki
ç[aeiou]|ce
ci
g[aou]|gue
gui
j[aeou]|g[ei]
ji
(gu)i|[aeou]
$1i
ii
i

Try it online!

This is my first Retina program, so there's probably a lot of improvements to make. Suggestions are welcome.

Thanks to Martin for correcting some mistakes and for some golfing suggestions.

Explanation

I'm going to break up the explanation into 3 sections, to make it easier on me.

Section 1: Preprocessing

[ÀÁÂàáâ]
a
[ÉÊéê]
e
Í|í
i
[ÓÔóô]
o
[ÚÜúü]
u
T`L`l

The first 5 rules replace any accented vowel with the corresponding unaccented version. It's shorter to list out the matches in character classes (or, in the third case, as two options) than to use the culture-invariance and case-insentivity options each time. The last rule converts all ASCII letters to lowercase.

Section 2: Mimimification

ão|õe
im
[ck][aou]|qu[ei]|ke
ki
ç[aeiou]|ce
ci
g[aou]|gue
gui
j[aeou]|g[ei]
ji

These rules simply apply the substitutions specified.

Section 3: Cleanup

(gu)i|[aeou]
$1i
i+
i

The first rule matches any vowel except for the u in gui, and replaces them with is. The second rule removes repeated is.

\$\endgroup\$
  • \$\begingroup\$ What better language is there than one that is based on regex :) \$\endgroup\$ – Cows quack Nov 13 '16 at 12:29
2
\$\begingroup\$

JavaScript, 396 392 389 bytes (383 379 376 characters)

Too many replaces, too much regex, ...

f=s=>s.toLowerCase().replace(/ão|õe/g,"im").replace(/[àâá]/g,"a").replace(/é|ê/g,"e").replace(/í/g,"i").replace(/ó|ô/g,"o").replace(/ú|ü/g,"u").replace(/(k[aeou])|(c[aou])|que|qui/g,"ki").replace(/(ç[aeiou])|ce/g,"ci").replace(/(g[aou])|gue/g,"gui").replace(/(j[aeou])|ge/g,"ji").split("gui").map(function(a){return a.replace(/[aeou]/g,"i")}).join("gui").replace(/i{2,}/g,"i")

I have used this link for a list of Brazilian accented letters so that I know for which letters I have to remove the accent.

Explanation

s.toLowerCase()

First, everything is converted to lowercase.

.replace(/ão|õe/g,"im")

Then I'm am implementing this rule.

.replace(/[àâá]/g,"a").replace(/é|ê/g,"e").replace(/í/g,"i").replace(/ó|ô/g,"o").replace(/ú|ü/g,"u")

Then the accents are removed using regex.

.replace(/(k[aeou])|(c[aou])|que|qui/g,"ki").replace(/(ç[aeiou])|ce/g,"ci").replace(/(g[aou])|gue/g,"gui").replace(/(j[aeou])|ge/g,"ji").split("gui")

After that, the the string is being bombarded by regular expressions to "memify" it.

.split("gui").map(function(a){return a.replace(/[aeou]/g,"i")}).join("gui")

Now all the vowels, except those in gui (that is why I used split) are being converted to i. After that, I rejoin the Array using gui as the delimiter.

.replace(/i{2,}/g,"i")

Finally, I am replacing 2 or more is with just 1 of them.

Snack Snippet!

f=s=>s.toLowerCase().replace(/ão|õe/g,"im").replace(/[àâá]/g,"a").replace(/é|ê/g,"e").replace(/í/g,"i").replace(/ó|ô/g,"o").replace(/ú|ü/g,"u").replace(/(k[aeou])|(c[aou])|que|qui/g,"ki").replace(/(ç[aeiou])|ce/g,"ci").replace(/(g[aou])|gue/g,"gui").replace(/(j[aeou])|ge/g,"ji").split("gui").map(function(a){return a.replace(/[aeou]/g,"i")}).join("gui").replace(/i{2,}/g,"i")

console.log(f("Por que você só fala assim?"))
console.log(f("Que horas são?"))                                                                                                                                                                                                                                                           //They call me the professional Brazilian-meme-maker
console.log(f("Óculos sem lente pode ser armação"))                                                                                                                                                                             //dank memes, dank memes everywhere
console.log(f("Ganha o código com menos bytes"))

Golfing suggestions are welcome

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.