@LeakyNun Arrays are stored on the stack. The size of anything on the stack must be known at compile time, otherwise you can't get the return address, etc.
@LeakyNun Calls to printf and I/O functions are done at runtime, of course. Function bodies will sometimes be inlined if they are sufficiently small, but generally they are called at runtime as well. C optimization in most compilers is pretty aggressive.
@LeakyNun No, but it's "optional implementation" which means that your code is no longer portable across compilers/versions.
Not that C was portable anyways.
@LeakyNun Because "[sizeof] is one of the few exceptions to the rule that the name of an array is converted to a pointer to the first element of the array".
So if you use the array variables in an expression, they just mean pointers.
But if you use the names in sizeof, it means something different.
> L <pfn> <n-1:any> <col> Left map. n>=2. Map A(B, ..., _) over C, where _ is the lambda variable. Map uses m underneath, and B may refer to its lambda variable.
CMC: Reduce by ternary. Given an odd length sequence of 0s and 1s, replace the first 3 numbers by the second one if the first is 1, and the third one if the first is 0. Repeat until there is one number, then return that number. For instance, [0, 0, 1, 1, 0] -> [1, 1, 0] -> 0.
@isaacg I don't get you CMC: I have [0, 0, 1, 1, 0]. The first 3 numbers are 0,0,1. The first is 0, so I replace them all with the third: 1,1,1. I get [1,1,1,1,0].
Pyth, 10 8 bytes
O+<Q2*2t
Uses the exact same algorithm as is @JonathanAllan's Python answer.
Try it online! (I have the same test case multiple times such that you can see it's random)
Explanation
O - Takes a random element of the String made by appending (with +):
<Q2 - The first tw...
@isaacg You must pick a random character from a string that has the first char repeated once, the second repeated thrice and the other two repeated twice each
@isaacg Consider making it a test suite with the same string multiple times, such that people can see it's random. And because it's a brilliant idea, consider adding a good explanation to it.
Pyth, 7 bytes
@z|O8 1
Test suite
O8 generates a random number from 0 to 7. | ... 1 applies a logical or with 1, converting the 0 to a 1 and leaving everything else the same. The number at this stage is 1 2/8th of the time, and 2, 3, 4, 5, 6, 7 or 8 1/8 of the time.
@z indexes into the input ...
I'm pretty sure there's not a better way to do this but figured it couldn't hurt to ask.
I'm tired of typing out a='abcdefghijklmnopqrstuvwxyz'.
Cool languages have Range('a'..'z') or similar
What can we come up with with JS that's as short as possible??
for(i=97,a='';i<123;){a+=String.fromCh...
Problem
Given input a where a is a grid of characters in any input format as long as it has only one element for each 'block' of the output.
And input b where b is a grid of numbers the same size as input a.
There are two types of road, a 1 represents a stone road marked by @ and a 2 represent...
The answer to life, the universe, and ASCII-art
Simple challenge: try to output the following text in as few bytes as you can:
the answer
toli fetheuniv
ersea nde ver
ything the ans
wer tol ife the
uni ver sean
dev ery...