frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Fizz Buzz without conditionals or booleans

https://evanhahn.com/fizz-buzz-without-conditionals-or-booleans/
17•ingve•5d ago

Comments

stop50•5d ago
Answer: Modulo or adding "%3" and "%5" before masking it
unsnap_biceps•4d ago
Much like stop50's solution, I also used the modulo, but I make use of the terminal to overwrite the number. It's only three lines of code, but I split up the list to be more readable on here.

This works from 1 to 100000000000000000000 before it overflows, and 100000000000000000000 is above the max size of a unsigned 64 bit int, so I feel that it's good enough

    fizzbuzz = [
        "fizzbuzz            ",
        "", "",
        "fizz                ",
        "",
        "buzz                ",
        "fizz                ",
        "", "",
        "fizz                ",
        "buzz                ",
        "",
        "fizz                ",
        "", "" ]
    for n in range(99999999999999999999-30, 100000000000000000000):
        print(f"{n}\r{fizzbuzz[n%15]}")
brudgers•4d ago
No matter how you calculate FizzBuzz, it is bad engineering.

  const Fizzbuzz = "1 2. Fizz, 4 ... "
  Print Fizzbuzz
hyperhello•1h ago
What’s the point of the game without booleans?
LanceH•1h ago
package main

  import (
   "fmt"
   "math/rand"
  )

  var fb [4]string = [4]string{"", "fizz", "buzz", "fizzbuzz"}
  var lucky int64 = 176064004

  func main() {
   for i := 1; i <= 100; i++ {
    if i%15 == 1 {
     rand.Seed(lucky)
    }
    fmt.Printf("%d: %s\n", i, fb[rand.Int63()%4])
   }
  }
frosting1337•25m ago
There's a conditional, though?
bluGill•56m ago
I always wanted to write this with duff's device. switch with fall through is almost never a good thing but it allows for some 'interesting' tricks. Wouldn't be hard, but I have kids so finding half an hour to concentrate is hard.
dullcrisp•48m ago
vim +'exec "norm 99o"|%s/$/\=line(".")/|vert new|exec "norm i\r\rFizz\r\rBuzz\rFizz\r\r\rFizz\rBuzz\r\rFizz\r\r\rFizzBuzz"|exec "norm gg\<c-v>G$y"|bd!|let @q="10a \<esc>\"0gpj"|exec "norm gg10@q"|silent /100/+,$d|silent %s/\d\+\s\+\(\w\+\)/\1'

Now I see it's the same solution as in the post.

HWR_14•36m ago
What's a "disguised Boolean" in this context?
swisniewski•18m ago
Sigh…

Saying the code doesn’t have conditions or booleans is only true if you completely ignore how the functions being called are being implemented.

Cycle involves conditionals, zip involves conditionals, range involves conditionals, array access involves conditionals, the string concatenation involves conditionals, the iterator expansion in the for loop involves conditionals.

This has orders of magnitude more conditionals than normal fizz buzz would.

Even the function calls involve conditionals (python uses dynamic dispatch). Even if call site caching is used to avoid repeated name lookups, that involves conditionals.

There is not a line of code in that file (even the import statement) that does not use at least one conditional.

So… interesting implementation, but it’s not “fizzbuzz without booleans or conditionals”.

somat•8m ago
Enumerating all values probably can't be done in python as that requires some sort of unchecked loop construct, that is a goto or bare loop.

baring that I too got nerd sniped by this and unsatified by the limitations of the authors solution here is my attempt. and when I read up on fizzbuz to make sure I was solving the correct thing. (I was not and my elagent duel state engine was wasted) it turns out the problem solution could be as simple as

    f_out = ['', '', 'fizz']
    b_out = ['', '', '', '', 'buzz']
    
    def fizzbuz(n):
        return(f_out[n % 3] +  b_out[n % 5])
soxfox42•2m ago
That solution fails for any value that is a multiple of neither 3 nor 5. In those cases, the result should be the original number.
cestith•8m ago
What exactly are we counting as “a conditional”? Is it only “if” statements? Do “case” or “switch” statements count? Do loops with loop conditions count? Do all the included functions being abused count for all the conditionals in them? Do short-circuited boolean operations count, or only boolean variables?

I mean, if we want to play fast and loose with those definitions then this also has no conditionals and no booleans.(Warning: Perl, somewhat golfed)

  $s = '', $i % 3 || ($s .= 'fizz'), $i % 5 || ($s .= 'buzz'), $s ||= $i, print "$s\n" while (++$i < 101)

Cloudflare outage on November 18, 2025 post mortem

https://blog.cloudflare.com/18-november-2025-outage/
520•eastdakota•4h ago•325 comments

Gemini 3

https://blog.google/products/gemini/gemini-3/
1219•preek•12h ago•794 comments

Google Antigravity

https://antigravity.google/
740•Fysi•12h ago•777 comments

Show HN: Browser-based interactive 3D Three-Body problem simulator

https://trisolarchaos.com/?pr=O_8(0.6)&n=3&s=5.0&so=0.00&im=rk4&dt=1.00e-4&rt=1.0e-6&at=1.0e-8&bs...
35•jgchaos•12h ago•13 comments

Pebble, Rebble, and a path forward

https://ericmigi.com/blog/pebble-rebble-and-a-path-forward/
344•phoronixrly•10h ago•167 comments

Blender 5.0

https://www.blender.org/download/releases/5-0/
538•FrostKiwi•6h ago•161 comments

Gemini 3 Pro Model Card [pdf]

https://storage.googleapis.com/deepmind-media/Model-Cards/Gemini-3-Pro-Model-Card.pdf
186•virgildotcodes•16h ago•311 comments

The code and open-source tools I used to produce a science fiction anthology

https://compellingsciencefiction.com/posts/the-code-and-open-source-tools-i-used-to-produce-a-sci...
96•mojoe•11h ago•11 comments

Better pre-commit, re-engineered in Rust

https://prek.j178.dev/
14•nikolay•4d ago•1 comments

Rebecca Heineman – from homelessness to porting Doom (2022)

https://corecursive.com/doomed-to-fail-with-burger-becky/
146•birdculture•4h ago•24 comments

Cloudflare Global Network experiencing issues

https://www.cloudflarestatus.com/incidents/8gmgl950y3h7
2325•imdsm•16h ago•1595 comments

Lucent 7 R/E 5ESS Telephone Switch Rescue (2024)

http://kev009.com/wp/2024/07/Lucent-5ESS-Rescue/
29•gjvc•3h ago•10 comments

I am stepping down as the CEO of Mastodon

https://blog.joinmastodon.org/2025/11/my-next-chapter-with-mastodon/
368•Tomte•9h ago•269 comments

Fizz Buzz without conditionals or booleans

https://evanhahn.com/fizz-buzz-without-conditionals-or-booleans/
17•ingve•5d ago•13 comments

GitHub: Git operation failures

https://www.githubstatus.com/incidents/5q7nmlxz30sk
341•wilhelmklopp•7h ago•283 comments

OrthoRoute – GPU-accelerated autorouting for KiCad

https://bbenchoff.github.io/pages/OrthoRoute.html
126•wanderingjew•9h ago•12 comments

What I learned about creativity from a man painting on a treadmill (2024)

https://quinnmaclay.com/texts/lets-paint
32•8organicbits•4d ago•6 comments

Show HN: RowboatX – open-source Claude Code for everyday automations

https://github.com/rowboatlabs/rowboat
68•segmenta•9h ago•15 comments

Bild AI (YC W25) is hiring – Make housing affordable

https://www.ycombinator.com/companies/bild-ai/jobs/m2ilR5L-founding-engineer-applied-ai
1•rooppal•6h ago

Solving a million-step LLM task with zero errors

https://arxiv.org/abs/2511.09030
144•Anon84•11h ago•45 comments

DOE gives Microsoft partner $1B loan to restart Three Mile Island reactor

https://techcrunch.com/2025/11/18/trump-doe-gives-microsoft-partner-1b-loan-to-restart-three-mile...
32•pseudolus•1h ago•14 comments

Monotype font licencing shake-down

https://www.insanityworks.org/randomtangent/2025/11/14/monotype-font-licencing-shake-down
115•evolve2k•5h ago•32 comments

Google boss says AI investment boom has 'elements of irrationality'

https://www.bbc.com/news/articles/cwy7vrd8k4eo
195•jillesvangurp•21h ago•369 comments

Nearly all UK drivers say headlights are too bright

https://www.bbc.com/news/articles/c1j8ewy1p86o
693•YeGoblynQueenne•13h ago•706 comments

Microsoft-backed Veir is bringing superconductors to data centers

https://techcrunch.com/2025/11/12/microsoft-backed-veir-targets-data-centers-for-its-megawatt-cla...
14•sudonanohome•5d ago•2 comments

Short Little Difficult Books

https://countercraft.substack.com/p/short-little-difficult-books
154•crescit_eundo•13h ago•87 comments

Mysterious holes in the Andes may have been an ancient marketplace

https://www.sydney.edu.au/news-opinion/news/2025/11/10/mysterious-holes-in-the-andes-may-have-bee...
40•gmays•6d ago•14 comments

Show HN: A subtly obvious e-paper room air monitor

https://www.nicolin-dora.ch/blog/en-epaper-room-air-monitor-part-1/
41•nomarv•20h ago•10 comments

Trying out Gemini 3 Pro with audio transcription and a new pelican benchmark

https://simonwillison.net/2025/Nov/18/gemini-3/
133•nabla9•8h ago•47 comments

Show HN: Guts – convert Golang types to TypeScript

https://github.com/coder/guts
77•emyrk•9h ago•21 comments