Skip to content

Instantly share code, notes, and snippets.

@davidecavaliere
Created August 5, 2015 13:28
Show Gist options
  • Save davidecavaliere/43610678ebc8a6b28361 to your computer and use it in GitHub Desktop.
Save davidecavaliere/43610678ebc8a6b28361 to your computer and use it in GitHub Desktop.
import itertools;
permutations = itertools.permutations([100,250,1000, 1200]);
times = []
for it in permutations :
print it
presum = 0;
roundTrip = []
sums = [];
for i in range(len(it)) :
el = it[i];
presum += el;
if (i!=0) : roundTrip.append(presum)
print roundTrip
times.append(sum(roundTrip))
print times
print 'minimum time', min(times);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment