Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > python coding contest

Reply
Thread Tools

python coding contest

 
 
Mark Dickinson
Guest
Posts: n/a
 
      12-31-2005
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,)

Mark
 
Reply With Quote
 
 
 
 
Christoph Zwerschke
Guest
Posts: n/a
 
      12-31-2005
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,)


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
 
Reply With Quote
 
 
 
 
Just
Guest
Posts: n/a
 
      12-31-2005
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,)

>
> 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
 
Reply With Quote
 
Just
Guest
Posts: n/a
 
      12-31-2005
In article <just->,
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,)

> >
> > 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
 
Reply With Quote
 
Christoph Zwerschke
Guest
Posts: n/a
 
      12-31-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
python coding contest Simon Hengel Python 23 01-02-2006 07:45 AM
Re: python coding contest Simon Hengel Python 92 01-02-2006 01:04 AM
Re: python coding contest Tim Peters Python 0 12-26-2005 03:28 AM
Re: python coding contest Christian Tismer Python 4 12-26-2005 02:54 AM
Re: python coding contest Tim Hochberg Python 3 12-26-2005 02:54 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57