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.


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':
	elif c in 'BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz':
print(l == list(reversed(l)), end = '')

Try it online!

  • \$\begingroup\$ When and who is #2? \$\endgroup\$ Commented Jun 10, 2017 at 15:58
  • \$\begingroup\$ @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. \$\endgroup\$
    – hyper-neutrino
    Commented Jun 10, 2017 at 17:08
  • \$\begingroup\$ @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. \$\endgroup\$
    – hyper-neutrino
    Commented Jun 10, 2017 at 17:32
  • \$\begingroup\$ @HyperNeutrino Umm, you can't use italics in titles. \$\endgroup\$ Commented Jun 10, 2017 at 18:47
  • 1
    \$\begingroup\$ @Hyperneutrino so multicharacter variable names are ridiculous now? ;) \$\endgroup\$
    – dylnan
    Commented Jan 15, 2018 at 18:51

47 Answers 47


Jelly, 11 bytes


Try it online!

Alternate versions:




Of course a challenge appreciating Dennis must have an answer in a language of his.

  • 21
    \$\begingroup\$ Œuf is Egg in french. Just sayin' \$\endgroup\$
    – YSC
    Commented May 29, 2017 at 13:59

05AB1E, 9 bytes


Try it online!

-2 thanks to Adnan.

This attacks Jelly's pain point exactly. It uses l and A, 1-byte equivalents for Jelly's Œl and Øa respectively.

  • \$\begingroup\$ Are you sure that this works? Run this \$\endgroup\$
    – MCCCS
    Commented May 28, 2017 at 16:34
  • \$\begingroup\$ @MCCCS Hmm, you may be right. \$\endgroup\$ Commented May 28, 2017 at 16:48
  • \$\begingroup\$ You can replace by á and DR by Â. \$\endgroup\$
    – Adnan
    Commented May 28, 2017 at 18:39
  • 13
    \$\begingroup\$ @alexis most of these golfing languages use 256 different characters and a custom codepage that maps hex 00 to FF to those 256 characters, see the Jelly answer \$\endgroup\$
    – Stephen
    Commented May 29, 2017 at 1:11
  • 1
    \$\begingroup\$ @alexis 4.5 years later, but to clarify Stephen's comment a bit more: 05AB1E uses this custom codepage of the 256 characters it knows. The program žM¹álSåÂQ above are the bytes 9E 4D B9 E1 6C 53 E5 C2 51. We can use the --osabie flag to compile and run it in Python. Here a Bash script with the same program as raw bytes. \$\endgroup\$ Commented Nov 30, 2021 at 8:09

x86 32-bit machine-code function, 42 41 bytes

Currently the shortest non-golfing-language answer, 1B shorter than @streetster's q/kdb+.

With 0 for truthy and non-zero for falsy: 41 40 bytes. (in general, saves 1 byte for 32-bit, 2 bytes for 64-bit).

With implicit-length strings (C-style 0-terminated): 45 44 bytes

x86-64 machine-code (with 32-bit pointers, like the x32 ABI): 44 43 bytes.

x86-64 with implicit-length strings, still 46 bytes (the shift/mask bitmap strategy is break-even now).

This is a function with C signature _Bool dennis_like(size_t ecx, const char *esi). The calling convention is slightly non-standard, close to MS vectorcall/fastcall but with different arg registers: string in ESI and the length in ECX. It only clobbers its arg-regs and EDX. AL holds the return value, with the higher bytes of EAX holding garbage (as allowed by the SysV i386 and x32 ABIs, and the Windows x64 calling convention.)

Explanation of the algorithm:

Loop over the input string, filtering and classifying into a boolean array on the stack: For each byte, check if it's an alphabetic character (if not, continue to next char), and transform it to an integer from 0-25 (A-Z). Use that 0-25 integer to check a bitmap of vowel=0/consonant=1. (The bitmap is loaded into a register as a 32-bit immediate constant). Push 0 or 0xFF onto the stack according to the bitmap result (actually in the low byte of a 32-bit element, which may have garbage in the top 3 bytes).

The first loop produces an array of 0 or 0xFF (in dword elements padded with garbage). Do the usual palindrome check with a second loop that stops when pointers cross in the middle (or when they both point to the same element if there were an odd number of alphabetic characters). The upward-moving pointer is the stack pointer, and we use POP to load+increment. Instead of compare / setcc in this loop, we can just use XOR to detect same/different since there are only two possible values. We could accumulate (with OR) whether we found any non-matching elements, but an early-out branch on flags set by XOR is at least as good.

Notice that the second loop uses byte operand-size, so it doesn't care what garbage the first loop leaves outside the low byte of each array element.

It uses the undocumented salc instruction to set AL from CF, in the same way that sbb al,al would. It's supported on every Intel CPU (except in 64-bit mode), even Knight's Landing! Agner Fog lists timings for it on all AMD CPUs as well (including Ryzen), so if x86 vendors insist on tying up that byte of opcode space ever since 8086, we might as well take advantage of it.

Interesting tricks:

  • unsigned-compare trick for a combined isalpha() and toupper(), and zero-extends the byte to fill eax, setting up for:
  • immediate bitmap in a register for bt, inspired by some nice compiler output for switch.
  • Creating a variable-sized array on the stack with push in a loop. (Standard for asm, but not something you can do with C for the implicit-length string version). It uses 4 bytes of stack space for every input character, but saves at least 1 byte vs. optimal golfing around stosb.
  • Instead of cmp/setne on the boolean array, XOR booleans together to get a truth value directly. (cmp/salc isn't an option, because salc only works for CF, and 0xFF-0 doesn't set CF. sete is 3 bytes, but would avoid the inc outside the loop, for a net cost of 2 bytes (1 in 64-bit mode)) vs. xor in the loop and fixing it with inc.
; explicit-length version: input string in ESI, byte count in ECX
08048060 <dennis_like>:
 8048060:       55                      push   ebp
 8048061:       89 e5                   mov    ebp,esp  ; a stack frame lets us restore esp with LEAVE (1B)
 8048063:       ba ee be ef 03          mov    edx,0x3efbeee ; consonant bitmap

08048068 <dennis_like.filter_loop>:
 8048068:       ac                      lods   al,BYTE PTR ds:[esi]
 8048069:       24 5f                   and    al,0x5f    ; uppercase
 804806b:       2c 41                   sub    al,0x41    ; range-shift to 0..25
 804806d:       3c 19                   cmp    al,0x19    ; reject non-letters
 804806f:       77 05                   ja     8048076 <dennis_like.non_alpha>
 8048071:       0f a3 c2                bt     edx,eax    # AL = 0..25 = position in alphabet
 8048074:       d6                      SALC     ; set AL=0 or 0xFF from carry.  Undocumented insn, but widely supported
 8048075:       50                      push   eax
08048076 <dennis_like.non_alpha>:
 8048076:       e2 f0                   loop   8048068 <dennis_like.filter_loop>   # ecx = remaining string bytes
 ; end of first loop

 8048078:       89 ee                   mov    esi,ebp  ; ebp = one-past-the-top of the bool array
0804807a <dennis_like.palindrome_loop>:
 804807a:       58                      pop    eax      ; read from the bottom
 804807b:       83 ee 04                sub    esi,0x4
 804807e:       32 06                   xor    al,BYTE PTR [esi]
 8048080:       75 04                   jne    8048086 <dennis_like.non_palindrome>
 8048082:       39 e6                   cmp    esi,esp             ; until the pointers meet or cross in the middle
 8048084:       77 f4                   ja     804807a  <dennis_like.palindrome_loop>

08048086 <dennis_like.non_palindrome>:
 ; jump or fall-through to here with al holding an inverted boolean
 8048086:       40                      inc    eax
 8048087:       c9                      leave  
 8048088:       c3                      ret    
;; 0x89 - 0x60 = 41 bytes

This is probably also one of the fastest answers, since none of the golfing really hurts too badly, at least for strings under a few thousand characters where the 4x memory usage doesn't cause a lot of cache-misses. (It might also lose to answers that take an early-out for non-Dennis-like strings before looping over all the characters.) salc is slower than setcc on many CPUs (e.g. 3 uops vs. 1 on Skylake), but a bitmap check with bt/salc is still faster than a string-search or regex-match. And there's no startup overhead, so it's extremely cheap for short strings.

Doing it in one pass on the fly would mean repeating the classification code for the up and down directions. That would be faster but larger code-size. (Of course if you want fast, you can do 16 or 32 chars at a time with SSE2 or AVX2, still using the compare trick by range-shifting to the bottom of the signed range).

Test program (for ia32 or x32 Linux) to call this function with a cmdline arg, and exit with status = return value. strlen implementation from int80h.org.

; build with the same %define macros as the source below (so this uses 32-bit regs in 32-bit mode)
global _start
    ;%define PTRSIZE 4   ; true for x32 and 32-bit mode.

    mov  esi, [rsp+4 + 4*1]  ; esi = argv[1]
    ;mov  rsi, [rsp+8 + 8*1]  ; rsi = argv[1]   ; For regular x86-64 (not x32)

        ; strlen(esi)
         mov     rdi, rsi
         mov     rcx, -1
        xor     eax, eax
        repne scasb    ; rcx = -strlen - 2
        not     rcx
        dec     rcx

    mov  eax, 0xFFFFAEBB   ; make sure the function works with garbage in EAX
    call dennis_like

    ;; use the 32-bit ABI _exit syscall, even in x32 code for simplicity
    mov ebx, eax
    mov eax, 1
    int 0x80           ; _exit( dennis_like(argv[1]) )

    ;; movzx edi, al   ; actually mov edi,eax is fine here, too
    ;; mov eax,231     ; 64-bit ABI exit_group( same thing )
    ;; syscall

A 64-bit version of this function could use sbb eax,eax, which is only 2 bytes instead of 3 for setc al. It would also need an extra byte for dec or not at the end (because only 32-bit has 1-byte inc/dec r32). Using the x32 ABI (32-bit pointers in long mode), we can still avoid REX prefixes even though we copy and compare pointers.

setc [rdi] can write directly to memory, but reserving ECX bytes of stack space costs more code-size than that saves. (And we need to move through the output array. [rdi+rcx] takes one extra byte for the addressing mode, but really we need a counter that doesn't update for filtered characters so it's going to be worse than that.)

This is the YASM/NASM source with %if conditionals. It can be built with -felf32 (32-bit code) or -felfx32 (64-bit code with the x32 ABI), and with implicit or explicit length. I've tested all 4 versions. See this answer for a script to build a static binary from NASM/YASM source.

To test the 64-bit version on a machine without support for the x32 ABI, you can change the pointer regs to 64-bit. (Then simply subtract the number of REX.W=1 prefixes (0x48 bytes) from the count. In this case, 4 instructions need REX prefixes to operate on 64-bit regs). Or simply call it with the rsp and the input pointer in the low 4G of address space.


; This source can be built as x32, or as plain old 32-bit mode
; x32 needs to push 64-bit regs, and using them in addressing modes avoids address-size prefixes
; 32-bit code needs to use the 32-bit names everywhere

;%if __BITS__ != 32   ; NASM-only
%ifidn __OUTPUT_FORMAT__, elfx32
%define CPUMODE 64
%define STACKWIDTH 8    ; push / pop 8 bytes
%define CPUMODE 32
%define STACKWIDTH 4    ; push / pop 4 bytes
%define rax eax
%define rcx ecx
%define rsi esi
%define rdi edi
%define rbp ebp
%define rsp esp

    ; A regular x86-64 version needs 4 REX prefixes to handle 64-bit pointers
    ; I haven't cluttered the source with that, but I guess stuff like %define ebp rbp  would do the trick.

    ;; Calling convention similar to SysV x32, or to MS vectorcall, but with different arg regs
    ;; _Bool dennis_like_implicit(const char *esi)
    ;; _Bool dennis_like_explicit(size_t ecx, const char *esi)
global dennis_like
    ; We want to restore esp later, so make a stack frame for LEAVE
    push  rbp
    mov   ebp, esp   ; enter 0,0 is 4 bytes.  Only saves bytes if we had a fixed-size allocation to do.

    mov  edx, 11111011111011111011101110b   ; consonant/vowel bitmap for use with bt

;;; assume that len >= 1
    lodsb   ; pipelining the loop is 1B shorter than  jmp .non_alpha

    and   al, 0x7F ^ 0x20  ; force ASCII to uppercase.
    sub   al, 'A'          ; range-shift to 'A' = 0
    cmp   al, 'Z'-'A'      ; if al was less than 'A', it will be a large unsigned number
    ja  .non_alpha
    ;; AL = position in alphabet (0-25)

    bt    edx, eax              ; 3B
%if CPUMODE == 32
    salc                        ; 1B   only sets AL = 0 or 0xFF.  Not available in 64-bit mode
    sbb   eax, eax              ; 2B   eax = 0 or -1, according to CF.
    push  rax

    test   al,al
    jnz .filter_loop
    loop .filter_loop
    ; al = potentially garbage if the last char was non-alpha
    ; esp = bottom of bool array

    mov   esi, ebp  ; ebp = one-past-the-top of the bool array
    pop   rax

    sub   esi, STACKWIDTH
    xor   al, [rsi]   ; al = (arr[up] != arr[--down]).  8-bit operand-size so flags are set from the non-garbage
    jnz .non_palindrome

    cmp   esi, esp
    ja .palindrome_loop

.non_palindrome:  ; we jump here with al=1 if we found a difference, or drop out of the loop with al=0 for no diff
    inc   eax     ;; AL transforms 0 -> 1  or  0xFF -> 0.
    ret           ; return value in AL.  high bytes of EAX are allowed to contain garbage.

I looked at messing around with DF (the direction flag that controls lodsd / scasd and so on), but it just didn't seem to be a win. The usual ABIs require that DF is cleared on function entry and exit. Assuming cleared on entry but leaving it set on exit would be cheating, IMO. It would be nice to use LODSD / SCASD to avoid the 3-byte sub esi, 4, especially in the case where there's no high-garbage.

Alternate bitmap strategy (for x86-64 implicit-length strings)

It turns out this doesn't save any bytes, because bt r32,r32 still works with high garbage in the bit-index. It's just not documented the way shr is.

Instead of bt / sbb to get the bit into / out of CF, use a shift / mask to isolate the bit we want from the bitmap.

    ; incompatible with LOOP for explicit-length, both need ECX.  In that case, bt/sbb is best
    xchg  eax, ecx
    mov   eax, 11111011111011111011101110b   ; not hoisted out of the loop
    shr   eax, cl
    and   al, 1
    bt    edx, eax
    sbb   eax, eax
    push  rax

Since this produces 0/1 in AL at the end (instead of 0/0xFF), we can do the necessary inversion of the return value at the end of the function with xor al, 1 (2B) instead of dec eax (also 2B in x86-64) to still produce a proper bool / _Bool return value.

This used to save 1B for x86-64 with implicit-length strings, by avoiding the need to zero the high bytes of EAX. (I had been using and eax, 0x7F ^ 0x20 to force to upper-case and zero the rest of eax with a 3-byte and r32,imm8. But now I'm using the 2-byte immediate-with-AL encoding that most 8086 instructions have, like I was already doing for the sub and cmp.)

It loses to bt/salc in 32-bit mode, and explicit-length strings need ECX for the count so this doesn't work there either.

But then I realized that I was wrong: bt edx, eax still works with high garbage in eax. It masks the shift count the same way shr r32, cl does (looking only at the low 5 bits of cl). This is different from bt [mem], reg, which can access outside the memory referenced by the addressing-mode/size, treating it as a bitstring. (Crazy CISC...)

Intel's insn set ref manual entry for bt does document the masking in the description section: If the bit base operand specifies a register, the instruction takes the modulo 16, 32, or 64 of the bit offset operand (modulo size depends on the mode and register size). Apparently I missed it when writing this answer originally; I checked a Jan 2015 version of the PDF and it was already there.

A neat trick here is using xchg eax,ecx (1 byte) to get the count into CL. Unfortunately, BMI2 shrx eax, edx, eax is 5 bytes, vs. only 2 bytes for shr eax, cl. Using bextr needs a 2-byte mov ah,1 (for the number of bits to extract), so it's again 5 + 2 bytes like SHRX + AND.

The source code has gotten pretty messy after adding %if conditionals. Here's disassembly of x32 implicit-length strings (using the alternate strategy for the bitmap, so it's still 46 bytes).

The main difference from the explicit-length version is in the first loop. Notice how there's a lods before it, and at the bottom, instead of just one at the top of the loop.

    ; 64-bit implicit-length version using the alternate bitmap strategy
    00400060 <dennis_like>:
      400060:       55                      push   rbp
      400061:       89 e5                   mov    ebp,esp
      400063:       ac                      lods   al,BYTE PTR ds:[rsi]
    00400064 <dennis_like.filter_loop>:
      400064:       24 5f                   and    al,0x5f
      400066:       2c 41                   sub    al,0x41
      400068:       3c 19                   cmp    al,0x19
      40006a:       77 0b                   ja     400077 <dennis_like.non_alpha>
      40006c:       91                      xchg   ecx,eax
      40006d:       b8 ee be ef 03          mov    eax,0x3efbeee  ; inside the loop since SHR destroys it
      400072:       d3 e8                   shr    eax,cl
      400074:       24 01                   and    al,0x1
      400076:       50                      push   rax
    00400077 <dennis_like.non_alpha>:
      400077:       ac                      lods   al,BYTE PTR ds:[rsi]
      400078:       84 c0                   test   al,al
      40007a:       75 e8                   jne    400064 <dennis_like.filter_loop>

      40007c:       89 ee                   mov    esi,ebp
    0040007e <dennis_like.palindrome_loop>:
      40007e:       58                      pop    rax
      40007f:       83 ee 08                sub    esi,0x8
      400082:       32 06                   xor    al,BYTE PTR [rsi]
      400084:       75 04                   jne    40008a <dennis_like.non_palindrome>
      400086:       39 e6                   cmp    esi,esp
      400088:       77 f4                   ja     40007e <dennis_like.palindrome_loop>
    0040008a <dennis_like.non_palindrome>:
      40008a:       ff c8                   dec    eax  ; invert the 0 / non-zero status of AL.  xor al,1 works too, and produces a proper bool.
      40008c:       c9                      leave  
      40008d:       c3                      ret    

   0x8e - 0x60 = 0x2e = 46 bytes

Update: instead of using 32-bit pointers, I could have used push rsp / pop rbp to copy a 64-bit register in 2 bytes of code. (Tips for golfing in x86/x64 machine code). But sub rsi,0x8 and cmp rsi,rsp would need REX prefixes which I'm avoiding here by using 32-bit pointers. Perhaps comparing the low 32 could work if the stack doesn't cross a 4GiB boundary, so just the sub.

I wonder if pop rdx / std / lodsq / cld / xor al, dl could work? No, that's 7 bytes, break-even with just using sub rsi, 8 in the loop body.

  • \$\begingroup\$ Some tricks I used in Vowels up, consonants down probably apply here, but I haven't yet re-golfed this one. Ideally we could have the interesting bit from the bitmap shifted to bit 7 so we could XOR / JS or JNS without needing and al, 1 anywhere, but that would require the top of the bitmap to extend past 32 bits. \$\endgroup\$ Commented Mar 23, 2020 at 8:04

Retina, 49 47 45 bytes



Try it online!

Saved 2 bytes thanks to Neil.

Saved another 2 bytes thanks to Martin.

Removes non-letters then replaces vowels with 1 and consonants with 2, to get consistent values. Then repeatedly removes the first and last character if they are the same. Once they aren't, the word was symmetric if there are one or zero characters remaining.

  • \$\begingroup\$ Does \D 2 work to save you a couple of bytes over T`lL`2? \$\endgroup\$
    – Neil
    Commented May 28, 2017 at 20:42
  • \$\begingroup\$ @Neil Yes it seems to, nice catch! \$\endgroup\$ Commented May 28, 2017 at 21:49
  • \$\begingroup\$ Well done. I was trying to do this :( \$\endgroup\$
    – user63187
    Commented May 28, 2017 at 23:32

PHP, 82 Bytes


Try it online!

  • \$\begingroup\$ You could prepend typecasting (bool) and remove the $s= and the ==$s check to save 1 byte. \$\endgroup\$
    – kaiser
    Commented May 29, 2017 at 17:33
  • \$\begingroup\$ If I am not mistaken, you could replace the (bool) with just 0|| to say false, or … instead, saving 3 additional bytes. \$\endgroup\$
    – kaiser
    Commented May 29, 2017 at 17:35
  • \$\begingroup\$ Hm. Couldn't you use \w for word characters instead of the a-z? \$\endgroup\$
    – kaiser
    Commented May 29, 2017 at 17:38
  • \$\begingroup\$ @kaiser \w contains digits underscore and letters . This will not work and [^/p{L}] is longer as [^a-z] plus i. I compare the reverse string with the string so $s is needed to create the boolean \$\endgroup\$ Commented May 29, 2017 at 18:06
  • \$\begingroup\$ That is true. Still the others should work. "Should" … they do. \$\endgroup\$
    – kaiser
    Commented May 30, 2017 at 4:56

MATL, 14 bytes


Try it at MATL Online.

Here is a slightly modified version to check all test cases.


        % Implicitly grab the input as a string
        %     STACK: {'Martin Ender'}
t       % Duplicate the input
        %     STACK: {'Martin Ender', 'Martin Ender'}
3Y2     % Push the string 'ABC...XYZabc...xyz'
        %     STACK: {'Martin Ender', 'Martin Ender', 'ABC...XYZabc...xyz'}
m       % Find which characters of the input are letters using this string
        %     STACK: {'Martin Ender', [1 1 1 1 1 1 0 1 1 1 1]}
)       % Use this boolean array to select only the letters
        %     STACK: {'MartinEnder'}
13Y2    % Push the string literal 'aeiouAEIOU' to the stack
        %     STACK: {'MartinEnder', 'aeiouAEIOU'}
m       % Check for membership of each letter of the input in this string.
        %     STACK: {[0 1 0 0 1 0 1 0 0 1 0]}
tP      % Create a reversed copy
        %     STACK: {[0 1 0 0 1 0 1 0 0 1 0], [0 1 0 0 1 0 1 0 0 1 0]}
=       % Perform an element-wise comparison yielding a truthy (all 1's) or 
        % falsey (any 0's) result
        %     STACK: {[1 1 1 1 1 1 1 1 1 1 1]}
        % Implicitly display the result
  • \$\begingroup\$ You demonstrate it with "Martin Ender" instead of "Dennis"? i have to look at the challenge title again. \$\endgroup\$ Commented May 28, 2017 at 17:36
  • 1
    \$\begingroup\$ Presumably Suever wanted a demonstration that had some amount of filtering at the first step. \$\endgroup\$ Commented May 28, 2017 at 19:58
  • \$\begingroup\$ Then he should use "Alex A." instead, it has a period too. \$\endgroup\$ Commented May 29, 2017 at 7:49
  • 2
    \$\begingroup\$ I'm confused what the issue is. I chose Martin Ender because it would actually be true if you remove spaces and false otherwise. I also included a link to all test cases \$\endgroup\$
    – Suever
    Commented May 29, 2017 at 12:51

Haskell, 84 75 74 69 bytes

-10 thanks to @nimi
-5 thanks to @Zgarb

f x=(==)<*>reverse$[elem c"aeiouAEIOU"|c<-x,'@'<c,c<'{','`'<c||c<'[']

The list comprehension replaces each letter with a boolean and removes all other characters. The first part checks whether or not the resulting list is a palindrome.

Try it online!

  • \$\begingroup\$ Two tips: 1) A list comprehension is often shorten than filter followed by map even if you have to switch to non-poitfree. 2) The <$>id is superfluous. f x=(==)<*>reverse$[elem c"aeiouAEIOU"|c<-x,celem['A'..'Z']++['a'..'z']]. \$\endgroup\$
    – nimi
    Commented May 28, 2017 at 14:54
  • \$\begingroup\$ You can drop the space between c and " for one more byte. \$\endgroup\$
    – nimi
    Commented May 28, 2017 at 16:27
  • 1
    \$\begingroup\$ I think c`elem`['A'..'Z']++['a'..'z'] can be shortened to '@'<c,c<'{','`'<c||c<'[' \$\endgroup\$
    – Zgarb
    Commented May 29, 2017 at 9:49

Pyth, 18 15 bytes


Try it here.

-2 thanks to KarlKastor, and subsequently -1.

  • \$\begingroup\$ 16 bytes: _I/L"aeiou"@Grz0 (using the invariance operator I) \$\endgroup\$
    – KarlKastor
    Commented May 28, 2017 at 18:11
  • \$\begingroup\$ @KarlKastor I knew there had to be some operator like that...thanks. (BTW I can now remove the z too, I will assume quoted input) \$\endgroup\$ Commented May 28, 2017 at 18:38

Brachylog, 13 bytes


Try it online!


ḷ                Lowercase the input
 {       }ˢ.     Select each char if:
  ∈Ṿg              it's a vowel, and replace it with ["aeiou"]            
     |             Or
      ∈Ḅg          it's a consonant, and replace it with ["bcdfghjklkmnpqrstvwxyz"]
           .↔    The resulting list is a palindrome

Alice, 28 bytes


Try it online!

Outputs 1 as truthy and nothing as falsy.


Every command in this program executes in ordinal mode, but with a slight twist in the template that allows me to save a byte. If a newline is an acceptable truthy value, I can save one more byte by the same method.

Linearized, the program is as follows:

1il.uN."aei ou"ayQy.R-$@1o1@

1                           % Append "1" to top of stack
                            % STACK: ["1"]
 i                          % Push input to stack
                            % STACK: ["1", "Dennis"]
  l                         % Convert to lowercase
                            % STACK: ["1", "dennis"]
   .                        % Duplicate
                            % STACK: ["1", "dennis", "dennis"]
    u                       % Convert to uppercase
                            % STACK: ["1", "dennis", "DENNIS"]
     N                      % Take multiset difference; this removes all non-alphabetic characters
                            % STACK: ["1", "dennis"]
      .                     % Duplicate
                            % STACK: ["1", "dennis", "dennis"]
       "aei ou"             % Push "aei ou"
                            % STACK: ["1", "dennis", "dennis", "aei ou"]
              a             % Push newline
                            % STACK: ["1", "dennis", "dennis", "aeiou", "\n"]
               y            % Transliterate: replace all vowels with newlines
                            % STACK: ["1", "dennis", "d\nnn\ns"]
                Q           % Reverse stack
                            % STACK: ["d\nnn\ns", "dennis", "1"]
                 y          % Transliterate: replace remaining characters with "1"
                            % STACK: ["1\n11\n1"]
                  .         % Duplicate
                            % STACK: ["1\n11\n1", "1\n11\n1"]
                   R        % Reverse top of stack
                            % STACK: ["1\n11\n1", "1\n11\n1"]
                    -       % Remove occurrences: for same-length strings, result is "" iff strings are equal.
                            % STACK: [""]
                     $      % Pop stack, and skip next command if ""
                      @     % Terminate (skipped if c/v pattern is palindromic)
                       1o   % Output "1"
                         1  % Push "1" (useless)
                          @ % Terminate

Python 3, 72 71 bytes

-1 byte thanks to @ovs

def f(s):s=[c in'AEIOU'for c in s.upper()if'@'<c<'['];return s==s[::-1]

Try it online!

  • \$\begingroup\$ def f(s):s=[c in'AEIOU'for c in s.upper()if'@'<c<'['];return s==s[::-1] for 71 bytes \$\endgroup\$
    – ovs
    Commented May 28, 2017 at 19:06

JavaScript (ES6), 72 69 bytes

Saved 3 bytes thanks to Neil

Returns a boolean.


Test cases

let f =


console.log(f("Dennis"))        // -> truthy
console.log(f("Martin"))        // -> truthy
console.log(f("Martin Ender"))  // -> truthy
console.log(f("Alex"))          // -> falsy
console.log(f("Alex A."))       // -> truthy
console.log(f("Doorknob"))      // -> falsy
console.log(f("Mego"))          // -> falsy

  • \$\begingroup\$ Save a couple of bytes by replacing the 2 empty strings with 2. \$\endgroup\$
    – Shaggy
    Commented May 28, 2017 at 19:56
  • 1
    \$\begingroup\$ Do you even need the +'' at the end? That would save 3 bytes instead. \$\endgroup\$
    – Neil
    Commented May 28, 2017 at 20:24
  • \$\begingroup\$ I like @Neil's idea better! \$\endgroup\$
    – Shaggy
    Commented May 28, 2017 at 20:45

Braingolf,  4  3 bytes


-1 byte thanks to Erik the Outgolfer

Turns out I had P all along, even before this challenge.

J however, despite being created before this challenge, wasn't pushed to github before the challenge, thus is still non-competing.


&JP  Implicit input, push ASCII value of each char in string to stack
&J   Replace each item in stack with 1 if vowel, otherwise 0
  P  Pop entire stack, push 1 if stack is palindromic, 0 otherwise
     Implicit output of last item on stack
  • \$\begingroup\$ Why do you need n? \$\endgroup\$ Commented May 30, 2017 at 15:05
  • \$\begingroup\$ @EriktheOutgolfer because I'm a certified moron \$\endgroup\$
    – Mayube
    Commented May 30, 2017 at 15:34
  • 1
    \$\begingroup\$ Hmm, you forgot to remove it from the explanation. \$\endgroup\$ Commented May 30, 2017 at 15:39
  • 1
    \$\begingroup\$ @EriktheOutgolfer I was gunna write "Erick" then strike out the c, but it just looks like "Eriek" \$\endgroup\$
    – Mayube
    Commented May 30, 2017 at 16:02
  • 1
    \$\begingroup\$ You might want to double check the spec ;) Non-letter characters should be ignored completely, making Alex A. truthy. \$\endgroup\$
    – Shaggy
    Commented Feb 7, 2018 at 16:37

Vyxal, 4 bytes


Try it Online!

Ǎ    # Non-alphabet chars removed
 A   # Vowel mask (1 for vowel, 0 for not)
  Ḃ⁼ # Is equal to its reverse?

Vyxal 2.4.1, 7 bytes


Try it Online!

-6 thanks to lyxal
-1 thanks to Underslash

  • \$\begingroup\$ Try it Online! for 8 bytes \$\endgroup\$
    – lyxal
    Commented Jun 30, 2021 at 11:38
  • \$\begingroup\$ Try it Online! for a flagless 8 bytes \$\endgroup\$
    – lyxal
    Commented Jun 30, 2021 at 11:44
  • \$\begingroup\$ Try it Online! another 8 bytes, but this time it uses a fancy double vectorize :D \$\endgroup\$
    – Underslash
    Commented Jul 3, 2021 at 0:40
  • \$\begingroup\$ @Underslash Nice! I think that works with a single vectorise, so 7! \$\endgroup\$
    – emanresu A
    Commented Jul 3, 2021 at 0:49
  • \$\begingroup\$ @Ausername I have mixed feelings about that, on the one hand, rip the double vectorize, but on the other hand, ez 7 bytes \$\endgroup\$
    – Underslash
    Commented Jul 3, 2021 at 0:50

Python 3, 92 87 74 72 69 68 bytes

l=[c in'aeouiAEOUI'for c in input()if c.isalpha()]

Try it online!

  • \$\begingroup\$ You can remove the space before the for c in s \$\endgroup\$
    – user41805
    Commented May 28, 2017 at 13:23
  • \$\begingroup\$ And you can remove the s variable by replacing s on the second line to input().lower() \$\endgroup\$
    – user41805
    Commented May 28, 2017 at 13:23

Mathematica, 113 bytes

  • \$\begingroup\$ You can get rid of quite a few bytes: PalindromeQ@StringReplace[#,{Characters@"aeiouAEIOU"->"1",LetterCharacter->"0",_->""}]& \$\endgroup\$
    – Not a tree
    Commented May 30, 2017 at 8:16

GolfScript, 42 bytes


Try it online!

The hard part is generating both the uppercase and lowercase alphabet in one string, which we'll use in a filter function to filter the letters out of the input. Luckily, since strings in GolfScript are just codepoint arrays with a special property, so we can just generate the codepoints in an efficient way. Here's how we generate them:

First, we generate range [0..122], 122 being the codepoint for z. Then, we take the elements from the element at index 65 onwards. 65 is the codepoint for A. Right now, we have [65..122]. All fine, except we have some unwanted codepoints ([91..96]) in there. So, we first make a duplicate of that range. Then, we take the elements from index 26 onwards, and we have [91..122]. After that, we get the elements up to and including index 5. Now we have [91..96]. Finally, we remove those elements from our [65..122], leaving us wil [65..90, 97..122]. Those are the codepoints we want.

Now that we made the upper/lower alphabet codepoint list, we continue our filtering function. The function gets mapped to each character on the input string, which, as I initially said, gets parsed as its codepoint instead. So now we essentially have [codepoint, [65..90, 97..122]]. To find out if char codepoint is a letter, we simply take its index in the list we made. If it isn't there, we'll get -1 as the index instead.

Right now, we get a falsey value only if codepoint == 65, i.e. the first index of our list, since only then would the index be 0. But a single increment will fix this problem, and, now, if codepoint is in our list, we'll get its index + 1, which is always a positive number, thus always truthy, while if it's not there we'll get -1 + 1 = 0, i.e. falsey.

We finally apply the function I described to every char of the input, and we only take the chars for which the function returned a truthy result.

Next up we have to determine if each char is a vowel or consonant. Since the vowels are fewer than the consonants, creating a string of vowels so that we check for that condition is shorter than creating a string of consonants, so we check if each char is a vowel. But, to check if the boolean list is palindromic, we need booleans, which we don't get just by taking the index + 1, since that can result in any number of [1..10] if the char is a vowel. And, as most golfing languages, this one, doesn't have a bool function either. So, we simply use not not x, since not always returns a boolean. But wait; do we really need to have specific booleans? Since not always returns a boolean, why don't we just remove the second not, and actually check if each char is a consonant? Yeah, that's exactly what we'll do!

After the check, which returns a list of booleans, we check if this boolean list we got is a palindrome, which is what this challenge asks us to do. Well, what is the definition of a palindrome? Yes, a palindrome is a list or string which is equal to its reverse. So, how do we check? Simple, we duplicate it, take its reverse, and check against the original list. The result we get is, finally, what our code should return.

  • 2
    \$\begingroup\$ Giant explanation for a 42-byte program. Now I guess that it's pretty much self-explanatory... \$\endgroup\$ Commented May 28, 2017 at 20:22

PHP, 87 bytes

Regex free PHP version. Added a "vowel" since stripos can return 0 which is false in PHP.

Flaw fixed by Jörg.


Try it online!

  • \$\begingroup\$ Same Byte count. for(;a&$c=$argn[$p++];)ctype_alpha($c)?$s.=stripos(_aeiou,$c)?0:1:0;echo$s==strrev($s); but it get the right result for strings that contains zero \$\endgroup\$ Commented May 29, 2017 at 14:08
  • \$\begingroup\$ @JörgHülsermann Thank you. \$\endgroup\$
    – M.E
    Commented May 29, 2017 at 14:24

q/kdb+, 42 38 bytes




q){x~|:[x]}{inter[x;.Q.a]in"aeiou"}lower"Alex A."


lower        // converts argument on the right to lowercase
.Q.a         // lowercase alphabet "abc..xyz"
inter[x;y]   // intersection of x and y (thus only return a-z)
x in "aeiou" // returns boolean list whether x is a vowel; "dennis" = 010010b
|:           // k shorthand for 'reverse'


  • -4 bytes; switching out reverse for k equivalent |:

CJam, 26 bytes


Try it online!

-1 thanks to Esolanging Fruit.

  • \$\begingroup\$ You can replace 26,'af+ with '{,97> to save a byte. \$\endgroup\$ Commented Feb 1, 2018 at 5:14
  • \$\begingroup\$ @EsolangingFruit such an old answer... \$\endgroup\$ Commented Feb 1, 2018 at 12:21
  • \$\begingroup\$ A byte saved half a year ago is no different than a byte saved now. It's not like there's byte inflation or anything :P \$\endgroup\$ Commented Feb 1, 2018 at 16:19
  • \$\begingroup\$ @EsolangingFruit I was referring to my always developing experience with golfing...of course you got a credit as usual, don't worry! \$\endgroup\$ Commented Feb 1, 2018 at 17:37

Stax, 18 bytes


Run and debug it


^                      capitalize input
 "[^A-Z]"zR            remove all non alphabet characters
           {     F     loop over modified string
            VV         "AEIOU"
              I        Index of character (-1 if not present)
               0<      less than 0
                       push the result to stack
                  L    wrap the stack in an array
                   c   duplicate it
                    r  reverse it
                     = are they equal?

Python 2, 83 bytes

def f(x):k=map(lambda y:y.lower()in"aeiou",filter(str.isalpha,x));return k==k[::-1]

Defines a function that either gives True or False

  • \$\begingroup\$ You can save 2 bytes by using "aeiouAEIOU".__contains__ instead of lambda y:y.lower()in"aeiou". \$\endgroup\$
    – Blender
    Commented May 31, 2017 at 8:07

CJam, 79 bytes

First-timer! (I did what I could)


Try it online!

  • 1
    \$\begingroup\$ Welcome to PP&CG! \$\endgroup\$ Commented May 28, 2017 at 19:58

Ruby, 57 bytes


Try it online!


Bash, 82 bytes

i=${1//[^a-zA-Z]};a=aeouiAEOUI;b=${i//[$a]/0};c=${b//[!0$a]/1};[ $c = `rev<<<$c` ]

Try it online!

Recives name as parameter, removes non-leters, replaces vowels with 0, non-vowels nor 0 with 1 and compares with same reversed.

Could golf some more if can get to work double or triple substitution

Exit status is 0 for true and 1 for no.

  • \$\begingroup\$ In recent bash versions, i=${i^^*}; converts i to uppercase. But I think it only saves you an a-z and an aeiou, which is less than the 10B it costs. \$\endgroup\$ Commented May 30, 2017 at 10:49

Perl, 42 bytes


Run with perl -p.


Japt v2.0a0, 19 11 bytes

k\L mè\v ê¬

Try it online


        :Implicit input of string U.
 k\L    :Remove all non-letter characters from U.
 m      :Map over resulting string, replacing each character ...
 è\v    :with the count of the number of vowels in each single character substring.
 ê¬     :Is the above a palindrome?
        :Implicit output of boolean result.

64-bit machine code, 89 bytes.

A function of following signature: eax = f(char * edi)

48 89 F8 48 89 FE 41 B8 22 82 20 00 8A 0E 84 C9
74 23 89 CA 83 E2 DF 0F BE D2 83 EA 41 83 FA 19
77 0E 44 89 C2 48 FF C0 D3 FA 83 E2 01 88 50 FF
48 FF C6 EB D7 C6 00 02 48 FF C7 48 FF C8 8A 17
40 8A 30 40 38 77 FF 75 05 80 FA 02 75 EA 31 C0
80 FA 02 0F 94 C0 C3

Assembled using NASM, from such assembly code:

; edi => input string.
; eax <= 1 or 0.

; notes:
; the string needs to be null terminated and located in a
; writable memory location, as it will be mutated.


        MOV RSI, RDI
        MOV R8D, 0x208222
        TEST CL, CL
        JE .SP
        MOV EDX, ECX
        AND EDX, -33
        MOVSX EDX, DL
        SUB EDX, 65
        CMP EDX, 25
        JA .LI
        MOV EDX, R8D
        INC RAX
        SAR EDX, CL
        AND EDX, 1
        MOV BYTE [RAX-1], DL
        JMP .CTOR
.SP:    MOV BYTE [RAX], 2
        DEC RAX
        MOV DL, BYTE [RDI]
        MOV SIL, BYTE [RAX]
        CMP BYTE [RDI-1], SIL
        JNE .EQE
        CMP DL, 2
        JNE .EQL
        CMP DL, 2
        SETE AL

Not a killer, not even close, but it has a couple of advantages over the 41-byte answer:

  • Requires no memory (not even stack).
  • Doesn't require to check the length of a string - it uses null-termination instead.
  • Doesn't use undocumented CPU instructions.

Just my $0.02 :).

  • \$\begingroup\$ My answer includes a 46-byte x86-64 version using implicit-length (null-terminated) strings, vs. the smaller C++ std::string style explicit-length string version. It uses 32-bit pointers in 64-bit mode (x32 ABI), but I had a look and I think it 64-bit pointers could be done with only 1 extra byte. My 64-bit versions don't use any undocumented instructions or behaviour (at the time I thought bt's masking of the count was undocumented, but I just missed it in the manual!) salc was removed in 64-bit mode. \$\endgroup\$ Commented Jun 3, 2023 at 14:25
  • \$\begingroup\$ So the interesting thing about your answer is not using any stack space. But using the input string for scratch space is using memory. Many callers would need to copy the string before calling this function, which is even worse than just needing to find its length if they didn't already have that value. Anyway, a different approach is fine and interesting; I don't mean to rain on your parade. :P \$\endgroup\$ Commented Jun 3, 2023 at 14:28
  • \$\begingroup\$ MOVSX EDX, DL could be avoided if you did MOVSX EDX, CL earlier, before the AND EDX, -33. Or loaded ECX originally with movsx ecx, byte [rsi]. -33 is all-ones outside the low 8 bits, so doing it before or after sign-extension is equivalent. I'm not sure you even need to sign-extend to 32-bit at all, though; the sub/cmp/ja trick to check for alphabetic ASCII works in 8-bit, after setting or clearing the lower-case bit like you're doing with and edx, ~32. You can probably use lea to copy-and-subtract, and mask cl instead of dl (the shift count gets masked mod 32) \$\endgroup\$ Commented Jun 3, 2023 at 14:39
  • \$\begingroup\$ Also, you can copy 64-bit registers in 2 bytes using push reg / pop reg. Tips for golfing in x86/x64 machine code . Using different registers could let you use AL for more of your 8-bit operations, allowing 2-byte instructions like cmp al, 25. (Tips for golfing in x86/x64 machine code). Having a pointer in RSI would allow lodsb to load into AL, and then you could copy from there into CL. Or not if the pointer increment needs to be conditional. \$\endgroup\$ Commented Jun 3, 2023 at 14:44
  • \$\begingroup\$ bt edx, ecx / setc BYTE [RAX-1] might save space over sar/and/mov. In the 2nd loop, CL instead of SIL would avoid a REX prefix. \$\endgroup\$ Commented Jun 3, 2023 at 14:48

APL (Dyalog Unicode), 34 33 24 bytes

Saved bytes thanks to Adám


Try it online!

819⌶⍨∘1 uppercase argument

⎕a∩⍨ intersection with uppercase alphabet

'AEIOU'∊⍨ belongs-to-'AEIOU'? resulting in a boolean vector

≡∘⌽⍨ reversed equivalent to self?

  • \$\begingroup\$ Save a byte with 819⌶⍨∘1 \$\endgroup\$
    – Adám
    Commented May 28, 2017 at 15:15
  • \$\begingroup\$ And two with (⊢≡⌽) \$\endgroup\$
    – Adám
    Commented May 28, 2017 at 15:18
  • \$\begingroup\$ … but I can solve this in 24. Want any hints? \$\endgroup\$
    – Adám
    Commented May 28, 2017 at 15:39
  • \$\begingroup\$ @Adám That trick is nice, thanks, got 24 too after over two years \$\endgroup\$
    – user41805
    Commented Jan 30, 2020 at 17:31
  • \$\begingroup\$ In a few of months, you can save another 2 bytes with 819⌶⎕C, or you can go Extended today, and do 819⌶⍨∘1 \$\endgroup\$
    – Adám
    Commented Jan 30, 2020 at 21:01

C (gcc), 130 bytes


Try it online!

Takes input as the string and its length, with the length passed by reference (d(str, &len)), and outputs by modifying len.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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