Skip to content

Commit 404a489

Browse files
Dev-06-06Copilot
andauthored
Update exercises/1000_programs/medium/1815_fresh_donuts.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent a92ce9c commit 404a489

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎exercises/1000_programs/medium/1815_fresh_donuts.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def dfs(current_rem, counts):
3737

3838
for i in range(1, batchSize):
3939
if counts[i] > 0:
40-
new_counts = list(counts)
41-
new_counts[i] -= 1
40+
# Create a new tuple state with counts[i] decremented, avoiding list conversion
41+
new_counts = counts[:i] + (counts[i] - 1,) + counts[i + 1:]
4242

4343
is_happy = 1 if current_rem == 0 else 0
44-
res = is_happy + dfs((current_rem + i) % batchSize, tuple(new_counts))
44+
res = is_happy + dfs((current_rem + i) % batchSize, new_counts)
4545
max_val = max(max_val, res)
4646

4747
return max_val

0 commit comments

Comments
 (0)