News for hackers. Stuff that matters.
Re:Tetris in 73 lines of Python by munchor on Sunday April 22, 2012 @07:59AM (#3874633)
This doesn't impress me at all. Python code is supposed to look sexy, and it does, when well-written.

A code of 73 lines with inlined semi-collons is no better than a 200 lines code. In fact, the 200 lines is better if one wants to understand the code.

import pygame,time,random,sys,copy,os;from pygame.locals import ;t2=0;nor=0;pg=pygame;pd=pg.display;cdc=copy.deepcopy;pc=[[[1,1],[1,1]],[[1,0],[1,0],[1,1]],[[0,1],[0,1],[1,1]],[[1],[1],[1],[1]],[[0,1,1],[1,1,0]],[[1,1,0],[0,1,1]],[[1,1,1],[0,1,0]]];cols=[(0,0,0),(100,100,100),(10,100,225),(0,150,220),(0,220,150),(60,200,10),(180,210,5),(210,180,10),(100,200,170)];pg.init();pd.set_mode((320,240),FULLSCREEN);sk=pd.get_surface();f=[[1]+[0 for x in range(8)]+[1] for x in range(19)]+[[1 for x in range(10)]];of=cdc(f);s=12;brt=Rect((100,0,s,s));b=-1;p=[];lc=[-9,0];t=0;bt=60;pg.key.set_repeat(200,100);rh=0;cr=[];crs=pg.Surface((8s,s));crs.fill((255,0,0));crs.set_alpha(100);gv=-1;z=pg.font.Font("c.ttf",14);_=0;pg.mixer.music.load("t.ogg");pg.mixer.music.play(-1)

Is that a proper line of code? No.

Re:Tetris in 73 lines of Python by cabalamat on Sunday April 22, 2012 @09:41AM (#3874787)
> A code of 73 lines with inlined semi-collons is no better than a 200 lines code

You mean: a program of 73 lines with inlined semi-colons is no better than a 200 lines program

Code is a mass noun (as is software, BTW). Program is a count noun.

Re:Tetris in 73 lines of Python by dalke on Sunday April 22, 2012 @11:07AM (#3874988)
As long as we're on a grammar correction theme, "... a 200 line program".
Re:Tetris in 73 lines of Python by munchor on Sunday April 22, 2012 @09:56AM (#3874831)
Indeed, I actually thought about not using 'code' while typing, but then just thought "it shouldn't matter.".
Re:Tetris in 73 lines of Python by zokier on Sunday April 22, 2012 @09:55AM (#3874830)
Well, it expands to 155 lines when newlines are inserted in "normal" places (replacing semi-colons and after if statements mostly). Which is still imho fairly neat.
Re:Tetris in 73 lines of Python by chrisrhoden on Sunday April 22, 2012 @11:55AM (#3875124)
I found an implementation of the entire jQuery API in a single line of javascript!

http://code.jquery.com/jquery-1.7.2.min.js

Re:Tetris in 73 lines of Python by okal on Sunday April 22, 2012 @07:46AM (#3874614)
Took me a while to find a live copy, but here it is. http://read.pudn.com/downloads118/sourcecode/windows/502418/...
Re:Tetris in 73 lines of Python by codesuela on Sunday April 22, 2012 @07:50AM (#3874620)
not to be snarky but adding a few comments wouldn't have increased the LOC

(I'm aware that okal is not the author)

Re:Tetris in 73 lines of Python by okal on Sunday April 22, 2012 @08:27AM (#3874663)
I'm not the author, just something I found while browsing.
Re:Tetris in 73 lines of Python by gghh on Sunday April 22, 2012 @06:49AM (#3874518)
I'd like to upvote this with all my heart, but: I wanted to browse the source with no downloading (ala Github so to speak), nope. Ok, let's follow this link to a zip file: http://jordan.trudgett.com/tetris_73.zip . 404. oh c'mon.
Re:Tetris in 73 lines of Python by Gazler on Sunday April 22, 2012 @07:22AM (#3874571)
I agree, if you are showcasing code, it should be easy to view. Ideally without even having to download anything by letting people view it on Github.
Re:Tetris in 73 lines of Python by tibbon on Sunday April 22, 2012 @09:57AM (#3874835)
Agreed. Who puts code on Hostgator and not Github?
Re:Tetris in 73 lines of Python by andyakb on Sunday April 22, 2012 @09:14AM (#3874741)
it was posted in 2008
Re:Tetris in 73 lines of Python by gjm11 on Sunday April 22, 2012 @12:56PM (#3875344)
Tetris in one line of BASIC: http://survex.com/~olly/rheolism/dsm_rheolism/

(This is BBC BASIC V as found on the Acorn Archimedes machines from way back when. Don't expect it to work in, say, Visual Basic.)

The description calls it "a Tetris-like game". I don't now remember how it diverges from strict Tetris (and don't have a machine handy on which I can check). I think it's very close.

Re:Tetris in 73 lines of Python by dbaupp on Sunday April 22, 2012 @10:18AM (#3874879)
If one is going to deface one's Python by minifying it, it should at least be done properly: I can count at least 8 places where 2 lines can be compressed into 1, like

   if not t%5:
    gv-=1;f[9-gv]=[1]*10;f[10+gv]=[1]*10;t=1
and

   while c+lc[0]<1:
    lc[0]+=1 
So the title could be "Tetris in 65 lines of Python"!
Re:Tetris in 73 lines of Python by DrJokepu on Sunday April 22, 2012 @01:18PM (#3875409)
Tetris in 256 bytes of binary (self-contained, no dynamic linking or libraries) handwritten in assembly: http://pouet.net/prod.php?which=6951
Re:Tetris in 73 lines of Python by bigsassy on Sunday April 22, 2012 @11:18AM (#3875019)
Re:Tetris in 73 lines of Python by tgfcoder on Monday April 23, 2012 @01:03AM (#3877328)
I wrote this in 2008 (when I was 17) while I was bored. Check out nanosnake on the pygame website, it's better :P
Re:Tetris in 73 lines of Python by kuszi on Sunday April 22, 2012 @03:53PM (#3875870)
heh, http://www.spoj.pl/SHORTEN/ - 4all who love codegolfing.
Re:Tetris in 73 lines of Python by makeramen on Sunday April 22, 2012 @09:02AM (#3874721)
Re:Tetris in 73 lines of Python by zokier on Sunday April 22, 2012 @10:49AM (#3874946)