I used to not like golfing. Now I kinda almost like it. Sometimes people come around
+1 I don't golf, and every time I visited the site (until very recently) the only thing I saw on the front page was golf. This caused me to just plain ignore the site for a long time, and I think many users here see golf as somehow a "better fit" for the site than other challenges/puzzles. — GeobitsMar 3 '14 at 17:11
Oh I know this well. But there are winning criteria that manage to do that. People choose golf because it's the easiest to tack onto a random challenge a lot of the time imo.
@JesterTran :/ no, there appears to be no documented API I think? but Steam can do it so if you install some kind of sniffer you might be able to find out how to do it easily :P
I have array [1,3-9] and
i want this array like [1,3,4,5,6,7,8,9].
if values is repeating then don't show duplicate value. E.g.[1,2,2-5] result:[1,2,3,4,5].
I want to use jquery or MVC.
Following on from this question where it was decided that, as we define languages by their implementation, JavaScript solutions could include a requirement that they be run under a specific domain. This allows us to use, for example, /questions/[id]?site=codegolf instead of //api.stackexchange.co...
@Adám I don't think that's an actual term, but to me most fastest code is pretty much "find this value" or "find this optimal result", not "perform a task as fast as possible"
But hmm depending on I/O format this appears to be pretty easy
@ASCII-only Oh, I didn't realise that. I never participated in a fastest code challenge, given that I mistakenly thought that an interpreted language like APL couldn't compete. It would be on-topic, however, no?
@ASCII-only It would be a challenge where you are simply given a long (KB-MB range) string (by whichever means) that contains about 1% CRLF, and you have to return the string where every CR that is followed by a LF has been removed.
There was a discussion yesterday about the fact that Mathematica is an invalid language for fastest-algorithm as it's time complexity can't be accurately scored. Its functions are essentially black boxes, and because of its pattern matching can vary wildly
however Mathematica would be perfectly valid for fastest-code. You give it a testcase, see how many ms it takes to complete.
@Mayube Right, I think the same applies to Dyalog APL. I might be able to find its time complexity, but AFAIK, few other PPCGers have access to its source code. Also, there are all kinds of special casings going on.
Typically the challenge poser times entries on their own machine, so it's mostly up to you on how much you want entries to able to thrash your processor/gpu/memory/etc.
@Adám It shouldn't be too hard to narrow it down. Do something naive to test various lengths, and assume somebody will find a 100-fold speedup to amaze us all :p
@Geobits Although I guess fastest-code tends to much fewer entries than CG, and that competitive entries mostly will be in C (which I bet APL will beat by a large margin).
You don't really need to bother with deleting that, or requesting extra votes, since the roomba will get it. That said, I don't think it needed to be flagged either.
It creates a dangerous precedent, @Erik, if things like this get posted in chat rooms. It's been a big problem on Stack Overflow, and we did have to create a bunch of strict rules about it, with a lot of moderator oversight.
But anyway, I was mostly just checking up to make sure the flag didn't get validated and cause the user who posted it get kicked, because that's not reasonable either.
also "delete requests" in here aren't that bad, especially since code golf as a place isn't exactly q&a and there are the people who post low-quality questions that really belong to stack overflow (maybe because "programming puzzles") but instead of using stack overflow as a dumping place we delete them here right away
A celebration of the many faces of APL
Given a string among those in column 1 or column 2 of the below table, return the string's neighbor to its right. In other words, if given a string in column 1 then return column 2's string on that row, and if given a string in column 2 then return column 3...
@Mr.Xcoder ñ sorts the array as though each element were passed through a function; a gets the absolute difference between the current element and the integer (V) and g returns the first element of the sorted array.
@Mr.Xcoder I don't know Jelly but, from @HyperNeutrino's explanation, it sounds like his solution is filtering rather than sorting but I'm open to correction on that.
@Adám Pyth, 17 bytes: ,-*QKE*JE=ZE+*JK*Z. The order of the inputs is: a, x, b, y.
@Adám Much more interesting, takes input as nested lists, 23 bytes: .e?k+Fb-F_bc2.>m*Fd*FQ1. Explanation to follow.
*FQ - Cartesian Product; m*Fd - Product of each pair; .>(...)1 - cyclically rotate 1 place to the right (brings the last element to the beginning); c2(...) - Chop into pieces of length 2; .e - Enumerated map, with the variable b representing the current value, and k representing the current index; ?k- If k (is equal 1), then +Fb - get the sum... Wait that can actually be sb :-/... Else -F_b - get the difference of the reversed pair
@Mr.Xcoder Ah, I guess I should explain my code too. Sounds similar to yours: -.× difference of the element-wise products , followed by +.× sum of element-wise product ∘⌽ of the left argument and the reverse right argument.
Is that "reduce over subtraction and multiply with each in list, then pair the product list with the original, swap the two sublists, multiply corresponding elements, and sum"?
×_/: vectorize-multiply the two lists (x), then reduce (/) by subtraction (_) ðṚ×S: new dyadic chain: reverse (Ṛ) then vectorize-multiply the reversed first list with the second list (×) then take the sum (S) ð,: fork ×_/ and ðṚ×S with ð, pair (,)