We haven't had one in a while so let's have a new coding contest. I'm open to suggestions for the challenge, but if we don't have any good suggestions we will default to something stupid like "implement cowsay in erlang shitty language X".
You have 24 hours from the time that you comprehend the task
This is an honor system designed to give each coder 24 hours, rather than the idea.
Name:
Haxxus the Tetris2009-11-29 0:20
>>41
Well fuck it, I'm starting. Monday at 12:00 AM EST it is.
Name:
Anonymous2009-11-29 0:48
I will not do anything involving tetris, fibs or pong. I might write a mud server. However, I will, in the spirit of this thread, write something I otherwise wouldn't have by Monday at 00:00 EST. (I may or may not post it here.)
Name:
Anonymous2009-11-29 1:36
>>46
I'm writing Tetris. I say we all just do whatever the fuck we want.
>>50
Kind of. I am too crappy of a programmer to have finished my Tetris game by now though.
Name:
Leah Culver!1LEahRIBg.2009-11-29 18:49
Here is a nearly complete version of cowsay implemented in python, although it differs slightly from the original.
* It doesn't support cowthink (although this shouldn't be difficult to add).
* The help returned by -h is sparse and the docstrings non-existant.
* It doesn't support the -l flag which displays the COWPATH as I don't support cowfiles.
* The -f flag opens up a regular file and uses that as a message, whereas the original uses a cowfile instead.
* It keeps the bug/feature of the original in that you can pass in a 1 character tongue string or eye string.
I'm sure there are others and bugs that I haven't found(well, I didn't do any unit tests ;), but there you go. Before you ask, the code is ugly, because I'm lazy and didn't really give a shit.
from optparse import OptionParser
from collections import namedtuple
def chunks(s,n):
l = []
while len(s) > n:
l.append(s[:n])
s = s[n:]
l.append(s)
return l
def strip_extra_whitespace(s):
l = []
prev = False
for c in s:
if c.isspace():
if prev:
continue
prev = True
else:
prev = False
l.append(c)
return "".join(l)
Yeah, I never finished. My goal is to have a pong program and a tetris program done by wednesday, after which I'll make fibbopongtris. Hey, I'll do it, give me a break.
Name:
Anonymous2009-11-29 20:09
>>54
I wasn't expecting you to ;), but I needed to ensure that I kept myself to the deadline (incidentally I posted the code after it, but was finished when I asked) and just so that it doesn't disappear from the front page and our memories.
Name:
Anonymous2009-11-29 21:04
Fully functional Tetris with a touch of Fibonacci. My first FIOC. Shouldn't be too hard to integrate a Pong if you're into that sort of thing.
#!/usr/bin/python
from curses import *
from curses.wrapper import *
import time
import random
def squaresOccupiedBy(self, (type, rotation, (x, y))):
shape = blockShapes[type][rotation]
return [(x+s[0], y+s[1]) for s in shape]
def blockFits(self, newBlock):
for (x,y) in self.squaresOccupiedBy(newBlock):
if x < 0 or x >= self.ncols or y < 0 or y >= self.nrows or self.board[y][x]:
return False
return True
def placeBlock(self, newBlock, allowClear=True):
for (x,y) in self.squaresOccupiedBy(newBlock):
self.board[y][x] = newBlock[0]+1
if allowClear:
self.clearFullRows()
def clearFullRows(self):
ncleared = 0
runStart = None
def clear(start, until):
n = until - start
self.board = [[0]*self.ncols for y in xrange(n)] \
+ self.board[0:start] + self.board[until:]
return n
for y in xrange(self.nrows):
if 0 in self.board[y]:
if runStart != None:
ncleared += clear(runStart, y)
runStart = None
elif runStart == None:
runStart = y
if runStart != None:
ncleared += clear(runStart, self.nrows)
if ncleared:
self.score += 50 * ncleared * (ncleared + 1)
self.maybeLevelUp()
def addGarbageRows(self, count):
self.board = self.board[count:]
for row in xrange(count):
self.board.append([8*random.randrange(0, 2) for x in xrange(self.ncols)])
def drawBoard(self, window):
window.border(0, 0, 32)
window.addch(0, 0, 32)
window.addch(0, 21, 32)
for y in xrange(self.nrows):
for x in xrange(self.ncols):
window.addstr(1 + y, 1 + 2*x, boardSymbols[self.board[y][x]])
if self.falling:
for (x,y) in self.squaresOccupiedBy(self.falling):
if x >= 0 and x < self.ncols and y >= 0 and y < self.nrows:
window.addstr(1 + y, 1 + 2*x, "[]")
def drawPreview(self, window, x0, y0):
for y in xrange(y0 + 1, y0 + 3):
window.addstr(y, x0, " ")
if self.preview != None:
for (x,y) in blockShapes[self.preview][0]:
window.addstr(y0 + y, x0 + 2*x, "[]")
>>61 hma :: Anus -> Anus -> Post
hma you me = post . map toUpper $ you .&. me
Name:
HMA FAN2009-11-30 5:29
>>62
Actually, I'm starting to reconsider the arguments. I don't think "HAX MY ANUS" should be executed by the other poster's anus. Perhaps using the .|. AKA *grabs dick* operator would be be necessary.
>>71
A few hours? Don't you think that's a little extreme? After about 90 minutes you are in severe danger of breaking down mentally and feeling kinda good about it :)