It's a reference to the Church-Turing Thesis, the latter namesake having been persecuted for "homosexual acts" and forced to undergo chemical castration.
There is “no way” to subvert this FizzBuzz interview when writing code in Python 3 only.
def inf_range(a):
while True:
yield a
a += 1
def take(n, it):
return [a for a, b in zip(it, range(n))]
def fizzbuzz():
return (a + b or str(c) for a, b, c in zip(
(a for _ in inf_range(1) for a in (("", "", "Fizz"))),
(a for _ in inf_range(1) for a in (("", "", "", "", "Buzz"))),
inf_range(1)))
print(take(30, fizzbuzz()))
For bonus points: which alphanumeric characters can be changed in the code above?
Is this style in homage to the linked-to page? I can't figure out why you're not using itertools nor re-using itertools names. Is it that translating from .. is that Haskell? .. to Python without idiomatic translation the subversion?
from itertools import islice, cycle
def fizzbuzz():
return (a + b or str(c) for c, (a, b) in enumerate(zip(
cycle(("", "", "Fizz")),
cycle(("", "", "", "", "Buzz")),
), start = 1))
>>> print(*islice(fizzbuzz(), 0, 30))
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz
16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz
I think I can see what you're getting at that you view this as a premature abstraction, but I don't think I'd call it over engineering. I'd call it a stylistic difference.
If `MAGIC` was sufficient to understand what the significance of the number was and `// explanation` was the citation or derivation, then I'd be fine with this, especially if there were a bunch of other constants with explanations with similar derivations or citations (eg a bunch of trig or constants from the same standard); then it'd be preserving a different sort of locality.
If `MAGIC` wasn't sufficient to capture the purpose of the constant & such a name wasn't readily available, so that you're always going to want to read `// explanation` (rather than only in the case you think the value is wrong), then I'd agree with you.
Concrete(ish) examples: if 67 terminated the Foo section of the Bar binary file format, even if we only used it once, I'd prefer to see END_OF_FOO rather than read a comment. Reading comments is context switching, at least for me. Names help me stay in the headspace of the programming language.
If 67 was the result of an ad-hoc calculation which only made sense in the context of this particular program (how many angels can dance on the head of an Acme brand pin executing our trademarked choreography) while, and so there wasn't a great name for that calculation, or at least not a name that would make sense unless you've already read the derivation, then I'd agree in that case.
That being said, I have absolutely seen overengineering or misengineering cause real problems.
At the risk of sounding contrarian, I don’t think it’s mind-boggling at all. There are two types of software engineers out there: those who read to understand, and those who understand to read. What I mean by this is that I find most of my coworkers “read to understand”- they don’t know X (or, more commonly, they don’t understand X and want to prove the person who wrote “X” wrong), so they Google around until they find an SO that supports their stance, or gets them code that does what they want it to do…. Then there are those who understand that to be truly great is to read beyond the minimum needed to achieve the goal, be it to get software to do X, to prove someone wrong in code review, or something else… and to READ for pleasure and to quench the thirst of knowledge. The passionate folk, in other words.
Most of the time you can find out which group a person falls into by whether they read about and write code in their free time. Kind of like leetcode, this litmus test I find has a low false-positive rate, but a relatively high false-negative rate, as there are many passionate engineers who don’t have the time or energy to read and write in their free time (typically a “wife and kids” scenario).
E: in other words, those who code to live vs live to code.
I see where you're going. You never know when MAGIC will be needed and whether or not it will remain constant. It also doesn't scale horizontally. The right answer if you want to be fully robust is to make a Magic microservice that will return the magic number when needed and autoscale on demand. You could have the swagger doc for the service include the explanation.
You're joking, but your description of a prepare-for-any-circumstance mentality summarizes exactly the problem, you never know if MAGIC will be needed or not remain constant, so assuming it will not and making your program structure more complex for it is overengineering.
The best approach if you want to be future-proof while would be to label the instance in-place, so that you can look later for places where #MAGIC is being used, without losing locality:
Everything makes sense to me until the Dual definitions:
newtype Dual a = Dual {getDual :: a}
instance Semigroup s => Dual s where
(Dual a <> Dual b) = Dual (b <> a)
instance Monoid m => Dual m where
mempty = Dual (mempty)
These are declaring instances of Dual, but they are providing method definitions for Semigroup and Monoid as if they were declaring instances for those types. I plugged this into ghc and I couldn't get this to compile either way. This isn't using an extension or some more obscure language than haskell is it?
Likely meant to be lifting instances of Semigroup and Monoid through Dual:
newtype Dual a = Dual {getDual :: a}
instance Semigroup s => Semigroup (Dual s) where
(Dual a) <> (Dual b) = Dual (b <> a)
instance Monoid m => Monoid (Dual m) where
mempty = Dual (mempty)
Gorgeous. I'm not versed well enough in the theory to validate his code, but I know enough to see where he's going with this.
As an aside, there's a lot of rightful complaining about the interview process. I've been on both sides and it sucks either way.
As a hiring manager for a small company, we never had the 'process' that bigger companies have, so it was always a seat of the pants decision. Not my favourite thing to do.
As an interviewee, I've struggled with people's favourite questions, you know the ones that you ask so much that it starts sounding like an easy question in your head?... I'm productive, I ship software but interviewing is so incredibly stressful and always makes me feel like I don't know much.
Anyhow, if I was interviewing the OP for a typical web app CRUD position or monolith to micro services refactor or some other common role, I'd think twice. Clearly he's very smart. Is he able to "deliver value" vs optimizing code? I know the post was tongue in cheek, but in the real interview setting you gotta demonstrate how you're a smart team player and allude to your capabilities. It's kinda like dating I guess. You can't show how much of a real person you're on the first date.
Not everyone has a LinkedIn account, not everyone may know that “Naomi” is usually feminine, and the article run through a textual gender analyser does read as “masculine”.
Mis-stating gender might be careless when as you imply “their” is the always the safe bet, but it’s probably not enough to justify OP’s unduly critical response. He / she or they could have just replied with “I checked their LinkedIn and Naomi’s a girl, btw”.
This man has won the People's Honour Award for climbing the highest mountains on 5 continents and being the first man to reach the north pole solo.
So Naomi is not necessarily a dead giveaway, you guys really split hairs and raise hackles over just about nothing worthwhile. Mistaking someone's sex is not a massive deal.
I used to have on my team a guy named Joan (pronounced joe-an) who spoke really softly, so his potential new employers would call me for a reference asking about "she" and "Joan", I'd gently correct them so as not to embarass him on any phone interview in the future. Nobody needed to throw a fit over an honest mistake.
Coincidentally, that guy was the best programmer I ever employed.
Anyway, just one of many counterexamples to a non-issue.
And this is on top of calling someone else out for presuming something... and here you all are presuming that Naomi is a feminine name.
We're making a mountain out of a molehill here. This is a persistent and pernicious problem in society at large now. What is the actual point of calling out any POSSIBLE perceived remote slight that you really have to perform mental gymnastics in bad faith to even arrive at?
There was no malicious intent on the part of the original poster, and yet they are excoriated for nothing?
What a massive amount of spare time we all have to waste.
Especially when it is a unisex name.
We could be doing something to better our world, and we spend time _on this_. We do it every day on a massive scale. It's so tiring, so wasteful, and so lamentably useless when there are so many useful and actually kind things we could be doing, instead of just virtue-signalling fake empathy on the internet that amounts to nothing.