Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Best Language for the job?

Name: Anonymous 2007-03-11 1:22 ID:V0b/AoE6

The problem is simple.
given a binary string of X(several megabytes)
it needs to be XORed with binary string Y(the same lenght).
The strings are read(converted) from files,and then results written to third file.After which a shell script is
performed on the third file.

The question is:Which language this problem is best coded in? (best=least code size,and the solution must work on Gigabyte+ files)

Name: Anonymous 2007-03-11 1:40 ID:TEBb0C0k

>shell script
>>1

Name: Anonymous 2007-03-11 3:01 ID:V0b/AoE6

>>2
Its not significant.You can read it as ("any operation performed on result file").

Name: Anonymous 2007-03-11 3:03 ID:V0b/AoE6

>>2
If you think .BAT file can XOR binary strings of 2GB files you're way off.

Name: Anonymous 2007-03-11 3:06 ID:TEBb0C0k

>>4
If .BAT is your shell script you’re already fucked.

Name: Anonymous 2007-03-11 3:18 ID:V0b/AoE6

>>5
Of course,the Universal Solution To Every Programming Problem:
Upgrade to Lunix.

Name: Anonymous 2007-03-11 3:27 ID:TPNQZtRW

Durr, if you must ask you truly are a dumbass.

Name: Anonymous 2007-03-11 3:40 ID:V0b/AoE6

>>7
I'm not asking for code.I'm ASKING FOR LANGUAGE NAME.
e.g: i'm not asking you translate  to French,just asking which language has
certain word order.

Name: Anonymous 2007-03-11 3:48 ID:TEBb0C0k

>>6
Yes, because under *nix you’d just have two input pipes XORing to one output pipe.

Name: Anonymous 2007-03-11 3:59 ID:rIy/dn7y

c you fags

int main(){FILE *a,*b,*c;int d,e;a=fopen("X","rb");b=fopen("Y","rb");c=fopen("Z","wb");
while((d=getc(a))!=EOF && (e=getc(b))!= EOF) putc(d^e,c);
return 0;
}

Name: Anonymous 2007-03-11 4:15 ID:Heaven

>>10
newlines are not a bad thing.
and i agree, C is the best language for something like this.
int main(){
 FILE *a,*b,*c;
 int d,e;
 a=fopen("X","rb");
 b=fopen("Y","rb");
 c=fopen("Z","wb");
 while((d=getc(a))!=EOF && (e=getc(b))!= EOF)
  putc(d^e,c);
 return 0;
}

Name: Anonymous 2007-03-11 4:41 ID:TPNQZtRW

>>8
What I'm saying is you're asking for something really fucking simple leading me to believe you know very little about programming. Anyone who is even remotely familiar with C/C++ should be able to whip up something like that in no time at all, as demonstrated above.

In short read more to prevent people from having to answer your ignorant, dumbass questions.

Name: Anonymous 2007-03-11 6:45 ID:kGtv67xu

C with asm inline (that comes with its horrible AT&T syntax) or you are not a real man.

Name: Anonymous 2007-03-11 7:36 ID:xE2qlGeY

Haskell.

Here's binary or: .|.

I don't know what xor looks like, but I used it a while ago.

Name: Anonymous 2007-03-11 10:57 ID:n/C1dcQY

int main(){
 char *a[3]={"X","Y","Z"};
 char *b[3]={"rb","rb","wb"};
 FILE *c[3];
 for(int i=0;i<3;c[i]=fopen(a[i],b[i]);
 for(int d,e;d-getc(f[0])!=EOF&&e=getc(f[1])!=EOF;putc(d^e,c[2]);
 return 0;
}

Name: 15 2007-03-11 10:58 ID:Heaven

oops, typo...
int main(){
 char *a[3]={"X","Y","Z"};
 char *b[3]={"rb","rb","wb"};
 FILE *c[3];
 for(int i=0;i<3;c[i]=fopen(a[i],b[i]);
 for(int d,e;d=getc(f[0])!=EOF&&e=getc(f[1])!=EOF;putc(d^e,c[2]);
 return 0;
}

Name: Anonymous 2007-03-11 11:22 ID:Heaven

>>16
don't you mean c[0] and c[1] instead of f[0] and f[1]?

Name: Anonymous 2007-03-11 11:46 ID:kGtv67xu

>>16
This code is made with fail and ignorance.

Name: Anonymous 2007-03-11 12:10 ID:Heaven

>>16
yeah, that's what happens when i rename variables after being awake for 37 hours

Name: Anonymous 2007-03-11 13:07 ID:xE2qlGeY

>>19
No, that's what happens when you rename variables USING C!!!!

Name: Anonymous 2007-03-11 15:33 ID:oOWMhShd

TOO BAD RENAMING VARIABLES IN C IS SLOW AS FUCK!

Name: Anonymous 2007-03-11 16:08 ID:Heaven

>>10
xor indentation, indentation

Name: Anonymous 2007-03-11 16:21 ID:oOWMhShd

>>22
0

Name: Anonymous 2007-03-11 17:44 ID:Fj3vrjIA

Using C to xor? Okay.

Using getc() and putc() to move gigabytes of data? Complete fucking idiocy.

You might as well use Ruby then. It'll be both faster and shorter.

Name: Anonymous 2007-03-11 22:10 ID:DIPhBG6e

>You might as well use Ruby then. It'll be both faster and shorter.

Time Paradox

Name: Anonymous 2007-03-12 0:34 ID:zdZyqDWS

Haskell will be something like;
import qualified Data.ByteString as B
import Data.Bits
import Data.Char

main = do
        x <- B.readFile "file1"
        y <- B.readFile "file2"
        putStr $ map (chr . fromIntegral) $ B.zipWith xor x y


Although I'm not sure if readFile is lazy. If it isn't, this will be a bad thing.

Name: Anonymous 2007-03-12 5:51 ID:Heaven

>>24
Too bad Ruby on Rails is slow as fuck.

Name: Anonymous 2007-03-12 20:03 ID:SHQU1u23

>>26
ByteString does quite a bit of unrolling and fusion and all that jazz. I'd worry more about the bit where you don't use "B.putStr" instead of the map thing.

Name: Anonymous 2007-03-13 1:49 ID:RqZVPZqG

>>28
I didn't use that because I didn't find `pack' before.

Fixed:
import qualified Data.ByteString as B
import Data.Bits

main = do
        x <- B.readFile "file1"
        y <- B.readFile "file2"
        B.putStr $ B.pack $ B.zipWith xor x y

Name: Anonymous 2009-01-14 13:35

Name: Anonymous 2009-03-06 5:41


like you only have   sex with men   this year and   then I moved   with my auntie   and uncle in!

Name: Anonymous 2011-01-31 21:34

<-- check em dubz

Name: Anonymous 2011-03-22 23:30

mfw character-at-a-time
learn to use buffers, holy fucking shit!

Name: Anonymous 2011-03-23 5:29

>>10-11,15-16
You are fucking faggot bottoms because you read byte-by-byte.  Lern2read bitches before I take my Aussie Bum pants off and plunge my erect penis into your shaved virgin anii sequentially.

Name: Sgt.Kabukiman쐠褓 2012-05-28 23:12

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List