All pastes #586397 Raw Edit

Stuff

public python v1 · immutable
#586397 ·published 2007-06-23 20:35 UTC
rendered paste body
La prossima volta fammi il piacere di andare in bagno come tutti i mortali... con i giornaletti porno!!! Faithfully, to#!/usr/bin/env python# encoding: utf-8"""undirect.pyCreated by Michele Catasta on 2007-06-23.Checks if a graph contained in a DIMACS .gr file is undirect.Silent output if positive.Usage: python undirect.py FILE_NAME.gr"""import sysimport osdef main():		f = open(sys.argv[1],"r")		# skips comments and additional infos	while 1:		start = f.tell()		header = f.readline()[0:1]				if header != 'a':			pass		else:			f.seek(start)			break		i = iter(f)		# undirectness check	try:		while True:			oddline = i.next()			evenline = i.next()						a1, b1, w1 = [int (j) for j in oddline.split(" ")[1:4]]			b2, a2, w2 = [int (j) for j in evenline.split(" ")[1:4]]						if(a1 != a2 or b1 != b2 or w1 != w2):				print "Given graph IS direct."				break	except StopIteration:		passif __name__ == '__main__':    main()