Live data from Hacker News

A non-programmer’s solution to “Fizz Buzz”

nixonmcinnes.co.uk

41–50 of 58 posts

Re: A non-programmer’s solution to “Fizz Buzz”

#41
post #29

What's very interesting here is the SICP-style recursive looping, combined with the fact that the non-programmer doesn't expect to be able to pass variables but rather expects to make stateful queries. That is, the infrastructure expected (here written in JS) is: var query = {}; function print(x) { console.log(x); if (typeof x === "number") { query = {last_num: x, time_since: 1}; } else { query.time_since += 1; } } A…

I wouldn't be so quick in concluding that the long back arrow stands for recursive looping. I'd guess it's just a non-coder notation for "and then do that thing again", for which the closest equivalent in actual language would be the `while` loop (most likely infinite, as the author remarked). I don't see the meta-level of considering the algorithm/procedure as a whole here, a one that is needed for thinking in terms of recursive application.

Furthermore, the fact that non-programmer expects to be able to poll the state of everything around (like the numbers which were already printed) would indicate that in their mind, there is no separation between the program/algorithm and the environment it is executed in. (Ironically, this is completely accurate viewpoint if we're thinking at the level of actual machines, be it real ones or abstract models like Turing machines.)

Re: A non-programmer’s solution to “Fizz Buzz”

#42
post #29

What's very interesting here is the SICP-style recursive looping, combined with the fact that the non-programmer doesn't expect to be able to pass variables but rather expects to make stateful queries. That is, the infrastructure expected (here written in JS) is: var query = {}; function print(x) { console.log(x); if (typeof x === "number") { query = {last_num: x, time_since: 1}; } else { query.time_since += 1; } } A…

I too was struck by the fact that it's essentially an FSM. It's cool that a non-programmer will naturally gravitate towards that structure, while we're forced to spend weeks learning it in upper-level courses...

Re: A non-programmer’s solution to “Fizz Buzz”

#43
post #41
post #29

What's very interesting here is the SICP-style recursive looping, combined with the fact that the non-programmer doesn't expect to be able to pass variables but rather expects to make stateful queries. That is, the infrastructure expected (here written in JS) is: var query = {}; function print(x) { console.log(x); if (typeof x === "number") { query = {last_num: x, time_since: 1}; } else { query.time_since += 1; } } A…

I wouldn't be so quick in concluding that the long back arrow stands for recursive looping. I'd guess it's just a non-coder notation for "and then do that thing again", for which the closest equivalent in actual language would be the `while` loop (most likely infinite, as the author remarked). I don't see the meta-level of considering the algorithm/procedure as a whole here, a one that is needed for thinking in terms…

I think the arrows are being though of as GOTO`s.

Re: A non-programmer’s solution to “Fizz Buzz”

#44

Earlier quoted context omitted.

To be fair when doing front end work you sometimes need to make pretty patterns that do something like "print this table but apply this css class to every other row and one of these other classes to this row if a certain flag is set depending on what the previous class was".

And this is the problem I have with CSS selectors. What you just described is ridiculously fragile and will send shudders down the spine of any developer experienced with wrangling projects that have tangles of inappropriate coupling, but in many cases, there simply isn't a more elegant solution. Your options are: 1. Implement a sane (albeit less powerful) view hierarchy system, foregoing basically all of the CSS sel…

3. Write your site in the form of a program that generates the site itself (or include javascript that generates the relevent pieces.)

Re: A non-programmer’s solution to “Fizz Buzz”

#45
post #17

I don't wish to complain but does that look like an infinite loop to you? Programs are just algorithms, a flow diagram is just a different programming language

It's an infinite loop, and the b variable isn't necessary, but it's interesting to see how a supposed non-programmer is able to structure a (near) solution.

It is actually a complete solution to the problem as stated. The only requirement are that the numbers 1 through 100 are printed, with fizz, buzz, and fizzbuzz replacing them where appropriate. It is not a requirement that that is all that the program does.

Re: A non-programmer’s solution to “Fizz Buzz”

#46
It's always interesting to have a peek at how how non-programmers think. What I dislike about these sorts of posts though, is the comments, where everyone feels like it'd be useful for them to submit yet another trivial Javascript, C or Python FizzBuzz implementation. Congratulations! You can do a basic programming task in a popular language!

Re: A non-programmer’s solution to “Fizz Buzz”

#47

Earlier quoted context omitted.

Me: Really? Is that really a business requirement? Any other requirements you need done? I landed a graduate assistantship in 1992 as "the computer guy's assistant" at my school's physical plant. My first assignment was to generate a fixed format file with one phone number per line. The file was to range from 1-900-0000 to 1-900-999-9999 and was needed by the campus telephone system to block all premium rate calls. T…

I know people who spent at least 40 hours/month just updating dates in monthly/weekly excel reports. Edit: and had 6 figure salaries.

Yes, but if you fuck it up heads are gonna roll.

Re: A non-programmer’s solution to “Fizz Buzz”

#49
I've been thinking a lot lately about what sorts of systems "the rest of us" (where by "us" I mean "them") are able to program effectively.

One thing I've noticed is that people that don't really know programming in a hacker sense seem to have no problem creating a spreadsheet that calculates even fairly complex things (not that FizzBuzz is complicated, but see here: https://docs.google.com/spreadsheet/ccc?key=0AnUa0E6R--UedGd...).

I think one of the biggest factors is that users don't have to keep track of the order of operations. If you change the value in cell A1, and cell B6 depends on it, and D5 depends on it, and so on until you get to Z22, there's no step-by-step thinking about what order the calculations will be done in. Basically a change in the input is instantaneously (and automatically, transparently) reflected in the output.

Another big factor is that all state is made explicit by default.

In some ways it seems similar to functional reactive programming. The code for e.g. FizzBuzz looks crazy complicated (http://www.lejordet.com/2012/01/fizzbuzz-with-reactive-exten...), but if you hooked it together in a GUI (sort of how Quartz Composer works on the Mac) it would probably be pretty easy to wrap your head around, and probably possible for someone with no formal programming knowledge to figure out, if not recreate.

Re: A non-programmer’s solution to “Fizz Buzz”

#50

Boss: I need you to write me a program to print the numbers from 1 to 100 Me: Really? Is that really a business requirement? Any other requirements you need done? Boss: Yes, it's your number 1 priority. No, just 1 to 100 Me: Done. Give it a review and I'll push it live. Boss: No! I said 1 to 100 and everything divisible by 3 should be replaced by "FIZZ". Why didn't you do that? Me: I'm pretty sure you didn't ask for…

Me: Really? Is that really a business requirement? Any other requirements you need done? I landed a graduate assistantship in 1992 as "the computer guy's assistant" at my school's physical plant. My first assignment was to generate a fixed format file with one phone number per line. The file was to range from 1-900-0000 to 1-900-999-9999 and was needed by the campus telephone system to block all premium rate calls. T…

I ended up doing the equivalent so many times I wrote a sequence command that had masks and could increment (count) through arbitrary series of characters (AVF => A, V, F, AA, AV, etc). Good for dataset fills.
Post reply on HN