>>91160622>I argued that the Clojure solution was not ideal on readability because the toy challenge is most naturally understood to be imperativenot the anons you've been arguing with but i disagree desu
the clojure solution the anon provided reads basically like the description of the challenge
>take 100 random tosses>group them by their outcome>count the groups longer than a given streak sizewhile a clean imperative solution aiming for readability rather than trying to be clever or whatever would look something like this:
from random import randint
tosses = []
toss_count = 100
streak_size = 5
for x in range(toss_count):
tosses.append(randint(0, 1))
curr = tosses[0]
streak_count = 0
group_count = 0
for coin in tosses:
if coin == curr:
group_count += 1
else:
if group_count >= streak_size:
streak_count += 1
group_count = 1
curr = coin
print(streak_count)
there's a lot more noise and implementation details, which may seem more """readable""" if you're used to it, but it's by no means a better representation of the problem. the clojure one does a better job at that hands down.