MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vda9j/deleted_by_user/cermwhk/?context=3
r/ProgrammerHumor • u/[deleted] • Jan 16 '14
[removed]
446 comments sorted by
View all comments
Show parent comment
1
If you have an input N to get fizzbuzz for the first N numbers, you should cache first 15 answers in a bitmask like (00, 00, 01, 00, 10, ..., 00, 11) and print buzz for the first bit, fizz for the last bit, the number otherwise
1 u/Ph0X Jan 17 '14 Is that necessary though? The normal algorithm is O(n), which is as good as you can ever hope to achieve. 1 u/sophacles Jan 17 '14 In real life, that constant tends to matter a lot. So do cache misses.
Is that necessary though? The normal algorithm is O(n), which is as good as you can ever hope to achieve.
1 u/sophacles Jan 17 '14 In real life, that constant tends to matter a lot. So do cache misses.
In real life, that constant tends to matter a lot. So do cache misses.
View all comments
Show parent comment
1
u/iopq Jan 17 '14
If you have an input N to get fizzbuzz for the first N numbers, you should cache first 15 answers in a bitmask like (00, 00, 01, 00, 10, ..., 00, 11) and print buzz for the first bit, fizz for the last bit, the number otherwise