Personal tools

Eth1winter pygame vexocide

From Eth0Wiki

Jump to: navigation, search

VeXocide's entry (238 chars, score 305)

def AreaMax(i):
 s=0
 for z in range(1,196):
  v,w=z%14,z/14
  t=sum(v*pow(-1,v%2==1) for v in [[map(int,z.split()) for z in i.split('\n')[::-1]][y][x] for x,y in [(v+x%3-1,w+x/3-1) for x in range(9) if x!=4]])
  if t>s:s,c=t,(v+1,w+1)
 return s,c

Edited after the compo, more readable somewhat shorter (233 chars, score 311)

def AreaMax(i,m=0):
  for n in range(196):
    v,w=n%14,n/14
    t=sum(s*(1,-1)[s&1]
          for s in [[map(int,z.split())
                     for z in i.split('\n')[::-1]][y][x]
                    for x,y in [(v+x%3-1,w+x/3-1)
                                 for x in range(9) if x!=4]])
    if t>m:m,c=t,(v+1,w+1)
  return m,c