Thread: doubt in C--(reducing the length of code)

  1. #31
    Registered User
    Join Date
    Oct 2006
    Posts
    16
    if any body wants to try it..try these two problems....

    http://www.spoj.pl/problems/KAMIL/

    &

    http://www.spoj.pl/problems/SIZECON/

  2. #32
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    I think it would be best if you just stayed out of dumb contests instead.

  3. #33
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Yes, those are DUMB STUPID contests.
    Stay away from them! I MEAN IT!!!
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  4. #34
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Well, they are not that stupid. I also notice that some/most don't have any real size restrictions. 10000 bytes of source code to add up positive integers isn't that bad, is it?

    Well, 256 bytes for the first one (KAMIL) is a bit stupid. I would try that myself, but I don't understand the sample output (should be 2, not 4?!) given the rules. (Otherwise you'd start with 1, loop through each letter and multiply the result by how many ways there is to pronounce this letter?)

  5. #35
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    KAMIL:
    Score

    The score awarded to your program is the number of bytes the source code you submit. The fewer points you score, the better. Submissions are not allowed to exceed 256 bytes.

    Remark. It may turn out impossible to solve this problem in some languages.
    That 256 bytes would include newlines, spaces and tabs!!
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  6. #36
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    They didn't say it needs to be typesafe. I can't think of anything better for the SIZECON contest.
    Code:
    #include <iostream>
    int main(){
        int c,t,b;
        std::cin>>c;
        for(int i=0;i<c;i++){
            std::cin>>b;
            if(c>0){
                t+=b;
            }
        }
        std::cout<<t;
        return 0;
    }
    It's C++.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  7. #37
    Registered User
    Join Date
    Oct 2006
    Posts
    16

    Smile

    @maxorator
    now chk my soln....

    And for all that is a site dedicated for programming...its worth it..it has got the best collection of problems...from easy ones to tough graph algos...

  8. #38
    Registered User
    Join Date
    Oct 2006
    Posts
    16
    @anon

    the sample input is right...the soln is 2^(no of occurances of D+F+L+T)..so it is 4..

  9. #39
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    KAMIL contest is still pure stupidity.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  10. #40
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by nardneran
    @maxorator
    now chk my soln....
    Relax, you may use spaces and newlines.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  11. #41
    C++ Newbie
    Join Date
    Nov 2005
    Posts
    49
    Why do they need to restrict score on source code size?

  12. #42
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Yup, they should check it for standards, typesafety etc.
    I am sure you could find many many such mistakes from almost every entry.
    Code:
    #define b scanf("%d",&
    t,a,n; main(){ for(b t);t--;a+=n*(n>0)) b n); printf("%d",a); return 0;}
    Now, let's rate his code:
    Maximum points 1000
    no header files > -50
    int missing before var names > -100
    confusing use of macros > -50
    int missing before main > -100
    no newlines, spaces nor tabs >-100
    it is not typesafe > -200
    Total points 400

    Hmm... 400 OF 1000... try again!
    Last edited by maxorator; 10-15-2006 at 02:30 AM.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  13. #43
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Bah... cheap imitations.
    Insist on the original.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  14. #44
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    You can never know who was there first...
    There may be hundreds of others too...
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  15. #45
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    IOCCC is the tue origional. They're the champs. Contrary to popular belief, immitation is [i]not[/] the sincerest form of flattery.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange string behavior
    By jcafaro10 in forum C Programming
    Replies: 2
    Last Post: 04-07-2009, 07:38 PM
  2. Can someone help me understand this example program
    By Guti14 in forum C Programming
    Replies: 6
    Last Post: 09-06-2004, 12:19 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM