CSS, 132 116 115 bytes a:not(:last-child):nth-child(n+2):after,a:nth-last-child(n+3):after{content:","}a+:last-child:before{content:"and " <p> <a>one</a> </p> <p> <a>one</a> <a>two</a> </p> <p> <a>one</a> <a>two</a> <a>three</a> &...


APL, 1 byte ⊥ Test it on TryAPL.


Python, 32 bytes lambda n:eval('['*n+'n'+']*n'*n) Try it online! Makes a string like "[[[n]*n]*n]*n" with n multiplcations, and evaluates it as Python code. Since the evaluation happens within the function scope, the variable name n evaluates to the function input.


Jelly, 7 6 bytes _/ị“ḃ» Typing on phone. Will add description. (1,0) goes to A, (0,1) to B, and (0,0) to C. Arrays in Jelly are 1-based, and the indexing function ị works cyclically. Therefore, we can just fold subtraction over the input. _ [vectorized] subtraction _/ Fold subtraction over the input “ḃ» "ABC" ...


APL, 9 bytes ⊢(/⍨)⊢=⌈\ This is a monadic function train with diagram: ┌─┼───┐ ⊢ ⍨ ┌─┼─┐ ┌─┘ ⊢ = \ / ┌─┘ ⌈ The non-train version is {⍵/⍨⍵=⌈\⍵} This basically checks if each element is equal to the running maximum. Note that Martin Büttner's J solution is the same length as this and was posted first.


K, 3 bytes ,// This is a fairly common idiom. "Join over converge". try it here with oK. How it works: Join (,) fuses together atoms or lists to produce a list. Over (/) takes a verb (in this case join) and applies it between each element of a list, left to right. Thus, the compound ,/ will flatten all the top level elements of the list. The symbol / ...


Wolfram Language (Mathematica), 42 bytes #&@@CellularAutomaton[{,{},0{,}},{#,0},0]& Try it online! Cellular automata are indeed the answer to life, the universe, and everything.1 How? CellularAutomaton accepts an input array and an optional background value. Thus, {#,0} specifies that a cellular automaton rule should be applied to the input, ...


JavaScript (ES6), 35 bytes Inspired by @user81655's answer: f=a=>a.map?[].concat(...a.map(f)):a


Jelly, 3 bytes ṭFẠ F flattens the input list. ṭ tacks on the original input list as an element, which is falsy if and only if it is empty. Ạ then checks if any element in the flattened list, or the original list itself, is falsy. (Original answer) FẠ^Ṇ Thanks to Dennis for encouraging finding a solution matching his. FẠ gives 0 if the input contains ...


Python, 29 bytes lambda s:ord(s[-1])-ord(s[0]) The sum of the differences forms a telescopic series, so most summands cancel out and (s1 - s0) + (s2 - s1) + … + (sn-1 - sn-2) + (sn - sn-1) = sn - s0. If taking a byte string as input is allowed lambda s:s[-1]-s[0] will work as well for 19 bytes. Test both on Ideone.


Pyth, 40 36 31 30 bytes Ju.|G^2slHxMf>FT.:Q2Z|tSIxRJQJ Try it online: Demonstration or Test Suite Each of the big test-cases finishes in a couple of seconds. Explanation: First I'll explain the method and why it works. I'll do this with the example list: [7, 2, 13, 9]. The first two numbers are already wrong (7 > 2). We want to xor with some ...


Dyalog APL, 6 2 bytes ⊥⍨ Test it on TryAPL. How it works ⊥ (uptack, dyadic: decode) performs base conversion. If the left operand is a vector, it performs mixed base conversion, which is perfect for this task. For a base vector b = bn, ⋯, b0 and a digit vector a = an, ⋯, a0, b ⊥ a converts a to the mixed base b, i.e., it computes b0⋯...


Python 2, 35 bytes while 1:b=input();print b;True&=b<1 Try it online! Input and output are lines of True/False. Based on Dennis's solution. Redefines the variable True to be False after a True input is encountered. That way, any further inputs of True will evaluate to False and be printed as such. The redefinition is True&=b<1, i.e. True = ...


JavaScript (Node.js), 38 bytes a=>a.map(v=>(n+=v>p&&v-p,p=v),p=n=0)|n Try it online! Simply a greedy algorithm which scan from left to right, only draw lines if needed, and draw it as long as possible. Thanks Arnauld, save 2 3 bytes


awk, 10 bytes Input is expected on STDIN, one number per line. ++a[$1]%$1 Explanation Keeps a counter for each number in an associative array, prints only if the counter value modulo n is not zero. Printing is implicit. Long version: ++a[$1]%$1{print $0}


Pyth, 7 bytes n{Q_{_Q Run the code on test cases. n Check whether the following are not equal: {Q The unique elements in order of first appearance _{_Q The unique elements in order of last appearance (done by reversing, taking unique elts, then reversing again) The only way to avoid surrounding is for the countries' leftmost ...


Jelly, 1 byte x Try it online! Note that this is not the “repeat n n times” built-in — its function is more general than that. For example 4,5,6x1,2,3 equals [4, 5, 5, 6, 6, 6]. Given only one argument, Jelly just happens to use it as both the left and right argument for the supplied link, but this functionality is not inherent to x. If this doesn’t ...


Pyth, 3 bytes !DQ Explanation: Q Input !D Sort by logical NOT Try it here.


J, 4 bytes $~#~ Try it online! Explanation $~#~ Input: integer n #~ Create n copies of n $~ Shape n into an array with dimensions n copies of n


Imperative Tampio, 168 bytes Listan x on riippuen siitä,onko sen ensimmäisen alkion pituus suurempi tai yhtä suuri kuin sen jokaisen alkion pituus,joko sen ensimmäinen alkio tai sen hännän x. Online version Ungolfed: Listan pisin alkio on riippuen siitä, onko sen ensimmäisen alkion pituus suurempi tai yhtä suuri kuin sen jokaisen alkion pituus, joko ...


C (gcc), 88 75 bytes h,e,a;t(int*_){for(h=e=a=0;*_;h+=e>4&a>2)e+=*_>24||(e=a=0),a+=*_++>29;e=h;} Try it online!


APL, 2 bytes <\ Evaluates to the function "scan using less-than". Try it online! Explanation In APL, the operator \ (scan) reduces each nonempty prefix of an array from the right using the provided function. For example, given the array 0 1 0, it computes 0 (prefix of length 1), 0<1 (prefix of length 2) and 0<(1<0) (prefix of length 2) and ...


Python 2 - 18 max(d,key=d.count) Since your python answer doesn't seem to print, I expect this is what you want. Add 6 bytes for print normally.


Jelly, 3 bytes Ṣ.ị Try it online! Sort the array, and then takes the 0.5-th element. Jelly uses 1-indexing, and floating points indexing means take its floor and its ceil. So the 0.5-th element would give you the 0th element and the 1st element. The 0th element is the last element.


MATL, 7 12 11 9 8 6 bytes Thanks a lot to @lirtosiast for removing 2 bytes ud7BXf Truthy is an array of nonzero values. Falsy is empty array (no output displayed). As of release 16.2.0, u is stable by default. So the code needs an extra S to sort the output: uSd7BXf (7 bytes). The link includes this modification. Try it online! u % input array ...


Mathematica, 18 bytes #~TakeWhile~EvenQ& Another glorious built-in that is beaten by a factor of 3 by golfing languages without the built-in...


05AB1E,  8 7  5 bytes Saved 2 bytes thanks to @Adnan 0š¥þO Try it online! How? This is using the algorithm that was first found by @tsh. If you like this answer, make sure to upvote their answer as well! Each time a skyscraper is lower than or as high as the previous one, it can be painted 'for free' by simply extending the brushstrokes. For ...


Javascript, 34 bytes for(r=[b=[i=10]];i--;r[i]=b)b[i]=1 Since it's apparently OK to make the rows equal by reference, I guess it's apparently OK to rely on that fact. This helps us shave off one for-loop by building the table at the same time as its rows. So, here's my new contestant. Since r[0] and b[0] are overwritten during the loop, they can contain ...


J, 31 30 14 12 11 bytes [:;<@|.`</. Ych. Too big. Takes a matrix as input. Explanation J has an advantage here. There's a command called oblique (/.) which takes the oblique lines in turn and applies a verb to them. In this case I'm using a gerund to apply two verbs alternately: < (box) and <@|. (reverse and box). Then it's just a matter of ...


Jelly, 4 bytes ḣ2ṁ⁼ Try it online! How it works ḣ2ṁ⁼ Main link. Argument: A (array) ḣ2 Head 2; truncate A after its second element. If A has two or less elements, this returns A itself. ṁ Mold; cyclically repeat the elements of the previous result to create an array that has the same shape/length as A. ⁼ Test the result for ...

Only top voted, non community-wiki answers of a minimum length are eligible