re: Daily Coding Puzzles - Oct 29th - Nov 2nd VIEW POST

re: The golfiest version would probably be in Dyalog APL - even with newlines: A←1 2 3 ¯4 ¯5 ¯6 X←+/(~A&lt;0)/A Y←+/(~A&gt;0)/A O←X Y Output: O...

I will one day be able to look at APL without my brain leaking out of my ears.

Today is not that day.

This was my first time trying to actually do something with it. It was fun and it still sucked my brains out. (Both of them.)

Oh holy shit! I was looking at it for several minutes and it started making sense! Maybe because I thought through problem with @aspittel , or maybe this APL is more sensible (the last one I saw, someone had spilled a bag of unicode across its source).

I'm using Ruby's comment syntax because IDK how to do it in APL

``````# Haskell uses arrows for assignment in `do` blocks.
# Whitespace delimited numbers are a thing in lisp.
# The high bar looks a lot like a minus sign, so:

A←                 # set into the variable A
A←1 2 3 ¯4 ¯5 ¯6   # the list of numbers: [1, 2, 3, -4, -5, -6]

# Haskell iplements + as a function that you can pass around
# The slash looks like and is used like a shell pipeline.
# Tilde is logical negation in many syntaxes.
# `A` in `A<0` is like SQL, which uses the
# table name to refer to that table's current row.

X←             # set into the variable X
X←+/           # the sum of
X←+/(~         # the numbers which aren't
X←+/(~A<0)/    # negative
X←+/(~A<0)/A   # from the list A

Y←            # set into the variable Y
Y←+/          # the sum of
Y←+/(~        # the variables that aren't
Y←+/(~A>0)/   # positive
Y←+/(~A>0)/A  # from the list A

O←X Y    # set X and Y as the output
``````

maybe this APL is more sensible (the last one I saw, someone had spilled a bag of unicode across its source).

That's the thing with first tries: You mostly write code which is relatively easy to understand. The APL symbol for comments is `⍝`, by the way. And I have no idea how to write it without a Unicode table. ;-)

Thank you for your explanation. I finally understand wtf I was doing. (I know that I could probably have obfuscated it even more, "not negative" is longer than "positive", but I think I still won.)

code of conduct - report abuse