I'm generally not a fan of overly clever-but-fragile solutions like, which cleverly solve the specific problem but can't generalize to problem variants. Like what happened if I asked you to get floor(sqrt(2*length(l)))+1? In most languages it's an easy one-liner (that probably looks like the pseudocode there), but I don't see an easy way to adapt the Prolog you gave me to get the new equation.
I've written about my discomfort with fragile solutions a couple of times before:
I'm generally not a fan of overly clever-but-fragile solutions like, which cleverly solve the specific problem but can't generalize to problem variants. Like what happened if I asked you to get
floor(sqrt(2*length(l)))+1? In most languages it's an easy one-liner (that probably looks like the pseudocode there), but I don't see an easy way to adapt the Prolog you gave me to get the new equation.I've written about my discomfort with fragile solutions a couple of times before: