# User Appreciation Challenge #1: Dennis ♦

I got the spontaneous idea of making a series of challenges of users that have helped and continue to help the PPCG community be an enjoyable place for everyone, or maybe just specifically for me. :P

If you convert Dennis's name to an array of 1s and 0s where each consonant is 1 and each vowel is 0, the array is [1, 0, 1, 1, 0, 1], which is symmetrical. Thus, your challenge is to determine what other names are like this.

# Challenge

Given an ASCII string, remove all characters that aren't letters and determine if the configuration of vowels and consonants are symmetrical. y is not a vowel.

Please note that your program does not have to be this type of string itself.

# Test Cases

Dennis -> truthy
Martin -> truthy
Martin Ender -> truthy
Alex -> falsy
Alex A. -> truthy
Doorknob -> falsy
Mego -> falsy


# Reference Implementation

This Python 3 code will give the correct output given a test case. It is as ungolfed as I could make it without being ridiculous.

# Python 3

s = input()
l = []
for c in s:
if c in 'AEIOUaeiou':
l.append(0)
elif c in 'BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz':
l.append(1)
print(l == list(reversed(l)), end = '')


Try it online!

• When and who is #2? Jun 10, 2017 at 15:58
• @cairdcoinheringaahing Thanks for reminding me. It's going to be about Mego (TNB RO hence the italics) but I haven't gotten around to finalizing it yet. Jun 10, 2017 at 17:08
• @cairdcoinheringaahing I'm pretty sure he knows already; I said I'd do one about him but I haven't decided if I'm going to do something relating to penguins or TNB yet. Jun 10, 2017 at 17:32
• @HyperNeutrino Umm, you can't use italics in titles. Jun 10, 2017 at 18:47
• @Hyperneutrino so multicharacter variable names are ridiculous now? ;) Jan 15, 2018 at 18:51

# Ly, 84 64 bytes

"aeiou">0i['aL[p' +0]ps'a,Gf'zLfp*[p<l~sp>rlr0]p]p&sJ>lrJs<l=u;


Try it online!

Still not that short, but getting a stack oriented language with no concept of characters to do this seemed interesting enough to submit. Plus it's a lot shorter than the initial version I posted in June...

1. Setup a vowel testing stack
    "aeiou"   - push vowels onto a stack
>  - swtich to a clean stack

1. Switch to an input processing stack, prep input
    0   - add a "0", acts as a stopper
i  - read input into the stack as codepoints

1. Check each codepoint/char on the stack, building a 0|1 list
    [                                      ]p - loop over the stack
'aL[p' +0]p                              - lowercase the char
s                             - stash the character
'a,Gf'zLfp*                 - check if in "a-z" (3.1)
[p<l~sp>rlr0]p   - do 0,1 vowel check (3.2)


3.1 Make sure the character is in a-z

'a,G          - load "a", decrement, do ">" check
f         - pull char forward (flip top two on stack)
'zL     - load "z", increment, do "<" check
fp   - pull char forward, delete it
*  - compute "and" of two tests


3.2 Compare char to vowel list, generate 0 or 1 result

    [p         0]p  - if/then, true if char in "a-z"
<             - switch to "vowel check" stack
~           - search stack, get 0,1 result
sp         - save results, delete from stack
>        - switch to processing stack
rlr     - reverse stack, load result, reverse again

1. Compare 0|1 list against it's reverse
    &s             - copy the 0,1 stack to the backup cell
J            - join the stack elements
>lrJs       - repeat on another stack, reversed
<l     - switch back, load 2nd joined stack
=u;  - print 0,1 depending on equals check


read-host|%{[char[]]$_|%{$d=$_-replace'\P{L}'-replace'[aeiou]',0-replace'\D',1;$s="$s$d";$r="$d$r"};$s-eq$r}  # Axiom, 126 bytes g(x)==~member?(x,alphabetic());v(s:String):Boolean==(w:=remove(g,s);a:=[member?(w.r,"aeiouAEIOU")for r in 1..#w];a=reverse(a))  test (8) -> [[i,v(i)] for i in ["Dennis", "Martin", "Martin Ender", "Alex", "Alex A.", "Doorknob", "Mego"]] (8) [["Dennis",true], ["Martin",true], ["Martin Ender",true], ["Alex",false], ["Alex A.",true], ["Doorknob",false], ["Mego",false]] Type: List List Any  ## Pyke, 12 bytes #B)l1~-L{D_q  Try it here! #B) - filter(is_alpha, input) l1 - ^.lower() ~-L{ - ^ - "bcdfghjklmnpqrstvwxyz" D_q - ^ == reversed(^)  # PowerShell, 87 Bytes $s=("$args"-replace '\P{L}'-replace'[aeiou]',0-replace'\D',1);$s-eq(-join($s[-1..-99]))  Get a copy of the string where vowels are 0 and consonants are 1, with all special chars removed, compare that string to a reversed version joined back to a string Output: PS C:\Users\Connor> "Dennis","Martin","Martin Ender","Alex","Alex A.","Doorknob","Mego" | % {$s=("$_"-replace '\P{L}'-replace'[aeiou]',0-replace'\D',1);$s-eq(-join($s[-1..-99])) } True True True False True False False  # Retina, 47 bytes i([^a-z] [aeiou] 1 \D 0 +^(.)(.*)\1$
$2 ^.?$


Try it online!

This is just a different approach for non alphabet chars

=ArrayFormula(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(UPPER(A1),"[^A-Z]",""),"[AEIOU]","0"),"[^0]","1")=REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(UPPER(JOIN("",(MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1)))),"[^A-Z]",""),"[AEIOU]","0"),"[^0]","1"))


Three nested REGEXREPLACE functions transform it from the original to a string of ones and zeroes. The JOIN function is used to reverse the original string so it's nested into the same REGEXREPLACE functions to transform it to the reverse string of ones and zeroes. It's a nightmare.

# Actually, 20 bytes

ù⌠úc⌡░⌠"aeiou"c⌡M;R=


Try it online! (runs all test cases)

-3 bytes from Erik the Outgolfer's suggestion on a different answer

Explanation:

ù⌠úc⌡░⌠"aeiou"c⌡M;R=
ù                     lowercase input
⌠úc⌡░                characters where function is truthy:
úc                    is the character a lowercase letter?
⌠"aeiou"c⌡M     for each letter:
"aeiou"c         does the vowel string contain the letter?
;R=  compare equality with reverse (is it a palindrome?)


# Excel VBA, 115 Bytes

Anonymous VBE immediate window function that takes input from range [A1] and outputs to the VBE immediate window.

For i=1To[Len(A1)]:a=Mid([A1],i,1):b=IIf(Instr(1,"AEIOU",a,1),1,IIf(a Like"[A-Za-z]",0,""))&b:Next:?b=StrReverse(b)


# Kotlin, 75 bytes

filter{it.isLetter()}.map{"aeiou".contains(it,true)}.let{it==it.reversed()}


## Beautified

filter { it.isLetter() }.map { "aeiou".contains(it, true) }.let { it == it.reversed() }


## Test

data class Test(val input: String, val output: Boolean)

val tests = listOf(
Test("Dennis",true),
Test("Martin",true),
Test("Martin Ender",true),
Test("Alex",false),
Test("Alex A.",true),
Test("Doorknob",false),
Test("Mego",false)
)

fun String.f() =
filter{it.isLetter()}.map{"aeiou".contains(it,true)}.let{it==it.reversed()}
fun main(args: Array<String>) {
for ((input, expected) in tests) {
val actual = input.f()
if (actual != expected) throw AssertionError()
}
}


TryItOnline

# Julia 0.6, 65 bytes

f(s,b=[c in "aeiouAEIOU" for c in s if isalpha(c)])=b==reverse(b)


Try it online!

# Pyt, 59 bytes

ɬ←ąĐ0↔ą∈⇹6²Ĩ*ž1ᴇ-5²⁺%⁺+ĐĐĐĐ1=⇹5=⇹04Ș9=06Ș+35*=0↔+37*=∨∨∨∨+₽


Try it online!

Much of this code is because Pyt is not very good at strings.

Explanation:

ɬ               Push "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
←ą              Get input string as an array of characters
Đ               Duplicate the array of characters
0↔              Push 0 and flip the stack
ą               Get the top of the stack as an array of characters
∈               Is each character in the input a letter?
⇹               Swap top two on the stack (input as array of characters)
6²Ĩ             Interpret element-wise as base-36 **
*ž              Remove all non-letters
1ᴇ-             Subtract 10 from each element
5²⁺%            Mod 26
⁺               Increment
+               Let's get rid of that 0
ĐĐĐĐ            Push 4 additional copies of the top of the stack
1=⇹             Is it equal to 1 ('a')
5=⇹04Ș          Is it equal to 5 ('e')
9=06Ș           Is it equal to 9 ('i')
+               Get rid of a 0
35*=            Is it equal to 15 ('o')
0↔              Push 0 and flip the stack
+               Get rid of a 0
37*=            Is it equal to 21 ('u')
∨∨∨∨            OR the arrays
+               Get rid of that last 0
₽               Is the top of the stack a palindrome?


# GolfScript, 34 bytes

{32|}%.123,97>--{"aeiou"?)!}%.-1%=


Try it online!

# Explanation

{32|}%                             # Convert to lowercase (Works at least with alpha)
.123,97>--                   # Keep only lowercase letters
{"aeiou"?)!}%      # Foreach: is it a vowel?
.-1%= # Is it a palindrome?
`