Using your language of choice, write a function that takes a variable number of arguments and returns the number of arguments it was called with. Your language needs to support variadic argument functions; passing an array does not count. The arguments can be of any type; you do not need to suppo...
CMC: given a nonempty list L of nonempty lists of integers, return a list of integers M such that L and M have the same length, and that M[i] in L[i] for all i.
A certain well-known cable company has a somewhat clumsy 'Search for Program' feature that works through the remote. It takes muchly much button pushing; so, being an admirer of economy of motion, I thought I'd seek out a programmer's help to minimize the number of finger movements I have to make...
Assembly (gcc, x64, Linux), 1 byte
.globl f
f:
ret # c3
Try it online!
The function has to be called with floats as arguments.
This works because, in the x86_64 ABI, the eax register holds the number of vector arguments for varadic function.
I made this simple program to convert infix expression to a postfix one.But I am unable to get the desired results.Please check this program once.I have done that numerous times but failed to find the fault.
A Magic Ritual
code-golf string
Given an input string N perform a sequence of steps.
Delete all spaces from the string.
Delete all second occurrences of the same letter from the string.
If the string contains the letters needed for zero, delete these letters and add the corresponding digit 0 ...
This is an answer-chaining challenge in which each answer builds on the previous answer. Taking no input, you are to output the most recent submission to this thread.
I would HIGHLY suggest sorting by oldest and skipping to the last page to find the most recent answer.
Scoring
This is not code...
Input:
An 2D array A containing two distinct (optional) values.
I'll use 0 and 1 when explaining the rules. The input format is of course flexible.
Challenge:
Zeros are water, and ones are islands. In order to ensure loneliness, your task is to surround all islands with water by inserting ro...
Premise
So recently I was about half an hour early to an appointment, and decided to wait outside. I also determined that it would look strange if I just stood motionlessly in front of the house. Therefore, I decided to go on a quick walk, within a limited area. I also concluded that if I starte...
@cairdcoinheringaahing Ah, right, Jelly doesn't have inverse, even though J does. If there was a single-char inverse in APL or J it would be just two bytes.
@cairdcoinheringaahing Whoa, that's going to be a bit slow for 2432902008176640000.
CMC: Given a list of lists, remove the first number from the first list and remove the last list entirely (don't just empty it out) if and only if the first list begins with 0 and the last list is just 0.
@Fatalize E.g. find me a list of strings such that if I rotate the 2nd and 5th strings by 3 characters I get ["Programming","Puzzles","&","Code","Golf"].
@Adám Question: does codegolf.stackexchange.com/a/161776/12012 actually take a variable number of arguments, or does ≢ simply compute the length of the right argument?
@Dennis See, that's why I hates the challenge. That's exactly the way how I would implement a function taking >2 args in {Jelly,APL,J}, but it doesn't count simply because the standard doesn't call that variadic.
For languages that allow a function to be called as infix and prefix (or infix and postfix): CMC: return how many arguments it was called with, i.e. 1 or 2.
@user202729 A couple of APL solutions, but neither is very elegant: {1⌈⎕NC'⍺'} the max of 1 and the nameclass of the left arg (2 if array, 0 if undef). {6::1⋄2⊣⍺} if value error give 1, try left arg and discard in favour of 2.
Given latitude/longitude of two points on the Moon (lat1, lon1) and (lat2, lon2) in Degree (angle), compute the distance between the two points in kilometre, by using Haversine formula.
Input
Four integer values lat1, lon1, lat2, lon2 in Degree (angle).
Output
Rounded integer distance in kil...
I say that codegolf.stackexchange.com/a/161733/60042 is valid, because the challenges definition of a function is unclear, and shell scripts function exactly the same as functions so a script is essentially a function saved to the disk. I could be convinced otherwise though.
Are there any limits to how many challenges you can have in the sandbox at one time?
Title: The Liquorice All-sort
(I'm going with the British spelling here, because I can... and it has more variety)
I have just invented a new sorting algorithm, which I would like you to implement in the small...
BTW, while loop pop instead of peek. Is that intentional?
And peek the empty stack errors out.
Also not having a floordiv is quite annoying.
(my original plan was to copy the stack to other and print it, then after realizing there is no way to interact between memories (except use a while-loop like BF, but it's a bit slow asymptotically) I switch to try to somehow print all values on the stack without destroying them, then realize there are no stack rotation command, switch to div/mod, realize there is no floordiv, and finally have to use this.)
For a challenge, I recently submitted the JavaScript solution
[].push
To be clear, this isn't x=>[].push. The entry itself is a function: it's the function identified by the JavaScript expression [].push. Is this legal?
Importantly, it wouldn't work to place this function in a different varia...
In this answer, the function is defined as
With(Math)f=(a,b,c,d)=>... (1)
However, f is not used in the function, so it seems fine to write
With(Math)(a,b,c,d)=>...
(the latter one's return value is also the function)
The point is that, you can't write
f = With(Math)(a,b,c,d)=>...
...
I assume you all are interested in a different delimiter? We can go with \$, perhaps. A good next step would be to search existing content to see how many posts would break. — Jon Ericson ♦6 mins ago
What's the correct syntax to search for that? I tried body:"\$" and body:\$ but those don't seem to work
@NathanMerrill Part of it just happened to be that I was the one who bothered to write up the question and Mego was the one who bothered to write up the answer :P
(I know that was an old message, I was just perusing the transcript)
@Dennis do you know if there's a julia type for whole numbers, of either floats or ints?
specifically (x-y problem maybe) I'm trying to make a function that accepts whole numbers of any datatype
I'm trying to throw an error for floats that aren't whole numbers, using throw(MethodError(x, y))
I want to get a custom type-thing for "not-whole-integer", but y is just an example of that datatype (and there's no type that I can find that's what I want)
I have this idea. I need to send data between two devices, but I'm too lazy to implement a proper socket server. The idea is to just write the data to a freenode channel with an obscure name and communicate that way.
I know that this is a godawful idea
But I can't think of any reason why it wouldn't work
Too lazy to implement a proper socket server, so you're going out of your way to program a custom, one-off communication method. Makes perfect sense to me. :p
@Angs I have literally used Github as an image hosting site when I couldn't figure out the imgur API.
@AdmBorkBork The actual thing I'm trying to achieve is actually a bit harder than I described earlier, it involves several (~20) clients connected to one server exchanging messages. I was thinking that it kinda resembled the way a chat system works, so I had the brilliant idea of just borrowing Freenode's functionality.
To be clear, what I'm actual implementing is a game (kinda like pacman), in wihch the player clients communicate their position to the server and the server tells everyone else information like what the map looks like