Skip to content

Instantly share code, notes, and snippets.

@kragniz
Created August 3, 2012 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kragniz/3251842 to your computer and use it in GitHub Desktop.
Save kragniz/3251842 to your computer and use it in GitHub Desktop.
A2S 2
#!/usr/bin/env python
import itertools
def f(a, b, c, d):
return a*b + b*c + c*d + a*d
greatest = 0
for p in itertools.permutations([1,2,3,4]):
c = f(*p)
if c > greatest:
greatest = c
print greatest
@eric-wieser
Copy link

What is this for? Googling "A2S" gives a malaria thing.

@kragniz
Copy link
Author

kragniz commented Aug 7, 2012

This was a solution for something at a taster day for southampton university. I avoided python hackery for readability, honest!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment