Binary addition

Each line in STDIN represents the number in binary format. Sum all these numbers and write result to STDOUT in binary form.

IN

1111
1010
11

OUT

11100

IN

10000000
10010
110001

OUT

11000011

IN

11111001111
101110110111

OUT

1001110000110
Login to submit solution


8 symbols pyth
Mon Sep 19 14:13:46 2016 Sait2000
.BsiR2.z
30 symbols perl
Mon Jun 16 23:04:13 2014 dionys
#!/usr/bin/perl -n
$r+=oct"0b$_"}{printf"%b",$r
31 symbols perl
Mon Jun 16 10:38:32 2014 avkhozov
#!/usr/bin/perl -nl
$r+=oct"0b$_"}{printf"%b",$r
32 symbols perl
Fri Jun 13 15:02:02 2014 dionys
#!/usr/bin/perl -nl
$r+=oct"0b".$_}{printf"%b",$r
53 symbols perl
Sun Jun 8 20:18:42 2014 Logioniz
#!/usr/bin/perl -n
chomp;
$a += oct('0b' . $_);
}
{
printf "%b" , $a;
58 symbols python2
Fri Aug 8 13:28:21 2014 PFischbeck
import sys
print bin(sum(int(a,2) for a in sys.stdin))[2:]
58 symbols python3
Sat Aug 9 01:05:14 2014 z423x5c6
import sys
print(bin(sum(int(i,2)for i in sys.stdin))[2:])
60 symbols python3
Sat Aug 9 01:04:22 2014 z423x5c6
import sys
print(bin(sum([int(i,2)for i in sys.stdin]))[2:])
108 symbols haskell
Wed Mar 18 07:48:35 2015 YoshikuniJujo
main=interact$reverse.s.sum.map(foldl((+).(*2))0.map(read.(:""))).lines
s 0=""
s n=show(n`mod`2)++s(n`div`2)
124 symbols bash
Mon Jul 25 09:28:44 2016 hidefromkgb
p=({0..1}{0..1}{0..1});n=$(printf %o $[2#`pr -t3s+2#`]);for i in `seq ${#n}`;do echo -n ${p[${n:$[i-1]:1}]};done|sed s/^0*//

View all solutions