Buzz Buzz
- Posted by mariteaux on February 18th, 2020 filed in Sperging
- Comment now »
In better spirits today. Since it’s mostly just VDU as of late, I figured I’d diverge a little from my normal topics and instead talk about something I never do: coding.
I don’t code because I’ve never really had a reason to. Believe me, I’ve long looked for a reason, but at least on the web front, everything I’ve ever wanted to do can either be handled in raw HTML or through WordPress. I’m a simple boy. Still, after reading about how a rather ludicrous amount of programmers can’t do basic tasks, I decided to dig out my old IDE and have a bit of fun with it.
So in case you’re not aware, the “fizz buzz” question is a programming exercise where you count up from one, replacing multiples of three with “fizz”, multiples of five with “buzz”, and apparently, multiples of both with “fizzbuzz”. This is a pretty successful honeypot for programmers who can’t program apparently.
Now, despite not being a coder, I looked at the above Reddit post (which mischaracterizes the “fizz buzz” question as being on multiples of five and ten, serves me right for not looking up arbitrary programming challenges) and dove into, well, really the only language I ever learned, which was BASIC in fifth grade.
Was also pleasantly surprised to see my dialect of choice, Just BASIC, got a new version two years ago, fucking sweet. You don’t know how much time tiny Cammy spent playing with this thing. None of it got saved, thankfully, but it still pleases me when I think about it. (I did some time in QBasic, too, especially on 32-bit Windows machines at camp one year.)
' FizzBuzz
' Proof of concept by Cammy :3c
for a = 1 to 100
' Divide by 5 because we're working on fives
fizzChecker = a/5
' If the fizzChecker returns an integer, it's a multiple of 5 or 10.
' If it's an even integer, it's a multiple of 10, odd is a multiple of 5.
if fizzChecker = int(fizzChecker) then
select case
case (fizzChecker/2 = int(fizzChecker/2))
print "buzz"
case else
print "fizz"
end select
else
print a
end if
next a
I was rather satisfied with my solution until I realized that it was essentially the longhand version of modulo arithmetic, where the remainder of an expression is used for…whatever it’s being used for. I passed Algebra 2 with a 65%, leave me alone, this worked first try.
(Fun fact about modulo, by the way: Pokémon from Gen IV onwards uses it to determine a Pokémon’s characteristic–that little blurb about how the little bastard is “often lost in thought”. This is how even mons from Gen III, which didn’t have characteristics, can have them when imported in through Pal Park.)