Is my integer significant? Your task is to write a function that takes an even-digit integer and compares the 2 halves of the integer. If the sum of the digits in the first half is greater than the sum of the digits in the second half, output a truthy value, otherwise, output falsey.

For example:

12345678
1234 5678
(1+2+3+4)>(5+6+7+8)
10>26

Output falsey

Input

A single integer.

This must be passed as a single whole integer in base 10, a single string, an array of integers, or an array of characters. Please specify which format your answer accepts
The input can be passed via Command Line Arguments, STDIN, or any other standard method of input supported by your language
Assume the input will always have an even digit count
Assume the input will always be positive and greater than 0
Assume the input will be within feasible number handling capacities for your language
The input will not contain leading zeroes

Output

A truthy value if the sum of the digits in the first half is greater than the sum of the digits in the second half.

A falsey value if the sum of the digits in the first half is less than or equal to the sum of the digits in the second half.

Test cases

Input > Output

12345678 > False
87654321 > True
12344321 > False
12 > False
214758392639543385 > False
1001 > False
100000 > True

Scoring

This is code-golf so fewest bytes wins.

Brachylog, 5 bytes

ḍ+ᵐ>₁

Try it online!

How it works

ḍ+ᵐ>₁                     example input: 12345678
ḍ        split in half                   [[1,2,3,4],[5,6,7,8]]
 +ᵐ      sum each half                   [10,26]
   >₁    results in a decreasing list    false


Java Package Correction I have a lot of java projects and I am often making new ones. I have a few helper classes (Vector, Logger, etc.) and it takes a lot of time correcting the first line to the correct package, I would really need a little program to help me fix it automatically.

Your program will first take the name of the package the files are moved to (eg. com.google.raycasting), after that each file with ****<FILENAME>**** between them. You read the input however you want (STDIN, program arguments, file, etc.).

When an EOF is reached, the program should output each file in the same way as in the input, but with the package declaration changed.

Example:

Input:

com.loovjo.tetris
****Vector.java****
package com.loovjo.someoldproject;
class Vector {
    public Vector (int x, int y) {
        System.out.println(x + ", " + y);
    }
}
****Logger.java****
package com.loovjo.someoldproject;
class Logger {
    public String name;
    public Logger(String name) {
        this.name = name;
    }
}

(Of course these aren't the real files.)

Output:

****Vector.java****
package com.loovjo.tetris;
class Vector {
    public Vector (int x, int y) {
        System.out.println(x + ", " + y);
    }
}
****Logger.java****
package com.loovjo.tetris;
class Vector {
    public Vector (int x, int y) {
        System.out.println(x + ", " + y);
    }
}

Further specification on Input/Output:

The package declaration will not always be on the first line, the input may contain some newlines/spaces before it. If this is the case, those characters must be there in the output.
The files in the input will always have correct syntax.

Remember, this is Code Golf, so the shortest code wins!

Mathematica, 106 bytes
StringReplace[Rest@#~StringRiffle~"\n","package "~~__~~";"->"package "<>#[[1]]<>";"]&@StringSplit[#,"\n"]&

Works by splitting the string into its lines and returning all but the first line with any package declarations replaced with the new package.


Piem validator programme Write a program that defines a function that can check if a string variable called "anything you want or inputted by the user" is or not a piem.
(piem =  a story or poem in which the word lengths represent the digits of π (from Wikipedia))

Some examples:

myfunction("I am clearly wrong") # False
myfunction("How I want a drink, alcoholic of course, after the heavy lectures involving quantum mechanics") #True (Taken from Wikipedia)
myfunction("Law ' s fine") # True

You should delete any kind of punctuation or newline before processing.
Pure code golf, the shortest wins

End date: evening of 1/10/2014

Various answers

How many digits do we need to handle? More than 10
As a matter of interest, how should 0's in PI be interpreted? Skipped or 10 letter words? As 10 letters words
"a variable called piem" – so the name of the parameter must be piem? No, it hasn't, question text corrected
A fun bonus might be a solution that is itself a piem If your solution is a piem you get *0.5 bonus
For the sake of argument, is _ always punctuation? You can decide if it is punctuation or if it isn't
It's unclear what is meant by "any kind of punctuation" I mean ,.'"?!;;()
So digits should be counted? And Law's fine would be false? Digits should be treated as letters, Law's fine = False; Law ' s fine = True

Comments

The APL solution should be counted in Bytes
If your solution works for 100+ digits of pi you get *0.8 bonus
Because of the great interest the end date is one day more in the future.


Maximal saturated domino covering of a rectangle Inspired by this OEIS entry.
Background
A saturated domino covering is a placement of dominoes over an area such that

the dominoes are completely inside the area,
the dominoes entirely cover the given area,
the dominoes may overlap, and
removal of any domino reveals an uncovered cell (thus failing to satisfy condition 2).

The following is an example of a maximal such covering of 3 × 3 rectangle (since dominoes may overlap, each domino is drawn separately):
AA.   B..   ..C   ...   ...   ...
...   B..   ..C   .D.   ...   ...
...   ...   ...   .D.   EE.   .FF

Challenge
Given the dimensions (width and height) of a rectangle, compute the maximum number of dominoes in its saturated domino covering.
You can assume the input is valid: the width and height are positive integers, and 1 × 1 will not be given as input.
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
A193764 gives the answers for square boards. The following test cases were verified with this Python + Z3 code (not supported on TIO).
Only the test cases for n <= m are shown for brevity, but your code should not assume so; it should give the same answer for n and m swapped.
n m => answer
1 2 => 1
1 3 => 2
1 9 => 6
1 10 => 6
2 2 => 2
2 3 => 4
2 5 => 7
3 3 => 6
3 4 => 8
3 7 => 15
4 4 => 12
4 7 => 21

Sagemath, 60 bytes
lambda m,n:m*n-len(graphs.GridGraph([m,n]).dominating_set())

Try it online!

From Saturated Domino Coverings by Buchanan et al:

Corollary 6.3: If \$B\$ is a rectangular \$m \times n\$ board, then \$d(B) = |B| - \gamma(G_{m,n})\$.

Where \$\gamma(\ldots)\$ is the domination number and \$G_{m,n}\$ is a grid graph. We also clearly have that if \$B\$ represents an \$m\times n\$ board then \$|B| = mn\$.


Degree of Unsaturation Degree of Unsaturation

This is not a particularly hard code puzzle - but I'm interested to see your multiple ways of solving it.

The Degree of Unsaturation is the number of double chemical bonds between atoms, and/or the number rings in a chemical compound.

You will be given the molecular formula of a chemical compound in the form XaYbZc (where a, b and c are the number of atoms of X, Y or Z in the compound) - the formula could be of any length and contain any chemical element in the periodic table (though elements other than C, H, N, F, Cl, Br, I may be ignored as they do not feature in the formula). The compound will contain at least one atom of carbon. You must calculate and display its Degree of Unsaturation.

For example, the compound benzene (pictured below) has a DoU of 4 as it has three double bonds (shown by a double line between atoms), and a single ring (a number of atoms connected in a loop):

As defined by LibreTexts:

  DoU = (2C + 2 + N − X − H ) / 2

Where:

C  is the number of carbon atoms
N  is the number of nitrogen atoms
X  is the number of halogen atoms (F, Cl, Br, I)
H  is the number of hydrogen atoms

Test cases:

C6H6 --> 4
C9H2O1 --> 0
C9H9N1O4 --> 6
U1Pt1 --> Not a valid input, no carbon
Na2O1 --> Not a valid input, no carbon
C1H1 --> 1.5, although in practice this would be one, but is a part of a compound rather than a compound in entirety.
N1H3 would return 0 - though in practice it isn't an organic compound (in other words it contains no carbon) so the formula wouldn't apply and it isn't a valid input

For an explanation of CH see here

In essence, you must identify if there are any of the above elements (C, H, N, F, Cl, Br, I) in the compound, and if so how many there are. Then, calculate the Degree of Unsaturation using the above formula.

Only C, H, N, F, Cl, Br, and I are valid inputs for the DoU formula. For the purposes of this puzzle, any other elements may be completely ignored (eg if the compound were C6H6Mn the result would still be 4). If there are none of the above compounds the answer would be zero.

You may assume that all the compounds input are chemically possible, contain at least one atom of carbon, and are known to exist. If the input is invalid, the program may output either 0 or -1, or produce no result.

Rules

Standard IO rules and loopholes apply. Input must be a standard string, and you can assume the input won't be empty. This is codegolf - so the shortest code in bytes wins.

Python 3, 142 151 148 bytes

import re
l=dict(re.findall("(\D+)(\d+)",input()))
m=lambda k:int(l.get(k,0))
print(m("C")and m("C")+1+(m("N")-sum(map(m,"F I H Cl Br".split())))/2)

Returns 0 on error.

Thanks to @HyperNeutrino bringing the bytes down.

Try it online!


Am I a Secondary Taxicab? Background
Ramanujan's number, \$1729\$, is called a taxi-cab number due to the (possibly apocryphal) tale of Hardy boarding a cab to visit Ramanujan in hospital having this number, which seemed bland to him.
It's since known as the most famous of a class of integers known as "taxicab numbers" which are expressible as the sum of two \$n\$th powers (of positive integers) in two (or sometimes \$k\$) different ways.
\$1729\$ is the smallest natural number expressible as the sum of 2 cubes in 2 different ways, making it the first \$3,2\$ taxicab number (\$n,k\$ being general).
Challenge
Given a number, decide whether it is a \$3,2\$ 'secondary taxicab number' - meaning it fulfils the same constraint as \$1729\$ (2 unique sums of cubes), but does not have to be the smallest such integer of the \$3,2\$ class (that being 1729, of course).
Example cases
$$1729 = 10^3 + 9^3 = 12^3 + 1^3 \\
4104 = 15^3 + 9^3 = 16^3 + 2^3 \\
13832 = 2^3 + 24^3 = 18^3 + 20^3$$
As well as \$20683, 32832, 39312...\$
Scoring
This is code-golf, so the shortest answer in each language wins.

Rough Matlab code to find other cases by brute force:
for k = 1729:20000
    C = sum(round(mod(real((k-[1:ceil(k^(1/3))].^3).^(1/3)),1)*10000)/10000==1);
    if C > 1
        D = (mod(C,2)==0)*C/2 + (mod(C,2)==1)*((C+1)/2);
        disp([num2str(k),' has ',num2str(D),' solns'])
    end
end

Jelly, 9 bytes

Credits to Erik the Outgolfer.

Œċ*3S€ċ>1

Try it online!

This is too slow that it won't even work for 1729 online.

Much faster, 12 bytes

Credits to Dennis.

R*3fRŒċS€ċ>1

Try it online!


Crossword grid verification Validate a proposed crossword grid.

Entries should be full programs that simply test a proposed grid
to determine if it meets a set of conditions for making crossword
solvers happy.

Input

The input will be the name of a file representing the crossword
grid. The input filename may be passed as an argument, on the
standard input, or by other conventional means other than
hardcoding.

Grid file format: The first line consists of two white-space
separated integer constants M and N. Following that line are M
lines each consisting of N characters (plus a new line) selected
from [#A-Z ]. These characters are interpreted such that '#'
indicates a blocked square, ' ' a open square in the puzzle
with no known contents and any letter an open square whose
containing that letter.

Output

The program should produce no output on valid grids and exit with
normal termination state. If the proposed grid fails, the program
should produce a diagnostic error message and exit with a
abnormal termination state (i.e. not 0 on unix) if this is
supported by your execution environment. The error message should
indicate both which condition for validity is violated and the
location of the offending square; you are free to chose the means
of conveying these facts.

Conditions for validity

Valid grids will have no answers (across or down) that are only 1
character long (extra credit for making the minimum length a
input parameter), and will exhibit the usual symmetry. The usual
symmetry means the crossword remains the same after (three
equivalent descriptions of the same operation):

reflection through it's own center
reflection both vertically and horizontally
180 degree rotation

Test input and expected output

Passes:

5   5
#  ##
#
  #
    #
##  #

Fails on short answer:

5   5
## ##
#
  #
    #
## ##

Fails on symmetry:

5   5
#  ##
#
  #
#   #
##  #

Aside

This is the second of several crossword related challenges. I
plan to use a consistent set of file-formats throughout and to
build up a respectable suite of crossword related utilities in
the process. For instance a subsequent puzzle will call for
printing a ASCII version of the crossword based on the input and
output of this puzzle.

Previous challenges in this series:

Crossword numbering

Ruby - 215 207

t,*d=$<.map &:chop;n,d,e=t.size+1,(d*S=?#).gsub(/[^#]/,W=" "),->c,i{puts [c,i/n+1,i%n+1]*" ";exit 1}
0.upto(d.size-1){|i|d[i]==d[-i-1]||e[?R,i];d[i]==W&&(d[i-1]!=W&&d[i+1]!=W||d[i-n]!=W&&d[i+n]!=W)&&e[?L,i]}

Ungolfed:

h, *g = $<.map &:chop
w = h.size+1
g = (g*?#).gsub(/[^#]/," ")
error = ->c,i{ puts [c,i/w+1,i% w+1]*" "; exit 1 }
0.upto(size-1) { |i|
        error[?R, i] if g[i] != g[-i-1]
        error[?L,i] if g[i]==" " && (g[i-1]!=" " && g[i+1]!=" " || g[i-w]!=" " && g[i+w] != " ")
}

.

h, *g = $<.map &:chop

This basically removes the last char (line break) of each input line by calling the chop method on them, and returning an array of the results.

h takes the first element of this array and *g takes the rest. So we end up with the first line in h and the crossword grid lines in g.

g = (g*?#).gsub(/[^#]/," ")

g*?# joins (*) the array g with the "#" (?# is a character literal). This is the same as g.*("#"), or g.join("#"). Then every non # is replaced by a space.

For the symmetry check we just have to check if the char at every index is equals to the char at the opposite index in the string:

0.upto(g.size-1) { |i| if g[i] != g[g.size - i - 1]; error() }

In Ruby we can index strings from the end using negative indexes (starting from -1 instead of 0), so that g[-i-1] is the opposite of g[i] in the string. This saves a few chars:

0.upto(g.size-1) { |i| if g[i] != g[-i-1]; error() }

We can save a ; by using a conditional statement:

0.upto(g.size-1) { |i| error() if g[i] != g[-i-1] }

In the golfed version we can save a few more chars:

0.upto(g.size-1){|i|g[i]==g[-i-1]||error()}

In a previous version I used recursion for iterating over the string:

(f=->i{g[i]&&f[i+1]&&g[i]!=g[-i-1]&&error()})[0]

An out of bound access to g returns nil, so once g[i] returns nil, this stops the iteration.

Output format:

{ L | R } line-number column-number

L for length errors, and R for rotation error (so L 1 2 means length error at line 1, column 2)


Roll for Initiative! Roll for Initiative!

Introduction

In tabletop games like Dungeons and Dragons, when you begin a battle, all involved parties roll for initiative. In DnD 5e, this is 1d20 + DEX + Other bonuses, where DEX is the bonus given by your Dexterity stat. The characters that roll higher numbers go first. We'll use a similar, deterministic system in this challenge.

The Challenge

Write a program or function that, when given a list of characters, will output a list of characters in order of initiative.

A character is defined as this:

character = {
    name: "name" // a string
    statblock: [SPD, DEX, WHT] // a list of numbers
                               // DEX = dexterity, SPD = speed, WHT = weight
}

The formula for initiative is the following:
$$\text{Initiative} = \left\lfloor{ \frac{\text{SPD}^2}{\sqrt{\lvert\text{DEX}\rvert}} }\right\rfloor - \text{WHT}$$

Input

A list of characters, unsorted. This can be a JSON object, a list of lists, a list of dictionaries, a series of strings etc.

It is guaranteed that all names will be unique.

Output

A list of characters, or character names, sorted by initiative order from highest to lowest, based on the above formula.

Rules

IO can be used with any convenient method.
Standard loopholes are forbidden.
This is code-golf, so smallest program wins!

Sample IO

Input --> Output
[[Name, SPD, DEX, WHT], ...]
    --> [[Name, SPD, DEX, WHT], ...] (or [Name, Name, ...])
---------
[[Alice,1,2,3],[Bob,10,5,0],[Charlie,3,2,1]]
    --> [Bob, Charlie, Alice]
// Alice = -3, Bob = 44, Charlie = 5

[[Z,1,1,1],[B,1,1,1],[XY,5,1,1]]
    --> [XY, Z, B]
// Retain the order of characters from the input if they have the same initiative.
// Z = 0, B = 0, XY = 24

[[Neg,-3,-3,-1],[SomeNeg,5,-2,-4],[NoNeg,4,6,8]]
    --> [SomeNeg, Neg, NoNeg]
// Negative values are valid.
// Neg = 6, SomeNeg = 21, NoNeg = -2

[[Flo,1.5,2.5,3.5],[MoreFlo,2,2.5,3.5]]
    --> [[MoreFlo,2,2.5,3.5], [Flo,1.5,2.5,3.5]]
// Floats are also valid.
// Flo = -2.5, MoreFlo = -1.5

[[Lonely,1,2,3]]
    --> [[Lonely,1,2,3]]
// Input with 1 item.

[]
    --> []
// Empty input leads to empty output.

[[Foo,2,1,4], [Baz,5,5,4], [Bar,5,1,4]]
    --> [Bar, Baz, Foo]
// Foo = 0, Bar = 21, Baz = 7

[['Adam', 2, 4, 1], ['Eve', 2, 3, 1]]
--> [Adam, Eve]
// Adam = 2, Eve = 2
// If you do not floor, you'll end up with [Eve, Adam] (Adam = 2, Eve ~= 2.3)

Sandbox link

JavaScript (ES7),  73  60 bytes
-13 bytes by just sorting the input without isolating the names, as suggested by @asgallant
Expects a list of [SPD, DEX, WHT, Name].

a=>a.sort((a,b)=>(g=([s,d,w])=>~(s*s/(d*d)**.25)+w)(a)-g(b))

Try it online!
How?
To save a few bytes:

we compute \$-\text{Initiative}-1\$ instead and sort the list the other way around
we compute \$\sqrt{|\text{DEX}|}\$ as \$(\text{DEX}^2)^{\frac{1}{4}}\$


Home on the Range of Lists This challenge is simply to return a list of lists of integers, similar to the Python range function, except that each successive number must be that deep in lists.

Rules:

Create a program or a non-anonymous function
It should return or print the result
The result should be returned in a list (of lists) or array (of arrays)
If the parameter is zero, return an empty list
This should be able to handle an integer parameter 0 <= n < 70.

(recursive solutions blow up pretty fast)

The function should be callable with only the one parameter.
Other behavior is undefined.
This is code golf, so shortest code wins.

Example Call:

rangeList(6)
> [0, [1, [2, [3, [4, [5]]]]]]

Test Cases:

0  => []
1  => [0]
2  => [0, [1]]
6  => [0, [1, [2, [3, [4, [5]]]]]]
26 => [0, [1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20, [21, [22, [23, [24, [25]]]]]]]]]]]]]]]]]]]]]]]]]]
69 => [0, [1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20, [21, [22, [23, [24, [25, [26, [27, [28, [29, [30, [31, [32, [33, [34, [35, [36, [37, [38, [39, [40, [41, [42, [43, [44, [45, [46, [47, [48, [49, [50, [51, [52, [53, [54, [55, [56, [57, [58, [59, [60, [61, [62, [63, [64, [65, [66, [67, [68]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

EDIT: isaacg's answer is the shortest so far. I'll update the accepted answer if anyone finds a shorter one in a language that existed at the posting of the challenge. Thanks for playing!

Pyth, 13 bytes
?hu]+HG_UQYQY

Try it here.
                 Implicit:
                 Q = eval(input())
                 Y = []
?           QY   If Q = 0, print Y
 h               else, print the first element of
  u     _UQY     the reduce, where Y is the initial value, over the list
                 reversed(range(Q))
   ]+HG          The reduce function: The list containing H prepended onto G.
                 The new number is inserted into the accumulated list,
                 then the resultant list is wrapped in another list.


Implement this key cipher Implement this key cipher
Goal
Use the algorithm (explained in the Algorithm section) to implement a certain cipher.
The program must read input from STDIN or the closest available equivalent, use the algorithm to generate the ciphertext and a key.
The ciphertext and the key will be written to STDOUT or the closest available equivalent. Any format is allowed, as long as it outputs the ciphertext and the key.
Algorithm
Convert the characters in the string into the respective ASCII values. For example:
Hello -> 72 101 108 108 111
Next, you will need to generate a key as long as the string with random numbers in the range of 0-9.
Hello -> 62841
Add the integers in the random number sequence to the ASCII values of the string. In the above examples, 72 would become 78, and 101 would become 104.
72 + 6 = 78, 101 + 2 = 103, 108 + 8 = 116, etc
Next, convert the new values back to characters. In the above examples, the text Hello has become Ngtpp.
Examples
(These are simply examples of what the output might look like. The output can and will vary.)
Hello World

Lfrlu)_supg
41606984343

This will be encoded

Zhjs$~koo gj$iuhofgj
60104723305544750226

Rules

You can assume that the input will only contain characters in the range a-z, A-Z, and spaces.
Submissions must be full programs or functions.
Submissions will be scored in bytes.
Standard loopholes are forbidden.
This is code-golf, so the shortest code wins.

(This is one of my first challenges, if there's something wrong with it, feel free to tell me how I could improve it.)

Python 3, 130 bytes
Thanks to @Rod for pointing out a bug
from random import*
def f(x):l=10**len(x);k=str(randint(0,l-1)+l)[1:];print(''.join(chr(ord(i)+int(j))for i,j in zip(x,k))+'\n'+k)

A function that takes input via argument as a string and prints to STDOUT.
How it works
from random import*  Import everything from the random module
def f(x):            Function with input string x
l=10**len(x)         Define l for later use as 10^length(x)
randint(0,l-1)+l     Generate a random integer in the range [0, l-1] and add l, giving a
                     number with l+1 digits...
k=str(...)[1:]       ...convert to a string and remove the first character, giving a key of
                     length l that can include leading zeroes, and store in k
for i,j in zip(x,k)  For each character pair i,j in x and k:
chr(ord(i)+int(j))    Find the UTF-8 code-point (same as ASCII for the ASCII characters),
                      add the relevant key digit and convert back to character
''.join(...)         Concatenate the characters of the ciphertext
print(...+'\n'+k)    Add newline and key, then print to STDOUT

Try it on Ideone


Through Space and Time Introduction:
In general we usually speak of four dimensions: three space dimensions for x, y, and z; and one time dimension. For the sake of this challenge however, we'll split the time dimension into three as well: past, present, and future.
Input:
Two input-lists. One containing integer x,y,z coordinates, and one containing integer years.
Output:
One of any four distinct and constant outputs of your own choice. One to indicate the output space; one to indicate the output time; one to indicate the output both space and time; and one to indicate the output neither space nor time.
We'll indicate we went to all three space dimensions if the differences of the integer-tuples is not 0 for all three dimensions.
We'll indicate we went to all three time dimensions if there is at least one year in the past, at least one year in the future, and at least one year equal to the current year (so in the present).
Example:
Input:
Coordinates-list: [{5,7,2}, {5,3,8}, {-6,3,8}, {5,7,2}]
Year-list: [2039, 2019, 2018, 2039, 2222]
Output:
Constant for space
Why?
The x coordinates are [5,5,-6,5]. Since they are not all the same, we've went through the x space dimension.
The y coordinates are [7,3,3,7]. Since they are not all the same, we've also went through the y space dimension.
The z coordinates are [2,8,8,2]. Since they are not all the same, we've also went through the z space dimension.
The current year is 2018. There are no years before this, so we did not visit the past time dimension.
There is a 2018 present in the year-list, so we did visit the present time dimension.
There are multiple years above 2018 ([2039, 2019, 2039, 2222]), so we also visited the future time dimension.
Since we've visited all three space dimensions, but only two of the three time dimensions, the output will only be (the constant for) space.
Challenge rules:

You can use any four distinct and constant outputs for the four possible states.
Input can be in any reasonable format. Coordinates list can be tuples, inner lists/arrays of size 3, strings, objects, etc. List of years may be a list of date-objects instead of integers as well if it would benefit your byte-count.
You can assume the x,y,z coordinates will be integers, so no need to handle floating point decimals. Any of the x, y, and/or z coordinates can be negative values, though.
You cannot take the input-lists pre-ordered. The input-lists should be in the order displayed in the test cases.
You can assume all year values will be in the range [0,9999]; and you can assume all coordinates are in the range [-9999,9999].
If your language doesn't have ANY way to retrieve the current year, but you'd still like to do this challenge, you may take it as additional input and mark your answer as (non-competing).

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code (i.e. TIO).
Also, adding an explanation for your answer is highly recommended.

Test cases:
Coordinates-input: [{5,7,2}, {5,3,8}, {-6,3,8}, {5,7,2}]
Years-input:       [2039, 2019, 2018, 2039, 2222]
Output:            space

Coordinates-input: [{0,0,0}, {-4,-4,0}, {-4,2,0}]
Years-input:       [2016, 2019, 2018, 2000]
Output:            time

Coordinates-input: [{-2,-2,-2}, {-3,-3,-3}]
Years-input:       [2020, 1991, 2014, 2018]
Output:            both

Coordinates-input: [{5,4,2}, {3,4,0}, {1,4,2}, {9,4,4}]
Years-input:       [2020, 1991, 2014, 2017, 2019, 1850]
Output:            neither

Perl 6, 47 46 bytes

-1 byte thanks to nwellnhof

{Set(@^b X<=>Date.today.year)>2,max [Z==] @^a}

Try it online!

Anonymous code block that takes two lists and returns a tuple of booleans, with the first element being whether you traveled in time, and the second being whether you didn't traveled in space.

Explanation

{                                            }  # Anonymous code block
     @^b X         # Map each element of the year list to:
          <=>      # Whether it is smaller, equal or larger than
             Date.today.year  # The current year
 Set(                       )    # Get the unique values
                             >2  # Is the length larger than 2?
                               ,
                                    [Z  ] @^a   # Reduce by zipping the lists together
                                max       # And return if any of them are
                                      ==  # All equal


Compute the Adler-32 checksum Background

Adler-32 is a 32-bit checksum invented by Mark Adler in 1995 which is part of the widely used zlib library (also developed by Adler). Adler-32 is not as reliable as a 32-bit cyclic redundancy check, but – at least in software  – it is much faster and easier to implement.

Definition

Let B = [b1, ⋯, bn] be a byte array.

The Adler-32 checksum of B is defined as the result of low + 65536 × high, where:

low := ((1 + b1 + ⋯ + bn) mod 65521)
high := (((1 + b1) + (1 + b1 + b2) + ⋯ (1 + b1 + ⋯ + bn)) mod 65521)

Task

Given a byte array as input, compute and return its Adler-32 checksum, abiding to the following.

You can take the input as an array of bytes or integers, or as a string.

In both cases, only bytes corresponding to printable ASCII characters will occur in the input.

You may assume that the length of the input will satisfy 0 < length ≤ 4096.
If you choose to print the output, you may use any positive base up to and including 256.

If you choose unary, make sure interpreter can handle up to 232 - 983056 bytes of output on a machine with 16 GiB of RAM.
Built-ins that compute the Adler-32 checksum are forbidden.
Standard code-golf rules apply.

Test cases

String:     "Eagles are great!"
Byte array: [69, 97, 103, 108, 101, 115, 32, 97, 114, 101, 32, 103, 114, 101, 97, 116, 33]
Checksum:   918816254

String:     "Programming Puzzles & Code Golf"
Byte array: [80, 114, 111, 103, 114, 97, 109, 109, 105, 110, 103, 32, 80, 117, 122, 122, 108, 101, 115, 32, 38, 32, 67, 111, 100, 101, 32, 71, 111, 108, 102]
Checksum:   3133147946

String:     "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
Byte array: [126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126]
Checksum:   68095937

String:     <1040 question marks>
Byte array: <1040 copies of 63>
Checksum:   2181038080

Mathematica, 46 bytes

{1,4^8}.Fold[##+{0,#&@@#}&,{1,0},#]~Mod~65521&

An anonymous function that takes an integer array and returns the Adler-32, with some improvements from miles and Martin (see comments).

miles' is also 46 bytes, but faster:

{1,4^8}.{Tr@#+1,Tr[Accumulate@#+1]}~Mod~65521&


Golf my iteration function Here is my ungolfed Ruby code for a function I want to try and golf:

Iter =-> k {
    str = ""
    (0..k).map{|m| str += "-> f#{m} {"}
    str += "f#{k}.times{f1 = f0[f1]};f1"
    (2..k).map{|m| str += "[f#{m}]"}
    eval(str + "}" * (k+1))
}

The best I can do to golf this is essentially shortening variable names, removing spaces, and rearranging the code to reduce the amount of loops:

I=->k{s="f#{k}.times{f1=f0[f1]};f1"
(2..k).map{|m|s+="[f#{m}]"}
(0..k).map{|m|s="->f#{k-m}{"+s+?}}
eval s}

Try it online!

This function can be compacted so that it avoids a lot of defining new functions. You can think of it like this:

$$\operatorname{Iter}(k;f_0,f_1,\dots,f_k)=f_0^{f_k}(f_1)(f_2)(f_3)\dots(f_k)$$

where

$$f^n(x)=\underbrace{f(f(\dots f(}_nx)\dots))$$

denotes function iteration. The types of arguments are given as:

$$\operatorname{Iter}(\text{int};\dots,(\text{int}\mapsto\text{int})\mapsto(\text{int}\mapsto\text{int}),\text{int}\mapsto\text{int},\text{int})$$

That is, the last argument is an integer, and each previous argument maps from T to T, where T is the type of the next argument on the right.

It is true that accepting all arguments at once would allow me to golf the above code further:

I=->k,*a{a[-1].times{a[1]=a[0][a[1]]};(2..k).map{|m|a[1]=a[1][a[m]]};a[1]}

However, the issue is that I need to curry this function. This way, I may treat objects such as

$$\operatorname{Iter}(k)(f_0)$$

as their own object, and thus be able to pass this into Iter(k) to get things such as

$$\operatorname{Iter}(k)(\operatorname{Iter}(k)(f_0))$$

As a specific example of what this function does, we have

\begin{align}\operatorname{Iter}(2)(\operatorname{Iter}(1))(x\mapsto x+1)(2)&=\operatorname{Iter}(1)(\operatorname{Iter}(1)(x\mapsto x+1))(2)\\&=\operatorname{Iter}(1)(x\mapsto x+1)(\operatorname{Iter}(1)(x\mapsto x+1)(2))\\&=\operatorname{Iter}(1)(x\mapsto x+1)(2+1+1)\\&=\operatorname{Iter}(1)(x\mapsto x+1)(4)\\&=4+1+1+1+1\\&=8\end{align}

  I'm interested in seeing if this can be golfed down further, with the restriction that the arguments must be curried in the order provided.

Ruby, 94 96 bytes

Using loops to do concatenations that followed such a simple pattern felt cumbersome, so I utilized the creative use of join instead, further golfed by the fact that array*str is equivalent to array.join(str)

+2 bytes to fix a typo I made that just so happened to return the same result on the test example by chance.

I=->k{eval"->f#{[*0..k]*'{->f'}{f#{k}.times{f1=f0[f1]};f1#{"[f#{[*2..k]*'][f'}]"if k>1}"+?}*-~k}

Try it online!


Detect a Symmetric polynomial A symmetric polynomial is a polynomial which is unchanged under permutation of its variables.

In other words, a polynomial f(x,y) is symmetric if and only if f(x,y) = f(y,x); a polynomial g(x,y,z) is symmetric iff g(x,y,z) = g(x,z,y) = g(y,x,z) = etc.

For example, x^2+2xy+y^2, xy and x^3+x^2y+xy^2+y^3 are symmetric polynomials, where 2x+y and x^2+y are not.

The challenge

You will be given a polynomial, and your program should output truthy/falsy values, depending on if the given polynomial is a symmetric polynomial.

The input format is allowed in two ways. A string, and an array, like ["x^2","2xy","y^2"], where the polynomial is the sum of each elements.

Example

x^2+2xy+y^2 => true
xy => true
xy+yz+xz-3xyz => true
(x+y)(x-y) => false
2x+y => false
x^2+y => false
x+2y+3 => false

Specs

The operation has orders, just like in normal math. the order is like this:

() => ^ => * => +-

code-golf rules apply.

All the characters in the alphabet (a~z) are accepted as variables, everything else are numbers.

The given polynomial will have 2 or more variables.

Multiplication does not require the * operator, You only need to detect juxtaposition. (detecting by juxtaposition is not neccessary, use the better option)

Mathematica, 43 bytes

Last@SymmetricReduction[#,Variables@#]===0&

Unnamed function taking as input a polynomial in the given format (except that juxtaposed variables must be separated by a space) and returning True or False. Variables@# detects the variables appearing in the input (and thus the input can contain all kinds of weird variable names, not just single letters). SymmetricReduction returns an ordered pair of polynomials, where the first one is symmetric and the two sum to the original polynomial; therefore we can detect whether the input is symmetric by seeing whether the second polynomial is identically 0.


War is peace. Freedom is slavery. Ignorance is strength As George Orwell wrote in 1984:

  War is peaceFreedom is slaveryIgnorance is strength

Write a program or function that takes in one of the six main words from the Orwell quote and outputs its counterpart.

Specifically:

[input] -> [output]
war -> peace
peace -> war
freedom -> slavery
slavery -> freedom
ignorance -> strength
strength -> ignorance

No other input/output pairs are required.

You should assume the words are always fully lowercase, as above. Alternatively, you may assume the words are always fully uppercase: WAR -> PEACE, PEACE -> WAR, etc.

The shortest code in bytes wins.

05AB1E, 30 bytes

05AB1E uses CP-1252.

“ignorance¤í‡î—™šÔÃÒry“#DIk1^è

Try it online! or as a Test suite

Explanation

The straight forward approach

Push the string ignorance strength war peace freedom slavery
Split on spaces
Get the index of the input in the list
XOR the index with 1
Get the element in the list at that index


CamelCase2snake_case() Write a function to convert CamelCased text to snake_case: FunctionForHTMLManipulation becomes function_for_html_manipulation

The input text will be a single suitable identifier in many languages. It must start with an English letter, then be followed by any number of English letters or digits. No other characters (spaces, symbols, etc.) are allowed.

Each "word" within the CamelCased text will start with a capital letter unless at the beginning of the text or immediately after a digit, and be followed by zero or more letters, all of the same case. Groups of digits will be considered as separate words but pass through unchanged.

In other words, a lowercase letter followed by an uppercase letter indicates a word break. Any letter and digit next to each other indicates a word break. An uppercase letter followed by another uppercase letter and a lowercase letter indicates a word break.

...lU... => ...l_u...
...l9... => ...l_9...
...U9... => ...u_9...
...9l... => ...9_l...
...9U... => ...9_u...
...UUl... => ...u_ul...

Both Buy24Beers and buy24beers become buy_24_beers.
MacDonaldAndObrian becomes mac_donald_and_obrian.
MACDonaldAndOBrian becomes mac_donald_and_o_brian.

Retina, 61 37 bytes

r1>`[A-Z]?[a-z]+|[A-Z]+|\d+
_$&
T`L`l

Try it online! (Slightly modified to run a full test suite.)

Explanation

Instead of finding word boundaries to insert underscores, we simply match each word and prepend a _. Matching words from the left is a bit annoying because of the UUl rule, but using .NET's right-to-left matching we can easily match words greedily. To avoid a leading _, we make use of Retina's limits.

r1>`[A-Z]?[a-z]+|[A-Z]+|\d+
_$&

The r activates right-to-left mode, the 1> tells Retina to process everything except the first match (counting from left to right). Then there's four types of "words": Ulll, lll, UUU, ddd. These are easily matched with the given pattern. The substitution just writes a _ followed by the word itself.

T`L`l

This simply turns upper case into lower case to complete the transformation.


Let's study Neil numbers Congratulations to Neil for hitting 100k rep! As a tribute, we are going to study 'Neil numbers'.

Neil's user ID is 17602 and there's something special about the binary representation of this number:

$$17602_{10}=1\color{blue}{000}1\color{blue}{00}11\color{blue}{0000}1\color{blue}{0}_2$$

$$\begin{array}{c|c}
1&\color{blue}{000}&1&\color{blue}{00}&11&\color{blue}{0000}&1&\color{blue}{0}\\
\hline
&3&&2&&4&&1
\end{array}$$

There's exactly one group of consecutive zeros of length 1, one group of length 2, one group of length 3 and one group of length 4.

This is an order-4 Neil number.

More generally:

  An order-\$n\$ Neil number is a positive integer whose binary
  representation contains exactly \$n\$ groups of consecutive zeros and
  for which there's exactly one group of consecutive zeros of length
  \$k\$ for each \$0<k\le n\$, with \$n>0\$.

Clarifications:

Leading zeros are obviously ignored.
Groups of consecutive zeros are indivisible (e.g. 000 is a group of length 3 and cannot be seen as a group of length 1 followed by a group of length 2, or the other way around).

Examples

Order-1 Neil numbers are A030130 (except 0, which is not a Neil number as per our definition).

The first few order-2 Neil numbers are:

18, 20, 37, 38, 41, 44, 50, 52, 75, 77, 78, 83, 89, 92, 101, 102, 105, 108, 114, ...

Your task

Given a positive integer as input, return \$n\ge 1\$ if this is an order-\$n\$ Neil number or another consistent and non-ambiguous value (0, -1, false, "foo", etc.) if this is not a Neil number at all.

This is code-golf.

Test cases

Using 0 for non-Neil numbers:

Input   Output
1       0
2       1
8       0
72      0
84      0
163     0
420     0
495     1
600     3
999     0
1001    2
4095    0
8466    4
16382   1
17602   4
532770  5

Or as lists:

Input : 1, 2, 8, 72, 84, 163, 420, 495, 600, 999, 1001, 4095, 8466, 16382, 17602, 532770
Output: 0, 1, 0, 0, 0, 0, 0, 1, 3, 0, 2, 0, 4, 1, 4, 5

Brownie points if your user ID is a Neil number. :-)

Charcoal, 21 bytes

≔Φ⪪⍘Ｎ²1ιθＩ×Ｌθ⬤θ№θ×0⊕κ

Try it online! Link is to verbose version of code. Outputs 0 for irrelevant numbers. Happens to output 1 for 0 as per the OEIS sequence. Explanation:

≔Φ⪪⍘Ｎ²1ιθ

Convert the input to binary, split on 1s, and remove empty elements.

Ｉ×Ｌθ⬤θ№θ×0⊕κ

Check that the array contains all lengths of 0s and output its length if it does or 0 if it does not.


Quine outputs itself in binary Your task, if you wish to accept it, is to write a program that outputs its own source code in the binary UTF-8 representation.

Rules

The source must be at least 1 byte long.
Your program must not take input (or have an unused, empty input).
The output may be in any convient format.
Optional trailing newline is allowed.
Notice that one byte is 8 bits, and the length of the binary UTF-8 representation is necessarily a multiple of 8.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
Standard loopholes are forbidden.

Example

Let's say your source code is Aä$$€h, its corresponding UTF-8 binary representation is 010000011100001110100100001001000010010011100010100000101010110001101000.

If I run Aä$$€h the output must be 010000011100001110100100001001000010010011100010100000101010110001101000.

A      --> 01000001
ä      --> 1100001110100100
$      --> 00100100
$      --> 00100100
€      --> 111000101000001010101100
h      --> 01101000
Aä$$€h --> 010000011100001110100100001001000010010011100010100000101010110001101000

String to binary UTF-8 converters

Try it online!
utf8-convert


Program that determines whether an int is greater or lesser Write a program which prompts a user to input two integers A and B, the program should determine whether A is greater than or lesser than B without the use of greater than [>] or less than [<] operators (and similar operators or methods like .compare) and should output :

Integer A is greater than B.

Rules  : No Brainfuck.

Should work for negative numbers.  Signed int. Code's for equality isn't necessary.

Edited Again.

Javascript

Here's the basic format of all the solutions.  This case returns true if a>b and false otherwise:

function greaterThan(a,b){
    c=a;//Copy a
    while(true){
        if(b==a){
            return false;
        }
        if(b==c){
            return true;
        }
        a++;//Approaches b if a<b
        c--;//Approaches b if a>b
    }
}

Warning:  Since we didn't need to support the A==B case, the next 3 solutions will lock up for those inputs.  Thus, don't fill in equal or empty numbers at the prompts in the test fiddles, unless of course you like pushing red buttons that say "Do NOT push!!!"

149 chars - Fiddle: Conforms EXACTLY to specs ;)

for(A=B='A',C='B',a=c=prompt(A),b=prompt(C);b!=c++||(B=C),b!=a--||(A=C),A==B;);alert("Integer "+B+" is Greater than "+A+".\n\n\nRules  : No Brainfuck.")

74 chars - Fiddle: Prompts user for 2 numbers, alerts '-1' if 1st<2nd, '1' if 2nd>1st:

for(A=0,a=c=prompt(),b=prompt();b!=c++||(A=-1),b!=a--||(A=1),!A;);alert(A)

54 chars - Fiddle: Function that takes 2 parameters and returns true if A > B, false if A < B, and, of course, locks up if A==B.

function a(a,b){for(c=a;b!=++a&&b!=--c;);return b!=a;}


Loading Forever... Windows style Make a Windows style Loading bar by the following instructions.

(notice that this is different than Loading... Forever)

Your output should start by [....      ].

Every tick, you should wait 100 ms, then move each dots by one character right. if the dot is on the tenth character, move it to the first. Notice that you should clear the screen before outputting again. The output is ordered as the following:

[....      ]
[ ....     ]
[  ....    ]
[   ....   ]
[    ....  ]
[     .... ]
[      ....]
[.      ...]
[..      ..]
[...      .]

..Then it loops forever.

Rules

This is code-golf, so the shortest answer wins I doubt I would even accept a winning answer tho
Please provide a gif file of the loading bar in action if possible.

V, 17 16 15 bytes

i[´.¶ ]<esc>ògó$X|p

<esc> is 0x1b.

And the hexdump:

00000000: 695b b42e b620 5d1b f267 f324 587c 70    i[... ]..g.$X|p

Explanation

i                       " Insert
[                       " a [
´.                      " 4 .s
¶<space>                " 6 spaces
]<esc>                  " and a ]. Then return to normal mode
ò                       " Recursively do:
 gó                     "  Sleep for 100 milliseconds
 $                      "  Go to the ]
 X                      "  Delete the character to the left of the ]
 |                      "  Go to the [
 p                      "  And paste the deleted character right after the [
                        " Implicit ending ò


Print random integers until 0 You are to write a program which generates random integers between \$0\$ and \$99\$ inclusive, outputting each integer in turn, until \$0\$ is generated. You may choose which single-order random distribution (uniform, binomial, Poisson etc.) you use so long as each integer has a non-zero chance of being generated and is chosen independently. The output should always end with 0. As each integer must be chosen independently, the output cannot be some permutation of the integers \$\{0, 1, 2, ..., 99\}\$ trimmed to end with \$0\$.
You may follow another method to accomplish the same task, so long as the result is identical to the described method here (for example: you may generate a number \$K\$ geometrically distributed with parameter \$\frac 1 {99}\$, then output \$K\$ independent numbers with a uniform distribution on the set \$\{1, 2, ..., 99\}\$, then output a \$0\$).
The integers may be separated by any non-digit, non-empty separator (e.g. newlines, spaces etc.), and may be output in any consistent base. You may output in any convenient method or format.
This is code-golf so the shortest code in bytes wins.

Scratch 3.0, 9 blocks/76 bytes

As SB Syntax:
define
set[N v]to(1
repeat until<(N)=(0
set[N v]to(pick random(0)to(99
say(N

Try it on Scratch
It just wouldn't be right if I didn't golf this in scratch. This is a function that achieves the desired result
Explained
define                             // Create a function with no name (not a lambda)
set[N v]to(1                       // Initalise the variable we will use to generate random numbers with
                                   // If we didn't set it to 1, the next loop wouldn't start, as it would see that N = 0.
repeat until<(N)=(0                // Pretty self-explanatory
set[N v]to(pick random(0)to(99     // Also pretty self-explanatory. But putting this here means we don't have to include two calls to this block: we've essentially created a post-test loop instead of a pre-test loop
say(N                              // Output the randomly generated number and repeat


The confused twister The basic idea is to write a program that twists itself, and the twisted version untwists itself. The first program will just be the twisting algorithm described here, and when given its own source code as input, outputs a program that reverses the twisting algorithm.

How strings are twisted

The twisting algorithm is very simple. Each column is shifted down by its index (col 0 moves down 0, col 1 moves 1, ...). The column shift wraps to the top. It kinda looks like this:

a
ba
cba
----
 cba
  cb
   c

With everything under the line wrapping to the top. Real example:

Original:
\\\\\\\\\\\\
............
............
............

Twisted:
\...\...\...
.\...\...\..
..\...\...\.
...\...\...\

(Further examples are here)

Input

Input is either an array of strings, or a multi-line string. All lines have the same length.

Output

The (un)twisted string, multi-line output to std-out (or closest alternative).

Example

I'm not quite sure what this is written in but oh well ;)

Twisting:
magic  TwistingAlgo
magic ntwistingAlgo
magicU twistingAlgo

Untwisting:
magic  twistingAlgo
magicUnTwistingAlgo
magic  twistingAlgo

Other notes

Your first and second program must be in the same language.
The programs must work for any input, not just itself.
Your program must have at least 2 rows and 2 columns.

Japt, 63 bytes
Uy m@XsV=(Y*Xl +Y %Xl)+X¯V}R y;
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;

Twisted:
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;
Uy m@XsV=(Y*Xl +Y %Xl)+X¯V}R y;

Test it online: Original, Twisted
How it works
I hadn't posted yet on the original twisting challenge, but the shortest answer I could come up with is 31 bytes:
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;

The untwisting algorithm I came up with is a lot shorter:
Uy m@XsV=Y%Xl)+X¯V}R y;

However, this won't work very well when intertwined with the other program. Fortunately, there's a way to make the two more similar:
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;
Uy m@XsV=(Y*Xl +Y %Xl)+X¯V}R y;

Now all that's different between the two is the +/-, which is already properly aligned to switch places when twisted!
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;
Uy        // Transpose rows and columns in U.
m@     }R // Map each item X and index Y in the result, split at newlines, to:
Y*Xl -Y   //  Take Y times X.length and subtract Y.
%Xl)      //  Modulate the result by X.length.
XsV=      //  Set V to the result of this, and slice off the first V chars of X.
+X¯V      //  Concatenate this with the first V chars of X.
y;        // Transpose the result again.
          // Implicit: output *last* expression


Unfold in all directions Input:

A string

Output:

1) First we take remove character at the end of the input-string until we are left with a length that is a square (i.e. 1, 4, 9, 16, 25, 36, etc.)
So abcdefghijklmnopqrstuvwxyz (length 26) becomes abcdefghijklmnopqrstuvwxy (length 25).

2) Then we put this in a square, one line at  a time, left to right:

abcde
fghij
klmno
pqrst
uvwxy

3) We fold it in all four directions, like this (we keep unfolding until the outer folded 'block' has no inner characters to unfold anymore):

      m
     qrs
     l n
     ghi
    abcde
 ihgf   jihg
mn lk   on lm
 srqp   tsrq
    uvwxy
     qrs
     l n
     ghi
      m

Some things to note, when we fold outward, we basically mirror like this (numbers added as clarification, which represents the 'indexes' in these examples):

When we fold out the left side:

 123    to:   321 123
fghij         ihgf   j

When we fold the right side:

 123    to:    123 321
fghij         f   jihg

When we fold upwards:

            3q
            2l
            1g
  b   to:    b
 1g         1
 2l         2
 3q         3
  v          v

When we fold downwards:

 b          b
1g         1
2l         2
3q         3
 v   to:    v
           3q
           2l
           1g

Challenge rules:

You can assume the input will always have at least 1 character (which will also be the output).
Output format is flexible, so you can print to STDOUT or STDERR; return as string-array/list or character 2D-array; single string with new-lines; etc.
The input will only contain alphanumeric characters (a-zA-Z0-9)
You can also use a non-alphanumeric character to fill up the spaces in and/or around the ASCII-art output, like a dot ..
Trailing spaces and a single trailing new-line are optional.
We continue unfolding until the outer folded 'block' has no more centers to unfold.

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.
Also, please add an explanation if necessary.

Test cases:

Input: abcdefghijklmnopqrstuvwxy
Output:
      m
     qrs
     l n
     ghi
    abcde
 ihgf   jihg
mn lk   on lm
 srqp   tsrq
    uvwxy
     qrs
     l n
     ghi
      m

Input: A
Ouput:
A

Input: ThisIsATest
Output:
  I
 Thi
Is sI
 ATe
  I

Input: HowAboutAVeryLongExampleWhichIsAlsoAnEvenSquareInsteadOfOddOneAndExceeds64Chars
Output:

               An
               ch
              xamp
              i  I
              o  E
              quar
             steadO
             S    e
             s    v
             h    s
             E    l
             VeryLo
            HowAbout
      oLyreVA      noLyreV
  xampl    Eg      el    Examp
hci  Is    hW      As    hi  Ihc
nAo  Ev    sl      ev    so  EnA
  quare    Sn      Ie    Squar
      Odaetsn      fOdaets
            OddOneAn
             steadO
             S    e
             s    v
             h    s
             E    l
             VeryLo
              xamp
              i  I
              o  E
              quar
               An
               ch

Input: Lenght7
Output:
Le
ng

Input: abc
Output:
a

SOGL V0.12, 75 bytes
l√u²m√lH»{ā;l⁾:A∫Ba{bIwFIWhFbž;FIbI@ž}};}¹K⁴{ē2\⌡±e{@Κ};⁴┼┼};0E{ē2\⌡№:h++}╚

Try it Here!
This expects the input on the stack, so for ease-of-use I added , at the start. That can cause issues if the input contains only numbers so here
is a a test-suite for that.
70 bytes √lH»{ā;l⁾:A∫Ba{bIwFIWhFbž;FIbI@ž}};}¹K⁴{ē2\⌡±e{@Κ};⁴┼┼};0E{ē2\⌡№:h++}╚ works too, but as I only now implemented √ on strings and the documentation didn't mention that it would floor the length I won't count it.
Explanation:
creating a square from the input

l       get the length of the input
 √      get its square root
  u     floor that
   ²    square it
    m   mold the input to that length
     √  convert it to a square

creating the unfoldings of the square - the idea is to cut out the inner squares to a new array

lH»{                              } (length-1)//2 times do
    ā;                                push an empty array below ToS
      l⁾                              push ToS.length - 2 (ToS here is the square or the previous unfolding)
        :A                            save a copy of that in the variable A
          ∫B                    }     repeat that amount of times, saving iteration on B - cutting the inner square to the empty array
            a{                 }        variable A times do
              bIw                         get the b+1th row of the previous unfolding
                 FIW                      get the (current loops iteration + 1)th character of that
                    h                     swap the 2 items below ToS - so the stack now is [..., prevUnfolding, newArray, character]
                     Fbž                  at [current loops iteration; b] insert that character in the array
                        ;                 swap the top 2 items - the stack now is [..., newArray, prevUnfolding]
                         FIbI@ž           at [current loops iteration+1; b+1] insert a space
                                 ;    get the now not empty array ontop of the stack

add the horizontal unfoldings

¹                    wrap the stack in an array
 K                   push the 1st item of that, which will function as the canvas
  ⁴{              }  iterate over a copy of the remaining items
    ē2\⌡               repeat (e++ divides by 2) times (default for the variable E is the input, which defaults to 0)
        ±                reverse the array horizontally
         e{  }         repeat e times
           @Κ            add a space before ToS
              ;⁴┼┼     add that horizontally before and after the canvas

add the veertical unfoldings

;                get the copy of the foldings above the canvas
 0E              reset the variable E to 0
   {         }   iterate the copy of the foldings
    ē2\⌡           repeat (e++ divides by 2) times (default for the variable E is the input, which defaults to 0)
        №            reverse the array vertically
         :h++      add that vertically before and after the canvas
              ╚  center the canvas vertically


Write a program that makes 2 + 2 = 5 Write a program that seemingly adds the numbers 2 and 2 and outputs 5. This is an underhanded contest.

Your program cannot output any errors. Watch out for memory holes! Input is optional.

Redefining 2+2 as 5 is not very creative! Don't doublethink it, try something else.

Java

Reflection is indeed the right way to go with abusing Java... but you need to go deeper than just tweaking some values.

import java.lang.reflect.Field;

public class Main {
    public static void main(String[] args) throws Exception {
        Class cache = Integer.class.getDeclaredClasses()[0];
        Field c = cache.getDeclaredField("cache");
        c.setAccessible(true);
        Integer[] array = (Integer[]) c.get(cache);
        array[132] = array[133];

        System.out.printf("%d",2 + 2);
    }
}

Output:

5

Explanation:

   You need to change it even deeper than you can typically access.  Note that this is designed for Java 6 with no funky parameters passed in on the JVM that would otherwise change the IntegerCache.Deep within the Integer class is a Flyweight of Integers.  This is an array of Integers from −128 to +127.  cache[132] is the spot where 4 would normally be.  Set it to 5.

Warning: Doing this in real code will make people very unhappy.

Code demo on ideone.


Spotify Shuffle (music playlist shuffle algorithm) Background

Perfect shuffle algorithms like Fisher-Yates shuffle don't produce great results when it comes to music playlist shuffling, because it often produces clusters of songs from the same album. In an attempt to solve this problem, Spotify introduced an interesting shuffle algorithm in 2014. At the end of the article, they claimed (emphasis mine):

  All in all the algorithm is very simple and it can be implemented in just a couple of lines. It’s also very fast and produces decent results.

Let's see if this is indeed the case.

Task

Implement the modified Spotify shuffle. The algorithm described in the article has some gaps in its specification, so I present a refined one here.

The algorithm

Let's assume we have a list of items grouped into categories, e.g.:

[['A', 'AA', 'AAA'], ['B'], ['C', 'CC'], ['D'], ['E', 'EE', 'EEE', 'EEEE']]

Shuffle items within each category.

You may use any shuffle algorithm that can produce every possible permutation with nonzero probability.

[['AAA', 'A', 'AA'], ['B'], ['C', 'CC'], ['D'], ['EEE', 'EEEE', 'EE', 'E']]

Assign each item a "positional value". Items in one category should be uniformly spaced, but with some randomness. To achieve this, do the following operations on each category having n items:

Initialize the positional value vector v of length n with the values v[k] = k/n for 0 <= k < n (i.e. 0-indexed), so that the items have default spacing of 1/n.
Generate an initial random offset io within the range of 0 <= io <= 1/n, and add it to every v[k].
Generate n individual random offsets o[k] within the range of -1/10n <= o[k] <= 1/10n, and apply v[k] += o[k] for each k. So the positional value of k-th item (0-indexed) within an n-item category will be v[k] = k/n + io + o[k].

The random offsets io and o[k] should ideally be picked from a uniform random variable, but can be approximated by picking from a discrete distribution with at least 5 distinct equally-spaced outcomes, including both lower and upper bounds. (e.g. you can choose to randomly pick io from [0, 1/4n, 2/4n, 3/4n, 1/n].)
Don't do extra processing even if v[k] < 0 or v[k] > 1.

[['AAA' -> 0.1, 'A' -> 0.41, 'AA' -> 0.79],
 ['B' -> 0.2],
 ['C' -> 0.49, 'CC' -> 1.01],
 ['D' -> 0.03],
 ['EEE' -> 0.12, 'EEEE' -> 0.37, 'EE' -> 0.6, 'E' -> 0.88]]

Sort all items by the positional values.

['D', 'AAA', 'EEE', 'B', 'EEEE', 'A', 'C', 'EE', 'AA', 'E', 'CC']

The shuffled result roughly looks like this (from the article):

Here is Python-like pseudocode of the above algorithm:

x = nested array of items
uniform(a,b) = uniformly generate a random value between a and b
items = []
v = []
for i in range(len(x)):  # for each category
    shuffle(x[i])  # shuffle items within category in place
    items += x[i]
    n = len(x[i])  # size of the current category
    io = uniform(0, 1/n)  # initial offset
    o = [uniform(-0.1/n, 0.1/n) for k in range(n)]  # individual offsets
    v += [k/n + io + o[k] for k in range(n)]  # resulting positional values
sort items by v
print items

Input and output

The input is a list of groups of items (i.e. a nested list) as shown in the example above. An item is a string made of only uppercase letters (or only lowercase if you want). You can assume that all items are distinct, within and across categories.

The output is a shuffled list including all items in the input, which is produced by the algorithm described above.

The randomness requirements are covered in the algorithm description.

Scoring and winning criterion

Standard code-golf rules apply. Shortest code in bytes wins.

JavaScript (Node.js),  125  124 bytes
Saved 1 byte thanks to @KevinCruijssen

a=>a.flatMap(a=>a.sort(_=>R()-.5).map(v=>[(o++-.1+R()/5)/a.length,v],o=R()),R=Math.random).sort(([a],[b])=>a-b).map(a=>a[1])

Try it online!
Commented
a =>                          // a[] = input
  a.flatMap(a =>              // for each category a[] in a[]:
    a.sort(_ => R() - .5)     //   shuffle a[]
    .map(v =>                 //   for each value v in a[]:
      [                       //     build a pair [position, value]:
        ( o++                 //       increment o
          - .1                //       subtract 1/10
          + R() / 5           //       add 2/10 * random value in [0,1)
        ) / a.length,         //       divide the result by the length of a[]
        v                     //       use v as the 2nd element
      ],                      //     end of pair
      o = R()                 //     start with o in [0,1)
    ),                        //   end of map()
    R = Math.random           //   R = alias for Math.random
  )                           // end of flatMap()
  .sort(([a], [b]) => a - b)  // sort by first element, in ascending order
  .map(a => a[1])             // keep only the 2nd element


Big or Little Endian Write a program or function that outputs an L if run on a little endian architecture or a B if run on a big endian architecture. Lower case output l or b is also acceptable.

There is no input.

Scoring is code golf, so the code with the fewest bytes wins.

Edit: As per the comments below, I am clarifying that the entry must be able to run on either architecture.

I believe that there is only one answer that this affects, and that answer has clearly indicated that this is the case.

Python, 33 bytes

import sys
exit(sys.byteorder[0])

sys.byteorder is either 'little' or 'big' (and for those of you who will read this sentence without looking at the code, [0] means take the first character).


Recognize Twin Primes by Crashing Background Story

Bob was handed the following assignment for his programming class. Please note: this is not the actual challenge.

  Homework assignment 11: Twin primes

  Input: an integer n ≥ 8, taken from STDIN.

  Output: a message to STDOUT, depending on n:

  If n is not a prime number, output Not prime.
  If n is a prime number, but neither of n - 2 and n + 2 is, output Isolated prime.
  If n and n + 2 are both prime numbers, output Lower twin prime.
  If n and n - 2 are both prime numbers, output Upper twin prime.

Bob tried hard to solve the assignment, but his program kept crashing, and in the end, he gave up and submitted it in hope of partial credit. Nevertheless, Bob's program has the curious property that even though it never does what it's supposed to, the input is still classified correctly depending on the program's behavior: non-primes result in no output, isolated primes in a crash, lower twin primes in an infinite loop with no output, and upper twin primes in an infinite loop that keeps printing the correct message.

The Task

Your task is to replicate the behavior or Bob's solution. In other words, write a program that reads a single integer n ≥ 8 from STDIN or closest equivalent, and does the following:

If n is not a prime number, output nothing and exit gracefully.
If n is a prime number, but none of n - 2 or n + 2 is, produce a runtime error of some kind. Stack overflows count as runtime errors.
If n and n + 2 are both prime numbers, output nothing, but keep running until the program is killed manually (or until you run out of memory).
If n and n - 2 are both prime numbers, repeatedly output Upper twin prime., with or without a trailing newline, to STDOUT or closest equivalent until the program is killed manually (or until you run out of memory).

Incorrect inputs can be ignored.

Scoring

The idea is that your program should appear correct, but contain hidden bugs that result in the above behavior. Your program should also be short (since programming assignments are graded by hand), but popularity is more important. Thus, your score is number of upvotes - (byte count / 100), higher score being better. Note that your score can be negative.

TI-BASIC, ~269

Input N
Lbl 1
2→P                                       :"  test N for divisibility by each prime
Lbl 2
If int(N/P)=N/P:Goto 3    :"composite"
If PP>N:Goto 4
P+1→P
Goto 2
Lbl 3
Disp "                NOT PRIME.               "
Stop
Lbl 4
If int((N+2)/3)=(N+2)/3                    :" determine which nearby value to test
Then:N-2→R
Else:N+2→R
End
2→P
Lbl 5
If int(R/P)=R/P:Goto 6    :"composite"
If PP>R:Goto 7
P+1→P
Goto 5
Lbl 6
Output("ISOLATED PRIME.")
Lbl 7          :" TI-BASIC how two ways of printing:
               :" Disp goes to the main screen,
               :" and Output goes to the graphical screen.
               :" This program uses both methods.
If R=N+2:Goto 5              :" go to print "lower twin prime"
Disp "UPPER TWIN PRIME"
Goto 7          :" only 16 chars can be printed per line, so we'll do the period separately (last line of program)
Lbl 5
Output("LOWER TWIN PRIME")
Lbl 7
Disp "."

   The NOT PRIME string has sixteen leading spaces, so nothing (except an ellipsis) will be printed, as noted in the comments.
 The ISOLATED PRIME string uses the Output() function, which requires two numbers (the coordinates of the printing location). This triggers an Argument Error.
 The LOWER TWIN PRIME string is indicated by the link to Lbl 5, which was already defined as the start of the twin prime test, causing an infinite loop.
 The UPPER TWIN PRIME string is followed by a link to the period, but Lbl 7 was already defined above, triggering an infinite loop.


Compare two integers in C or C++ without comparison operators Produce the shortest program which takes two signed integers as input (through stdin or as arguments) and displays 3 different outputs depending upon whether the first number is (1) greater than, (2) smaller than, or (3) equal to the second number.

The Catch

You cannot use any of the following in your program:

The standard comparison operators: <, >, <=, >=, ==, !=.
Any library file apart from conio, stdio, or iostream.
Any non-ASCII or non-printable ASCII character.

The Winner

The program with the shortest number of characters wins.

90 bytes

If we can use stdio, why not use its formatting capabilities to perform comparison?

main(a,b){scanf("%d%d",&a,&b);snprintf(&a,2,"%d",b-a);a&=63;putchar(51-!(a-45)-!!(a-48));}

Assumes ASCII-compatible encoding and little-endianness.

72 bytes

Quotients are rounded toward zero but right-shifts are (in practice) "rounded down". That's a dead giveaway.

main(a,b){scanf("%d%d",&a,&b);a-=b;putchar(a?a|=1,a/2-(a>>1)?60:62:61);}

65 79 bytes

Another distinguishing property of negative numbers is that they produce negative modulo.
This one doesn't depend on integer representation at all; it even works on my 8-bit excess-127 toaster!
Oh, and since we can use conio, why not save two bytes with putch? Now, if I could only find my copy of TurboC...

main(a,b){scanf("%d%d",&a,&b);long long d=a;d-=b;putch(d?d|=1,d%2-1?60:62:61);}

EDIT: Handle large differences assuming long long is wider than int.


Compute the winding number The winding number is the integer number of net counterclockwise revolutions an observer must have made to follow a given closed path. Note that any clockwise revolutions count negative towards the winding number. The path is allowed to self intersect.

Some examples (shamelessly taken from Wikipedia) are given below:

Your goal is to compute the winding number for a given path.

Input

The observer is assumed be at the origin (0,0).

The input is a finite sequence of points (pair-like of integer numbers) from any desired input source which describes the piece-wise linear path. You may flatten this into a 1D sequence of integer numbers if desired, and may also swizzle the input to take all x coordinates before all y coordinates/vise-versa. You may also take the input as a complex number a+b i. The path may self intersect and may contain zero-length segments. The first point is the start of the path and is assumed to lie somewhere on the positive x axis.

No part of the path will intersect the origin. The path will always be closed (i.e. the first and lost point are the same). Your code may either imply the last point or require it to be included.

For example, depending on your preference both inputs specify the same square:

implied end point

1,0
1,1
-1,1
-1,-1
1,-1

explicit end point

1,0
1,1
-1,1
-1,-1
1,-1
1,0

Output

The output is a single integer for the winding number. This may be to any source (return value, stdout, file, etc.).

Examples

All examples have the end point explicitly defined and are given as x,y pairs. Incidentally, you should be able to also directly feed these examples into any codes assuming implicitly defined end points and the outputs should be the same.

1. Basic test

1,0
1,1
-1,1
-1,-1
1,-1
1,0

Output

1

2. Repeated point test

1,0
1,0
1,1
1,1
-1,1
-1,1
-1,-1
-1,-1
1,-1
1,-1
1,0

Output

1

3. Clockwise test

1,0
1,-1
-1,-1
-1,1
1,1
1,0

Output

-1

4. Outside test

1,0
1,1
2,1
1,0

Output

0

5. Mixed winding

1,0
1,1
-1,1
-1,-1
1,-1
1,0
1,-1
-1,-1
-1,1
1,1
1,0
1,1
-1,1
-1,-1
1,-1
1,0
1,1
-1,1
-1,-1
1,-1
1,0

Output

2

Scoring

This is code golf; shortest code wins. Standard loopholes apply. You may use any builtin functions so long as they were not specifically designed to compute the winding number.

ES6, 83 bytes

a=>a.map(([x,y])=>r+=Math.atan2(y*b-x*c,y*c+x*b,b=x,c=y),b=c=r=0)&&r/Math.PI/2

Takes as input an array of pairs of points which are interpreted as complex numbers. Rather than converting each point into an angle, the points are divided by the previous point, which Math.atan2 then converts into an angle between -π and π, thus automatically determining which way the path is winding. The sum of the angles is then 2π times the winding number.

Since Math.atan2 doesn't care about the scale of its arguments I don't actually perform the full division z / w = (z * w*) / (w * w*) instead I just multiply each point by the complex conjugate of the previous point.

Edit: Saved 4 bytes thanks to @edc65.


Choose the Most Dramatic Outcome The premise of this is simple: A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing!

So, write code that implements the following "dramatic" probability rules:

Take in a floating point P from 0 to 1 representing the unmodified chance of some plot-related event, and a boolean representing whether we're in the climax or not.
Determine P' on these conditions:

If 0 < P ≤ 10-3 then P' = 1.
If .999 ≤ P < 1 then P' = 0.
If P = 0 and we're in the climax, then the heroes will likely get a last-minute sudden advantage and P' = .9.
If P = 1 and we're in the climax, then the villain will unveil an as-yet-unseen superweapon and P' = .1.
Otherwise, P' = P.

Return truthy or falsey based on P' as the chance of truth. For example, if P' = .7, then you should return truthy 70% of the time and falsey 30% of the time.

Shortest code in bytes wins!

R, 86 bytes

function(a,b,d=a*(1-a))runif(1)<="if"(d,"if"(d>999e-6,a,1-round(a)),"if"(b,.9-.8*a,a))

Try it online!

a is P' and b is 1 or 0 for "in the climax" or not.

If a is 0 or 1, then d will be 0, in which case if b is 0 just return a, otherwise .9 minus .8*a.

Otherwise if a is not near 0 or 1, d will be "far" from 0 so return a. Otherwise 1-round(a) will take a to the "opposite" 0 or 1.

Then see if a random selection from [0,1] is less than or equal to the resulting probability.

The link does a little simulation for all the possible scenarios to demonstrate that it all seems to work.


Approximate square root from algorithm time complexity There have been a few square root challenges lately, but I think this one is different.

Challenge

Find an algorithm such that the worst case time complexity is proportional to n^2 and the best case is proportional to n where n is the size of the algorithm input. Given a value x, find the approximate square root of x by running the chosen algorithm with some number of inputs (to be decided in code) arranged to give worst case performance; rearrange the algorithm input values to give best case performance, which will approximate the square root of the worst case run time.

Psuedocode example to help explain the challenge:

input target is 9 // find square root of 9
// target time is then 9000 ms

do
{
    create array with 10000 elements
    populate array in reverse order (array[0] = 10000; array[1] = 9999; etc)
    time how long it takes to bubble sort array
    if (time to sort > 9000 ms + margin of error)
    {
        sorting took too long; decrease array size
    }
    else if (time to sort < 9000 ms - margin of error)
    {
        sorting didn't take long enough; increase array size
    }
} while (run time is outside of 9000 ms +/- margin of error)

// the number of elements it takes to sort in n^2 time is now known
create array with correct number of elements
fill array with zeros
return the amount of time it takes to bubble sort

Implementing the above in C as a rough prototype takes 110 seconds to determine the square root of 9 is 3.781.

Rules

Input is read from stdin, file, hard-coded, wherever, as long as any positive integer can be used for input, and the program will approximate the square root. For hard-coded values, changing the input constant should be the only change needed to approximate another square root.
An algorithm must be used and must have worst case time complexity of n^2 and best case time complexity of n.
When changing form worst case to best case run time, the number of inputs must be the same.
I'm assuming that measuring run time will actually be difficult and probably slightly inaccurate. Additionally, time complexity does not mean that run time is exactly equivalent to input size, therefore the answer only needs to be accurate to within +/- 25% of the actual square root. Bonus points for improved accuracy.
Any built in math functions are available for use, but the actual square root calculation must come from measuring the best case run time. That is, calculating the square root of the input and then searching for a best case run time equivalent to the square root is allowed, but somewhat discouraged. The spirit of the challenge is to find the square root by measuring worst case run times.
Program run time must be "reasonable," say, less than an hour.

C(++), 93 Bytes

My solution:

int s(int a){int b=0;for(int i=1<<15;i>0;i/=2){if((b+i)*(b+i)<=a)b+=i;else{for(int j=1;j<i;j*=2);}}return b;}

It is O(n) for a = 0xFFFF..., and O(n^2) for a = 0x1000...
And it returns floor(sqrt(x)), which is an approximation of sqrt(x)

However, If you want an algorithm that works in O(n) time, you can shave off 28 bytes.

For test cases, append:

int main()
{
    int a = 1024;
    return s(a); //returns sqrt(1024) = 32
}


I copied my password to the clipboard! Can you delete it? Following the best security practices, I keep a plain text file with my passwords on my hard drive. In fact, I just copied and pasted one of them to access my PPCG account.
In a lucid moment, I decide that the password should better not remain in the clipboard after its use. Since this happens to me often, I could use a program to remove the clipboard contents.
Challenge
Write a program or function that deletes or overwrites any text contained in the clipboard, using a programming language of your choice.
Additional details:

If your system has several clipboards, you can write the program for any one of them. The only requirement is that it must be possible for the user to copy and paste text using that clipboard.

If your clipboard keeps a history of recent copied entries, assume the most recent entry.

If your answer is specific to an operating system or clipboard, indicate it in the title of your post, together with the used language.

The clipboard is guaranteed to contain text when your program is run. You can either delete the contents from the clipboard, or overwrite it with something else (not necessarily text). The only requirement is that after running the program, pasting from the clipboard will not produce the original text.

If you choose to overwrite with some fixed or randomly chosen text, you can assume that the previous clipboard contents are different from that text, so the password is effectively removed. In other words, disregard the possibility that the filler text coincides with the password.

The program should not have any side-effects like restarting the system, closing programs, shutting down the computer, or freezing it. After your program is run, the user should be able to keep using the computer as normal, only with the password removed from the clipboard. Also, standard loopholes are forbidden.

Shortest code in bytes wins.

PowerShell, 3 bytes

scb

That's a default alias for Set-Clipboard. When called with nothing piped in and no arguments supplied, it blows away the current clipboard contents.


Decide existence of total orderings In this task, we consider arrays of positive integers such as this:

3 18 321 17 4 4 51 1 293 17

The input comprises a pair of such arrays both of arbitrary, possibly distinct, positive length. Determine if a total ordering ≤X ⊂ N × N, where N is the set of positive integers, exists such that both input arrays are in order with respect to ≤X.  Notice that (A ≤X B ∧ B ≤X A) ↔ A = B must hold, that is, two numbers are considered equal under ≤X if and only if they are the same number.

For example, if the input was the pair of arrays

7 2 1 1 4 12 3
9 8 7 2 5 1

then you are supposed to figure out if a total ordering ≤X exists such that

  7 ≤X 2 ≤X 1 ≤X 1 ≤X 4 ≤X 12 ≤X 3

and

  9 ≤X 8 ≤X 7 ≤X 2 ≤X 5 ≤X 1.

Your submission may be a subroutine or program that receives two arrays (as specified above) of input in an implementation-defined way, computes whether a total ordering ≤X satisfying the demands mentioned above exists and returns one value representing “yes” or a different value representing “no.” The choice of these values is arbitrary, please document them.

You may assume that the input arrays contain no more than 215 - 1 elements each and that each of their elements is in the range from 1 to 215 - 1 inclusive. You may require each arrays to be terminated by a constant sentinel outside of the aforementioned range such as 0. Please specify what sentinel is needed. You may require the lengths of the arrays as additional input if the length cannot be inferred from the arrays themselves (e. g. in languages like C). In addition to the prohibition of standard loopholes, you are not allowed to use topological sorting routines.

This challenge is code golf. The submission with the least amount of characters wins.

Pyth, 28 22
L.AmqdSdmfhTmxhkbek^b2

Creates a function y that you can call with a tuple containing the two arrays. Returns "True" if a total ordering exists, "False" if not.
A helper program that defines and calls the above function with stdin:
L.AmqdSdmfhTmxhkbek^b2y,rw7rw7

Try it here.
We first read both arrays. Then we will create all combinations of both arrays. Then for each combination we will assume the first array is authoritative, and check if it's consistent with the second array.


Create a sophisticated livelock The point of the puzzle is to learn about livelocks:

Create a multi-threaded (or a multi-process) program, whose threads (processes) indefinitely try to wait for each other and never finish. Unlike a deadlock situation, the state of threads (processes) in a livelock constantly change as they try to resolve the situation, but never succeeding.

The task isn't to create a shortest or a simplest solution. Try to create a solution that resembles a real situation, something that looks like a genuine piece of code, but with some kind of an error that creates the livelock.

This is a popularity contest. The most up-voted answer in ~10 days wins.

Ruby

Based on the Dining Philosophers tale - 4 philosophers:

  Five silent philosophers sit at a table around a bowl of spaghetti. A
  fork is placed between each pair of adjacent philosophers. (An
  alternative problem formulation uses rice and chopsticks instead of
  spaghetti and forks.)

  Each philosopher must alternately think and eat. However, a
  philosopher can only eat spaghetti when he has both left and right
  forks. Each fork can be held by only one philosopher and so a
  philosopher can use the fork only if it's not being used by another
  philosopher. After he finishes eating, he needs to put down both forks
  so they become available to others. A philosopher can grab the fork on
  his right or the one on his left as they become available, but can't
  start eating before getting both of them.

class Fork

  attr_reader :owner
  def initialize
   @mutex = Mutex.new
  end

  def pickup(new_owner)
    @mutex.synchronize do
      if @owner.nil?
        @owner = new_owner
    return true
      end
      return false
    end
  end

  def release(owner)
     @mutex.synchronize do
      if @owner == owner
        @owner = nil
    return true
      end
      return false
    end
  end
end

class Philosopher

  attr_reader :name, :hungry
  attr_accessor :left_fork, :right_fork

  def initialize(name, left_fork, right_fork)
    @name = name
    @hungry = true
    @left_fork = left_fork
    @right_fork = right_fork
  end

  def eat
    while hungry
      got_left = left_fork.pickup(self)
      think
      got_right = right_fork.pickup(self)
      if got_left && got_right
        @hungry = false
    puts "#{name} has eaten!"
      end
      right_fork.release(self)
      think
      left_fork.release(self)
    end
    puts "#{name} ended"
  end

  def think
    puts "#{name} thinks..."
    sleep 1
  end
end

fork = nil
philosophers = %w(aristotle plato confucius descartes).map { |p| Philosopher.new(p, fork, fork = Fork.new) }
philosophers[0].left_fork = fork

threads = philosophers.map do |p|
  puts p.left_fork.pickup(p)
  Thread.new {
    p.eat
  }
end

threads.map(&:join)


Simplistic Lava Lamp Introduction:

I think everyone knows what a Lava Lamp is, but in case they do not:

(Image source)

They're basically glass tubes that contain wax in a translucent liquid. The bottom part is heated when the lamp is turned on, causing a change in density and thus the wax floats to the top. When it cools down, it falls down again, causing the effect we see above.

It usually takes about 45-60 minutes for the base of the lamp to rise in temperature high enough to change the solid wax to liquid wax (if the lamp is located in an area at room temperature).

More information on Wikipedia, which is also used as source for some of the text above.

Challenge:

Given a positive integer n indicating the amount of minutes that have passed since we've turned the Lava Lamp on, output a random state of the Lava Lamp based on integers on five levels.

For this challenge we'll say the Lava Lamp contains 1000 units of wax in total, and we have five levels where the wax can be at.

1) If n is below 45, the Lava Lamp is still heating up, so the output will be four empty lines with 1000 at the bottom:

1000

2) If n is in the range [45, 60) the Lava Lamp has increased in temperature enough for wax to move around, but no very high yet. The wax can reach up to and including the third level.
3) If n is 60 or higher, the wax can be at any of the five levels.

So given the positive integer n as input, we'll output a random state with the three rules above in mind.

Here are some example outputs:

Possible outputs for any n that is >= 45:

523
106
371

913

87

Possible outputs for any n that is >= 60:

73
113
312
5
497

284
55
637

24

Constant output for n that is <= 44 (and possible output for any n):

1000

Challenge rules:

There can be empty lines, even though the level above it is not empty.
Just 0 isn't allowed on any line. Should be empty instead.
Output is somewhat flexible. You are allowed to output a list/array of strings/objects instead of a new-line delimited result as above. The reason I say strings/objects is due to the rule above. An empty line should be "", null, [], etc., but cannot be 0 or a negative integer (nor can it be false) (I.e. ["", "", 913, "", 87] for n >= 45). You are also allowed to reverse the output (I.e. 1000\n\n\n\n instead of \n\n\n\n1000 or [87, null, 913, null, null] instead of [null, null, 913, null, 87]).
The numbers should all be integers. The can be decimals with 0 as decimal value, but none of the numbers should have any decimal digits, and the integers should always sum to exactly 1000.
All possible random outputs based on n should have a non-zero chance of occurring.
A trailing new-line (so there are six lines of output) is allowed.

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.
Also, adding an explanation for your answer is highly recommended.

Python 2, 117 113 108 107 106 105 bytes

from random import*
def f(n):a=['']*5;exec"i=randint(0,(n>44)+(n>59)<<1);a[i]=(a[i]or 0)+1;"*1000;print a

Try it online!

Returns a reversed list (bottom first)

Version inspired by the stackoverflow answer in the comments (edgecases are more likely):

Python 2, 129 bytes

from random import*
def f(n):a=sorted([1000]*5+sample(range(1001)*5,(n>44)+(n>59)<<1));print[y-x or''for x,y in zip([0]+a,a)[:5]]

Try it online!


For what block sizes is this checksum valid? The input:
As an example, take a list containing a number of bits (in this case, 32):
11000010000100111011000011001011

We can calculate a simple checksum of this data by dividing it into evenly sized blocks, and taking the XOR of each of them. For example, with eight bit blocks:
11000010
00010011
10110000
11001011

10101010

We then append this to the end, making it 40 bits:
1100001000010011101100001100101110101010

This will be the form your input is given in.
To validate a checksum in this form, you just take the XOR of each block, including the checksum. If it's valid, it will result in a string of zeroes.
The challenge:
I've got a bunch of data with checksums. The problem is, I don't remember what the block size was! Your task is to write a program or function which takes input of any length, and returns all of the block sizes where the checksum is valid.
Blocks with sizes that do not fit evenly into the input should be ignored (so 7 would not be allowed in the output given 00000000). In the example above, the valid block sizes would be [1, 2, 4, 8], and the invalid ones would be [5, 10, 20].
Note that block sizes of one are possible (valid if the XOR of every bit in the string results in 0). A block the size of the entire string is not valid (so 8 would not be allowed in the output given 00000000), and blocks with sizes less than two do not need to be handled.
You can produce output and take input in any reasonable manner, such as lists of bits, strings of 0s and 1s, integers representing the binary values, etc.
This is code-golf, so shortest answer in bytes per language wins!
Test cases:
1100100001000000  ->  [1, 2, 4]
010010100100      ->  [1, 2, 3]
0000000000        ->  [1, 2, 5]
101101000         ->  [1, 3]
10010110          ->  [1, 2]
10000000          ->  []
0101010           ->  []
11                ->  [1]
1                 ->  (does not need to be handled)
                  ->  (does not need to be handled)

05AB1E, 10 8 bytes
Input is a list of bits.
gÑ¨ʒιOÈP

Try it online!
Commented:
gÑ          # push the divisors of the length of the input
  ¨         # remove the last one (the length itself)
   ʒ        # filter this list on:
    ι       #   push [a[0::b], a[1::b], ..., a[(b - 1)::b]] where a is the input b the divisor
            #   this groups the digits from each group at the same index together
     O      #   sum each list
      ÈP    #   are all sums even?


nth number with n distinct prime factors A073329 is a sequence where the \$n\$th term is the \$n\$th number with exactly \$n\$ distinct prime factors. For example, \$a(3) = 60\$ as the first \$3\$ integers with \$3\$ distinct prime factors are \$30 = 2 \times 3 \times 5\$, \$42 = 2\times3\times7\$ and \$60 = 2^2 \times 3 \times 5\$.
You are to take a positive integer \$n\$ and output the first \$n\$ terms of the sequence. You may assume the input will never exceed the bounds of your language's integers. This is code-golf so the shortest code in bytes wins.
The first 10 terms of the sequence are
2, 10, 60, 420, 4290, 53130, 903210, 17687670, 406816410, 11125544430

Java, 170 characters in one line

int a(int n) {
    int a = 2, t = a, m = 1, i = 1;
    Set s = new HashSet();
    while (i++ > 0) {
        if (t % i == 0) {
            s.add(i);
            t /= i;
            if (t == 1) {
                if (s.size() == n) {
                    if (n == m) {
                        break;
                    }
                    m++;
                }
                t = ++a;
                s.clear();
            }
            i = 1;
        }
    }
    return a;
}

Update, +77 characters IOL

int[] f(int n) {
    int[] f = new int[n];
    for (int i = 0; i < n; i++) {
        f[i] = a(i+1);
    }
    return f;
}


Calculate A(N) / B(N) with C(N) digits Consider three number sequences, \$A\$, \$B\$ and \$C\$:

\$A\$: A sequence based on recurrence relations, \$f(n) = f(n-1)+f(n-2)\$, starting with \$f(1) = 3, f(2) = 4\$. So, the sequence begins like this: \$3, 4, 7, 11, 18, 29, 47, 76, ...\$
\$B\$: The composite numbers, that is all integers that aren't primes (or 1): \$4, 6, 8, 9, 10, 12, 14, 15, 16, ...\$
\$C\$: The digits of \$\pi\$: \$3, 1, 4, 1, 5, 9, 2, 6, 5, ...\$

Given a positive integer \$N < 50\$, either as function argument or STDIN, return the decimal value of the fraction \$\frac{A(N)}{B(N)}\$ with \$C(N)\$ digits after the decimal point. Normal rules for rounding applies (round up if the \$N+1\$'th digit is 5 or higher). If the Nth digit of \$\pi\$ is zero, an integer should be printed. scientific notation / Standard form is accepted for numbers higher than 1000.
This is code golf, so the shortest answer in bytes wins.
Some examples:
N = 1: 0.750
N = 2: 0.7
N = 3: 0.8750
N = 4: 1.2
N = 6: 2.416666667
N = 10: 11.056
N = 20: 764.8750

Of course, standard code golf rules applies.
The function must terminate in less than two minutes on any modern laptop.

Pyth, 60 57 58 bytes

.[K`.Rchu,eGsGQjT7e.ftPZQ)Je/u+/*GHhyHy^TQr^T3ZZT\0+xK\.hJ

Test harness

It's pretty straightforward - calculate pi, the fibonacci series and the composites, round to C(n) digits, pad to C(n) digits plus the location of the decimal point digits, done.

A(n): hu,eGsGQjT7

B(n): e.ftPZQ)

C(n): e/u+/*GHhyHy^TQr99ZZT

60 -> 57: Cleaned up the n = 1 special case in the pi calculation.

57 -> 58: Wasn't using high enough precsion for pi for the entire input range - increased 99 iterations to 1000 iterations.

Note on rounding: This uses Python's "nearest even" rounding system, rather than the OP specified "towards infinity" system. However, the difference only matters if the digits immediately following the rounding point are 5000..., e.g. 1.25 rounded to 1 digit. I checked the input range, and this never happens, so the correct result is alway returned.


Make FizzBuzz using only preprocessor directives I have a source file here:

#include <FizzBuzz.h>
fizzbuzz

And I want to make "fizzbuzz" turn into a FizzBuzz program solely through the preprocessor.

Your task is to write a FizzBuzz.h that uses only preprocessor directives (things like include, define, etc.) to create a working FizzBuzz program. Specifically, I want to see the use of macros, which will be required to make this work (at minimum, defining fizzbuzz to be some code).

However, to make sure people try and take full advantage of the power of macros, your score will be defined as the sum of the cubes of the length of the definition portion (the part after #define <symbol>) of each macro.

So, for example, the following file:

#define A 123
#define B A+A
#define C B*2+A

would have a total score of 179 (3^3 + 3^3 + 5^3). As a rule, I want multiple shorter lines instead of one long line.

C, Score 1,283 1,213 1,205

EDIT: Instead of basing on Loki Astari's solution, now I'm based on breadbox's

The basic code is not exactly the same as breadbox's - I replaced the loop with recursion, which is longer, but has more repetition.

With GCC, it can be improved further, by using ?: instead of ?0:.

#define A "Fi"
#define D "Bu"
#define E "z"
#define L E E
#define F L,z
#define R F)
#define G A R
#define H D R
#define I ""
#define K "%d"
#define X printf
#define Y puts
#define Z main
#define M 99
#define N z%5
#define O z%3
#define P Z(z
#define Q P)
#define a Q{X
#define b a(O
#define c b?N
#define d c?K
#define e d:I
#define f e:G
#define i f;Y
#define j i(N
#define k j?I
#define l k:H
#define n l;z
#define o n++
#define p o>M
#define q p?0
#define r q:Q
#define s r;
#define fizzbuzz s}

Macro-free code:

main(z){printf(z%3?z%5?"%d":"":"Fizz",z);puts(z%5?"":"Buzz",z);z++>99?0:main(z);}

The 2nd parameter to puts does nothing. It allows me to utilize the zz",z) sequence.


Illustrate the square of a binomial Given (by any means) two different natural numbers (of any reasonable size), output (by any means) the square of their sum as in the examples below:

Given 4 and 3, output:

12 12 12 12  9  9  9
12 12 12 12  9  9  9
12 12 12 12  9  9  9
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12

Given 1 and 3, output:

3 9 9 9
3 9 9 9
3 9 9 9
1 3 3 3

Whitespace may vary within reason but the columns must be left-aligned, right-aligned, or (pseudo-)centered.

A trailing newline is fine, but standard loopholes are not.

This is code-golf so include a header like # LanguageName, 123 in your answer, where the number is chars (bytes for languages that are not text-based). Packing code to large Unicode chars is not allowed.

Bonus: -3 if your code outputs just one square when one of the numbers is 0; e.g. given 0 and 3, output:

9 9 9
9 9 9
9 9 9

J, 9 bytes - 3 = 6

#~@|.*/#~

Inspired by @NBZ's APL answer, golfed down by @randomra.
This defines a verb that takes in an array of numbers. It's used as follows:

   (#~@|.*/#~) 4 3
12 12 12 12  9  9  9
12 12 12 12  9  9  9
12 12 12 12  9  9  9
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12

I also claim the 3-byte bonus, since an input of 0 produces sub-matrices of size zero:

   (#~@|.*/#~) 4 0
16 16 16 16
16 16 16 16
16 16 16 16
16 16 16 16
   (#~@|.*/#~) 0 3
9 9 9
9 9 9
9 9 9

Explanation

J has a definite edge in this challenge.
In addition to eating array manipulation problems for breakfast, it prints 2D matrices in the correct format by default.

       #~  Replicate each number n in input n times
#~@|.      The same for reversed input
     */    Compute their multiplication table


Write a program with infinite expected output Write a program that halts producing a random finite numerical output with probability 1. The expected value of the outputs of the program must be infinite.
For physical limits, you can assume your language and related functions use infinite precision numbers. E.g. for languages with random function providing range \$[0,1)\$, it returns a real in \$[0,1)\$. (Anyway I need to choose from 1/rnd and while(rnd)print(1))
Inspired by St. Petersburg paradox.
Shortest code wins. Would be quite small for lots of language though.

There are two easy-seen ways to do this, both are accepted given the question: (in Javascript)
_=>1/Math.random() // ∫₀¹1/xdx=∞
_=>{c='1';while(Math.random()<.5)c+='1';return c} // Not golfed to easier get understood for other language user, at least I try to
    // 1/2+11/4+111/8+1111/16+...=∞

R, 9 bytes

rf(1,1,1)

Try it online!
Outputs a realization of the \$F(1,1)\$ distribution. The \$F(d_1,d_2)\$-distribution has infinite mean for \$d_2 \leq 2\$.
One way of defining the \$F(1,1)\$ distribution is as follows: let \$X_1,X_2\$ be independent \$\mathcal N(0,1)\$ random variables. Then \$\frac{X_1^2}{X_2^2}\sim F(1,1)\$.
Using the \$F\$ distribution comes out 1 byte shorter than the 2 more obvious solutions 1/runif(1) and rcauchy(1).
The plot below shows the evolution of the sample mean, for sample size ranging from 1 to 1e6; you can see that it diverges.

Alternate solution for the same byte count:
rt(1,1)^2

which outputs the square of a realization of Student's distribution \$t(1)\$. It has infinite expected value, since the \$t(1)\$ distribution has infinite variance. The square is needed to guarantee that the output is positive; without it, the expected value is undefined, since the realizations are often enough arbitrarily large positive or negative numbers.