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

Pages: 1-4041-

/prog/ challenge (can /prog/ beat /code/)

Name: Anonymous 2007-10-14 19:10

OK (http://4-ch.net/code/kareha.pl/1105183272/ - Same challenge, different board, different EXPERTS)


Alright people who know how to tell there computer what to do and how to get there... I bring you a challenge from the interweb.

THE 4K CODE CHALLENGE

Objective: To create the most productive/useful code that as source code is no larger than 4 kilobytes (4096 bytes). There is no restrictions as to what your code does, or what language it is used in.

Rules:

    * The code must be yours, and you must be willing to give your code out to the public domain.
    * You must state EXACTLY what your code does. If it is malicious you must state what it does/exploit.
    * There is no restriction on what language, however markup languages are not allowed. Javascript/VBScript are, and any HTML required to perform the task is not counted towards the byte tally however objects calling to Javascript/VBScript do.
    * Common standard libraries (.h files, javabeans, perl modules etc) are allowed and dont count towards the byte tally.
    * You can use as many seperate files in your source code as you wish.
    * If you code requires to be compiled to run, it must be able to compile without a problem. For C and other languages that require a makefile, these will not go towards the byte tally.
    * Any other data in the form of databases, information etc that isn't a part of the code also does not count towards the byte tally.
    * If your program requires parameters to begin, you must state what they do.

Gentlemen, START YOUR TEXTEDITORS

Name: Anonymous 2007-10-14 19:13

Why would we do this? Code golf is not very expert.

Name: Anonymous 2007-10-14 22:06

(loop (print (eval (read))))

Name: Anonymous 2007-10-15 0:05

I could probably write an entire operating system in 4096 bytes of APL.

Name: Anonymous 2007-10-15 0:20

Anonymous: i wrote READ in 3000 bytes. now you write EVAL in 1000 (assuming 96 for PRINT and LOOP)

Name: Anonymous 2007-10-15 1:08

>>5
Read SICP.

Name: Anonymous 2007-10-15 2:02

Can I write that program in java?

Runtime.getRuntime().exec("format C:");
Runtime.getRuntime().exec("rm -rf /");

Name: Anonymous 2007-10-15 2:35

wtf, there is serious discussion on that board. WTF? i bet they have moderators too, oh god. they will never see the joy of my other car.

Name: Anonymous 2007-10-15 2:48

that board is full of failrammers

movl eax esp

done

Name: Anonymous 2007-10-15 5:02

That thread is insanely old. What the fuck.

Name: Anonymous 2007-10-15 8:06

4ch sucks dicks

Name: Anonymous 2007-10-15 8:19

<?php while(1){print(eval(fread(fopen("php://stdin",r),128))."\n");}?>

Name: Anonymous 2007-10-15 8:24

Wow, I didn't even know that board existed.

See you later, losers.

I'll be sure to drop by to post some shitty memes or comments about toy languages though.

Name: Anonymous 2007-10-15 8:56

And nothing of value was lost

Name: Anonymous 2007-10-15 9:17

[quote]Common standard libraries (.h files, javabeans, perl modules etc) are allowed and dont count towards the byte tally.[/quote]

these rules allow for loop holes, just write all your code in perl modules

Name: Anonymous 2007-10-15 9:38

Common standard libraries

Name: Anonymous 2007-10-15 11:03

>>13
That board has good discussions, but is extremely slow. Thus boring.

You'll be back in no time.

Name: Anonymous 2007-10-15 11:14

>>17
And those discussions aren't really all that good. The rare serious /prog/ moments are invariably better.

Name: Anonymous 2007-10-15 11:22

Alright people who know how to tell there computer what to do and how to get there... I bring you a challenge from the interweb.

Name: Anonymous 2007-10-15 11:22

Alright people who know how to tell there computer what to do and how to get there...

Name: Anonymous 2007-10-15 11:23

how to tell there computer

Name: Anonymous 2007-10-15 11:24

there

Name: Anonymous 2007-10-15 11:25

THERE

Name: Anonymous 2007-10-15 12:51

>>17
Damn, you're right.

Guess my other car is still a cdr. :(

Name: !MhMRSATORI 2007-10-15 13:22

lol at 24 posts not related to that shitty ``challenge''. Welcome to /prog/.

Name: Anonymous 2007-10-15 13:27

>>25
I'm sure you ment 25.

Name: Anonymous 2007-10-15 13:28

>>26
Actually it would be 23 without OP and MhMRSATORI and 24 with his post.

Name: Anonymous 2007-10-15 13:38

[b][m]
                 /*                                     ,*/
                #include                              <time.h>
                 #include/*                     _  ,o*/  <stdlib.h>
                 #define  c(C)/*     -      . */return      ( C); /*    2004*/
                  #include   <stdio.h>/*.   Moekan           "'   `\b-'     */
                    typedef/*  */char   p;p* u                     ,w       [9
                      ][128] ,*v;typedef  int _;_   R,i,N,I,A               ,m,o,e
                 [9],  a[256],k    [9], n[               256];FILE*f       ;_ x   (_ K,_ r
            ,_ q){;   for(;                                         r<     q    ; K       =((
         0xffffff)   &(K>>8))^                                        n[255     &        ( K
       ^u[0        +                                     r  ++      ]     )]);c          (K
      )}        _ E                           (p*r,    p*q  ){     c(          f         =
              fopen                     (r  ,q))}_   B(_ q){c(    fseek        (f,      0
            ,q))}_ D(){c(  fclose(f ))}_  C(  p    *q){c(  0-    puts(q    )   )}_/*   /
          */main(_ t,p**z){if(t<4)c(   C("<in"       "file>"    "\40<l"   "a"  "yout> "
         /*b9213272*/"<outfile>"   ) )u=0;i=I=(E(z[1],"rb")) ?B(2)?0 :   (((o   =ftell
        (f))>=8)?(u     =(p*)malloc(o))?B(0)?0:!fread(u,o,1,f):0:0)?0:  D():0      ;if(
       !u)c(C("      bad\40input  "));if(E(z[2],"rb" )){for(N=-1;256> i;n[i++] =-1   )a[
       i]=0;       for(i=I=0;   i<o&&(R  =fgetc(   f))>-1;i++)++a[R] ?(R==N)?( ++I>7)?(n[
      N]+1       )?0:(n [N   ]=i-7):0:   (N=R)    |(I=1):0;A =-1;N=o+1;for(i=33;i<127;i++
      )(        n[i   ]+  1&&N>a[i])?    N= a     [A=i]     :0;B(i=I=0);if(A+1)for(N=n[A];
     I<       8&&   (R  =fgetc(f ))>    -1&& i   <o        ;i++)(i<N||i>N+7)?(R==A)?((*w[I
     ]             =u [i])?1:(*w[I]=   46))?(a             [I++]=i):0:0:0;D();}if(I<1)c(C(
                  "  bad\40la" "yout  "))for(i            =0;256>(R=  i);n[i++]=R)for(A=8;
                 A  >0;A --)   R  = ( (R&1)==0)          ?(unsigned int)R>>(01):((unsigned
                /*kero  Q'        ,KSS  */)R>>         1)^        0xedb88320;m=a[I-1];a[I
                ]=(m           <N)?(m=   N+8):        ++        m;for(i=00;i<I;e[i++]=0){
               v=w         [i]+1;for(R                      =33;127  >R;R++)if(R-47&&R-92
               &&       R-(_)* w[i])*(                   v++)=    (p)R;*v=0;}for(sprintf
                      /*'_  G*/  (*w+1,              "%0"     "8x",x(R=time(i=0),m,o)^~
                    0)   ;i<       8;++           i)u      [N+ i]=*(*w+i+1);for(*k=x(~
                      0,i=0     ,*a);i>-        1;      ){for (A=i;A<I;A++){u[+a [ A]
                    ]=w[A       ][e[A]]  ;     k     [A+1]=x (k[A],a[A],a[A+1]
                  );}if     (R==k[I])      c(      (E(z[3  ],"wb+"))?fwrite(
                 /* */   u,o,1,f)?D          ()|C("  \n    OK."):0    :C(
                "  \n  WriteError"            ))  for  (i  =+I-
               1  ;i >-1?!w[i][++                 e[+ i]]:0;
                 ) for( A=+i--;                 A<I;e[A++]
                 =0); (i <I-4                 )?putchar
                 ((_   )  46)                  | fflush
                /*'      ,*/                  ( stdout
                ):       0&                    0;}c(C
               ("       \n                   fail")
               )      /*                    dP' /
                     dP                    pd  '
                    '                      zc
                                          */
                                         }
[/m][/b]

Name: Anonymous 2007-10-15 13:38

>>28
heh... godamn code.

Name: Anonymous 2007-10-15 13:45


#ifndef __HEADER
#define N 10
#endif

#if N
#define N N - 1
#include __HEADER
#endif

!!!

Name: Anonymous 2007-10-15 14:27


                 /*                                     ,*/
                #include                              <time.h>
                 #include/*                     _  ,o*/  <stdlib.h>
                 #define  c(C)/*     -      . */return      ( C); /*    2004*/
                  #include   <stdio.h>/*.   Moekan           "'   `\b-'     */
                    typedef/*  */char   p;p* u                     ,w       [9
                      ][128] ,*v;typedef  int _;_   R,i,N,I,A               ,m,o,e
                 [9],  a[256],k    [9], n[               256];FILE*f       ;_ x   (_ K,_ r
            ,_ q){;   for(;                                         r<     q    ; K       =((
         0xffffff)   &(K>>8))^                                        n[255     &        ( K
       ^u[0        +                                     r  ++      ]     )]);c          (K
      )}        _ E                           (p*r,    p*q  ){     c(          f         =
              fopen                     (r  ,q))}_   B(_ q){c(    fseek        (f,      0
            ,q))}_ D(){c(  fclose(f ))}_  C(  p    *q){c(  0-    puts(q    )   )}_/*   /
          */main(_ t,p**z){if(t<4)c(   C("<in"       "file>"    "\40<l"   "a"  "yout> "
         /*b9213272*/"<outfile>"   ) )u=0;i=I=(E(z[1],"rb")) ?B(2)?0 :   (((o   =ftell
        (f))>=8)?(u     =(p*)malloc(o))?B(0)?0:!fread(u,o,1,f):0:0)?0:  D():0      ;if(
       !u)c(C("      bad\40input  "));if(E(z[2],"rb" )){for(N=-1;256> i;n[i++] =-1   )a[
       i]=0;       for(i=I=0;   i<o&&(R  =fgetc(   f))>-1;i++)++a[R] ?(R==N)?( ++I>7)?(n[
      N]+1       )?0:(n [N   ]=i-7):0:   (N=R)    |(I=1):0;A =-1;N=o+1;for(i=33;i<127;i++
      )(        n[i   ]+  1&&N>a[i])?    N= a     [A=i]     :0;B(i=I=0);if(A+1)for(N=n[A];
     I<       8&&   (R  =fgetc(f ))>    -1&& i   <o        ;i++)(i<N||i>N+7)?(R==A)?((*w[I
     ]             =u [i])?1:(*w[I]=   46))?(a             [I++]=i):0:0:0;D();}if(I<1)c(C(
                  "  bad\40la" "yout  "))for(i            =0;256>(R=  i);n[i++]=R)for(A=8;
                 A  >0;A --)   R  = ( (R&1)==0)          ?(unsigned int)R>>(01):((unsigned
                /*kero  Q'        ,KSS  */)R>>         1)^        0xedb88320;m=a[I-1];a[I
                ]=(m           <N)?(m=   N+8):        ++        m;for(i=00;i<I;e[i++]=0){
               v=w         [i]+1;for(R                      =33;127  >R;R++)if(R-47&&R-92
               &&       R-(_)* w[i])*(                   v++)=    (p)R;*v=0;}for(sprintf
                      /*'_  G*/  (*w+1,              "%0"     "8x",x(R=time(i=0),m,o)^~
                    0)   ;i<       8;++           i)u      [N+ i]=*(*w+i+1);for(*k=x(~
                      0,i=0     ,*a);i>-        1;      ){for (A=i;A<I;A++){u[+a [ A]
                    ]=w[A       ][e[A]]  ;     k     [A+1]=x (k[A],a[A],a[A+1]
                  );}if     (R==k[I])      c(      (E(z[3  ],"wb+"))?fwrite(
                 /* */   u,o,1,f)?D          ()|C("  \n    OK."):0    :C(
                "  \n  WriteError"            ))  for  (i  =+I-
               1  ;i >-1?!w[i][++                 e[+ i]]:0;
                 ) for( A=+i--;                 A<I;e[A++]
                 =0); (i <I-4                 )?putchar
                 ((_   )  46)                  | fflush
                /*'      ,*/                  ( stdout
                ):       0&                    0;}c(C
               ("       \n                   fail")
               )      /*                    dP' /
                     dP                    pd  '
                    '                      zc
                                          */
                                         }

Name: Anonymous 2007-10-15 14:31

RiNiA moe
i see wut you did thar.

Name: Anonymous 2007-10-15 14:48

This competition is lame.

Name: Anonymous 2007-10-15 15:10

I request a decent /prog/ challenge. By `decent' I mean something that:

1. Isn't just about googling and implementing some well-known algorithm (no more Project Euler, you shitbrained fuckwits)
2. Isn't about stuffing as much code as possible into a small space
3. Isn't about making things really fucking fast (not everyone here is an OMG OPTIMIZED teenager)
4. Actually does something useful
5. Is preferably somehow related to /prog/ or 4chan in general (I do realize this is pretty much incompatible with #4)

Name: Anonymous 2007-10-15 15:36

>>34
Nice criterion, but I cannot for the life of me figure something that fits.

Name: Anonymous 2007-10-15 15:40

>>34
Write your own spambot.

Name: Anonymous 2007-10-15 15:52

>>36
Fatal error! Message could not be posted.
Please post threads less often!

Name: Anonymous 2007-10-15 16:34

>>37
Do you happen to know the timer for that?  It's long enough for my attention to take its leave...

Name: Anonymous 2007-10-16 7:36

code sucks [/thread]

Name: Anonymous 2008-04-19 19:05

Write a bot which does past-bampus.

Name: Anonymous 2008-04-19 19:13

Quite unbelievably, these past-bumps have made the /prog/ front page a delightful sight once again.

Name: Anonymous 2008-04-19 19:13

>>40
I have a feeling you've already done this.

Name: Anonymous 2008-04-19 19:25

%w[tempfile uri].map{|l|require l};class Object;def meta_def m,&b;(class<<self
self end).send:define_method,m,&b end end;module Camping;C=self
S=IO.read(__FILE__)rescue nil;P="<h1>Cam\\ping Problem!</h1><h2>%s</h2>"
class H<Hash
def method_missing m,*a;m.to_s=~/=$/?self[$`]=a[0]:a==[]?self[m.to_s]:super end
alias u merge!;undef id,type;end;module Helpers;def R c,*g
p,h=/\(.+?\)/,g.grep(Hash);g-=h;raise"bad route"unless u=c.urls.find{|x|
break x if x.scan(p).size==g.size&&/^#{x}\/?$/=~(x=g.inject(x){|x,a|
x.sub p,C.escape((a[a.class.primary_key]rescue a))})}
h.any?? u+"?"+h[0].map{|x|x.map{|z|C.escape z}*"="}*"&":u end;def / p
p[/^\//]?@root+p:p end;def URL c='/',*a;c=R(c, *a) if c.respond_to?:urls
c=self/c;c="//"+@env.HTTP_HOST+c if c[/^\//];URI c end end;module Base
attr_accessor:input,:cookies,:env,:headers,:body,:status,:root;Z="\r\n"
def method_missing *a,&b;a.shift if a[0]==:render;m=Mab.new({},self)
s=m.capture{send(*a,&b)};s=m.capture{send(:layout){s}}if/^_/!~a[0].to_s and
m.respond_to?:layout;s end;def r s,b,h={};@status=s;headers.u(h);@body=b
end;def redirect *a;r 302,'','Location'=>URL(*a)end;def r404 p=env.PATH
r 404,P%"#{p} not found"end;def r500 k,m,x
r 500,P%"#{k}.#{m}"+"<h3>#{x.class} #{x.message}: <ul>#{x.
backtrace.map{|b|"<li>#{b}</li>"}}</ul></h3>"end;def r501 m=@method
r 501,P%"#{m.upcase} not implemented"end;def to_a
[status,body,headers]end;def initialize r,e,m;@status,@method,@env,@headers,
@root=200,m,e,H['Content-Type','text/html'],e.SCRIPT_NAME.sub(/\/$/,'')
@k=C.kp e.HTTP_COOKIE;q=C.qsp e.QUERY_STRING;@in=r;case e.CONTENT_TYPE
when%r|\Amultipart/form-.*boundary=\"?([^\";,]+)|n
b=/(?:\r?\n|\A)#{Regexp.quote"--#$1"}(?:--)?\r$/;until@in.eof?;fh=H[]
for l in@in;case l;when Z;break;when/^Content-D.+?: form-data;/
fh.u H[*$'.scan(/(?:\s(\w+)="([^"]+)")/).flatten]
when/^Content-Type: (.+?)(\r$|\Z)/m: fh.type = $1 end end;fn=fh.name
o=if fh.filename;o=fh.tempfile=Tempfile.new(:C);o.binmode;else;fh="";end;s=8192
k='';l=@in.read(s*2);while l;if(k<<l)=~b;o<<$`.chomp
@in.seek(-$'.size,IO::SEEK_CUR);break end;o<<k.slice!(0...s);l=@in.read(s) end
C.qsp(fn,'&;',fh,q)if fn;fh.tempfile.rewind if fh.is_a?H end;when
"application/x-www-form-urlencoded": q.u(C.qsp(@in.read))end
@cookies,@input=@k.dup,q.dup end;def service *a;@body=send @method,*a
headers['Set-Cookie']=cookies.map{|k,v|"#{k}=#{C.escape(v)}; path=#{self/
"/"}"if v!=@k[k]}-[nil];self end;def to_s;"Status: #@status#{Z+(headers.inject([
]){|a,o|[*o[1]].map{|v|a<<[o[0],v]*": "if v&&v.to_s.any?};a}*Z)+Z+Z}#@body"end
end;X=module Controllers;@r=[];class<<self;def r;@r end;def R *u;r=@r
Class.new{meta_def(:urls){u};meta_def(:inherited){|x|r<<x}}end
def D p,m;r.map{|k|k.urls.map{|x|return(k.instance_method(m)rescue nil)?
[k,m,*$~[1..-1]]:[I,'r501',m]if p=~/^#{x}\/?$/}};[I,'r404',p]
end;def M;def M;end;constants.map{|c|k=const_get(c)
k.send:include,C,Base,Helpers,Models;@r=[k]+r if r-[k]==r
k.meta_def(:urls){["/#{c.downcase}"]}if !k.respond_to?:urls}end end;class I<R()
end;self end;class<<self;def goes m
eval S.gsub(/Camping/,m.to_s),TOPLEVEL_BINDING end;def escape s
s.to_s.gsub(/[^ \w.-]+/n){'%'+($&.unpack('H2'*$&.size)*'%').upcase}.tr' ','+'
end;def un s;s.tr('+',' ').gsub(/%([\da-f]{2})/in){[$1].pack'H*'}end
def qsp q,d='&;',y=nil,z=H[];m=proc{|_,o,n|o.u(n,&m)rescue([*o]<<n)}
(q.to_s.split(/[#{d}]+ */n)-[""]).inject((b,z=z,H[])[0]){|h,p|k,v=un(p).
split'=',2;h.u k.split(/[\]\[]+/).reverse.inject(y||v){|x,i|H[i,x]},&m}end
def kp s;c=qsp s,';,'end;def run r=$stdin,e=ENV;X.M;e=H[e.to_hash];k,m,*a=X.D e.
PATH_INFO=un("/#{e.PATH_INFO}".gsub(/\/+/,'/')),
(e.REQUEST_METHOD||'get').downcase
k.new(r,e,m).Y.service(*a);rescue=>x;X::I.new(r,e,'r500').service k,m,x
end;def method_missing m,c,*a;X.M;k=X.const_get(c).new StringIO.new,
H['HTTP_HOST','','SCRIPT_NAME','','HTTP_COOKIE',''],m.to_s
H[a.pop].each{|e,f|k.send"#{e}=",f}if Hash===a[-1];k.service(*a)end end
module Views;include X,Helpers end;module Models;autoload:Base,'camping/db'
def Y;self;end end;autoload:Mab,'camping/mab'end

Name: Anonymous 2008-04-19 19:30

>>43
Is that a C++ template?

Name: Anonymous 2008-04-19 19:33

>>44
Forget it, it's Ruby-complete

Name: Anonymous 2008-04-19 19:52

How did I miss this thread the first time .. I may have even bothered to do something.

Name: Anonymous 2008-04-19 20:00

>>46
This implies yer too busy jerking off and sucking soda or video-gaming.1

1 Die well, kid.

Name: Anonymous 2008-04-19 21:53

10 GOTO 10

Name: Anonymous 2008-06-05 13:56

>>49 PRINT "HALLO WORLD"

Name: Anonymous 2008-06-05 13:56

>>50 GOTO >>49

Name: Anonymous 2008-06-05 14:02

>>51 COME FROM >>49

Name: Anonymous 2008-06-05 22:18

>>999 SAGE FROM >>1

Name: Anonymous 2010-02-24 14:17

/prog/ lost

Name: Anonymous 2010-02-24 14:43

>>53
good thing you told us. now get out.

Name: Anonymous 2010-02-24 14:49

>>54
NO U

Name: Anonymous 2010-02-24 14:54

>>55
i said get, the hell out!

Name: Anonymous 2010-02-24 14:59


Name: Anonymous 2010-02-24 15:11

>>56
NO U

Name: Anon !ynIgG3Rdog 2010-02-24 17:18

a tripcode generator would be nice

Name: Anonymous 2010-02-24 17:26

>>59
That's like 6 lines of C.

Name: Anonymous 2010-02-24 22:50

>>13, 17, 18
Damn. I had the exact same thought.

Name: Anonymous 2011-02-05 19:24

>>60
more like 600

Name: Anonymous 2011-02-05 19:32

>>63
Not counting the memory management.

Name: Anonymous 2011-02-05 19:47

>>60,63

More like 60.

Name: Anonymous 2011-02-06 2:03

I'm not going to write this program, but the most useful thing you can do with 4k bytes is write a small virtual machine that lets you run something more sophisticated.

</thread>

Name: Anonymous 2011-02-06 5:46

<fact>Nk challenges without any direction are lame</fact>

<opinion type="personal">
if anything, we should have a prog.user.js challenge.
</opinion>

Name: Anonymous 2011-02-06 6:20

Ok.


fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)

fac 0 = 1
fac n = n * fac (n-1)


99 characters. I win.

Name: Anonymous 2011-02-06 6:40

If you run this in your HTML-compiler you get a nice swastika:


░░░░░░░░░░░░░░░▄▀▄░░░░░░░░░░░░░░░
░░░░░░░░░░░░░▄▀░░░▀▄░░░░░░░░░░░░░
░░░░░░░░░░░▄▀░░░░▄▀█░░░░░░░░░░░░░
░░░░░░░░░▄▀░░░░▄▀░▄▀░▄▀▄░░░░░░░░░
░░░░░░░▄▀░░░░▄▀░▄▀░▄▀░░░▀▄░░░░░░░
░░░░░░░█▀▄░░░░▀█░▄▀░░░░░░░▀▄░░░░░
░░░▄▀▄░▀▄░▀▄░░░░▀░░░░▄█▄░░░░▀▄░░░
░▄▀░░░▀▄░▀▄░▀▄░░░░░▄▀░█░▀▄░░░░▀▄░
░█▀▄░░░░▀▄░█▀░░░░░░░▀█░▀▄░▀▄░▄▀█░
░▀▄░▀▄░░░░▀░░░░▄█▄░░░░▀▄░▀▄░█░▄▀░
░░░▀▄░▀▄░░░░░▄▀░█░▀▄░░░░▀▄░▀█▀░░░
░░░░░▀▄░▀▄░▄▀░▄▀░█▀░░░░▄▀█░░░░░░░
░░░░░░░▀▄░█░▄▀░▄▀░░░░▄▀░▄▀░░░░░░░
░░░░░░░░░▀█▀░▄▀░░░░▄▀░▄▀░░░░░░░░░
░░░░░░░░░░░░░█▀▄░▄▀░▄▀░░░░░░░░░░░
░░░░░░░░░░░░░▀▄░█░▄▀░░░░░░░░░░░░░
░░░░░░░░░░░░░░░▀█▀░░░░░░░░░░░░░░░

Name: Anonymous 2011-02-06 12:33

>>69
Back to /newpol/, please

Name: Anonymous 2011-02-06 13:01

Even though I'm a couple of years late,

#include <stdlib.h>

int main(int argc, char **argv) {
  int exit_val = 0;

  while (--argc)
    exit_val += system(*++argv) ? 1 : 0;

  exit(exit_val)
}

Name: Anonymous 2011-02-06 13:37

>>71

int main(int argv, char *argv[]) {
  int r;
  for (r = 0; *argv; r += !!system(*++argv));
  exit(r);
}


Or OMG OPTIMIZED:


#include<stdlib.h>
main(int c,char**v){int e;for(e=0;*v;e+=!!system(*++v));exit(e);}

Name: Anonymous 2011-02-06 14:30

>>72
why include entire stdlib?

int system(char*c);main(int c,char**v){int e;for(e=0;*v;e+=!!system(*++v));exit(e);}

Name: Anonymous 2011-02-06 15:32

>>73
Why declaring e?

int system(char*c);main(int c,char**v){for(c=0;*v;c+=!!system(*++v));exit(e);}

Name: Anonymous 2011-02-06 15:34

>>74

int system(char*c);main(int c,char**v){for(c=0;*v;c+=!!system(*++v));exit(c);}

Name: Anonymous 2011-02-06 15:43

>>72
Is undefined.

>>73
exit not declared.

>>74
exit not declared.
e not declared.

Besides, >>71 already meets the space requirements.

Name: Anonymous 2011-02-06 15:51

>>76
e not declared.
>>75
Besides, >>71 already meets the space requirements.
Never say no to premature OMGPTIMIZATION.

int system(char*c);main(int c,char**v){for(c=0;*v;c+=!!system(*++v));return c;}

(It doesn't use exit now because its declaration would make the code longer)

Name: Anonymous 2011-02-06 20:56

>>76
That's not an error, merely a warning

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