Re: python coding contest

Discussion in 'Python' started by Simon Hengel, Dec 25, 2005.

  1. Simon Hengel

    Simon Hengel Guest

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    > I'm envisioning lots of convoluted one-liners which
    > are more suitable to a different P-language... :)

    I feel that python is more beautiful and readable, even if you write
    short programs.

    > How about """best compromize between shortness and readibility
    > plus elegance of design"""?

    I would love to choose those criteria for future events. But I'm not
    aware of any algorithm that is capable of creating a ranking upon them.
    Maybe we can come up with a solution. Any ideas?

    Cheers, Simon.

    - --
    python coding contest - http://www.pycontest.net/
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.1 (GNU/Linux)
    Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

    iD8DBQFDrtFhd4QlweXdn3ERAn7tAJ9PEpOdqyfDhvHo7+TVy7RravwA/QCg4g9g
    TdCYEDqOsL5qxQarsUI7jow=
    =/KN6
    -----END PGP SIGNATURE-----
     
    Simon Hengel, Dec 25, 2005
    #1
    1. Advertising

  2. On Sun, 25 Dec 2005 18:05:37 +0100, Simon Hengel wrote:

    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    >> I'm envisioning lots of convoluted one-liners which
    >> are more suitable to a different P-language... :)

    > I feel that python is more beautiful and readable, even if you write
    > short programs.
    >
    >> How about """best compromize between shortness and readibility
    >> plus elegance of design"""?

    > I would love to choose those criteria for future events. But I'm not
    > aware of any algorithm that is capable of creating a ranking upon them.



    What is your algorithm for determining "shortest" program? Are you
    counting tokens, lines or characters? Does whitespace count?


    --
    Steven.
     
    Steven D'Aprano, Dec 26, 2005
    #2
    1. Advertising

  3. Simon Hengel

    rbt Guest

    Steven D'Aprano wrote:
    > On Sun, 25 Dec 2005 18:05:37 +0100, Simon Hengel wrote:
    >
    >> -----BEGIN PGP SIGNED MESSAGE-----
    >> Hash: SHA1
    >>
    >>> I'm envisioning lots of convoluted one-liners which
    >>> are more suitable to a different P-language... :)

    >> I feel that python is more beautiful and readable, even if you write
    >> short programs.
    >>
    >>> How about """best compromize between shortness and readibility
    >>> plus elegance of design"""?

    >> I would love to choose those criteria for future events. But I'm not
    >> aware of any algorithm that is capable of creating a ranking upon them.

    >
    >
    > What is your algorithm for determining "shortest" program? Are you
    > counting tokens, lines or characters? Does whitespace count?
    >
    >

    If whitespace and var names count, these things are going to be ugly :)
     
    rbt, Dec 26, 2005
    #3
  4. On Sun, 25 Dec 2005 19:14:43 -0500, rbt wrote:

    > Steven D'Aprano wrote:
    >> On Sun, 25 Dec 2005 18:05:37 +0100, Simon Hengel wrote:
    >>
    >>> -----BEGIN PGP SIGNED MESSAGE-----
    >>> Hash: SHA1
    >>>
    >>>> I'm envisioning lots of convoluted one-liners which
    >>>> are more suitable to a different P-language... :)
    >>> I feel that python is more beautiful and readable, even if you write
    >>> short programs.
    >>>
    >>>> How about """best compromize between shortness and readibility
    >>>> plus elegance of design"""?
    >>> I would love to choose those criteria for future events. But I'm not
    >>> aware of any algorithm that is capable of creating a ranking upon them.

    >>
    >>
    >> What is your algorithm for determining "shortest" program? Are you
    >> counting tokens, lines or characters? Does whitespace count?
    >>
    >>

    > If whitespace and var names count, these things are going to be ugly :)


    Yes, but the question is, is two lines and 347 characters ugly enough to
    win?



    --
    Steven.
     
    Steven D'Aprano, Dec 26, 2005
    #4
  5. Simon Hengel

    Simon Hengel Guest

    > What is your algorithm for determining "shortest" program? Are you
    > counting tokens, lines or characters? Does whitespace count?


    like:
    $wc -c seven_seg.py

    At the moment we have to live with characters, and yes whitespace
    characters do count. Sorry for that.

    Have fun,

    Simon Hengel

    --
    python coding contest - http://www.pycontest.net/
     
    Simon Hengel, Dec 26, 2005
    #5
  6. * Steven D'Aprano wrote:

    > is two lines and 347 characters ugly enough to win?


    Nope. 3 lines / 179 chars here >:->
    Yes, it's quite unreadable.

    (The problem is that I need to find an internet cafe on 28/29th in order to
    be able to submit)

    nd
    --
    my @japh = (sub{q~Just~},sub{q~Another~},sub{q~Perl~},sub{q~Hacker~});
    my $japh = q[sub japh { }]; print join #########################
    [ $japh =~ /{(.)}/] -> [0] => map $_ -> () # André Malo #
    => @japh; # http://www.perlig.de/ #
     
    =?UTF-8?B?QW5kcsOp?= Malo, Dec 26, 2005
    #6
  7. Simon Hengel

    Tim Hochberg Guest

    Steven D'Aprano wrote:
    > On Sun, 25 Dec 2005 19:14:43 -0500, rbt wrote:
    >
    >
    >>Steven D'Aprano wrote:
    >>
    >>>On Sun, 25 Dec 2005 18:05:37 +0100, Simon Hengel wrote:
    >>>
    >>>
    >>>>-----BEGIN PGP SIGNED MESSAGE-----
    >>>>Hash: SHA1
    >>>>
    >>>>
    >>>>>I'm envisioning lots of convoluted one-liners which
    >>>>>are more suitable to a different P-language... :)
    >>>>
    >>>>I feel that python is more beautiful and readable, even if you write
    >>>>short programs.
    >>>>
    >>>>
    >>>>>How about """best compromize between shortness and readibility
    >>>>>plus elegance of design"""?
    >>>>
    >>>>I would love to choose those criteria for future events. But I'm not
    >>>>aware of any algorithm that is capable of creating a ranking upon them.
    >>>
    >>>
    >>>What is your algorithm for determining "shortest" program? Are you
    >>>counting tokens, lines or characters? Does whitespace count?
    >>>
    >>>

    >>
    >>If whitespace and var names count, these things are going to be ugly :)

    >
    >
    > Yes, but the question is, is two lines and 347 characters ugly enough to
    > win?
    >


    No. I have 8 lines and 175 chars at present. And, I expect that's gonna
    get beaten.

    -tim
     
    Tim Hochberg, Dec 26, 2005
    #7
  8. Simon Hengel

    Tim Hochberg Guest

    Is it necessary to keep the input parameter as 'input'? Reducing that to
    a single character drops the length of a program by at least 8
    characters. Technically it changes the interface of the function, so
    it's a little bogus, but test.py doesn't check. (Personally I prefer
    that if be illegal, but if it's legal I'll have to do it).

    -tim
     
    Tim Hochberg, Dec 26, 2005
    #8
  9. Simon Hengel

    rbt Guest

    Tim Hochberg wrote:
    >
    > Is it necessary to keep the input parameter as 'input'? Reducing that to
    > a single character drops the length of a program by at least 8
    > characters. Technically it changes the interface of the function, so
    > it's a little bogus, but test.py doesn't check. (Personally I prefer
    > that if be illegal, but if it's legal I'll have to do it).
    >
    > -tim
    >


    isn't the word 'input' a special word anyway???
     
    rbt, Dec 26, 2005
    #9
  10. Simon Hengel

    Simon Hengel Guest

    > Is it necessary to keep the input parameter as 'input'? Reducing that to
    > a single character drops the length of a program by at least 8
    > characters. Technically it changes the interface of the function, so
    > it's a little bogus, but test.py doesn't check. (Personally I prefer
    > that if be illegal, but if it's legal I'll have to do it).


    You may change input to something more short, like x. Everything that
    passes the test, has a good chance to be accepted.

    Cheers,

    Simon Hengel

    --
    python coding contest - http://www.pycontest.net/
     
    Simon Hengel, Dec 26, 2005
    #10
  11. Simon Hengel

    Justin Azoff Guest

    >>> c=open("seven_seg.py").read()
    >>> len(c)

    251
    >>> len(c.replace(" ",""))

    152

    :)

    Knowing me, I'll forget to submit it.
     
    Justin Azoff, Dec 26, 2005
    #11
  12. On Mon, 26 Dec 2005 02:21:11 +0100, André Malo wrote:

    > * Steven D'Aprano wrote:
    >
    >> is two lines and 347 characters ugly enough to win?

    >
    > Nope. 3 lines / 179 chars here >:->
    > Yes, it's quite unreadable.


    I think Perl coders should be banned from this contest, as they have an
    unfair advantage in that they have more experience with write-only code.

    *grin*


    --
    Steven.
     
    Steven D'Aprano, Dec 26, 2005
    #12
  13. André Malo wrote:

    >>is two lines and 347 characters ugly enough to win?


    > Nope. 3 lines / 179 chars here >:->
    > Yes, it's quite unreadable.


    I'm in for the second place with 4 lines / 228 chars.

    > (The problem is that I need to find an internet cafe on 28/29th in order to
    > be able to submit)


    Do your best! I'd really like to see your code. Right now, 179 chars
    doesn't seem enough for me to write a "Hello world". ;-)

    --
    ==================
    Remi Villatel
    maxilys_@_tele2.fr
    ==================
     
    Remi Villatel, Dec 26, 2005
    #13
  14. Simon Hengel

    Tim Hochberg Guest

    Remi Villatel wrote:
    > André Malo wrote:
    >
    >
    >>>is two lines and 347 characters ugly enough to win?

    >
    >
    >>Nope. 3 lines / 179 chars here >:->
    >>Yes, it's quite unreadable.

    >
    >
    > I'm in for the second place with 4 lines / 228 chars.
    >
    >
    >>(The problem is that I need to find an internet cafe on 28/29th in order to
    >>be able to submit)

    >
    >
    > Do your best! I'd really like to see your code. Right now, 179 chars
    > doesn't seem enough for me to write a "Hello world". ;-)
    >


    I'm down to below 160 characters at this point. And 9 lines, so 22 of
    those characters are leading white space or returns :( I'd really like
    to get down to 150, but I'm having a hard time figuring where I can do
    any more compaction.

    -tim
     
    Tim Hochberg, Dec 26, 2005
    #14
  15. rbt <> wrote:

    > Tim Hochberg wrote:
    > >
    > > Is it necessary to keep the input parameter as 'input'? Reducing that to
    > > a single character drops the length of a program by at least 8
    > > characters. Technically it changes the interface of the function, so
    > > it's a little bogus, but test.py doesn't check. (Personally I prefer
    > > that if be illegal, but if it's legal I'll have to do it).

    >
    > isn't the word 'input' a special word anyway???


    No, just the name of a builtin -- no problem overriding it.


    Alex
     
    Alex Martelli, Dec 26, 2005
    #15
  16. Simon Hengel

    Guest

    Tim Hochberg wrote:

    > No. I have 8 lines and 175 chars at present. And, I expect that's gonna
    > get beaten.



    I wasn't going to get into this, but I couldn't resist :).

    I'm already behind though... 198 characters on 1 line. It's ugly, but
    it works.
     
    , Dec 26, 2005
    #16
  17. Simon Hengel

    Guest

    Currently I'm on 149 characters in <urgh> one line - 128 without
    spaces/newlines. (it'd be three characters shorter if it didn't have
    to end with a "\n")

    -T. "unclean... unclean..."
     
    , Dec 26, 2005
    #17
  18. Simon Hengel

    Peter Otten Guest

    Simon Hengel wrote:

    >> Is it necessary to keep the input parameter as 'input'? Reducing that to
    >> a single character drops the length of a program by at least 8
    >> characters. Technically it changes the interface of the function, so
    >> it's a little bogus, but test.py doesn't check. (Personally I prefer
    >> that if be illegal, but if it's legal I'll have to do it).

    >
    > You may change input to something more short, like x. Everything that
    > passes the test, has a good chance to be accepted.


    How good is "good" for

    import test_vectors
    seven_seg = test_vectors.test_vectors.get

    or code using the test suite in general?

    Peter
     
    Peter Otten, Dec 26, 2005
    #18
  19. Simon Hengel

    anonymous Guest

    <taroso <at> gmail.com> writes:

    >
    > Currently I'm on 149 characters in <urgh> one line - 128 without
    > spaces/newlines. (it'd be three characters shorter if it didn't have
    > to end with a "\n")
    >
    > -T. "unclean... unclean..."
    >


    are you importing zlib or bz2 ?
     
    anonymous, Dec 26, 2005
    #19
  20. Simon Hengel

    Brian Beck Guest

    anonymous wrote:
    > are you importing zlib or bz2 ?


    I don't think either of these would help in this case. While the
    length of the compressed string might be significantly shorter than
    your solution, the resulting string *literal* you decompress will
    contain a bunch of \-escaped characters, so it will end up being longer.
     
    Brian Beck, Dec 26, 2005
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Hengel

    python coding contest

    Simon Hengel, Dec 25, 2005, in forum: Python
    Replies:
    23
    Views:
    713
    Claudio Grondi
    Jan 2, 2006
  2. Christian Tismer

    Re: python coding contest

    Christian Tismer, Dec 25, 2005, in forum: Python
    Replies:
    4
    Views:
    297
    Alex Martelli
    Dec 26, 2005
  3. Tim Hochberg

    Re: python coding contest

    Tim Hochberg, Dec 25, 2005, in forum: Python
    Replies:
    3
    Views:
    293
    Alex Martelli
    Dec 26, 2005
  4. Tim Peters

    Re: python coding contest

    Tim Peters, Dec 26, 2005, in forum: Python
    Replies:
    0
    Views:
    425
    Tim Peters
    Dec 26, 2005
  5. Jean-Paul Calderone

    Re: python coding contest

    Jean-Paul Calderone, Dec 27, 2005, in forum: Python
    Replies:
    2
    Views:
    283
    Tim Hochberg
    Dec 28, 2005
Loading...

Share This Page