On the Subject of Passwords In Keep Talking and Nobody Explodes, players are tasked with defusing bombs based on information from their "experts" (other people with a manual). Each bomb is made up of modules, one of which can be passwords, where the expert is given this list of possible passwords, all five letters long:

about   after   again   below   could
every   first   found   great   house
large   learn   never   other   place
plant   point   right   small   sound
spell   still   study   their   there
these   thing   think   three   water
where   which   world   would   write

And the player is given a list of 6 possible letters for each place in the password. Given the possible letter combinations, output the correct password. Input can be in any reasonable format (2D array, string separated by newline, etc.) You may discount the code which you use to compress/generate the list/string/array/whatever of passwords. (Thanks @DenkerAffe)

NOTE: Passwords are case insensitive. You may assume that input will only solve for one password.

Examples / Test Cases

Input here will be represented as a array of strings.

["FGARTW","LKSIRE","UHRKPA","TGYSTG","LUOTEU"] => first
["ULOIPE","GEYARF","SHRGWE","JEHSDG","EJHDSP"] => large
["SHWYEU","YEUTLS","IHEWRA","HWULER","EUELJD"] => still

Pyth, 13 bytes

:#%*"[%s]"5Q0c"ABOUTAFTERAGAINBELOWCOULDEVERYFIRSTFOUNDGREATHOUSELARGELEARNNEVEROTHERPLACEPLANTPOINTRIGHTSMALLSOUNDSPELLSTILLSTUDYTHEIRTHERETHESETHINGTHINKTHREEWATERWHEREWHICHWORLDWOULDWRITE"5

Test suite.

 #             filter possible words on
:           0  regex match, with pattern
  %        Q   format input as
    "[%s]"     surround each group of letters with brackets (regex char class)
   *      5    repeat format string 5 times for 5 groups of letters


Encode the alphabet cipher Given a string that contains only lowercase letters, encode that string with the alphabet cipher.

To encode with the alphabet cipher (I will be using the example hello):

First, convert each letter in the string to a number depending on its position in the alphabet (a = 1, b = 2, etc.) Example: 8 5 12 12 15
Pad each number to two characters with 0s. Example: 08 05 12 12 15
Join. Example: 0805121215

Test cases

helloworld -> 08051212152315181204
codegolf -> 0315040507151206
alphabetcipher -> 0112160801020520030916080518
johncena -> 1015081403051401

Remember, this is code-golf, so the code with the fewest number of bytes wins.

05AB1E, 11 6 bytes

Code:

Ç4+€¦J

Explanation:

First, we convert the string to their ASCII values. codegolf would become:

[99, 111, 100, 101, 103, 111, 108, 102]

To get to the indices of the alphabet, you subtract 96:

[3, 15, 4, 5, 7, 15, 12, 6]

To pad with zeros, add 100 to each element and remove the first character of each int. For the above example, +100 would be:

[103, 115, 104, 105, 107, 115, 112, 106]

And removing the first character of each would lead to:

[03, 15, 04, 05, 07, 15, 12, 06]

We can merge both steps above (the -96 and the +100) part to just +4. For the code:

Ç       # Convert to an array of ASCII code points
 4+     # Add four to each element in the array
   €¦   # Remove the first character of each element
     J  # Join to a single string

Try it online!


Write a Playfair encryption program Write a program that takes two lines of input and uses the first as a key phrase to encrypt the second according to the Playfair encryption technique.
Wikipedia describes Playfair encryption in some detail, but to avoid any ambiguity, here's a brief summary:
1. Generate a key table:
Replace all occurrences of J in the key phrase with I, then strip all non-alphabet characters and repeated characters. Insert into a 5×5 encryption table, filling the remaining cells with the rest of the alphabet (except J; we don't like J).
Example:
                                        S T A C K
                                        O V E R F
Stack Overflow  -->  STACKOVERFLW  -->  L W B D G
                                        H I M N P
                                        Q U X Y Z

2. Prepare the message to be encrypted
Replace every J with an I, strip all non-alphabet characters and split into pairs, using an X to break any pairs that contain the same letter twice. If you end up with an odd number of letters, add X at the end. (Note: Numerals have to be spelt out in full — ONE, TWO, THREE, etc. — but you can assume this has already been done for you.)
Example:
In:
The cat crept into the crypt, crapped, and crept out again.

Out:
TH EC AT CR EP TI NT OT HE CR YP TC RA PX PE DA ND CR EP TO UT AG AI NX

3. Encryption
Encrypt each pair of letters in turn. If they are in different rows and columns of the key table, replace each with the letter from the same row in the column where the other letter is found (e.g., VM⇒EI, LZ⇒GQ). If they are in the same row (or column), choose the two characters immediately to the right (or below), wrapping around if necessary (e.g., OE⇒VR, ZG⇒KP).
Example:
In:
TH EC AT CR EP TI NT OT HE CR YP TC RA PX PE DA ND CR EP TO UT AG AI NX

Out:
SI RA CA RD FM VU IC VS MO RD ZN AK EC MZ MF BC YN RD FM SV TV KB TM MY

The string produced by this process is the encrypted message, which your program should output.
Rules:

The input text and key may be obtained from stdin, command line arguments or other such sources. Hard-coded input is not allowed.
Your program must accept both upper and lower case text for the pass phrase and message.
The encrypted output may be upper or lower case.
Your program should accept key phrases of at least 64 characters in length, and message texts of at least 16 KB.
You are not required to handle non-ASCII input.
You may ignore the possibility of the letter pair XX occurring during encryption.
There is no need to add whitespace to the output of the program.
Your answer should include an example of a message, key phrase and encrypted output produced by your program.
This is a code golf challenge, so the answer with the shortest code (in bytes) will win.

NOTE: Please remember that you only need to break consecutive letters if they appear in the same pair. So for example MASSACHUSETTS should be encrypted as MA SX SA CH US ET TS — the double S has to be split, but the double T doesn't.

J I*, 536 431 417 380 263 218 203 197 186 167

p=:4 :0
a=.u:65+9-.~i.26
,_2(5|,:~@|.@(=/)+$$,A.~5*1-0{=/)&.(5 5#:(~.n x,a)&i.)\(,'X'#~2|#)(({.,'X',}.)~1+2*1{&I._2{.\2=/\]) ::]^:_(n=:a(e.~#])'JI'charsub toupper)y
)

(with extensive suggestions from @algorithmshark)

example use:

   'Stack Overflow' p 'The cat crept into the crypt, crapped, and crept out again.'
SIRACARDFMVUICVSMORDZNAKECMZMFBCYNRDFMSVTVKBTMMY

splits input correctly:

   d=:(({.,'X',}.)~1+2*1{&I._2{.\2=/\]) ::]
   d^:_ 'MASSACHUSETTS'
MASXSACHUSETTS

*replace every J with an I, right?


Shortest undefined behavior sample in C++ What's the shortest, well-formed C++ code that exhibits undefined behavior?

int main(){main;}

  3.6.1 Main function [basic.start.main]

  3 - [...] The function main shall not be used within a program.

Edit: this is diagnosable, so not UB.

int main(){for(;;);}

  1.10 Multi-threaded executions and data races [intro.multithread]

  24 - The implementation may assume that any thread will eventually do one of the following:
  — terminate,
  — make a call to a library I/O function,
  — access or modify a volatile object, or
  — perform a synchronization operation or an atomic operation.

int main(){int i=i;}

  4.1 Lvalue-to-rvalue conversion [conv.lval]

  1 - [...] If the object to which the glvalue refers is [...] uninitialized, a program
  that necessitates this conversion has undeﬁned behavior.

//^L.

Here ^L is the form feed character, which is part of the basic character set.  4 characters (a newline is not required per 2.2:2).  Undefined behaviour is per

  2.8 Comments [lex.comment]

  1 - If there is a
  form-feed or a vertical-tab character in [a //-style] comment, only white-space characters shall appear between it
  and the new-line that terminates the comment; no diagnostic is required.


Reverse order of words in a string inplace The Task

You are given a mutable string that matches [a-z]+( [a-z]+)*.
You must mutate it into the string which contains the same words, but in reverse order, so that "hello there everyone" becomes "everyone there hello".
You are not permitted to use more than a constant amount of additional memory (so no copying the entire string or any whole word into a buffer you just allocated).
There are no time constraints. Being hopelessly inefficient will not harm your score.
If your language of choice does not permit mutation of strings, arrays of characters are an acceptable substitute.

Your Score

Your score is counted purely on the number of assigments you make to string elements (small scores are best). If you use a library function that writes to the string, its writes also count.
Suppose the number of assignments you need for input s is n(s). Then your score is the maximum (pedantically, supremum) over all inputs s (matching the regex specified above) of n(s)/length(s). If you cannot calculate this precisely, you can use the lowest upper bound that you can prove.
You can break a tie if you can prove that your algorithm uses asymptotically fewer assignments (this can happen even if you have the same score, see below). If you can't do this, you can break a tie by showing that you use less additional memory. However, the first tie-break condition always takes precedence.
For some inputs every character needs to change, so it is not possible to score less than 1.
I can think of a simple algorithm with score 2 (but I'm not entering it).

Notes on suprema and ties

A supremum of a set of numbers is the smallest number that is not smaller than any of them. This is much like the maximum of a set, except that some infinite sets like {2/3, 3/4, 4/5, 5/6, ...} have no single maximum element, but will still have a supremum, in this case 1.
If you manage to "save" only a constant number of assignments over my algorithm of score 2 (say), your score will still be 2, because you'll get arbitrarily close to 2 the larger your input gets. However, you win on the tie-break if it comes to that.

Perl, score 1.3̅

For each non-space character one assignment is performed, and for each space character two assignments. Because space characters cannot amount to more than one half the total number of characters, the worst case score is 1.5.

The algorithm hasn't changed, but I can prove a lower upper bound. Let us make two observations:

Spaces directly across from spaces do not need to be swapped.
Single character words directly across from spaces are not swapped during the main phase, but only once at the end.

It can then be seen that the theoretical 'worst case' with asymptotically 1/2 spaces is not worst case at all: ab c d e f g h i ...

$ echo ab c d e f g h i j k l m n o p q r s t u v w x y z|perl reverse-inplace.pl
z y x w v u t s r q p o n m l k j i h g f e d c ab
swaps: 51; len: 50
ratio: 1.02

In fact, it's quite a good case.

In order to prevent observation one and two above, each one-character word would need to be repositioned into the middle of a word three or more characters long. This would suggest a worst case containing asymptotically 1/3 spaces: a bcd a bcd a ... bc

$ echo a bcd a bcd a bcd a bcd a bcd a bc|perl reverse-inplace.pl
bc a bcd a bcd a bcd a bcd a bcd a
swaps: 45; len: 34
ratio: 1.32352941176471

Or equivalently, only two-character words: a bc de fg hi jk ...

$ echo a bc de fg hi jk lm no pq rs tu vx xy|perl reverse-inplace.pl
xy vx tu rs pq no lm jk hi fg de bc a
swaps: 49; len: 37
ratio: 1.32432432432432

Because the worst case contains asymptotically 1/3 spaces, the worst case score becomes 1.3̅.

#!perl -l
use warnings;

$words = <>;
chomp($words);
$len = length($words);
$words .= ' ';
$spaces = 0;
# iterate over the string, count the spaces
$spaces++ while $words =~ m/ /g;

$origin = 0;
$o = vec($words, $origin, 8);
$cycle_begin = $origin;
$swaps = 0;

# this possibly terinates one iteration early,
# if the last char is a one-cycle (i.e. moves to its current location)
# one-cycles previous to the last are iterated, but not swapped.
while ($i++ < $len - $spaces || !$was_cycle) {
  $w_start = rindex($words, ' ', $origin);
  $w_end = index($words, ' ', $origin);
  $pos = ($origin - $w_start) - 1;
  $target = $len - ($w_end - $pos);
  $t = vec($words, $target, 8);

  if ($t == 32) {
    $target = $len - $target - 1;
    $t = vec($words, $target, 8);
  }

  # char is already correct, possibly a one-cycle
  if ($t != $o) {
    $swaps += 1;
    vec($words, $target, 8) = $o;
  }

  $origin = $target;
  $o = $t;
  if ($origin == $cycle_begin) {
    if ($i < $len - $spaces) {
      # backtrack through everything we've done up to this point
      # to find the next unswapped char ...seriously.
      $origin += 1;
      if (vec($words, $origin, 8) == 32) {
        $origin += 1;
      }
      $bt_origin = 0;
      $bt_cycle_begin = 0;
      while ($bt_cycle_begin < $origin) {
        $w_start = rindex($words, ' ', $bt_origin);
        $w_end = index($words, ' ', $bt_origin);
        $pos = ($bt_origin - $w_start) - 1;
        $target = $len - ($w_end - $pos);
        $t = vec($words, $target, 8);

        if ($t == 32) {
          $target = $len - $target - 1;
          $t = vec($words, $target, 8);
        }

        if ($target == $bt_cycle_begin) {
          $bt_origin = ++$bt_cycle_begin;
          if (vec($words, $bt_origin, 8) == 32) {
            $bt_origin = ++$bt_cycle_begin;
          }
        } else {
          $bt_origin = $target;
        }

        if ($target == $origin) {
          $origin += 1;
          if (vec($words, $origin, 8) == 32) {
            $origin += 1;
          }
          $bt_origin = $bt_cycle_begin = 0;
        }
      }
    }

    $cycle_begin = $origin;
    $o = vec($words, $origin, 8);
    $was_cycle = 1;
  } else {
    $was_cycle = 0;
  }
}

for $i (0..$len/2-1) {
  $mirror = $len - $i - 1;
  $o = vec($words, $i, 8);
  $m = vec($words, $mirror, 8);
  # if exactly one is a space...
  if (($o == 32) ^ ($m == 32)) {
    $swaps += 2;
    vec($words, $mirror, 8) = $o;
    vec($words, $i, 8) = $m;
  }
}

chop($words);
print $words;
print "swaps: $swaps; len: $len";
print 'ratio: ', $swaps/$len;

Edit: Added a swap counter, and the ratio.

Input is taken from stdin. Sample usage:

$ echo where in the world is carmen sandiego|perl reverse-inplace.pl
sandiego carmen is world the in where
swaps: 35; len: 37
ratio: 0.945945945945946

Method

To begin, the first character of the string is moved to its final destination. The character just replaced is then moved to its destination, etc. This continues until one of two conditions is met:

The character should be swapped with a space.
When this occurs, the character is not swapped with the space, but rather into the mirror position of the space. The algorithm continues from that position.
A cycle has been reached.
When the target returns to the initial starting position of the current cycle, the next unswapped character (or rather, any unswapped character would do) needs to be found. To do this under constant memory constraints, all swaps that have been made up to this point are back-tracked.

After this phase, each non-space character has been moved at most once. To finish, all space characters are swapped with the characters at their mirror positions, requiring two assignment operations per space.


Generalized Gray codes Input: An array I of k positive integers. The integers will be no larger than 100 and k ≤ 100.

Output: Your code must output all possible arrays O of non-negative integers  of length k with the restriction that 0 ≤ Oi ≤ Ii. To get from one array to the next you may  add or subtract 1 to one value in the array.  Your code must not output the same array twice.  If the number of different arrays to be output is very large, your code should just carry on outputting forever until it is killed.

Examples

If I is an array of k ones then this is exactly the problem of iterating over all Gray codes of bit width k, except that the first and the last element do not need to be reachable in one step.
If I = [2,1] then one possible ordering of the output arrays is (0,0),(0,1),(1,1),(1,0),(2,0),(2,1)
If I = [2,1,3] then one possible ordering of the output arrays is (0,0,0),(0,0,1),(0,0,2),(0,0,3),(0,1,3),(0,1,2),(0,1,1),(0,1,0),(1,1,0),(1,1,1),(1,1,2),(1,1,3),(2,1,3),(2,1,2),(2,1,1),(2,1,0),....

This is a code-golf challenge, the submission with the source code with the shortest length wins. Don't let the short answers in golfing languages discourage you from posting an answer in other languages. Try to come up with the shortest answer in any language.

This is also a restricted-complexity challenge. Every new array should be output with O(k) time elapsing since the previous outputted array (or the start of the program for the first array outputted). This means that the running time per new output array (they are each of length k) should be no greater than O(k). That is it should take time proportion to k and not, for example k2 or 2k.  Note this is not the average time per output but the worst case time for each and every array outputted.

You can assume that all arithmetic on 64 bit integers can be performed in constant time as can reading and outputting them as well as assignment and looking up and changing values in arrays.

One consequence of the restricted-complexity is that solutions that only output at program exit are not acceptable.

Python 3, 116 bytes

def f(a):
 l=len(a);t=[0]*l;d=[1]*l
 while 1:
  i=0;yield t
  while not-1<t[i]+d[i]<=a[i]:d[i]*=-1;i+=1
  t[i]+=d[i]

Try it online!

Thanks Mnemonic for -1 byte.

Generator function. (thanks Dennis for reminding me, I forgot the feature exists) If the output should be printed to stdout then use print(t,flush=1) for 9 additional bytes, or if Python is called with -u, print(t) suffices for +1 bytes.

Stops with an error (IndexError). If you want to call this function and then continue the program, you have to catch it.


The Great, White, North! Eh!
You know, the problem with us Canadians is that sometimes, after a long day of moose hunting and dam repairing, we forget our way back to our cabins! Wouldn't it be great if our handy laptop (which, is always at our side), had some way to point us home? Well, it's been long told that, if you display a compass on your computer, it will be the brightest when pointed North. I'd like to test this out, but I need a compact program to take with me on my next trip, because my hard drive is already filled with maple syrup recipes (and those CANNOT go). So, your task is to design me a program which, when run, saves or displays an image of the following compass rose:

The letters may be in a different font. Remember, least is best, so lowest byte count wins!
Specifications
Colors

Light purple: #9999FF
Gray: #E5E5E5

Lengths and Angles

Angle a = 45°
Angle b = 90°
Length c = 250 units
Length d = 200 units
Length e = 40 units
Length f = 45 units

Clarifications

The text may be in any appropriate font, where appropriate denotes that it is readable to the average, educated human being.
The text must be 3 units away from the spikes at its closest point, must not touch the rose, and must be upright
If a line is drawn from the center of the rose, through the end point of the spike and beyond, it should cross through the center of the text with a precision of +/- 2 units (the text must be centered along an axis a, where a extends from the middle of the page, through the end of the spike, and beyond)
Each character must be at least 15 units by 15 units, and have an x/y or y/x ratio of no more than 2:1 (no stretching – readability)
The dim circle passing through the longer spikes and text closest to the middle on the reference image is not to be drawn.
The image must be square, and at least 400px by 400px
A compressed image within the source is disallowed
A unit must be at least 1 pixel

HTML + CSS, 487 + 189 = 676

The compass rose is constructed from CSS borders using the triangle technique and some basic transformations. The letters are just given fixed positions, so that turned out quite long :/

The snippet below is scaled down so that it all fits. You can check out the JSFiddle here. Also, I'm not sure how well the letters will line up on different browsers (with different fonts, default styles, etc.).

html{transform:scale(0.2)}body{margin:5em}hr{margin:0;float:left;border:250px solid transparent;border-right:58px solid #E5E5E5;border-bottom:58px solid #9999FF}a{position:fixed;width:616px;font-size:4em}#a{transform:rotate(90deg)}#b{transform:rotate(270deg)}#c{transform:rotate(180deg)}#d{transform:rotate(45deg)scale(.8)}#n{top:20px;left:365px}#e{top:356px;left:700px}#s{top:700px;left:370px}#w{top:356px;left:10px}#N{top:150px;left:550px}#E{top:560px;left:550px}#S{top:560px;left:140px}#W{top:150px;left:140px}
NESWNESESWNW


Does this month start on a Monday? June 2020 is a month in which June 1st corresponds to Monday, June 2nd corresponds to Tuesday, ... June 7th corresponds to Sunday. For reference, here's the cal of June 2020.
      June 2020
Su Mo Tu We Th Fr Sa
    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

Given a year and a month in the format [year, month], output two distinct values that tell whether this month starts on a Monday.
Test cases
[2020,6] -> True
[2021,2] -> True
[1929,4] -> True

[1969,1] -> False
[1997,5] -> False
[2060,1] -> False

Specification

The input can be in any format you prefer for your answer, e.g. numeric list, numeric tuple, etc. It doesn't have to be taken in this rigid format (it's JSON by the way).
However, making the input a Date object is a loophole here. You shouldn't make the input a Date object.
The month in the input doesn't have to be 1-indexed - it can also be 0-indexed.
You need to support all years after 1582 (the start of the Proleptic Gregorian calendar), up to the year 9999.

Excel,  44  34 23 19 18 bytes
=2=MOD(A3&"-"&A2,7

-11 thanks to Adam and -4 thanks to Shazback
-1 thanks to this
Original Answer
=(TEXT(DATE(A2,A3,1),"ddd")="Mon")

Ensure that the year is placed in cell A2 and the month in A3.
:( Crossed out 44 is still 44.


Generate a Baseball Pitch String Goal
Write a program or function that takes a positive integer n and randomly generate a legal series of pitches (henceforth called a Pitch string) of length n.
Input
A non-zero, positive integer n <= 100
Output
Return a random string, or list of characters, that represent a possible, valid pitch string of length n. The characters used will be:

B - Ball. If you accumulate 4 of these, the batter is walked and finished batting.
S - Strike. If you accumulate 3 of these, the batter is out and finished batting.
F - Foul. Will also increase the Strike count but cannot get the batter out. I.e., you cannot have a Foul be the last pitch in a valid string. Any fouls past two strikes/fouls will not increase the Strike count (the batter already has 2 strikes at that point and a 3rd would get him out).
H - Hit. The batter has hit a ball into play and is finished batting.

(This is simplified slightly but don't you worry about that)
Valid pitch strings are those that end in a strike-out, a walk, or a hit.
I.e., an invalid pitch string has either

additional pitches after the 4th Ball, 3rd Strike, or Hit
terminated before generating a 4th ball, 3rd strike, or Hit.

Rules

Your program must be able to produce all possible results for a given input.
Your program does not have to be uniformly random but still must follow the previous rule.
This is code-golf.

Examples
Input => Possible Outputs
1 => [H] #Can only end with a hit
2 => [S,H], [B,H], [F,H] #Can only end with a hit
3 => [S,S,S], [F,F,S], [B,B,H], ... #Can now strike-out, otherwise must end with a hit
4 => [B,B,B,B], [S,B,S,S], [B,F,S,S], [B,B,B,H], ... #Can now be walked, struck-out, or get a hit
6 => [S,B,S,B,B,H], [F,F,F,F,F,S], ... #Can now have a full-count (3 balls, 2 strikes) before finishing

Input => Invalid Outputs
1 => [S], [B]    #Not enough for a strike-out/walk
2 => [S,S]       #Not enough for a strike-out/walk
2 => [H,H]       #Batter has already scored a hit
3 => [S,S,F]     #Fouls will not cause a strike-out
4 => [S,S,S,H]   #Batter has already struck out
5 => [B,B,B,B,B] #Batter has already walked

Python 2, 128 bytes

from random import*
def g(n):
 x=i=S=0;r=''
 while(S>2)+x<3>=i-S:x=randint(0,3);r+='BFSH'[x];S+=x>0;i+=1
 return(i==n)*r or g(n)

Try it online!

Randomly generate the pitch string until the batter is done, output it if it turns out the right length, and otherwise try again from scratch.

Python 2, 136 bytes

from random import*
def g(n):
 B=H=F=S=0;r=''
 while(F+S<3or'S'>x)>B/4+H:x=choice('BHFS');r+=x;exec x+"+=1"
 return(len(r)==n)*r or g(n)

Try it online!


Write a Programming language of Unknown Completeness Determining whether a Language is Turing Complete is very important when designing a language.  It is a also a pretty difficult task for a lot of esoteric programming languages to begin with, but lets kick it up a notch.  Lets make some programming languages that are so hard to prove Turing Complete that even the best mathematicians in the world will fail to prove them either way.  Your task is to devise and implement a language whose Turing Completeness relies on a major unsolved problem in Mathematics.
Rules

The problem you choose must have be posed at least 10 years ago and must be  unsolved, as of the posting of this question.  It can be any provable conjecture in mathematics not just one of the ones listed on the Wikipedia page.

You must provide a specification of the language and an implementation in an existing language.

The programming language must be Turing complete if and only if the conjecture holds.  (or if and only if the conjecture doesn't hold)

You must include a proof as to why it would be Turing complete or incomplete based on the chosen conjecture.  You may assume access to unbounded memory when running the interpreter or compiled program.

Since we are concerned with Turing Completeness I/O is not required, however the goal is to make the most interesting language so it might help.

This is a popularity-contest so the answer with the most votes will win.

Target Criteria
What should a good answer do?  Here are some things to look for when voting but are not technically required

It should not be a simple patch of an existing language.  Changing an existing language to fit the specifications is fine but patching on a condition is discouraged because it is boring.  As said by ais523 in the Nineteeth Byte:

I prefer to make my esolangs' gimmicks more firmly baked into the language

It should be interesting as a standalone esoteric language.

Legendre

This language is only Turing-complete if and only if Legendre's conjecture is false, i.e. there exists a integer n > 0 such that there are no primes between n^2 and (n+1)^2. This language takes some inspiration from Underload, though in some respects it is very different from it.

Programs in Legendre are made up of series of positive integers (0 is especially banned, because it essentially negates the entire purpose of the language). Each integer corresponds to a base command in Legendre, or a potential user-defined one. Which command it is assigned to is based on the number of primes between its square and the next integer (equivalent to the OEIS sequence A014085).

The language's commands modify a stack, which can hold arbitrarily large positive integers. If the stack ever holds 0, the 0 is immediately removed. In detail, the commands are:

2 (smallest integer producing this command: 1): Push the next integer in the program onto the stack.
3 (smallest producing integer: 4): Pop the top integer on the stack and execute the command associated with it.
4 (smallest: 6): Pop the top integer. If it was 1, increment the top integer on the stack.
5 (10): Swap the top two stack items.
6 (15): Decrement the top integer on the stack. If that results in 0, pop the 0 and discard it.
7 (16): Duplicate the top integer on the stack.
8 (25): Halt execution and print the stack contents.

This is the basic instruction set, which is unable to do anything interesting, let alone loop. However, there is another command, which can be accessed only if Legendre's conjecture proves false.

0 (unknown): Remove all items from the stack and combine them into a new function, which will execute all commands starting at the original bottom of the stack and ending at the top, accessible as a command whose "command number" is equal to the one the next integer in the program source corresponds to.

If this command is somehow accessible, the language becomes Turing-complete, as one can simulate a Minsky machine in it.

When the command 8 is execute or the end of the program is reached, the program terminates and the (Unicode) character corresponding to each integer on the stack is printed.

Example programs

1 2 1 3 1 10 4

This simple program pushes the number 2, then 3 and finally a 10, before executing a 4 (command: 3), which causes the 10 (command: 5) to be popped and executed, swapping the 2 and 3.

1 5 3 15 2 1 6 7

This program demonstrates the use of the indirect integer-to-command correspondence. First, a 5 is pushed, then a 15 and a 1, using three different ways of encoding the 2 command. Then, the 1 is popped and as a result, the 15 is incremented to a 16, and finally executed. The program ends with two instances of the number 5 on the stack.

1 1 1 5 ? 24 1 15 1 31 ? 31 24 31

This program demonstrates the use of the 0 command, using ? as a placeholder number. The program first stores '1 5' in the function 9, then '15 31' in 10, before running function 9 (using 24), which pushes 5 onto the stack, and the repeatedly decrements it, until it reaches 0 and is removed. Then, the program halts.

Minsky machine

In order to convert a Minsky machine to Legendre code, the 0 command must be used. Because this command is inaccessible unless Legendre's conjecture is false, I have used a placeholder ? instead.

Note that all Minsky machine instruction line names need to have integers with different A014085 correspondences from each other and the base commands as well as 24 (9) and 31 (10).

Initialization:

1 1 1 1 ? 24

x INC (A/B) y:

A:

1 y 1 24 1 ? 1 6 1 1 16 1 24 ? x

B:

1 y 1 24 1 ? 1 10 1 6 1 1 16 1 10 1 24 ? x

x DEC (A/B) y z:

A:

1 4 1 10 1 15 1 10 1 31 1 1 1 10 1 z 1 1 1 16 1 24 1 31 1 ? 1 24 1 15 1 y 1 6 16 1 24 16 1 ? 1 1 16 1 10 1 1 16 1 24 ? x

B:

1 4 1 10 1 15 1 10 1 31 1 1 1 10 1 z 1 1 1 16 1 24 1 31 1 ? 1 24 1 15 1 10 1 y 1 6 16 1 24 16 1 ? 1 1 16 1 10 1 1 16 1 10 1 24 ? x

x HALT:

1 25 ? x

To create the final program, append all parts (with x,y,z replaced by their counterparts) and add a single integer to start the first instruction in the chain. This should prove the language's Turing-completeness in case Legendre's conjecture is proven false by counterexample.

Interpreter

This interpreter is written in Python (3), and has been tested on all three above examples. Use the -a/--allowZero flags to allow ? to be used, -f/--file to run code directly from a file and -s/--stackOut to output the stack as a Python list instead. If no file is given, the interpreter enters a sort of REPL mode, which is best used with --stackOut.

import sys
import argparse
import io

class I_need_missing(dict): #used to avoid try/except statements. Essentially a dict
    def __missing__(self,key):
        return None

def appropriate(integer,prev): #returns number of primes between the square of the integer given and the next

    return_value = 0

    if prev[integer]:
        return prev[integer],prev
    if integer == "?":
        return 0,prev
    for i in range(integer ** 2, (integer + 1) ** 2):
        t = False
        if i > 1:
            t = True
            for j in range(2,int(i ** 0.5)+1):
                t = i/j != round(i/j)
                if not t:
                    break
        return_value += t

    prev[integer] = return_value
    return return_value,prev

def run_command(commandseries,stack,functions,prev): #Runs the appropriate action for each command.

    command,prev = appropriate(commandseries.pop(0),prev)

    halt = False

    if command == 0: #store in given number
        functions[appropriate(commandseries.pop(0),prev)[0]] = stack
        stack = []

    elif command == 2:#push
        stack.append(commandseries.pop(0))

    elif command == 3:#execute top instruction
        commandseries.insert(0,stack.pop())

    elif command == 4:#pop, add 1 to new top if popped value was 1
        if stack.pop() == 1:
            stack[-1] += 1

    elif command == 5:#swap top two integers/?
        stack[-1],stack[-2] = stack[-2],stack[-1]

    elif command == 6:#subtract 1 from top of stack
        stack[-1] -= 1
        if stack[-1] == 0:
            stack.pop()

    elif command == 7:#duplicate top of stack
        stack.append(stack[-1])

    elif command == 8:#halt
        halt = True

    else:#run custom
        try:
            commandseries[0:0] = functions[command]
        except TypeError:
            print("Warning: unassigned function " + str(command) + " is unassigned", file = sys.stderr)

    return commandseries,stack,functions,prev,halt

def main(stack,functions,prev):
    #Parser for command line options
    parser = argparse.ArgumentParser(description = "Interpreter for the Legendre esoteric programming language.")
    parser.add_argument("-a","--allowZero", action = "store_true")
    parser.add_argument("-f","--file")
    parser.add_argument("-s","--stackOut", action = "store_true")

    args = parser.parse_args()
    allow_zero = bool(args.allowZero)

    #Program decoding starts
    pre = ""

    if not args.file:
        pre = input()
        if pre == "":
            return
    else:
        pre = open(args.file).read()

    mid = pre.split()
    final = []

    for i in mid:
        if i == "?" and allow_zero:
            final.append("?")
        elif i != 0 or allow_zero: #and allow_zero)
            final.append(int(i))

    halt = False

    #Functional programming at its best
    while final and not halt:
        final,stack,functions,prev,halt = run_command(final,stack,functions,prev)

    #Halting and output
    else:
        if args.stackOut:
            print(stack)
        else:
            for i in stack:
                print(i == "?" and "?" or chr(i),end = "")
            print("")
        if args.file or halt:
            return
        else:
            main(stack,functions,prev)

if __name__ == '__main__':
    main([],I_need_missing(),I_need_missing())


What's the odd one out? You are to write a program which outputs a single positive integer \$n\$. The integer may have leading zeros and whitespace, and/or trailing whitespace.
Then, choose a positive integer \$m > 1\$. When the program is repeated exactly \$m\$ times, it should output \$m \times n\$ (and only \$m\times n\$). When repeated any number of times other than \$m\$, it should output \$n\$ (and only \$n\$).
You may choose the value of \$m\$, so long as it is a positive integer greater than 1.
In this context, "repeated \$m\$ times" means that the whole program is repeated \$m\$ times, rather than each character. For example, repeating abcde \$4\$ times yields  abcdeabcdeabcdeabcde.
This is code-golf so the shortest code (not repeated \$m\$ times) in bytes wins.

For example, if your program is print 5 which outputs 5, and you choose \$m = 3\$, then:

print 5 should output 5
print 5print 5 should output 5
print 5print 5print 5 should output 15
print 5print 5print 5print 5 should output 5
print 5print 5print 5print 5print 5 should output 5
etc.

R, 16 bytes

T=a=1+!T;T=T-1;a

Try it online!
Works with \$n=1\$ and \$m=2\$.

Previous version:
R, 24 23 21 19 bytes
-4 bytes thanks to Dominic van Essen

T=a=1+0^T^2;T=T-1;a

Try it online!
Works with \$n=1\$ and \$m=2\$. This uses the fact that
\$0^k = \begin{cases} 1 & \text{ if } k=0\\0& \text { otherwise.}\end{cases}\$
Therefore, when the code is repeated \$k\$ times, we output \$1+0^{(2-k)^2}\$, which is worth \$2\$ when \$k=2\$, and \$1\$ otherwise.


JFor? More like XNor As it turns out, Python allows for 1j for to be compressed to 1jfor. However, jfor sounds like xnor. Since all similar-phonic phrases have something in common, there must be some property shared between jfor and xnor.
If we look at the ASCII representation of the first two characters of jfor in binary, we see:
j:   1101010
f:   1100110
j&f: 1100010

Notice that the bitwise AND of j and f has a streak of 1s at the beginning, then some 0s, then a single 1.
Definition: A pair of numbers meets the JFor property iff their bitwise AND in binary meets the following regex (excluding leading 0s): /1+0+1+0*/ (1 or more 1s, followed by 1 or more 0s, followed by 1 or more 1s, followed by 0 or more 0s)
Do the ASCII codes for x and n meet the JFor property?
x:   1111000
n:   1101110
x&n: 1101000

Yes! So my hunch was correct; jfor and xnor sound similar, and they share a property (This means, of course, that odor must have that property too).
Task
Given a pair of numbers, determine if they meet the JFor property.
The two numbers may not be distinct, but they will both be integers from 0 to 255 respectively.
Output may follow your language's conventions for Truthy and Falsey, or you may choose any two consistent, distinct values to represent truthy and falsey respectively.
Your program/function may take input in any reasonable format to represent an ordered pair of integers/bytes.
Test cases
# Truthy:
106 102
110 120
42 26
17 29
228 159
255 253

# Falsey:
85 170
228 67
17 38
255 255
38 120
21 21

(Bounty: 50 rep to the shortest answer on July 24 if it somehow uses a XOR or XNOR operation; please mention if your submission qualifies)

Python, 34 bytes

lambda a,b:bin(a&b).count('01')==1

Try it online!
Although this doesn't use xor, I'm xnor.


My Robot Has Escaped the Lab! My robot has short circuited somehow and randomly run off somewhere from my lab!

Luckily, whenever he does this, his shut-down sequence initiates, giving him enough time to randomly turn and run in the direction its facing for five rounds before he switches off. His gyro and accelerometer functions are still relaying the data back to the lab while he is still on.

The data will always come in the form of five sets of two numbers, for example.

12:234,-135:47,-68:230,140:324,127,87

Your mission, golfers is to a) simulate the robot's frantic run and turn sequence by displaying five sets of numbers in the form of a1:d1,a2:d2,a3:d3,a4:d4,a5:d5 where a(n) is the clockwise angle (in degrees) such that -179<=a<=+180 that the robot will turn from its current heading (initially it is at zero heading before it runs amok and turns for the first time), and d(n) is the distance in feet it has run before the next heading change which is such that 0<=d<=500 feet; and b) A calculated heading from the lab (which is also facing a heading of zero), distance in feet (accuracy up to 3 decimal places is strongly encouraged, -5 bytes if you do), and the orientation heading (in degrees) of where my robot it is facing when it has switched off.

Easy example:

Data: 0:1,45:1,90:1,90:1,90:1
Heading: 0
Distance: 1
Orientation: -45

The random turns and distances are just that, random. No set values are to be hard coded, we must see the randomness in action within the code.

Restrictions to randomness: No clock or date based references, we need to see a native random reference within the code. Whenever you run this code, the randomness must present itself with a possibility of showing 1 of 360 possible angles of turning with each turn-run round. So the robot may turn -36 degrees at one turn and may turn +157 degrees the next, followed by another turn of +2 degrees by another turn of -116 degrees and a final turn of +42 degrees on the final turn. At least 360 distinct values must be possible (between -179 to +180 degrees inclusive) with each random angle generation.

Restrictions to distance run: Similarly set, there are 501 possible distances the robot can run, (between 0 and 500 feet inclusive), so I expect the randomness to also be available when determining the robot's running distance. The robot could theoretically run 45, 117, 364, 27 and 6 feet with each of its respective rounds...

The data fed to you will always be in integer values... the robot will turn in integer ranges of degrees, and will run in integer ranges of distance. The output values however, will be floats...

This is code-golf. Shortest code wins... Now go find my robot!

PS: In reference to my "Accuracy up to 3 decimal places", if you can provide the heading (in degrees, to a MINIMUM of 3 decimal places) and a distance in feet (also accurate also to a MINIMUM 3 decimal places) you will get a -5 byte bonus).

Ruby, 274 252 249 245 214 211 207 204 202 characters (-5 = 197)

How did PHP beat Ruby in char count?! >:O Must find some way to golf more...

Edit: I beat the PHP answer, but the user who wrote it helped me do it! Go upvote him; he deserves it :-P

Another edit: Gah! He passed me again! You are a very worthy opponent, @MathieuRodic; congratulations, I have to let you win ;-)

P=(M=Math)::PI
puts"Data: #{([x=y=a=0]*5).map{a+=o=rand -179..e=180;x+=M.sin(b=a*P/e)*d=rand 500;y+=d*M.cos b;"#{o}:#{d}"}*?,}
Heading: #{M.atan(y/x)/P*-e+90}
Distance: #{M.hypot x,y}
Orientation: #{a}"

Ungolfed code (and slightly much older version):

data = Array.new(5) { [rand(-179..180), rand(0..500)] }
puts "Data: #{data.map{|x|"#{x[0]}:#{x[1]}"}.join ?,}"
x, y, a = [0] * 3
data.each do |o, d|
    a += o
    x += Math.sin(a * Math::PI / 180) * d
    y += Math.cos(a * Math::PI / 180) * d
end
puts "Heading: #{Math.atan(y / x) / Math::PI * -180 + 90}
Distance: #{Math.sqrt(x * x + y * y)}
Orientation: #{a}"

Sample output:

c:\a\ruby>robotgolf
Data: 94:26,175:332,14:390,159:448,-45:20
Heading: 124.52305879195005
Distance: 279.5742334385328
Orientation: 397


Optimizing SKI compiler The SKI calculus is a variant of the Lambda calculus that doesn't use lambda expressions. Instead, only application and the combinators S, K, and I are used. In this challenge, your task is to translate SKI terms into Lambda terms in β normal form.

Input Specification

The input is an SKI term in the following textual representation. You may choose to receive an optional trailing newline. The input is composed of the characters S, K, I, (, and ) and satisfies the following grammar (in ABNF form) with sterm being the start symbol:

sterm = sterm combinator     ; application
sterm = combinator           ;
sterm = '(' sterm ')'        ; grouping
combinator = 'S' | 'K' | 'I' ; primitives

Output Specification

The output is a lambda term with no free variables in the following textual representation. You may choose to output an optional trailing newline. The output shall satisfy the following grammar in ABNF form with lterm being the start symbol:

lterm   = lterm operand     ; application
lterm   = ALPHA '.' lterm   ; lambda
lterm   = operand
operand = '(' lterm ')'     ; grouping
operand = ALPHA             ; variable (a letter)

Constraints

You may assume that the input has a β normal form. You may assume that the β normal form uses at most 26 different variables. You may assume that both input and output are representable in 79 characters.

Sample inputs

Here are a couple of sample inputs. The output is one possible output for the given input.

input                        output
I                            a.a
SKK                          a.a
KSK                          a.b.c.ac(bc)
SII                          a.aa

Scoring

The shortest solution in octets wins. Common loopholes are prohibited.

Python 2, 674

exec u"""import sys
$ V#):%=V.c;V.c+=1
 c=97;p!,v,t:[s,t.u({})][v==s];r!:s;u!,d:d.get(s,s);s!:chr(%)
 def m(s,x):%=min(%,x);-(%==x)+x
$ A#,*x):%,&=x
 C='()';p!,x,y:s.__$__(%.p/,&.p/);m!,x:&.m(%.m(x));u!,d:A(%.u(d),&.u(d));s!:%.s()+s.C[0]+&.s()+s.C[1:]
 def r(s):x=%.r();y=&.r();-x.b.p(x.a,y).r()if'L'in`x`else s.__$__/
$ L(A):C='.';u!,d:L(d.setdefault(%,V()),&.u(d))
x=V();y=V();z=V()
I=L(x,x)
K=L(y,L/)
S=L(x,L(z,L(y,A(A/,A(z,y)))))
def E():
 t=I
 while 1:
    q=sys.stdin.read(1)
    if q in')\\n':-t
    t=A(t,eval(max(q,'E()')).u({}))
t=E().r()
t.m(97)
print t.s()""".translate({33:u'=lambda s',35:u':\n def __init__(s',36:u'class',37:u's.a',38:u's.b',45:u'return ',47:u'(x,y)'})

Note: after while 1:, 3 lines are indented with a tab character.

This is basically the code behind http://ski.aditsu.net/ , translated to python, greatly simplified and heavily golfed.

Reference: (this is probably less useful now that the code is compressed)

V = variable term
A = application term
L = lambda term
c = variable counter
p = replace variable with term
r = reduce
m = final variable renumbering
u = internal variable renumbering (for duplicated terms)
s = string conversion
(parameter s = self)
C = separator character(s) for string conversion
I,K,S: combinators
E = parse

Examples:

python ski.py <<< "KSK"
a.b.c.a(c)(b(c))
python ski.py <<< "SII"
a.a(a)
python ski.py <<< "SS(SS)(SS)"
a.b.a(b)(c.b(c)(a(b)(c)))(a(d.a(d)(e.d(e)(a(d)(e))))(b))
python ski.py <<< "S(K(SI))K"
a.b.b(a)
python ski.py <<< "S(S(KS)K)I"
a.b.a(a(b))
python ski.py <<< "S(S(KS)K)(S(S(KS)K)I)"
a.b.a(a(a(b)))
python ski.py <<< "K(K(K(KK)))"
a.b.c.d.e.f.e
python ski.py <<< "SII(SII)"
[...]
RuntimeError: maximum recursion depth exceeded

(this ↑ is expected because SII(SII) is irreducible)

Thanks Mauris and Sp3000 for helping to kill a bunch of bytes :)


Appearing a unique number of times Your task is to write a program or function that takes as input a list of positive integers and determines if there are any two integers in the list, that both appear the same number of times.

For example the list

[1, 2, 3, 2]

Has one 1 and one 3 so it satisfies the condition.

But the list

[3, 2, 2, 1, 2, 3]

does not satisfy the condition since every member appears a unique number of times.

Additionally your program should not satisfy this condition when its source code is interpreted as a list of bytes.

For example

abcb

Would not be a valid submission since both a and c appear exactly once.

Here is a verifier you can use if your source is in ASCII.

Output

Your submission when executed should output one of two possible values, one when the input satisfies the condition, one when the input does not.

This is code-golf so answers will be scored in bytes with fewer bytes being better.

05AB1E, 6 bytes

D¢DD¢Q

Try it online! or validate more test cases.

Outputs 1 if each item appears a unique number of times, 0 otherwise.

D           # duplicate the input
 ¢          # count occurences of each item in the input
  DD        # triplicate the list of occurence counts
    ¢       # count occurences of each occurence count in the list of occurence counts
     Q      # check whether this is equal to the list of occurence counts

Without the source restriction, this could be 4 bytes: ¢Ð¢Q.


Bleeeet Bleeeet Bl Bleet! (Meaning: Convert English to Bleet)

We have praised goats as god for years now.

But if we can't translate English to 'Bleet', the Goat God's language, we cannot communicate with them.

So, to communicate with them, we have researched the activities of goats, and retrieved this pattern, which is the core of the language.

  Say 'Bleet' for the length of each words. That means the amount of 'e's should be (length-3) for words longer than 3 letters.You shall cut down 'Bleet' for words shorter than 'Blt'. For example, 'be' becomes 'bl', but 'cat' and 'boat' becomes 'blt' and 'blet'.

As it seems, they don't actually change non-alphabet characters to 'Bleet'. Our research showed that 'Hello, World!' to Bleet is 'Bleet, Bleet!' not 'Bleeet Bleeet'. Also, The goats are not so intelligent(no offense), so they don't  seem to understand non-ascii characters or diacritics at all.

Now, It's time to make a translator to communicate with the goat gods.

Bleeeeet (Meaning: Examples)

Hello, World! => Bleet, Bleet!
lorem ipsum dolor sit amet. => Bleet Bleet Bleet Blt Blet.
We praise the Goat God! => Bl Bleeet Blt Blet Blt!
I have a pen => B Blet B Blt
0123456789_ => 0123456789_
0te_st1 => 0Bl_Bl1

Retina, 31 bytes

T`lL`e
(?<!e)e
B
Be
Bl
e(?!e)
t

Try it online!

Explanation

T`lL`e

Turn all letters into es.

(?<!e)e
B

Turn the first e in each run into B.

Be
Bl

Turn Be into Bl.

e(?!e)
t

Turn the last e in each run into t.


Has My Pie Been Bisected? Write a program or function that takes in a nonempty list of positive integers. You may assume it is input in a reasonable convenient format such as "1 2 3 4" or [1, 2, 3, 4].

The numbers in the input list represent the slices of a full pie chart where each slice size is proportional to its corresponding number and all slices are arranged around the chart in the order given.

For example, the pie for 1 2 3 4 is:

The question your code must answer is: Is the pie chart ever bisected? That is, is there ever a perfectly straight line from one side of the circle to the other, splitting it symmetrically in two?

You need to output a truthy value if there is at least one bisector and output a falsy value if there are none.

In the 1 2 3 4 example there is a bisection between 4 1 and 2 3 so the output would be truthy.

But for input 1 2 3 4 5 there is no bisector so the output would be falsy:

Additional Examples

Arranging numbers differently may remove bisectors.
e.g. 2 1 3 4 → falsy:

If only one number is in the input list the pie is not bisected.
e.g. 10 → falsy:

There may be multiple bisectors. As long as there are more than zero the output is truthy.
e.g. 6 6 12 12 12 11 1 12 → truthy: (there are 3 bisectors here)

Bisections may exist even if they are not visually obvious.
e.g. 1000000 1000001 → falsy:

e.g. 1000000 1000001 1 → truthy:

(Thanks to nces.ed.gov for generating the pie charts.)

Test Cases

Truthy
1 2 3 4
6 6 12 12 12 11 1 12
1000000 1000001 1
1 2 3
1 1
42 42
1 17 9 13 2 7 3
3 1 2
10 20 10

Falsy
1 2 3 4 5
2 1 3 4
10
1000000 1000001
1
1 2
3 1 1
1 2 1 2 1 2
10 20 10 1

Scoring

The shortest code in bytes wins. Tiebreaker is earlier answer.

J, 18 bytes

5 bytes thanks to Dennis.

+/e.[:,/2*+/\-/+/\

@HelkaHomba: Nope.

Usage

>> f =: +/e.[:,/2*+/\-/+/\
>> f 6 6 12 12 12 11 1 12
<< 4
>> f 10 20 10 1
<< 0

Ungolfed

black_magic  =: +/\-/+/\
doubled_bm   =: 2 * black_magic
flatten      =: ,/
sum          =: +/
is_member_of =: e.
f =: sum is_member_of monadic flatten doubled_bm

Previous 23-byte version:

[:+/[:+/+/=+:@-/~@(+/\)

Usage

>> f =: [:+/[:+/+/=+:@-/~@(+/\)
>> f 6 6 12 12 12 11 1 12
<< 4
>> f 10 20 10 1
<< 0

Ungolfed

black_magic =: -/~@(+/\)
double      =: +:
equals      =: =
sum         =: +/
monadic     =: [:
of          =: @
f =: monadic sum monadic sum (sum equals double of black_magic)

Explanation

The sum of all substrings is calculated by the black_magic. The +/\ calculate the partial sums.

For example, a b c d becomes a a+b a+b+c a+b+c+d.

The -/~ then constructs a subtraction table based on the input, so x y z becomes:

x-x x-y x-z
y-x y-y y-z
z-x z-y z-z

When applied to a a+b a+b+c a+b+c+d, the result would be:

    0  -b -b-c -b-c-d
    b   0   -c   -c-d
  b+c   c    0     -d
b+c+d c+d    d      0

This calculated the sums of all the substrings which does not contain a.

This guarantees to be enough, since if one bisection contains a, the other bisection will not contain a and also will not wrap around.


How much reputation does a steam user have? Introduction

For those not familiar with steam - or at least this particular aspect:

Often on peoples' profiles, people leave comments saying either "+rep _____" or "-rep _____". These are an unofficial means of showing whether you think someone in the community has a good or a bad reputation, for a number of reasons. Such comments look like:

  +rep a good player

  +rep helpful

  -rep hacker

  -rep scammer

Task

The program must take input through any consensual way. The input consists of a string with optional newlines (\n). At the very start of each line, '+rep ' or '-rep ' might be present. The rest of the line can be discarded. If the line doesn't start with '+rep ' or '-rep ' (note the trailing space), the line should be ignored.

The program then must keep a total reputation score. Starting at 0, this score should be incremented on every line that starts with '+rep ' and decremented on every line that starts with '-rep '.

This result should be output in any agreed-upon way.

Test cases

Input:
+rep fast trade
+rep nice person
-rep too good

Output: 1

Input:
-rep hacker
-rep scammer
-rep was mean

Output: -3

Input:
first
i don't like him
+rep good at cs go

Output: 1

Input (note the lack of a trailing space on the third line):
+rep +rep
hi +rep
-rep

Output: 1

Input:
+ rep

Output: 0

Input:
+rep like
-thing

Output: 1

Bonus

I don't even know if it's possible, but bonus points if you can somehow get these comments from Steam.

Python 3, 73 bytes

I'm sure this answer is garbage and will be beaten soon, but there's no other python answers yet

lambda x:sum(["- +".index(i[0])-1for i in x.split('\n')if i[1:4]=="rep"])

Use like this:

f = lambda x:sum(["- +".index(i[0])-1for i in x.split('\n')if i[1:4]=="rep"])
print(f("PUT INPUT HERE"))

Fetching from steam

Here's some sample code which fetches the first 100 comments from KennyS' profile and calculates his rep.

import requests
from bs4 import BeautifulSoup

# Kenny's profile as Steam ID 64
# You can adjust this to whatever numbers you want
STEAM_PROFILE_URL = "76561198024905796"
payload =  {"start" : 0, "count" : 100}
r = requests.post("http://steamcommunity.com/comment/Profile/render/{}/-1/".format(STEAM_PROFILE_URL), payload)

# Comments are html inside a json object
soup = BeautifulSoup(r.json()["comments_html"], "html.parser")

# Get raw text for every comment.
# The " ".join() strips out the newlines and tabs which are part of html
comments = [" ".join(s.text.split()) for s in soup.find_all("div", {"class" : "commentthread_comment_text"})]

calculateRep = lambda x:sum(["- +".index(i[0])-1for i in x.split('\n')if i[1:4]=="rep"])

print(calculateRep("\n".join(comments)))


When life gives you lemons, make lemonade Challenge

You will be given an input string, anywhere the word "Lemon" is found it should be converted to "Lemonade" but the a, d, and e must be borrowed from somewhere else in the sentence.

Example

Example Input:

  I found a lemon when I was a kid

Example Output:

  I foun a lemonade whn I was  kid

The Lemonade was created by stealing the following superscript letters from the original

  I found a lemonade when I was a kid

This is just one possible output example, the "e", "d", and "a", could have been taken from anywhere (except for from the word lemon of course)

Comments

•If there are not enough e, a, or ds you must output what was do-able with the letters given. For example the input bdblemon would output bblemond

•The lemon text might not always be standalone (space on each side). For example you may have the word lemons somewhere in the input and the output should be lemonades

•The input may contain any number of lemons, even 0 lemons (in which case the output would be identical to the input)

•You can make your lemonade with uppercase and lowercase letters, for example leMon could become leMonade, and the ade borrowed can be any case (so it could also have become leMonADe).The case of the letter you borrowed must remain what it was when you borrowed it.(Example input -> output, he hAD lemOn -> h h lemOnADe)

•Does not have to be a full program, a function alone is fine.

•You may assume input will be only the CP437 Character Set

Code Golf

This is code-golf, so the lowest number of bytes wins!

Pseudo-TestCases

*Note: For any given input there might be multiple possible outputs so your program may not output exactly as these test cases do, this is more just so people can understand the logic:

  Input: EpaD leMons
  Output: p LeMonaDEs

  Input: hello world
  Output: hello world

  Input: lemon lemon
  Output: lemon lemon
  *(The e, a, d letters should never be taken from another "Lemon")

  Input: HE HAD lemonade
  Output: H H lemonADEade

  Input: Do you like lemons? You hAd me at lemon!
  Output: o you lik lemonADes? You h m t lemonade!

  Input: AE lemon
  Output:  lemonAE

  Input: 55bad lemon
  Output: 55b lemonad

JavaScript (ES6), 159 157 155 162 bytes

Edit: +7 bytes to "output what was do-able with the letters given" rather than throwing out an error

A recursive function that returns the modified string.

f=(s,a=s.split(/(lemon)/i),n=(a.length-1)*1.5)=>n?f(n,a.map((s,i)=>i&1|!n||(a[i]=s.replace([/a/i,/e/i,/d/i][n%3],c=>(a[--n/3<<1|1]+=c,''))))&&a,n-(n==s)):a.join``

How it works

The expression s.split(/(lemon)/i) splits the input string on lemon but preserves the capture groups in the result.

For instance, "foo lemon bar LEMON baz".split(/(lemon)/i) will produce the array [ 'foo ', 'lemon', ' bar ', 'LEMON', ' baz' ].

We recursively iterate on this array, extracting the characters a, d and e or their uppercase counterparts from the entries located at an even position, and appending them to the entries located at an odd position.

Commented

f = (                                   // given:
  s,                                    //   s = input string or previous value of 'n'
  a = s.split(/(lemon)/i),              //   a = split array, as described above
  n = (a.length - 1) * 1.5              //   n = total number of characters to be found
) =>                                    //
  n ?                                   // if there's still at least one character to find:
    f(                                  //   do a recursive call with:
      n,                                //     1) the current value of 'n'
      a.map((s, i) =>                   //     2) an updated version of 'a', where
        i & 1 | !n || (                 //       for even positions:
          a[i] = s.replace(             //         we look for the next character
            [/a/i, /e/i, /d/i][n % 3],  //           'a', 'e' or 'd' (case insensitive)
            c => (                      //           append it to
              a[--n / 3 << 1 | 1] += c, //           one of the entries at an odd position
              ''                        //           and remove it from the original entry
            )                           //           end of replace() callback
          )                             //         end of replace()
        )                               //       end of position condition
      ) && a,                           //     end of map() -> yield the updated 'a'
      n -                               //     3) the updated value of 'n', skipping the
      (n == s)                          //        current character if not found at all
    )                                   //   end of recursive call
  :                                     // else:
    a.join``                            //   success: join 'a' and return it

Demo

f=(s,a=s.split(/(lemon)/i),n=(a.length-1)*1.5)=>n?f(n,a.map((s,i)=>i&1|!n||(a[i]=s.replace([/a/i,/e/i,/d/i][n%3],c=>(a[--n/3<<1|1]+=c,''))))&&a,n-(n==s)):a.join``

console.log(f("I found a lemon when I was a kid"))
console.log(f("I found a lemon when I was a kid. I found another lemon when I was older."))
console.log(f("bdblemon"))
console.log(f("he hAD lemOn"))


Quine...but shifted by one Referring to the printable ASCII character codes in decimal, we know that from 32 to 126 we have the printable characters with 32 being (space). Your challenge is to write a program using only characters from 32 to 125 (excluding 126) which when executed, prints its own source code except that each character in the source code has its ASCII code increased by one.

For example, if the source code was

main(){printf("Hello World");}

its output would be

nbjo)*|qsjoug)#Ifmmp!Xpsme#*<~

The following are forbidden:

Reading/writing/using any external files or storage (including the internet)
Reading/echoing your own source code
Source codes with fewer than 2 characters (they are no fun). Must be greater than or equal to 2.

Making it a popularity contest where after waiting for at least two weeks, the answer, in any language, with the highest upvotes wins with the smaller character count being the tie-breaker.

Python (27 characters)

In the Python shell, the following script will output the desired result:

TzoubyFssps;!jowbmje!tzouby

Yes! it outputs:

SyntaxError: invalid syntax


Find the largest independent set in a high-dimensional lattice-like graph For a given positive integer n, consider all binary strings of length 2n-1.  For a given string S, let L be an array of length n which contains the count of the number of 1s in each substring of length n of S. For example, if n=3 and S = 01010 then L=[1,2,1]. We call L the counting array of S.

We say that two strings S1 and S2 of the same length match if their respective counting arrays L1 and L2 have the property that L1[i] <= 2*L2[i] and L2[i] <= 2*L1[i] for all i.

Task

For increasing n starting at n=1, the task is to find the size of the largest set of strings, each of length 2n-1 so that no two strings match.

Your code should output one number per value of n.

Score

Your score is the highest n for which no one else has posted a higher correct answer for any of your answers.  Clearly if you have all optimum answers then you will get the score for the highest n you post. However, even if your answer is not the optimum, you can still get the score if no one else can beat it.

Example answers

For n=1,2,3,4 I get 2,4,10,16.

Languages and libraries

You can use any available language and libraries you like. Where feasible, it would be good to be able to run your code so please include a full explanation for how to run/compile your code in linux if at all possible.

Leading entries

5 by Martin Büttner in Mathematica
6 by Reto Koradi in C++. Values are 2, 4, 10, 16, 31, 47, 75, 111, 164, 232, 328, 445, 606, 814, 1086.  The first 5 are known to be optimal.
7 by  Peter Taylor in Java. Values are  2, 4, 10, 16, 31, 47, 76, 111, 166, 235.
9 by joriki in Java. Values are 2, 4, 10, 16, 31, 47, 76, 112, 168.

2, 4, 10, 16, 31, 47, 76, 111, 166, 235

Notes

If we consider a graph G with vertices 0 to n and edges joining two numbers which match, then the tensor power G^n has vertices (x_0, ..., x_{n-1}) forming the Cartesian power {0, ..., n}^n and edges between matching tuples. The graph of interest is the subgraph of G^n induced by those vertices which correspond to the possible "counting arrays".

So the first subtask is to generate those vertices. The naïve approach enumerates over 2^{2n-1} strings, or on the order of 4^n. But if we instead look at the array of first differences of the counting arrays we find that there are only 3^n possibilities, and from the first differences we can deduce the range of possible initial values by requiring that no element in the zeroth differences is less than 0 or greater than n.

We then want to find the maximum independent set. I'm using one theorem and two heuristics:

Theorem: the maximum independent set of a disjoint union of graphs is the union of their maximum independent sets. So if we break a graph down into unconnected components we can simplify the problem.
Heuristic: assume that (n, n, ..., n) will be in a maximum independent set. There's a fairly large clique of vertices {m, m+1, ..., n}^n where m is the smallest integer which matches n; (n, n, ..., n) is guaranteed to have no matches outside that clique.
Heuristic: take the greedy approach of selecting the vertex of lowest degree.

On my computer this finds 111 for n=8 in 16 seconds, 166 for n=9 in about 8 minutes, and 235 for n=10 in about 2 hours.

Code

Save as PPCG54354.java, compile as javac PPCG54354.java, and run as java PPCG54354.

import java.util.*;

public class PPCG54354 {
    public static void main(String[] args) {
        for (int n = 1; n < 20; n++) {
            long start = System.nanoTime();

            Set<Vertex> constructive = new HashSet<Vertex>();
            for (int i = 0; i < (int)Math.pow(3, n-1); i++) {
                int min = 0, max = 1, diffs[] = new int[n-1];
                for (int j = i, k = 0; k < n-1; j /= 3, k++) {
                    int delta = (j % 3) - 1;
                    if (delta == -1) min++;
                    if (delta != 1) max++;
                    diffs[k] = delta;
                }

                for (; min <= max; min++) constructive.add(new Vertex(min, diffs));
            }

            // Heuristic: favour (n, n, ..., n)
            Vertex max = new Vertex(n, new int[n-1]);
            Iterator<Vertex> it = constructive.iterator();
            while (it.hasNext()) {
                Vertex v = it.next();
                if (v.matches(max) && !v.equals(max)) it.remove();
            }

            Set<Vertex> ind = independentSet(constructive, n);
            System.out.println(ind.size() + " after " + ((System.nanoTime() - start) / 1000000000L) + " secs");
        }
    }

    private static Set<Vertex> independentSet(Set<Vertex> vertices, int dim) {
        if (vertices.size() < 2) return vertices;

        for (int idx = 0; idx < dim; idx++) {
            Set<Set<Vertex>> p = connectedComponents(vertices, idx);
            if (p.size() > 1) {
                Set<Vertex> ind = new HashSet<Vertex>();
                for (Set<Vertex> part : connectedComponents(vertices, idx)) {
                    ind.addAll(independentSet(part, dim));
                }
                return ind;
            }
        }

        // Greedy
        int minMatches = Integer.MAX_VALUE;
        Vertex minV = null;
        for (Vertex v0 : vertices) {
            int numMatches = 0;
            for (Vertex vi : vertices) if (v0.matches(vi)) numMatches++;
            if (numMatches < minMatches) {
                minMatches = numMatches;
                minV = v0;
            }
        }

        Set<Vertex> nonmatch = new HashSet<Vertex>();
        for (Vertex vi : vertices) if (!minV.matches(vi)) nonmatch.add(vi);
        Set<Vertex> ind = independentSet(nonmatch, dim);
        ind.add(minV);
        return ind;
    }

    // Separates out a set of vertices which form connected components when projected into the idx axis.
    private static Set<Set<Vertex>> connectedComponents(Set<Vertex> vertices, final int idx) {
        List<Vertex> sorted = new ArrayList<Vertex>(vertices);
        Collections.sort(sorted, new Comparator<Vertex>() {
                public int compare(Vertex a, Vertex b) {
                    return a.x[idx] - b.x[idx];
                }
            });

        Set<Set<Vertex>> connectedComponents = new HashSet<Set<Vertex>>();
        Set<Vertex> current = new HashSet<Vertex>();
        int currentVal = 0;
        for (Vertex v : sorted) {
            if (!match(currentVal, v.x[idx]) && !current.isEmpty()) {
                connectedComponents.add(current);
                current = new HashSet<Vertex>();
            }

            current.add(v);
            currentVal = v.x[idx];
        }

        if (!current.isEmpty()) connectedComponents.add(current);
        return connectedComponents;
    }

    private static boolean match(int a, int b) {
        return a <= 2 * b && b <= 2 * a;
    }

    private static class Vertex {
        final int[] x;
        private final int h;

        Vertex(int[] x) {
            this.x = x.clone();

            int _h = 0;
            for (int xi : x) _h = _h * 37 + xi;
            h = _h;
        }

        Vertex(int x0, int[] diffs) {
            x = new int[diffs.length + 1];
            x[0] = x0;
            for (int i = 0; i < diffs.length; i++) x[i+1] = x[i] + diffs[i];

            int _h = 0;
            for (int xi : x) _h = _h * 37 + xi;
            h = _h;
        }

        public boolean matches(Vertex v) {
            if (v == this) return true;
            if (x.length != v.x.length) throw new IllegalArgumentException("v");
            for (int i = 0; i < x.length; i++) {
                if (!match(x[i], v.x[i])) return false;
            }
            return true;
        }

        @Override
        public int hashCode() {
            return h;
        }

        @Override
        public boolean equals(Object obj) {
            return (obj instanceof Vertex) && equals((Vertex)obj);
        }

        public boolean equals(Vertex v) {
            if (v == this) return true;
            if (x.length != v.x.length) return false;
            for (int i = 0; i < x.length; i++) {
                if (x[i] != v.x[i]) return false;
            }
            return true;
        }

        @Override
        public String toString() {
            if (x.length == 0) return "e";

            StringBuilder sb = new StringBuilder(x.length);
            for (int xi : x) sb.append(xi < 10 ? (char)('0' + xi) : (char)('A' + xi - 10));
            return sb.toString();
        }
    }
}


Did I win the lotto? I just submitted an answer to this question, and then looked about at some news stories about the MegaMillions lottery craze going on right now in the US. This news article stated that an individual purchased $20,000 worth of tickets at one time (that's 20,000 sets of numbers to confirm!) to try and test their luck.

That led me to thinking about how one might quickly determine whether or not they'd won any prize, not just a jackpot, on a large lot of tickets that they had purchased.

The challenge then is this:

Overview:

Write a function or program that will accept a string of numbers as an argument (STDIN, or read in from a file, your choice), and return the numbers of the tickets with at least the minimum payout awarded.

Code Details:

The input will consist of a series of lines, one for each ticket purchased. The winning numbers will be prefixed with a 0, while the drawn numbers will be prefixed with an incremented number starting at 1. (see example)
The input should be a completely random set of numbers each time, including draws and winning numbers.
The input should accept any number of tickets n where 1 <= n <= 20,000. (Assume no 0 ticket runs.)
Each line of input will have 7 numbers per line. One for the prefix noted above, 5 for the standard balls, and one additional for the 'match' ball. (see Lotto Details below)
The input can be delimited any way you wish (whitespace, semicolon, etc.)
The output should be a listing of all winning draws and the winning amount. (So you know which to turn in.)
The output listing should be ordered by win amount. (Who cares if you won $2 on one ticket if you also won $10,000 on another???)
When more than one ticket wins the same amount, the order of those tickets is irrelevant.
The output should also give a listing of the total amount won.

Lotto Details:

Standard rules for the MegaMillions game will apply, since that's what's so hot right now.
Draws consist of six numbers from two separate pools of numbers - five different numbers from 1 to 56 and one number (the match ball) from 1 to 46.
The jackpot is won by matching all six winning numbers in a drawing.
Awards for non-jackpot wins are awarded as follows (see image below).

(Main) + (Match) = (Payout)
5 + 1 = Jackpot
5 + 0 = $250,000
4 + 1 = $10,000
4 + 0 = $150
3 + 1 = $150
3 + 0 = $7
2 + 1 = $10
1 + 1 = $3
0 + 1 = $2
Assume current jackpot is $1,000,000 (one million).
Assume only one jackpot winner, unless your random draw pulls the same jackpot pick more than once (are you cheating?).
Assume no multiplier/California rules are in-play.

Challenge Details:

This is code golf, so shortest code wins.
In the event of a tie, I'll take the highest upvoted answer. I know this is somewhat subjective, but the main point is still the score.

Example:

Input:

0   2   4   23  38  46  23
1   17  18  22  23  30  40
2   2   5   24  37  45  23
3   4   23  38  40  50  9
4   2   4   23  38  46  17
5   5   16  32  33  56  46

Output:

4 - $250,000
3 - $7
2 - $3
Total Winnings: $250,010

Python, 239 chars

import sys
a=map(eval,sys.stdin)
w=lambda x:(0,2,0,3,0,10,7,150,150,1e4,25e4,1e6)[2*len(set(x[1:-1])&set(a[0][1:-1]))+(x[6]==a[0][6])]
s=0
for e in sorted(a[1:],cmp,w,1):
    t=w(e);s+=t
    if t:print e[0],"- $%u"%t
print"Total Winnings: $%u"%s

Assuming the input numbers are comma separated.


Pseudorandom Cellular Automaton Introduction

In this challenge, we will simulate a certain probabilistic cellular automaton using very bad pseudorandom numbers.
The cellular automaton is defined on binary strings by the following local rule.
Suppose that the left neighbor of a cell and the cell itself have states a and b.

If min(a,b) == 0, then the new state of b is max(a,b).
If min(a,b) == 1, then the new state of b is chosen randomly from {0,1}.

The following picture shows one possible 10-step evolution of a single 1.

1
11
101
1111
11001
101011
1111111
10001001
110011011
1010111101

Note how two adjacent 1s sometimes evolve to 1, and sometimes to 0, and the border-most bits are always 1s.
Your task is to produce a cellular automaton evolution of this form.

Inputs

Your inputs are a positive integer n, denoting the number of rows to display, and a non-empty list of bits L, which we use as a source of randomness.

Output

Your output is a list of lists or 2D array of bits, depicting the evolution of a single 1 for n time steps, as in the above figure.
You can pad the output with 0s to get rows of equal lengths, if desired, but there must not be leading 0s.

The random choices in the cellular automaton must be drawn from the list L, jumping back to the beginning when it is exhausted.
More explicitly, if the output is traversed one row at a time form top to bottom, left to right, then the successive random choices shall form the list L repeated as many times as necessary.

Example

Suppose the inputs are n = 7 and L = [0,1,0].
Then the cellular automaton evolves as follows during the 7 steps, where we have put a v right above every random choice:

[1]

[1,1]
   v
[1,0,1]

[1,1,1,1]
   v v v
[1,1,0,0,1]
   v
[1,1,1,0,1,1]
   v v   v
[1,0,0,1,1,1,1]

If we read all the bits marked with a v, we get 01001001, which is L repeated 2.66 times.
The next random bit would be 0.

Rules and Scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
The exact format of the inputs and outputs is unimportant (within reason).

Test Cases

Deterministic version, every random bit is 0:

Inputs: 10 [0]
Output:
1
11
101
1111
10001
110011
1010101
11111111
100000001
1100000011

Every random bit is 1:

Inputs: 6 [1,1]
Output:
1
11
111
1111
11111
111111

Pseudorandom versions:

Inputs: 10 [0,0,1]
Output:
1
11
101
1111
10101
111111
1010011
11110101
101011111
1111101001

Inputs: 10 [1,0,0,1]
Output:
1
11
111
1001
11011
111111
1001101
11010111
111111101
1011001111

Inputs: 15 [1,1,1,0,0,0]
Output:
1
11
111
1111
10001
110011
1110111
11011001
111111011
1100011111
11100100011
111101100101
1001111101111
11011000111111
101101001011101

Retina, 139 bytes

^.
1

 00:0 01:1 10:1 11:
(m`^(..)((\S*)(?<=0) .*)
$1$3#$1!$2
+m`(?<=^(?<-2>.)*(..).*?#(.)*.)\d!(.)(.*\1:)(.)(\d*)
$5$3!$4$6$5
)`!0
0
 .+
<empty>

Where <empty> indicates that there is a trailing empty line. Each line goes in a separate file and the # should be replaced with linefeeds (0x0A).

Expects the input to be n in unary (made of zeroes, as in Unary), followed by a space, followed by the "pseudo-random" string, e.g. 10, [1, 0, 0, 1] would be read as

0000000000 1001

Output is as in the challenge, but padded with zeroes, e.g.

1000000000
1100000000
1110000000
1001000000
1101100000
1111110000
1001101000
1101011100
1111111010
1011001111

This was way trickier than I expected...


Given an input, print all exponents where the base and power sum to the input So this is my first challenge on this site.

The challenge is to take in an input integer \$n\$, which will be positive, and print, in ascending order (\$1\$ to \$n\$, including n), the output of \$i^{(n-i)}\$ (where \$i\$ is the current integer).

Example

Given the input 5, the program will print:

1
8
9
4
1

\$1^4\$ is 1 and \$1+4=5\$
\$2^3\$ is 8 and \$2+3=5\$
\$3^2\$ is 9 and \$3+2=5\$
\$4^1\$ is 4 and \$4+1=5\$
\$5^0\$ is 1 and \$5+0=5\$

Input and Output

Input will be in the form of a positive integer.
Output will be a list of numbers, delimited by either commas or new lines.

This is code-golf, so shortest code wins.

APL (Dyalog Unicode), 8 5 bytes

⍳*⊢-⍳

Try it online!
Anonymous prefix tacit function. TIO tests for the range [1..10].
Thanks @lirtosiast for 3 bytes.
How:
⍳*⊢-⍳ ⍝ Tacit function
    ⍳ ⍝ Range. ⍳n generates the vector [1..n].
  ⊢- ⍝ Subtracted from the argument. The vector is now [n-1,n-2,...,0]
⍳*    ⍝ Exponentiate using the range [1..n] as base. The result is the vector
      ⍝ [1^(n-1), 2^(n-2), 3^(n-3),...]


Find the Centroid of a Polygon From Wikipedia:

  The centroid of a non-self-intersecting closed polygon
  defined by n vertices (x0,y0),
  (x1,y1), ...,
  (xn−1,yn−1) is the point (Cx,
  Cy), where

  and where A is the polygon's signed area,

  In these formulas, the vertices are assumed to be numbered in order of
  their occurrence along the polygon's perimeter. Furthermore, the
  vertex ( xn, yn ) is assumed to be the same as
  ( x0, y0 ), meaning i + 1 on the last case
  must loop around to i = 0. Note that if the points are numbered in
  clockwise order the area A, computed as above, will have a negative
  sign; but the centroid coordinates will be correct even in this case.

Given a list of vertices in order (either clockwise, or counter-clockwise), find the centroid of the non-self-intersecting closed polygon represented by the vertices.

If it helps, you may assume input to be only CW, or only CCW. Say so in your answer if you require this.

The coordinates are not required to be integers, and may contain negative numbers.
Input will always be valid and contain at least three vertices.
Inputs only need to be handled that fit in your language's native floating point data type.
You may assume that input numbers will always contain a decimal point.
You may assume that input integers end in . or .0.
You may use complex numbers for input.
Output should be accurate to the nearest thousandth.

Examples

[(0.,0.), (1.,0.), (1.,1.), (0.,1.)]        -> (0.5, 0.5)
[(-15.21,0.8), (10.1,-0.3), (-0.07,23.55)]  -> -1.727 8.017
[(-39.00,-55.94), (-56.08,-4.73), (-72.64,12.12), (-31.04,53.58), (-30.36,28.29), (17.96,59.17), (0.00,0.00), (10.00,0.00), (20.00,0.00), (148.63,114.32), (8.06,-41.04), (-41.25,34.43)]   -> 5.80104769975, 15.0673812762

Too see each polygon on a coordinate plane, paste the coordinates without the square brackets in the "Edit" menu of this page.

I confirmed my results using this Polygon Centroid Point Calculator, which is awful. I couldn't find one that you can input all vertices at once, or that didn't try to erase your - sign when you type it first. I'll post my Python solution for your use after people have had a chance to answer.

Mathematica, 23 bytes
RegionCentroid@*Polygon

Take THAT, Jelly!
Edit: One does not simply beat Jelly...
Explanation
Polygon

Generate a polygon with vertices at the points specified.
RegionCentroid

Find the centroid of the polygon.


Transform 7-segment display pattern into number Given A and B, where A is the scale of a Digital LED Pattern B. Parse pattern B and print the number.

input:

1
 _  _  _  _     _     _     _  _  _  _  _     _
 _| _| _|| ||_||_   ||_ |_|| |  ||_||_||_   ||_|
|_  _||_ |_|  | _|  ||_|  ||_|  |  |  | _|  ||_|

output:

2320451640799518

input:

2
 __  __
   |   |
 __| __|
|      |
|__  __|

output:

23

Rules:

Use STDIN/STDOUT for input/output
I tried to mimic this question as much as possible, but I think code-golf suits this one better.
Shortest code (in bytes) wins

Ruby, 151 characters

s,*r=*$<;c=r[s=s.to_i]
i=0;(n=(r[0][i+1]+c[i]+c[i+s,2]+r[-1][i]).tr(" |_","01").to_i 2
$><<(0..9).find{|j|0x3df9778eb5c5b>>5*j&31==n};i+=s+2)while b[i]

Leaves out digits it cannot recognise, but some invalid digits are recognised nevertheless.

Assumes the lines are padded with spaces to their full length.


What's the most popular question right now? Your task is to print the titles of the questions with the five highest scores (upvotes minus downvotes) here on CodeGolf.SE, while skipping over any closed, locked and on-hold questions.

Currently these are:

Produce the number 2014 without any numbers in your source code
Showcase your language one vote at a time
American Gothic in the palette of Mona Lisa: Rearrange the pixels
Images with all colors
Build a Compiler Bomb

Remember, this is code-golf, so the code with the smallest number of bytes wins.

JavaScript + JQuery, 178 bytes

Quite a simple approach that makes the StackExchange API do all the work.

$.ajax('//api.stackexchange.com/search/advanced?sort=votes&closed=False&wiki=False&notice=False&pagesize=5&site=codegolf').pipe(x=>x.items.map(x=>document.write(x.title+'
')))

a=x=>x.items.map(x=>document.write(x.title+'
'))
document.write('StackExchange&nbsp;Site:&nbsp;<input value="codegolf"> <button onclick="$.ajax({success:x=>{try{document.getElementById('pre').innerHTML=x.items.map(x=>x.title).join('\n')+'\n\nQueries left: ' + x.quota_remaining}catch(e){try{document.getElementById('pre').textContent='Queries left: ' + (x.quota_remaining || 'Error')}catch(e){document.getElementById('pre').textContent='Error'}}},url:'//api.stackexchange.com/search/advanced?sort='+document.getElementById('s').value+'&closed=False&wiki=False&notice=False&pagesize=5&site=' + this.previousElementSibling.value})">Go</button> Sort&nbsp;by:&nbsp;<select id='s'><option value="activity">Active</option><option value="votes" selected="selected">Score</option><option value="creation">New</option></select>

Some caveats while answering this question:

StackExchange API always trys to returns gzipped data. In JS, the browser un-gzips for you.
The API only seems to be able to return the top 100 at maximum, so if you were to filter out the closed questions programatically, you must assume that less than 96 of the top 100 questions are closed, which you can't so you have to do everything in the APIs query.
The things in the API are HTML encoded, so you must also decode those. In JS, I let the browser decode it, but in something like Python, you must employ an external library, or else hard-code the dozens of entities.

That said, here is my Python solution that has to jump all of those hoops:

Python 3, 259 bytes

import urllib.request as r,gzip,html,json
for i in json.loads(gzip.decompress(r.urlopen('http://api.stackexchange.com/search/advanced?sort=votes&closed=False&wiki=False&notice=False&pagesize=5&site=codegolf').read()))['items']:print(html.unescape(i['title']))


Stack Exchange Answerer Oof! You've been coding the whole day and you even had no time for Stack Exchange!

Now, you just want to rest and answer some questions. You have T minutes of free time. You enter the site and see N new questions. To write an answer for each you'll need ti minutes. Of course, as a dedicated reputation gatherer, you want to answer as many questions as you can.

Can you write a program to calculate which questions do you have to answer to write maximum posts in T minutes?

Input

First line of input consists T minutes you have for answering, and N, how many new questions are on the site.
The second line has N numbers: time you need to answer qi question.

Output

Write either an array or numbers split with space: indexes of questions(counting from 0 or 1 - what is better for you) you should answer in order to write as many answers as you can. If you can't answer any questions, write nothing or anything to express that it's impossible. If there are several variants, write any.

Examples

Inputs               Possible outputs
60 5
30 5 10 20 3    0 1 2 4, 0 1 3 4 or 1 2 3 4

10 5
1 9 5 7 2         0 2 4 or 0 3 4

5 5
1 1 1 1 1         0 1 2 3 4

60 5
48 15 20 40 3  1 2 4 or 1 3 4

5 1
10

1 0

And of course it's code-golf, so the shortest code in bytes wins.

Python 3.8, 81, 79, 75 bytes

Using the walrus operator :=:

lambda k,l:[i for j,i in sorted((v,k)for k,v in enumerate(l))if(k:=k-j)>=0]

Try it online!

-2 bytes thanks to @JoKing

-4 bytes thanks to @justhalf

Python 3, 158, 137, 136, 130, 127, 117, 103, 95 bytes

def f(k,l):
 q=[]
 for j,i in sorted((v,k)for k,v in enumerate(l)):k-=j;q+=[i]*(k>=0)
 print(q)

Try it online!

-21 bytes thanks to @79037662 by limiting indentation to 1-space.

-14 bytes thanks to @ mypetlion

-8 bytes thanks to @justhalf

Both solutions ignore N parameter.


Appended Numbers Game Appended Numbers Game

Write a function/program that takes 2 integer parameters integer parameters or integer variables, a start number, and a max iterations count. The code should perform the following game example to construct a new number, and repeat until the number is a single digit left. eg.

3 7 2 = (3 + 7) & (7 + 2) = 10 9
1 0 9 = (1 + 0) & (0 + 9) = 1 9
1 9 = (1 + 9) = 10
1 0 = (1 + 0) = 1

Basically, taking each individual digit and adding it to its neighbour, then appending the result of the next addition as well.

Max iteration count is to safeguard infinite loops, and when the max is hit, code should dump the last 5 number steps. The same output should occur when finishing by reaching a single digit. If less than 5 steps occurred, only output the valid numbers.

Output should appear like (Step: Number) including the last 5 steps of the finished or terminated steps:

func(3541, 50) would produce this exact output format:

6: 1411
7: 552
8: 107
9: 17
10: 8

func(3541, 5) would produce:

1: 895
2: 1714
3: 885
4: 1613
5: 774

The entire calculation being:

1: 895
2: 1714
3: 885
4: 1613
5: 774
6: 1411
7: 552
8: 107
9: 17
10: 8

If there are less than 5 steps, just print those steps taken.

Only use built-in libs, parameters can be from anywhere (whatever's easiest for your language of choice). No limit on maximum integer size, and if there are overflows, let it crash.

Given this isn't too difficult from a puzzle point of view, I will give until Sunday 25th, 8PM (UTC+8) for submissions to be considered for the accepted answer, at which point the shortest of any language will be the winner.

EDIT:

Congratulations to Howard, winning with a 48 GolfScript answer.

Special mention to 2nd place marinus with a 66 APL answer.

My personal favourite (being biased towards JavaScript) was core1024's answer.

APL (66)

{↑¯5↑{(⍕⍵),': ',⍺}/∆,⍪⍳⍴∆←⍺{(1<⍴⍵)∧⍺>0:∆,(⍺-1)∇⊃∆←,/⍕¨2+/⍎¨⍵⋄⍬}⍕⍵}

The left argument is the maximum iteration count and the right argument is the start number.

Explanation:

∆←⍺{...}⍕⍵: pass the left argument as a number and the right argument as a string to the function that calculates the list of numbers, and store it in ∆:

(1<⍴⍵)∧⍺>0:: if the amount of digits is more than 1 and the amount of iterations left is more than 0:

⍎¨⍵: evaluate each digit
2+/: sum each pair
⍕¨: format each number as a string
∆←,/: concatenate the strings and store in ∆
∆,(⍺-1)∇⊃∆: return ∆, followed by the result of applying this function to ∆ with one less iteration allowed

⋄⍬: if not, return the empty list

∆,⍪⍳⍴∆: pair each element of ∆ with its index in ∆
{...}/: for each pair:

(⍕⍵),': ',⍺: return a string with the index, followed by :, followed by the number

↑¯5↑: turn the list of strings into a matrix so they display on separate lines, and take the last 5 items

Test:

      5{↑¯5↑{(⍕⍵),': ',⍺}/∆,⍪⍳⍴∆←⍺{(1<⍴⍵)∧⍺>0:∆,(⍺-1)∇⊃∆←,/⍕¨2+/⍎¨⍵⋄⍬}⍕⍵}3541
1: 895
2: 1714
3: 885
4: 1613
5: 774
      50{↑¯5↑{(⍕⍵),': ',⍺}/∆,⍪⍳⍴∆←⍺{(1<⍴⍵)∧⍺>0:∆,(⍺-1)∇⊃∆←,/⍕¨2+/⍎¨⍵⋄⍬}⍕⍵}3541
6: 1411
7: 552
8: 107
9: 17
10: 8


The Bowlers-Golfers Fraction War Introduction

Let's start by arranging all fractions from 0 to 1 in order of lowest denominator, then lowest numerator:

1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5, 4/5, 1/6, 5/6, 1/7...

Note that duplicates aren't counted, so I haven't listed 2/4, 2/6, 3/6, or 4/6, since they already appeared in their simplified forms (1/2, 1/3, and 2/3).

Your task is now simple: given a positive integer nas a command line argument, print to standard output the nth fraction in the list. Thus, an input of 5 should yield an output of 3/4 (not 0.75).

Bowlers

Your goal is to solve this in the longest program possible. Your score is the number of characters.

Golfers

Your goal is to take existing answers, and golf them. When golfing those answers, remove one or more characters from the code, and optionally rearrange the remaining characters, in such a way that the resulting code is still a valid solution in the same language. Your score is the product of all the reductions. (So if you remove 10 characters from one answer, and 15 from another, your score is 150.)

Rules

A valid program must have at least three unique characters.
Only ASCII characters may be used.
If your program's size is reduced, your score is reduced accordingly.
When golfing a program...

Edit the code in the text of the answer
Change the character count listed
Leave the following comment: **Removed X characters (from Y to Z)** (in bold)

You may not golf a valid program into an invalid one.
The golfed program must work in some version of the language listed. So if the original answer is marked as Python, and the code only works in Python 2, you may golf it to a program that only works in Python 3.

Therefore, it is recommended (but not required) that you be specific in titling your answer, mentioning the version and/or compiler used.

If you already golfed an answer, you may golf it again.
If you golf the same answer multiple times, your score for that answer is the sum of your reductions.

For example, if you reduce 10 characters from a program, and later remove another 15, and also golf 7 characters from another answer, your total score is (10+15)*7=175.
This applies regardless of whether someone else golfed the program in between your golfings.

You may golf your own answer, but you do not receive any points for doing so.

Winners

I will try to keep this leaderboard periodically updated. If I make a mistake, please let me know, or else you can edit this post yourself.

Top bowlers

Dennis (CJam): 1.17 × 10678
Pppery (CPython 3.6.2): 25984
OldCurmudgeon (Java): 278

Top golfers

jimmy23013: 105.2 * 10152
Martin Ender: 2.8 * 1014484
Pppery: 2 * 104111


Code to toggle a program Challenge

Write a program that toggles another. Your program should accept exactly two command arguments. Specifically, your two tasks are:

If the names of any running processes are identical to argument one, close them and exit
If the names of zero running processes are named identical to argument one, spawn one with that name, pass it the second command arg, and exit

The life of the spawned process must be completely independent of your own (think Daemon threads in Java, or Background threads in C#). You are responsible for closing programs that you didn't necessarily start in a past life.

Example

Here are two separate examples of how your program might be called.

python YourToggler.py Notepad.exe C:\MyTextFile.txt
java MyToggler.java cmd "echo hello world"

In the first example, if Notepad.exe is currently running, you should close all processes named Notepad.exe. Otherwise, you should start one with the argument C:\MyTextFile.txt.

Assumptions

You can sleep better knowing the following:

The name passed to you will be a valid program
You are not responsible for name discrepancies

If you are asked to find Notepad, you are not responsible for closing Notepad.exe

You will be run with the privileges you need to carry out your duty

Bash+common Linux utilities, 12 or 16 bytes
pkill "$1"||"$@"

If we can assume no whitespace in the program name and arg, then we can drop the quotes for a score of 12:
pkill $1||$@


Print X without X (robber's thread) This is the robber's thread of a cops-and-robbers challenge.  You can view the cop's thread here
A pretty common beginner style question is to print some string, but, there's a catch!, you need to do it without using any of the characters in the string itself!
For this challenge we will find out who is the best at printing X without X.  There are two threads to this, a cop's thread and a robber's thread.
In the cop's thread users will choose a language (which we will call Y) and a string (which we will call X) and write a program in language Y which takes no input and outputs X without using any of the characters in X.  The cop will then post both X and Y without revealing the program they have written.
Robbers will be select cop answers and write programs in language Y which  take no input and output X.  They will post these "cracks" as answers in this thread.  A crack need only work not be the intended solution.
Once a cop's answer is one week old, so long as it has not been cracked, the cop may reveal their program and mark it as "safe". Safe answers can no longer be cracked
Robbers will be scored by the total number of successful cracks with more cracks being better.


Iterative binary search Binary search is an algorithm that looks for an element in a sorted data-structure by constantly dividing the search space in half.
Rosetta Code

A binary search divides a range of values into halves, and continues to narrow down the field of search until the unknown value is found. It is the classic example of a "divide and conquer" algorithm.

Wikipedia

In computer science, a binary search or half-interval search algorithm finds the position of a target value within a sorted array. The binary search algorithm can be classified as a dichotomic divide-and-conquer search algorithm and executes in logarithmic time.

Smallest # of bytes wins
Clarifications

Example of calling the function/lambda/macro should be included, but don't count those chars!
Output should be > -1 if found, and <=-1 otherwise
import binary_search (20 bytes) DOES NOT count!
Implementation should run in O(log n), as algorithm dictates

Also see the code-golf StackExchange FAQ.
Example
> binary_search([1,3,5,6,7,8,8,10], 5);
4
> binary_search([1,3,5,6,7,8,8,10], 543);
-1

JavaScript (94 bytes)

(a,e)=>{u=a.length,m=0;for(l=0;l<=u;)e>a[m=(l+u)>>1]?l=m+1:u=e==a[m]?-2:m-1;return u==-2?m:-1}

Expanded out a little so you can see what's going on:

function binary_search(array, elem) {
    let u = array.length, m;
    for (let l = 0; l <= u;)
        if (elem > array[(m = (l + u) >> 1)]) l = m + 1;
        else u = (elem == array[m]) ? -2 : m - 1;
    return (u == -2) ? m : -1;
}

Example usage:

> a = [1,2,3,4,5,6,7,8,9,10]
> binary_search(a, 5)
4
> binary_search(a, 15)
-1


Find the Cross Product The cross product of two three-dimensional vectors \$\vec a\$ and \$\vec b\$ is the unique vector \$\vec c\$ such that:

\$\vec c\$ is orthogonal to both \$\vec a\$ and \$\vec b\$

The magnitude of \$\vec c\$ is equal to the area of the parallelogram formed by \$\vec a\$ and \$\vec b\$

The directions of \$\vec a\$, \$\vec b\$, and \$\vec c\$, in that order, follow the right-hand rule.

There are a few equivalent formulas for cross product, but one is as follows:
$$\vec a\times\vec b=\det\begin{bmatrix}\vec i&\vec j&\vec k\\a_1&a_2&a_3\\b_1&b_2&b_3\end{bmatrix}$$
where \$\vec i\$, \$\vec j\$, and \$\vec k\$ are the unit vectors in the first, second, and third dimensions.
Challenge
Given two 3D vectors, write a full program or function to find their cross product. Builtins that specifically calculate the cross product are disallowed.
Input
Two arrays of three real numbers each. If your language doesn't have arrays, the numbers still must be grouped into threes. Both vectors will have magnitude \$<2^{16}\$. Note that the cross product is noncommutative (\$\vec a\times\vec b=-\bigl(\vec b\times\vec a\bigr)\$), so you should have a way to specify order.
Output
Their cross product, in a reasonable format, with each component accurate to four significant figures or \$10^{-4}\$, whichever is looser. Scientific notation is optional.
Test cases
[3, 1, 4], [1, 5, 9]
[-11, -23, 14]

[5, 0, -3], [-3, -2, -8]
[-6, 49, -10]

[0.95972, 0.25833, 0.22140],[0.93507, -0.80917, -0.99177]
[-0.077054, 1.158846, -1.018133]

[1024.28, -2316.39, 2567.14], [-2290.77, 1941.87, 712.09]
[-6.6345e+06, -6.6101e+06, -3.3173e+06]

This is code-golf, so the shortest solution in bytes wins.
Maltysen posted a similar challenge, but the response was poor and the question wasn't edited.

Jelly, 14 13 12 bytes

;"s€2U×¥/ḅ-U

Try it online!

How it works

;"s€2U×¥/ḅ-U Main link. Input: [a1, a2, a3], [b1, b2, b3]

;"           Concatenate each [x1, x2, x3] with itself.
             Yields [a1, a2, a3, a1, a2, a3], [b1, b2, b3, b1, b2, b3].
  s€2        Split each array into pairs.
             Yields [[a1, a2], [a3, a1], [a2, a3]], [[b1, b2], [b3, b1], [b2, b3]].
       ¥     Define a dyadic chain:
     U         Reverse the order of all arrays in the left argument.
      ×        Multiply both arguments, element by element.
        /    Reduce the 2D array of pairs by this chain.
             Reversing yields [a2, a1], [a1, a3], [a3, a2].
             Reducing yields [a2b1, a1b2], [a1b3, a3b1], [a3b2, a2b3].
         ḅ-  Convert each pair from base -1 to integer.
             This yields [a1b2 - a2b1, a3b1 - a1b3, a2b3 - a3b2]
           U Reverse the array.
             This yields [a2b3 - a3b2, a3b1 - a1b3, a1b2 - a2b1] (cross product).

Non-competing version (10 bytes)

OK, this is embarrassing, but the array manipulation language Jelly did not have a built-in for array rotation until just now. With this new built-in, we can save two additional bytes.

ṙ-×
ç_ç@ṙ-

This uses the approach from @AlexA.'s J answer. Try it online!

How it works

ṙ-×     Helper link. Left input: x = [x1, x2, x3]. Right input: y = [y1, y2, y3].

ṙ-      Rotate x 1 unit to the right (actually, -1 units to the left).
        This yields [x3, x1, x2].
  ×     Multiply the result with y.
        This yields [x3y1, x1y2, x2y3].

ç_ç@ṙ-  Main link. Left input: a = [a1, a2, a3]. Right input: b = [b1, b2, b3].

ç       Call the helper link with arguments a and b.
        This yields [a3b1, a1b2, a2b3].
  ç@    Call the helper link with arguments b and a.
        This yields [b3a1, b1a2, b2a3].
_       Subtract the result to the right from the result to the left.
        This yields [a3b1 - a1b3, a1b2 - a2b1, a2b3 - a3b2].
    ṙ-  Rotate the result 1 unit to the right.
        This yields [a2b3 - a3b2, a3b1 - a1b3, a1b2 - a2b1] (cross product).