python coding contest

Discussion in 'Python' started by Mark Dickinson, Dec 31, 2005.

  1. Here's a variant of André's brilliant idea that's
    119 characters long, and fully printable:

    j=''.join;seven_seg=lambda z:j(j(' _ | |_ _|_|'
    [ord('^r|=Zm.:v\r'[int(a)])%u*2:][:3]for a in z)
    +"\n"for u in(3,7,8))

    Mark
    Mark Dickinson, Dec 31, 2005
    #1
    1. Advertising

  2. Mark Dickinson wrote:
    > Here's a variant of André's brilliant idea that's
    > 119 characters long, and fully printable:
    >
    > j=''.join;seven_seg=lambda z:j(j(' _ | |_ _|_|'
    > [ord('^r|=Zm.:v\r'[int(a)])%u*2:][:3]for a in z)
    > +"\n"for u in(3,7,8))


    You have an escaped CR (\r) as the last character in your string.

    Here is a 118 character fully printable variant without the \r:

    j=''.join;seven_seg=lambda x:j(j(' _ |_|_ _|
    |'[ord('^rm=3|4:s»'[int(c)])%d*2:][:3]for c in x)+"\n"for d in(3,8,7))

    Note that there is only one non-ascii character in the code.

    However, André's final solution is one character shorter (117).

    -- Christoph
    Christoph Zwerschke, Dec 31, 2005
    #2
    1. Advertising

  3. Mark Dickinson

    Just Guest

    In article <dp4rkq$s45$>,
    Christoph Zwerschke <> wrote:

    > Mark Dickinson wrote:
    > > Here's a variant of André's brilliant idea that's
    > > 119 characters long, and fully printable:
    > >
    > > j=''.join;seven_seg=lambda z:j(j(' _ | |_ _|_|'
    > > [ord('^r|=Zm.:v\r'[int(a)])%u*2:][:3]for a in z)
    > > +"\n"for u in(3,7,8))

    >
    > You have an escaped CR (\r) as the last character in your string.


    Which is perfectly printable.

    > Here is a 118 character fully printable variant without the \r:
    >
    > j=''.join;seven_seg=lambda x:j(j(' _ |_|_ _|
    > |'[ord('^rm=3|4:s»'[int(c)])%d*2:][:3]for c in x)+"\n"for d in(3,8,7))
    >
    > Note that there is only one non-ascii character in the code.


    Which isn't. So I'm not sure what the point is you're trying to make.

    Just
    Just, Dec 31, 2005
    #3
  4. Mark Dickinson

    Just Guest

    In article <4all.nl>,
    Just <> wrote:

    > In article <dp4rkq$s45$>,
    > Christoph Zwerschke <> wrote:
    >
    > > Mark Dickinson wrote:
    > > > Here's a variant of André's brilliant idea that's
    > > > 119 characters long, and fully printable:
    > > >
    > > > j=''.join;seven_seg=lambda z:j(j(' _ | |_ _|_|'
    > > > [ord('^r|=Zm.:v\r'[int(a)])%u*2:][:3]for a in z)
    > > > +"\n"for u in(3,7,8))

    > >
    > > You have an escaped CR (\r) as the last character in your string.

    >
    > Which is perfectly printable.
    >
    > > Here is a 118 character fully printable variant without the \r:
    > >
    > > j=''.join;seven_seg=lambda x:j(j(' _ |_|_ _|
    > > |'[ord('^rm=3|4:s»'[int(c)])%d*2:][:3]for c in x)+"\n"for d in(3,8,7))
    > >
    > > Note that there is only one non-ascii character in the code.

    >
    > Which isn't. So I'm not sure what the point is you're trying to make.


    Duh, sorry, it's early. 118 is better than 119. Printable or not :)
    Still, a 119 bytes version that is fully printable is pretty cool.

    Just
    Just, Dec 31, 2005
    #4
  5. Just wrote:
    > Duh, sorry, it's early. 118 is better than 119. Printable or not :)
    > Still, a 119 bytes version that is fully printable is pretty cool.


    No, you're right, I also somehow missed the point. I believed "»" to be
    "printable" (opposed to control char's) but technically speaking, the
    consensus is that "printable" restricts to 7-bit-ascii (in Python,
    string.printable does not even change if you change the locale setting,
    contrary to string.letters; this is a bit unclear in the Python docs).

    Mark's point was that his solution was purely 7-bit-ascii printable and
    as such it was good although it was one byte more.

    In the next contest, there should be subcategories for solutions that
    are 7-bit-printable and/or have no imports.

    -- Christoph
    Christoph Zwerschke, Dec 31, 2005
    #5
    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:
    692
    Claudio Grondi
    Jan 2, 2006
  2. Simon Hengel

    Re: python coding contest

    Simon Hengel, Dec 25, 2005, in forum: Python
    Replies:
    92
    Views:
    1,409
    Alex Martelli
    Jan 2, 2006
  3. Christian Tismer

    Re: python coding contest

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

    Re: python coding contest

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

    Re: python coding contest

    Tim Peters, Dec 26, 2005, in forum: Python
    Replies:
    0
    Views:
    417
    Tim Peters
    Dec 26, 2005
Loading...

Share This Page