[Edu-sig] [edupython] Python in Education Advocacy Article
Ivan Krstić
krstic at solarsail.hcs.harvard.edu
Tue Mar 27 23:19:14 CEST 2007
Michael Tobis wrote:
> As penance I have reduced it from seven lines to six. This one is
> actually tested.
You know, when confronted with this type of little, one-off problems
before, I used to write Perl code like this:
for (1..5){@d = sort split //,($_+(chomp($_=<STDIN>))*0);
$t=(@d%2)?($d[int(@d/2)]):($d[@d/2-1]);
s/$t/($t<3)?$d[-1]:(($t<6)?$d[0]:(($t<9)?(sub{$s+=$_for(@d);$s%10}->()):0))/e;
print $_+0;}
So when I see code that reads about as easily on a Python list, I think
it might be time to tell people to step back, take a deep breath, and
remember there's a reason they're using Python -- and it's not reducing
the LOC count ;)
--
Ivan Krstić <krstic at solarsail.hcs.harvard.edu> | GPG: 0x147C722D
More information about the Edu-sig
mailing list