Vowel Tree

About

This is a simple bit of code to count vowels in a string. It reads the string as an argument, and simply loops using pointer arithmetic. Originally it was a task set for first-years, though my version uses no memory beyond that handed to it in argc and argv, which it reuses, and is obfuscated & shaped like a christmas tree.

Download

Download voweltree.c.

Look, it's Tree Shaped!

                        X
                       (I,
                      t(f(
                     p(i,A(
                    F(b),(t(
                   a,2,-=))))
                  ,r z),h(p(o,
                 c(M,a))),f(f(d
                ,(A(g(B,q(A)),A(
                      l(B,
                     q(u)),
                    A(t(B,1,
                   &),A((O(E(
                  q(e)),O(E(q(
                 a)),O(E(q(o)),
                O(E(q(i)),O(E(q(
               u)),O(E(q(E)),O(E(
              q(A)),O(E(q(O)),O(E(
             q(I)),E(q(U)))))))))))
            ),F(a))))))),p(w,F(C((C(
                     b)))))
                     )),n(k
                     (I,a),
                   k(char,B)))

Original Code

The original code is also slightly snazzy:

#include <stdio.h>

// uses no memory other than the calling vars,
// contains many optimisations to speed up vowel counting.
int main(int a, char ** b){


	if(b++ && (a-=2)) return 0;

	do
		(**b >= 'A' && **b <= 'u' && **b&1 && 
					(  **b == 'e' 
					|| **b == 'a'
					|| **b == 'o'
					|| **b == 'i'
					|| **b == 'u'
					|| **b == 'E' 
					|| **b == 'A'
					|| **b == 'O'
					|| **b == 'I'
					|| **b == 'U') 
					&& ++a);
	while(*(*b)++);

	printf("%i vowels found.\n", a);
}