Re:Subverting the Software Interview
by Kamq on Monday January 16, 2023 @12:10AM
(#34397061)
I always liked the version with no branching statements. In python it would be roughly:
[ Parent
| on HN ]
Here is another version of similar idea. (no loops and no conditions)
fizz_buzz = lambda n : (n == 0) or not fizz_buzz(n-1) or not print(['{}',"fizz","buzz","fizzbuzz"][((n%3)==0)|(((n%5)==0)*2)].format(n))
fizz_buzz(100)
Re:Subverting the Software Interview
by rahimnathwani on Monday January 16, 2023 @11:40AM
(#34402417)
Nice use of bitwise OR
Re:Subverting the Software Interview
by sjadoinqwoeihad on Monday January 16, 2023 @04:38AM
(#34398716)
> 0, 0, 1, 0, 2, 1, 0, 0, 1, 2, 0, 1, 0, 0
I never noticed this symmetry in fizzbuzz before.