Hello, new world! again
C99 + sh + C11, 165 162 146 145 combined chars
Edit: using @flonk's trick I managed to put the "comment" in C (making use of C11's u""
Unicode literals).
Common characters are: acehinortu
.
hello.c (106):
*a="\2+++++++++++++++++++++++++++++++++";i;main(){for(;i<24;)putchar("Lipps0$ri{${svph%$ekemr2"[i++]+~3);}
hello.sh (39):
true
echo -n 'Hello, new world! again.'
hello-combined.c (145):
*tar=u"e\
2e+c+h+o+ +-+n+ +'+H+e+l+l+o+,+ +n+e+w+ +w+o+r+l+d+!+ +a+g+a+i+n+.+'";i;main(){for(;i<24;)putchar("Lipps0$ri{${svph%$ekemr2"[i++]+~3);}
Here are some utilities that might prove useful for other participants.
combine.c:
#include <stdio.h>
int main(int argc, char *argv[]) {
FILE *f1 = fopen(argv[1], "r"), *f2 = fopen(argv[2], "r");
while (!feof(f1) || !feof(f2)) {
int c1 = fgetc(f1), c2 = fgetc(f2);
if (c1 != EOF) putchar(c1);
if (c2 != EOF) putchar(c2);
}
return 0;
}
char-check.{ba,z}sh:
comm -12 <(grep -o . "$1" | sort | uniq) \
<(grep -o . "$2" | sort | uniq) | tr -d '\n'
Here's a variation that unfortunately ended up (considerably) longer, but it's pretty cool in how it works. (I didn't bother getting the intersection between the sets of characters down to 10, since it ended up longer anyway.)
hello.c (113):
*a="\5Lipps0$ri{${svph%$ekemr2+++++++++++",*b=&a,c=6;i;main(){char*p=*b;for(i=c/8;p[i]-50;)putchar(p[i+=c/4]-4);}
hello.sh (51):
true
echo -n 'Hello, new world! again.' # tr 1
hello-combined.c (164):
*tar=u"e\
5eLcihpop s-0n$ r'iH{e$l{lsov,p hn%e$we kweomrrl2d+!+ +a+g+a+i+n+.+'+ +#" , * b = &tar, c =16;i;main(){char*p=*b;for(i=c/8;p[i]-50;)putchar(p[i+=c/4]-4);}
This one is fun, because it doesn't just "comment out" a bunch of characters, but actually stores the characters it prints inside the string literal and accounts for the extra characters in the for-loop of the generated program.
Brainfuck + C (196+77)
Not a very golfy answer, but I just think it is fun
Brainfuck:
++++++++++[>+++++++>++++>++++++++++>+++<<<<-]>++.>>+.+++++++..+++.<++++.>>++.<-.---------.++++++++++++++++++.>.<.--------.+++.------.--------.>+.-.<---.++++++.------.++++++++.+++++.<++.printfHelo
C
main(){printf("Hello");putchar(44);printf(" new world! again");putchar(46);}
Combined (Also in brainfuck):
+m+a+i+n+(+)+{+p+r+i[n>t+f+(+"+H+e+l+l>o+"+)+;+p>u+t+c+h+a+r+(+4+4+)+;>p+r+i+n<t<f<(<"- ]n>e+w+ .w>o>r+l.d+!+ +a+g+a+i+n.".)+;+p+u.t<c+h+a+r+(.4>6>)+;+}.
<-.---------.++++++++++++++++++.>.<.--------.+++.------.--------.>+.-.<---.++++++.------.++++++++.+++++.<++.printfHelo
All the characters from the C code are considered as comments in brainfuck
The common characters are printfHelo
, appended at the end of the brainfuck code as comments
Befunge + sh + Befunge, 111 chars
Common characters are: !,-Hehilor
hello.bef (78):
vHelo----------------------------
<v"Lipps0$ri{${svph%$ekemr2"
_>4-:,b4*2+-!#@
hello.sh (33):
echo -n Hello, new world\! again.
hello-combined.bef (111):
veHcehloo ---n- -H-e-l-l-o-,- -n-e-w- -w-o-r-l-d-\-!- -a-g-a-i-n-.
<v"Lipps0$ri{${svph%$ekemr2"
_>4-:,b4*2+-!#@