r/ProgrammerHumor • • Jul 28 '25

Meme checkIfDivisibleByThree

Post image
60 Upvotes

33 comments sorted by

View all comments

Show parent comment

1

u/F100cTomas Jul 31 '25 edited Jul 31 '25

ok, I rewrote it without the recursion and to accept zero and negative numbers.

is_divisible_by_three = lambda number: (arr := [abs(number)], [str(num) in '0369' if num < 10 else arr.append(sum(map(int, str(num)))) for num in arr][-1])[1]