Skip to main content
Updated count
Source Link

C, 255 201201 199 bytes

I don't see a lot of C answers around here, so enjoy; Also, first time golfing, suggestions and critique are welcome.

#define S(w,p)p=strpbrk(w,"aeiou")-w
#define c ;strcpy(r
#define l c+strlen(v[1])+b+1
main(int q,char**v){char r[64],S(v[1],a),S(v[2],b);cc,v[2])c+b,v[1]+a);strcat(r," ")l-a,v[1]);ll,v[2]+b);puts(r);}

If main() is not required we can save 24 bytes, getting to 181179 bytes

#define S(w,p)p=strpbrk(w,"aeiou")-w
#define c ;strcpy(r
#define l c+strlen(x)+b+1
s(char*x,char*y){char r[64],S(x,a),S(y,b);cc,y)c+b, x+a);strcat(r," ")l-a,x);ll,y+b);puts(r);}

Ungolfed:

void spoonerise(char* w1, char* w2)
{
    char rt[64];

    int p1 = strpbrk(w1, "aeiou")-w1;
    int p2 = strpbrk(w2, "aeiou")-w2;

    strcpy(rt, w2);
    strcpy(rt+p2, w1+p1);

    strcat(rt, " ");

    strcpy(rt+strlen(w1)+p2+1-p1, w1);
    strcpy(rt+strlen(w1)+p2+1, w2+p2);

    puts(rt);
}

EDIT: Thanks to feersum's suggestion I saved 54 bytes. =D

C, 255 201 bytes

I don't see a lot of C answers around here, so enjoy; Also, first time golfing, suggestions and critique are welcome.

#define S(w,p)p=strpbrk(w,"aeiou")-w
#define c ;strcpy(r
#define l c+strlen(v[1])+b+1
main(int q,char**v){char r[64],S(v[1],a),S(v[2],b);c,v[2])c+b,v[1]+a);strcat(r," ")l-a,v[1]);l,v[2]+b);puts(r);}

If main() is not required we can save 24 bytes, getting to 181 bytes

#define S(w,p)p=strpbrk(w,"aeiou")-w
#define c ;strcpy(r
#define l c+strlen(x)+b+1
s(char*x,char*y){char r[64],S(x,a),S(y,b);c,y)c+b, x+a);strcat(r," ")l-a,x);l,y+b);puts(r);}

Ungolfed:

void spoonerise(char* w1, char* w2)
{
    char rt[64];

    int p1 = strpbrk(w1, "aeiou")-w1;
    int p2 = strpbrk(w2, "aeiou")-w2;

    strcpy(rt, w2);
    strcpy(rt+p2, w1+p1);

    strcat(rt, " ");

    strcpy(rt+strlen(w1)+p2+1-p1, w1);
    strcpy(rt+strlen(w1)+p2+1, w2+p2);

    puts(rt);
}

EDIT: Thanks to feersum's suggestion I saved 54 bytes. =D

C, 255 201 199 bytes

I don't see a lot of C answers around here, so enjoy; Also, first time golfing, suggestions and critique are welcome.

#define S(w,p)p=strpbrk(w,"aeiou")-w
#define c ;strcpy(r
#define l c+strlen(v[1])+b+1
main(int q,char**v){char r[64],S(v[1],a),S(v[2],b)c,v[2])c+b,v[1]+a);strcat(r," ")l-a,v[1])l,v[2]+b);puts(r);}

If main() is not required we can save 24 bytes, getting to 179 bytes

#define S(w,p)p=strpbrk(w,"aeiou")-w
#define c ;strcpy(r
#define l c+strlen(x)+b+1
s(char*x,char*y){char r[64],S(x,a),S(y,b)c,y)c+b, x+a);strcat(r," ")l-a,x)l,y+b);puts(r);}

Ungolfed:

void spoonerise(char* w1, char* w2)
{
    char rt[64];

    int p1 = strpbrk(w1, "aeiou")-w1;
    int p2 = strpbrk(w2, "aeiou")-w2;

    strcpy(rt, w2);
    strcpy(rt+p2, w1+p1);

    strcat(rt, " ");

    strcpy(rt+strlen(w1)+p2+1-p1, w1);
    strcpy(rt+strlen(w1)+p2+1, w2+p2);

    puts(rt);
}

EDIT: Thanks to feersum's suggestion I saved 54 bytes. =D

Golfed further with help from the comments
Source Link

C, 255255 201 bytes

I don't see a lot of C answers around here, so enjoy; Also, first time golfing, suggestions and critique are welcome.

#define V(c)(c==97|c=='e'|c=='i'|c=='o'|c=='u')
#define S(w,sp)while(!Vp=strpbrk(w[s])w,"aeiou")s++;-w
#define c ;strcpy(r
#define l +strlenc+strlen(v[1])+b+1
main(int q,char**v){char r[64],a=0,b=0;SS(v[1],a),S(v[2],b)c;c,v[2])c+b,v[1]+a);strcat(r," ")c l-a,v[1])c l;l,v[2]+b);puts(r);}

If main() is not required we can save 24 bytes, getting to 181 bytes

#define V(c)(c==97|c=='e'|c=='i'|c=='o'|c=='u')
#define S(w,sp)while(!Vp=strpbrk(w[s])w,"aeiou")s++;-w
#define c ;strcpy(r
#define l +strlenc+strlen(x)+b+1
s(char*x,char*y){char r[64],a=0,b=0;SS(x,a),S(y,b)c;c,y)c+b, x+a);strcat(r," ")c l-a,x)c l;l,y+b);puts(r);}

Ungolfed:

#define isVowel(c)(c=='a'|c=='e'|c=='i'|c=='o'|c=='u')
void spoonerise(char* word1w1, char* word2w2)
{
    char rt[64]; 

    int p1 = 0strpbrk(w1, p2 = 0;
"aeiou")-w1;
    while (!isVowel(word1[p1])) p1++;
  int p2 while= (!isVowelstrpbrk(word2[p2]))w2, p2++;"aeiou")-w2;

    strcpy(rt, word2w2);
    strcpy(rt+p2, word1+p1w1+p1);

    strcat(rt, " ");

    strcpy(rt+strlen(word1w1)+p2+1-p1, word1w1);
    strcpy(rt+strlen(word1w1)+p2+1, word2+p2w2+p2);

    puts(rt);
}

EDIT: Thanks to feersum's suggestion I saved 54 bytes. =D

C, 255 bytes

I don't see a lot of C answers around here, so enjoy; Also, first time golfing, suggestions and critique are welcome.

#define V(c)(c==97|c=='e'|c=='i'|c=='o'|c=='u')
#define S(w,s)while(!V(w[s]))s++;
#define c ;strcpy(r
#define l +strlen(v[1])+b+1
main(int q,char**v){char r[64],a=0,b=0;S(v[1],a)S(v[2],b)c,v[2])c+b,v[1]+a);strcat(r," ")c l-a,v[1])c l,v[2]+b);puts(r);}

If main() is not required we can save 24 bytes

#define V(c)(c==97|c=='e'|c=='i'|c=='o'|c=='u')
#define S(w,s)while(!V(w[s]))s++;
#define c ;strcpy(r
#define l +strlen(x)+b+1
s(char*x,char*y){char r[64],a=0,b=0;S(x,a)S(y,b)c,y)c+b,x+a);strcat(r," ")c l-a,x)c l,y+b);puts(r);}

Ungolfed:

#define isVowel(c)(c=='a'|c=='e'|c=='i'|c=='o'|c=='u')
void spoonerise(char* word1, char* word2)
{
    char rt[64];
    int p1 = 0, p2 = 0;

    while (!isVowel(word1[p1])) p1++;
    while (!isVowel(word2[p2])) p2++;

    strcpy(rt, word2);
    strcpy(rt+p2, word1+p1);

    strcat(rt, " ");

    strcpy(rt+strlen(word1)+p2+1-p1, word1);
    strcpy(rt+strlen(word1)+p2+1, word2+p2);

    puts(rt);
}

C, 255 201 bytes

I don't see a lot of C answers around here, so enjoy; Also, first time golfing, suggestions and critique are welcome.

#define S(w,p)p=strpbrk(w,"aeiou")-w
#define c ;strcpy(r
#define l c+strlen(v[1])+b+1
main(int q,char**v){char r[64],S(v[1],a),S(v[2],b);c,v[2])c+b,v[1]+a);strcat(r," ")l-a,v[1]);l,v[2]+b);puts(r);}

If main() is not required we can save 24 bytes, getting to 181 bytes

#define S(w,p)p=strpbrk(w,"aeiou")-w
#define c ;strcpy(r
#define l c+strlen(x)+b+1
s(char*x,char*y){char r[64],S(x,a),S(y,b);c,y)c+b, x+a);strcat(r," ")l-a,x);l,y+b);puts(r);}

Ungolfed:

void spoonerise(char* w1, char* w2)
{
    char rt[64]; 

    int p1 = strpbrk(w1, "aeiou")-w1;
    int p2 = strpbrk(w2, "aeiou")-w2;

    strcpy(rt, w2);
    strcpy(rt+p2, w1+p1);

    strcat(rt, " ");

    strcpy(rt+strlen(w1)+p2+1-p1, w1);
    strcpy(rt+strlen(w1)+p2+1, w2+p2);

    puts(rt);
}

EDIT: Thanks to feersum's suggestion I saved 54 bytes. =D

Source Link

C, 255 bytes

I don't see a lot of C answers around here, so enjoy; Also, first time golfing, suggestions and critique are welcome.

#define V(c)(c==97|c=='e'|c=='i'|c=='o'|c=='u')
#define S(w,s)while(!V(w[s]))s++;
#define c ;strcpy(r
#define l +strlen(v[1])+b+1
main(int q,char**v){char r[64],a=0,b=0;S(v[1],a)S(v[2],b)c,v[2])c+b,v[1]+a);strcat(r," ")c l-a,v[1])c l,v[2]+b);puts(r);}

If main() is not required we can save 24 bytes

#define V(c)(c==97|c=='e'|c=='i'|c=='o'|c=='u')
#define S(w,s)while(!V(w[s]))s++;
#define c ;strcpy(r
#define l +strlen(x)+b+1
s(char*x,char*y){char r[64],a=0,b=0;S(x,a)S(y,b)c,y)c+b,x+a);strcat(r," ")c l-a,x)c l,y+b);puts(r);}

Ungolfed:

#define isVowel(c)(c=='a'|c=='e'|c=='i'|c=='o'|c=='u')
void spoonerise(char* word1, char* word2)
{
    char rt[64];
    int p1 = 0, p2 = 0;

    while (!isVowel(word1[p1])) p1++;
    while (!isVowel(word2[p2])) p2++;

    strcpy(rt, word2);
    strcpy(rt+p2, word1+p1);

    strcat(rt, " ");

    strcpy(rt+strlen(word1)+p2+1-p1, word1);
    strcpy(rt+strlen(word1)+p2+1, word2+p2);

    puts(rt);
}