Havel-Hakimi

February 19th, 2010

The code is in catalan, but should be self-explanatory.

def comprova(nodes):
    if sum(nodes) % 2 != 0:
      print 'la suma se graus no es parell'
      return 0
    if max(nodes) > len(nodes)-1:
      print 'hi ha un node de grau mes gran que el total de nodes'
      return 0
    if min(nodes) < 0:
      print 'hi ha un node de grau negatiu'
      return 0
    if max(nodes) == 0:
      print 'es un graf correcte'
      return 0
    return 1

# mostra de Butà un hidrocarbó amb fórmula C4H10
nodes = [4,4,4,4,1,1,1,1,1,1,1,1,1,1]
# mostra d'una definició de graf incorrecte
# nodes = [6,5,5,5,5,2,1,1]

while (comprova(nodes)):
  print nodes
  nodes2 = list(nodes)
  nodes.sort()
  nodes.reverse()
  if nodes!=nodes2: print str(nodes) + " ordenat"
  node = nodes.pop(0)
  for i in range(node):
    nodes[i]=nodes[i]-1
print nodes
def comprova(nodes):
if sum(nodes) % 2 != 0:
print ‘la suma se graus no es parell’
return 0
if max(nodes) > len(nodes)-1:
print ‘hi ha un node de grau mes gran que el total de nodes’
return 0
if min(nodes) < 0:
print ‘hi ha un node de grau negatiu’
return 0
if max(nodes) == 0:
print ‘es un graf correcte’
return 0
return 1

nodes = [7,5,4,3,2,2,2]
nodes = [7,6,5,4,4,3,2,1]
nodes = [5,5,3,2,2,1,1]
nodes = [4,3,2,2,2,2,1]
nodes = [6,5,5,5,5,2,1,1]
nodes = [4,4,4,4,1,1,1,1,1,1,1,1,1,1]
while (comprova(nodes)):
print nodes
nodes2 = list(nodes)
nodes.sort()
nodes.reverse()
if nodes!=nodes2: print str(nodes) + ” ordenat”
node = nodes.pop(0)
for i in range(node):
nodes[i]=nodes[i]-1
print nodes

Minotaur’s labyrinth

February 4th, 2010

Minotaur’s labytinth in Python

Minotaure

Read the rest of this entry »

Terrassa Fast motion (Time-lapse)

February 2nd, 2010

Terrassa Time-lapse

Spiders

February 1st, 2010

The other day I saw a very interesting documentary on spiders and although I am taking my finals, I decided to to write some prototypes of what a game would be like.

orbweb

Cologne

January 25th, 2010

I went with Dani to Cologne. Thank God for the european low-cost airlines.

Athens

January 10th, 2010

I’ve had some cultural days in Athens.

Getaway to the south of france

December 27th, 2009

Getaway to the south of france.

Carcasonne

Domains

November 10th, 2009

I’ve accomulated a few domains. Anyone with ideas or an offer, don’t hesitate to contacte me.

BLU7.NET
CABRES.NET
DICE9.NET
KEBEO.COM
MIUIM.COM
OPENMAILID.COM OPENMAILID.INFO OPENMAILID.NET OPENMAILID.ORG
SOLTIC.NET
TOT8.COM
VALLS.NAME
WEBORANGES.COM WEBORANGES.NET
WUMUW.COM
XUWOO.COM

Photos

September 14th, 2009

I’ve selected  a few pictures and I’ve uploaded them to my portfolio along with some panoramas and other Photoshop stuff.

Hope you like them!

Spain’s states and provinces

September 10th, 2009

Spain’s states and provinces for importing into DB.

Read the rest of this entry »