Google Cached link: http://webcache.googleusercontent.com/search?q=cache:http://...
Which doesn't include the image of the solution since the server hosting the image is down.
A non-programmer’s solution to “Fizz Buzz”
21–30 of 58 posts
Re: A non-programmer’s solution to “Fizz Buzz”
#22I 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
Re: A non-programmer’s solution to “Fizz Buzz”
#23Boss: 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…
Edit: and had 6 figure salaries.
Re: A non-programmer’s solution to “Fizz Buzz”
#24I like how instead of giving a procedure to produce the whole answer he created an induction-style algorithm that, given part of an answer, produces the next output. Looks like "The mathematician's solution to Fizz Buzz"
Re: A non-programmer’s solution to “Fizz Buzz”
#25I like how instead of giving a procedure to produce the whole answer he created an induction-style algorithm that, given part of an answer, produces the next output. Looks like "The mathematician's solution to Fizz Buzz"
Re: A non-programmer’s solution to “Fizz Buzz”
#26Boss: 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…
Sigh.
Re: A non-programmer’s solution to “Fizz Buzz”
#27Earlier quoted context omitted.
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…
This stuff is getting solved, for the particular example you can use n-th child in modern browsers[0]. [0] http://www.quirksmode.org/css/nthchild.html
Imperatively generating and dealing with a DOM structure using simple selector queries is relatively easy to do, as is modeling what is happening in your head. Dealing with more complex CSS rules as they apply to a static (or dynamic but very simple) DOM structure is a little trickier, but not completely unwieldy. When you run into problems is when you try to do both simultaneously. Suddenly you have to not only mentally model a mutable DOM structure, but you have to model how those CSS rules will be applied in a generalized and abstract form. It's not hard to paint yourself into a corner where you'd actually start having to prove theorems about your code in order to be reasonably assured that the CSS will apply correctly.
Of course, hardly anybody actually lets it get that far. Instead, they start applying styles imperatively using JavaScript. And that sucks.
I don't know what the solution to this is, or if there even can be one that is a progression from where we currently are. But I don't think fancier CSS selectors are the answer.
Re: A non-programmer’s solution to “Fizz Buzz”
#28I like how instead of giving a procedure to produce the whole answer he created an induction-style algorithm that, given part of an answer, produces the next output. Looks like "The mathematician's solution to Fizz Buzz"
Re: A non-programmer’s solution to “Fizz Buzz”
#29 var query = {};
function print(x) {
console.log(x);
if (typeof x === "number") {
query = {last_num: x, time_since: 1};
} else {
query.time_since += 1;
}
}
And given all that, they have invented a fizzbuzz() which, as its last statement in each branch, calls fizzbuzz(). I like the way that it's graphically represented but I also think those semantics are quite interesting.Re: A non-programmer’s solution to “Fizz Buzz”
#30I like how instead of giving a procedure to produce the whole answer he created an induction-style algorithm that, given part of an answer, produces the next output. Looks like "The mathematician's solution to Fizz Buzz"
Another way to think about it would be that he defined a little finite-state automaton to compute the answer. You just run the automaton for as many steps as you want, noting down what it outputs each time. I think this is actually very much like what a programmer would write if tasked with solving FizzBuzz in an online streaming fashion (rather than for some bounded n).
Maybe it's just my bias towards functional programming showing, but I actually think this approach is fairly intuitive. In fact, I would have probably come up with something structurally similar (differing only in details).