
notice the contrast with Zuckerberg's business model stunt :P
A few days ago Thibaut from Vendido introduced me to Springwise a super source of inspiration ... today's latest post is about CitizenShipper, brilliant!
The COlivri privacy policy doesn't take 10 minutes to read. 200h per year for a casual web user baby!
Last but not least, this afternoon I spent some time with Raphael playing with the mastermind implementation (which I fixed it for the second time :P).
Thursday morning Arnaud showed me an Haskell implementation which I found unreadable but wanted to see if I could go more functional in Python ... Where, Why, When and How to Refactor. The least I can say is that I am not impressed but would love to discuss the matter during a Coding Dojo!
def play(self, guess):
""" play return a tuple (correct, misplaced) """
correct = list()
new_secret = list()
new_guess = list()
for index, peg in enumerate(guess):
if self.secret[index]==peg:
correct.append(peg)
else:
new_secret.append(self.secret[index])
new_guess.append(guess[index])
misplaced = list()
for peg in new_guess:
if peg in new_secret:
misplaced.append(peg)
new_secret.remove(peg)
return len(correct), len(misplaced)
def play(self, guess):
""" play return a tuple (correct, misplaced) """
if self.secret == guess:
return len(guess), 0
not_correct = [(s,g) for (s,g) in zip(self.secret, guess) if s!=g]
new_secret, new_guess = map(list, zip(*not_correct))
misplaced = sum(
min(new_secret.count(g), new_guess.count(g))
for g in set(new_guess)
)
return len(guess) - len(not_correct), misplaced
Speaking with Xavier and José about it, the cognitive load of the functional version is probably too heavy for future maintainability ... puzzling :P
At least in the process I learnt how to use the python built-in function zip and why unzip is un-needed in Python (via Matt Wilson).
Last but not least, wonder no more about the difference between simplicity and emptiness, the later is a receptacle for creativity. Kenya Hara may not be the best speaker but ...
blog comments powered by Disqus


