Simulate a 1D Game-of-Life-ish Model This question just trended over on code-review and I figured you might like it adapted as a codegolf challenge:

You are given a non-empty list of x houses represented as booleans. Each day, the houses compete with adjacent ones. 1 represents an "active" house and 0 represents an "inactive" house. If the neighbors on both sides of a given house are either both active or both inactive, then that house becomes inactive on the next day. Otherwise it becomes active.

def get_state_as_pos(thelist, pos):
    if thelist[pos-1] == thelist[pos+1]:
        return 0
    else:
        return 1

For example, if we had a group of neighbors [0, 1, 0] then the house at [1] would become 0 since both the house to its left and right are both inactive. The cells at both ends check the opposite side as well, so the neighbors at index 0 are at index length-1 and indexn1 and vice versa.
Even after updating the cell, you have to consider its prior state when updating the others so that the state information of each cell is updated simultaneously.

The function takes the array of states and a number of steps and should output the state of the houses after the given number of steps.

    input: states = [1, 0, 0, 0, 0, 1, 0, 0], steps = 1
   output should be [0, 1, 0, 0, 1, 0, 1, 1]

    input: states = [1, 1, 1, 0, 1, 1, 1, 1], steps = 2
intermediate state= [0, 0, 1, 0, 1, 0, 0, 0]
   output should be [0, 1, 0, 0, 0, 1, 0, 0]

    input: states = [1], steps=1
    output: states= [0]

Take the list and steps however you like and output the resulting list via default I/O. Standard loopholes are forbidden. This is codegolf, shortest answer in bytes wins!

05AB1E, 14 13 10 9 6 bytes

Based on Shaggy's Japt solution

F©Á®À^

Try it online!

F                  # repeat n times:
 ©Á                #  the list, rotated right
   ®À              #  the list, rotated left
     ^             #  xor (vectorizes)

Unnecessarily clever 9-byte solution:

F¥DO.øü+É

Try it online!

F                  # repeat n times:
                   #  (examples given for the initial state [0, 1, 1, 0, 1])
 ¥                 #  deltas of the list ([1, 0, -1, 1])
  D                #  duplicate
   O               #  sum (1)
    .ø             #  surround ([1, 1, 0, -1, 1, 1])
      ü+           #  pairwise addition ([2, 1, -1, 0, 2])
        É          #  modulo 2 ([0, 1, 1, 0, 0])


The fourth power (Juzuk) In 1939 Juzuk described a way to generate the fourth powers of natural numbers.
Group the natural numbers like this:

1   2 3   4 5 6   7 8 9 10   11 12 13 14 15   ...

Scratch each second group:

1   4 5 6   11 12 13 14 15 ...

The sum of the n remaining groups is n**4.

Input: none
Task: print the fourth powers upto 100**4, using Juzuk's method.
Output:

0 (optional)
1
16
81
...
100000000


The Eratosthenes Shuffle Challenge

Write a function or program that accepts a line of input, performs a very specific and oddly familiar shuffle on its characters, and outputs the result.

The required shuffling can be described using the following algorithm:

Label each character in the input with a 1 based index.
Write character number 1 as output.
Starting with character number 2, write every other character to the output in order, excluding character 2 itself.  In other words, write characters 4, 6, 8, 10, and so on as output.
Starting with the next character number n not yet written as output, write every nth character to the output, excluding character n itself, and excluding any other character (by numeric label) you may have already written to the output.
Repeat step 4 as long it continues to add new characters to the output.
Write the remaining characters to output, in order.

Example

Label the characters.

  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
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R

2. Write the first character to output:

  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
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O

3. Write every other character starting with 2, excluding 2.

  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
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCRE

4. The next character not yet written is character number 3; write every 3rd character starting with 3, but excluding character 3 itself, and any character already written.

  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
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCREYB R

5. Repeat step 4 using the next character, character 5.

4. The next character not yet written is character number 5; write every 5th character starting with 5, but excluding character 5 itself, and any character already written.  (This amounts to just character 25).

  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
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCREYB RN

5. The next character is 7; but 14, 21 have already been written, so no more characters would be output if we repeat step 4.  Thus, we're done with 5.

6. Write the remaining characters out in order.

  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
  O  L  D     D  O  C     Y  A  K  '  S     B  E  A  U  T  Y     C  O  R  N  E  R
O O A' EUYCREYB RNLDDCKSATO

Rules

Input and output may be via standard input/standard output, strings, or arrays of characters.

If reading in as standard input you may at your convenience assume there's a trailing newline, or that the entire input contains the line.  Newline characters do not participate in the shuffle.

Likewise, at your convenience, your output may either have a trailing newline or not.

Standard loopholes are disallowed.

This is a code golf competition.  Smallest code in bytes wins.

Test Cases

123456789ABCDEF -> 1468ACE9F2357BD

OLD DOC YAK'S BEAUTY CORNER -> O O A' EUYCREYB RNLDDCKSATO

Blue boxes use a 2600hz tone to convince telephone switches that use in-band signalling that the caller is actually a telephone operator.
->
Bebxsuea20h oet ovnetlpoesice htuei-adsgaln httecle satal  eehn prtre 0ncce ha nng aiuapootnt ihyon atallu o s 6z oi ehwstsnbilt lr clee.

Mathematica, 61 bytes

#[[SortBy[Range@Length@#,FactorInteger[#][[1,1]]PrimeQ@#&]]]&

Unnamed function taking a list of characters as input and returning a list of characters.

FactorInteger[#][[1,1]] yields the smallest prime factor of # (and returns 1 if # equals 1). Therefore FactorInteger[#][[1,1]]PrimeQ@# yields a strange expression: [#'s smallest prime factor] False if # is not prime, and # True if # is prime (these are unevaluated products of a number and a boolean).

Range@Length@# yields a list of the numbers up to the length of the input. Then SortBy sorts those numbers by the funny function described above. Mathematica is really type-sensitive in many ways, but cheerfully mixes them in other ways: expressions of the form [number] False are alphabetically sorted before expressions of the form [number] True, while ties are broken by sorting the numbers numerically. That produces exactly the permutation we want here, and #[[...]] permutes the characters of the input accordingly.


Parking lot supervisor Introduction
You are a supervisor of a parking lot and your manager is preparing for shrinking the size to the extreme.
It is a simplified and adapted version of a problem in last year's PAT top-level.
Challenge
You are asked to calculate how many cars are in the lot at the same time, at most.
Standard rules apply. And this is a code-golf so shortest code wins.
First line is the quantity of entries (no more than 100,000, your input may not contain this line if you like, for it is only a makeshift to determine where input ends). The following text contains one entry per line. And each entry includes three numbers:
<Car plate number> <Time (seconds) since open> <0(In) | 1(Out)>

Modification 2: It is OK to use an array of triples as input.
Modification 3: You can change the order of numbers in one entry. And you can choose which to use. (see the Remarks section)
The input is guaranteed to be valid, assuming that:

Car plate number is a integer in the range of 10000 ~ 99999
Time is a integer in the range of 0 ~ 86400

And

Entries are not necessarily chronologically ordered.
There is no car before the first second.
There is not necessarily no car after the last second.
A car would not leave before it gets in.
Car plate number is unique. (but a same car may visit for more than one time)
So it is impossible for a car to enter the lot when it is already in it.
A same car wouldn't go in and out at the same time.
A car is considered to be in the lot at the time of in / out.

Example 1
Input
11
97845 36000 1
75487 16500 1
12345 16 0
75486 3300 0
12345 6500 1
97845 32800 0
12345 16400 0
97846 16501 1
97846 16500 0
75486 8800 1
75487 3300 0

Output
3

Explanation
At 16500, car 12345 and 75487 were in the parking lot.
Example 2
I made this because I found many code failed on it.
Input (with first line left out)
12345 16400 0
12345 16500 1
75487 16500 0
75487 16600 1

Output
2

Explanation
At 16500, car 12345 and 75487 were in the parking lot.
Remarks
Actually, not all three are required for the output. At least, you only need plate+time or in/out+time for the result. But the algorithm is slightly different under two circumstances, so the choice of being shorter stays unknown in a certain language. And of course you can use all of three numbers. So I leave them in the challenge.

Mathematica, 33 bytes

-Min@Accumulate[2#2-1&@@@Sort@#]&

I had to read the problem statement better to realize that there's a much simpler algorithm that doesn't require the license plate information.

Unnamed function returning an integer; the input format is a list of ordered triples in the form {time, 0|1, license plate}. We start by Sorting, which makes the list chronological and also breaks time-ties by sorting 0s before 1s; then 2#2-1&@@@ keeps the arrival/departure information and forgets the rest, and also converts 0s to -1s.

Accumulate calculates the running totals of that list; the result is a list of the negatives of the numbers of cars in the parking lot after every arrival/departure. Then Min picks the smallest (most negative) of these and the negative sign is stripped.

Mathematica, 56 bytes

Max[<|#|>~Count~0&/@FoldList[List,{},#3->#2&@@@Sort@#]]&

The original submission (the first several comments refer to this submission). Unnamed function returning an integer; the input format is a list of ordered triples in the form {time, 0|1, license plate}.

The reason we choose to put the time entry first and the in/out entry second is so that Sort@# sorts the list chronologically, and records arrivals before departures if they're simultaneous. After that, #3->#2&@@@ returns a list of "rules" of the form license plate -> 0|1, still sorted chronologically.

Then, FoldList[List,{},...] creates a list of all the initial segments of that list of rules. Actually, it really messes up those initial segments; the kth initial segment ends up being a list with one rule at depth 2, one rule at depth 3, ..., and one rule at depth k+1. (FoldList[Append,{},...] would yield the more natural result.) However, <|#|> turns each of these initial segments into an "association", which has two desirable effects: first, it completely flattens the nested-list structure we just created; and second, it forces later rules to override earlier rules, which is exactly what we need here—for any car that has left the parking lot, the record of its initial entry is now completely gone (and similarly for cars that re-enter).

So all that's left to do is to Count how many 0s there are in each of these associations, and take the Max.


Programming with a Sporadic Shift Key There's something wrong with your keyboard. The Shift key has a mind of its own. Every time you type a character you have no idea whether it will come out shifted or not (though it is 50-50). Besides the standard character keys, nothing on the keyboard is functional. There is no mouse or other means of input.
Somehow you know the only way to fix things is to write a program that outputs Dear Computer, please stop giving me shift! to stdout. Luckily your IDE is open and you are capable of running a program, but of course as you type it you won't know which characters will be shifted.
What sequence of key-presses would you use to write a program that has the best possible chance of working on the first try?
Details
You are using a standard QWERTY keyboard, so there are 50 character keys you can press.
Unshifted versions (47 only):
`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./

Shifted versions (47 only):
~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?

The last 3 keys are Enter, Tab, and Space, which are the same shifted and unshifted.
A sequence of N of these characters has 2N - (whitespace char count) ways it might have been output if you had typed them with your faulty keyboard. For example, typing A Space m might have yielded
a m or A m or a M or A M.
Write a program these characters and look at all of its 2N - (whitespace char count) possible shift combinations. The more combinations that output Dear Computer, please stop giving me shift! the better. Your score is the number of working combinations (valid programs) divided by the total number of combinations. The highest score wins.
Notes

For valid programs, printing precisely Dear Computer, please stop giving me shift! and nothing else to stdout should be the only side effect.
Valid programs should not take input.
Invalid programs can do anything whatsoever.
Comments may be used anywhere.
Whitespace answers cannot win because getting a 100% score is (relatively) trivial. You may still submit a Whitespace solution for fun.
Your program must be at most 1024 characters long.

Update: Changed Stop giving me shift! to Dear Computer, please stop giving me shift! to allow for more complex answers. Existing answers may stay the way they are if desired.

Applescript, 20 (100%)
I believe I can claim a perfect score here:

The Applescript Editor (my IDE) automatically converts all keywords to lower case upon compiling/running
Furthermore, defined variable and handler names are case insensitive - For example if a handler myFunc is defined, then the IDE will automatically convert MYFUNC, myfunc, MyFuNc, etc references to myFunc
I have only used alphabetic characters, spaces and newlines, so I don't need to worry about shifted numbers and punctuation characters.

Here is is:
global f
on j at a
set end of a to j
end
on c at a
j at a
j at a
end
on k at a
repeat with q in system info
j at a
end
end
on w at a
set d to count a
j at a
return string id d
end
on z at a
set end of f to a
end
set h to space
set y to h as list
k at y
k at y
set x to w at y
c at y
c at y
c at y
c at y
c at y
set q to w at y
k at y
c at y
c at y
copy y to b
c at y
set s to w at y
set d to w at y
set f to d as list
k at b
k at b
set a to w at b
c at b
j at b
set e to w at b
set y to w at b
set g to w at b
set d to w at b
set i to w at b
c at b
set l to w at b
set m to w at b
set n to w at b
set o to w at b
set p to w at b
j at b
set r to w at b
z at e
z at a
z at r
z at h
z at s
set s to w at b
set t to w at b
set u to w at b
set v to w at b
z at o
z at m
z at p
z at u
z at t
z at e
z at r
z at q
z at h
z at p
z at l
z at e
z at a
z at s
z at e
z at h
z at s
z at t
z at o
z at p
z at h
z at g
z at i
z at v
z at i
z at n
z at g
z at h
z at m
z at e
z at h
z at s
z at d
z at i
z at y
z at t
z at x
f as text

Thanks to the help of @kernigh and @paradigmsort, this is now 1020 bytes, just squeaking in under the 1024 byte limit!
Explanation:

The characters for output string are generated using string id <n>, which returns the character corresponding to the ascii value n
Because we are avoiding digits, each n has has to be generated by more fundamental means.  Specifically we generate each n by counting a list, and then adding another item to that list.  The repeat with q in system info allows us to do this 16 times, as system info always returns a 16-item list.
Using a similar technique, we add each character of the final string in turn to a list.
Finally that last list is coerced to text and printed.

Output:
Using the osascript interpreter, but the Applescript Editor works just as well:
$ # Interpret as-is:
$ osascript dearcase.scpt
Dear Computer, please stop giving me shift!
$
$ # Interpret all lower case:
$ tr A-Z a-z < dearcase.scpt | osascript
Dear Computer, please stop giving me shift!
$
$ # Interpret all upper case:
$ tr a-z A-Z < dearcase.scpt | osascript
Dear Computer, please stop giving me shift!
$
$ # Interpret random case for each letter:
$ while read; do for ((i=0;i<${#REPLY};i++)); do c="${REPLY:i:1}"; if ((RANDOM%2)); then printf "%s" "$(tr a-z A-Z <<< "$c")"; else printf "%s" "$(tr A-Z a-z <<< "$c")"; fi; done; echo; done < dearcase.scpt | osascript
Dear Computer, please stop giving me shift!
$


The Speed of Letters Given a string as input, print a new string with each letter pushed to the right by its respective alphabet index.

We all know that A is a slow and Z is a fast letter. This means that Z gets shifted to the right by 25 spaces, A doesn't get shifted at all and B gets shifted by 1 space.

Your program only has to handle uppercase letters from A-Z, and no other characters, no whitespaces, no punctuation.

Note that if 2 or more letters fall onto the same space after shifting, the latest character will be used. (Example: BA ->  A)

Examples

"AZ" -> "A                         Z"

"ABC" -> "A B C"

"ACE" -> "A  C  E"

"CBA" -> "  A"

"HELLOWORLD" -> "     E H    DLL   OLO   R  W"

Rules

This is code-golf, so the shortest code in any language bytes wins.
Standard loopholes are forbidden.
Input must be received as a string.
You may print the result to stdout or return a string.
A single trailing whitespace and/or newline is allowed.
You may also use lowercase letters as input or output, but only use either case.

Python 2, 81 bytes

t=[]
i=65
for c in input():t+=[' ']*26;t[ord(c)-i]=c;i-=1
print`t`[2::5].rstrip()

Try it online!


Check If Two or More Variables Are All Equal to Zero in JavaScript What is the shortest way to check if two or more variables are equal to 0 in JavaScript?

I'm curious to know if there's something shorter than if(!x&&!y&&!z){...}.

(EDIT: This first part refers to the original phrasing of the question.)

First, (!x&&!y&&!z) returns a boolean, which makes ?true:false entirely redundant. It's basically like using

if (x == true)
  return true;
else if (x == false)
  return false;

instead of return x;.

That gives you

!x&&!y&&!z

(EDIT: The remainder still applies to the new version of the question.)

Now you could apply De Morgan's law. The above is equivalent to

!(x||y||z)

Which is the same length for 3 variables and longer for 2 variables. But for each variable beyond the third, you save one more character!

Lastly, if you know that your variables are numbers, you can also use the bitwise operator, i.e.

!(x|y|z)

If you actually need booleans (which I assume from your snippet), this doesn't work for the & case, because !x&!y&!z will give you an integer. Then again, in JavaScript it's often enough to have truthy or falsy values, in which case, that's a perfectly valid option.

Bonus tip: if you ever want to turn a truthy/falsy value (like a non-zero/zero number) into a boolean, don't use x?true:false either, but use !!x instead. !x is a boolean with the opposite truthiness/falsiness than x, so !!x is true for x truthy  and false for x falsy.


Output optimal trill fingerings Note: all array references in this post are zero-indexed.

When playing the piano, two notes on the same key must be pressed with two different fingers. You could use the same finger, but it doesn't sound as good. At least, according to my piano teacher. I can't hear any difference.

The challenge is to take a space-separated list of 3 integers: Starting finger, ending finger, and length of repeating notes, and output the optimal sequence of finger numbers to match the input.

All piano jargon aside, output a string of numbers based on the input, where each number is +1/-1 the one before it, all numbers are between 1 and 5, the sequence is args[2] digits long, starting with args[0] and ending with args[1], and is formatted as below.

The input can be command line arguments, values on the stack (for ><> users), STDIN, or any other conventional method.

Output will be a list of numbers, with these being valid outputs.

[1, 2, 3, 4, 5]
(1 2 3 4 5)
"12345"
12345*
1-2-3-4-5**
1 2 3 4 5**

For each asterisk on the style above, compute the following to calculate your score:

final-score = code.length * (1.00 - (asterisks * 0.05));

You can assume the first two params will be between 1 and 5, but if it handles at least 0-9, multiply your code by 95%.

If the last digit is less than 2, or the input parameters are impossible, error however you like, or just exit.

Finger numbers on the piano work like this, however this is not integral to the challenge.

1 | Thumb
2 | Index finger
3 | Middle finger
4 | Ring finger
5 | Pinky (finger)

Sample input and output:

Input: 1 2 2
Output: 1 2

Input: 1 4 8
Output: 1 2 3 2 3 2 3 4

Input: 2 3 10
Output: 2 3 2 3 2 3 2 3 2 3

Input: 5 2 1
Output: Error

Input: 1 2 5
Output: Error

Input: 5 1 5
Output: 5 4 3 2 1

Input: 1 1 1
Output: 1

These do not have to be handled correctly.

Input: 1 6 6
Output: 1 2 3 4 5 6

Input: 0 9 8
Output: Error

Pyth, 36 * .95 * .90 = 30.78

jd+JrFAQ<*vz,H.xeJhH?&%K-vzlJ2>K0K.q

Test suite

Outputs space separated integers and can handle arbitrary integer inputs, so it qualifies for both bonuses.

Input format:

length
starting finger, ending finger

The output is constructed by starting with a range from the starting finger to the ending finger, then repeating the end of that range and the ending finger the necessary number of times. Exiting is done via explicit checks for the length of the second step being odd and positive, or else .q, Pyth's exit function is called.


Rememebere tehe vowelese! Input

A string of printable ASCII characters, for example:

This is an example string.

Output

For every consonant (BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz) that is not followed by a vowel (AEIOUaeiou) add the last vowel before it, in lowercase.
Consonants before the first vowel are left as-is:

Thisi isi ana examapale seterinigi.

Test cases

AN EXAMPLE WITH A LOT UPPERCASE (plus some lowercase)
=> ANa EXAMaPaLE WITiHi A LOTo UPuPEReCASE (pelusu some lowerecase)

And here comes a **TEST** case with 10% symbols/numbers(#)!
=> Anada here comese a **TESeTe** case witihi 10% siyimiboloso/numuberese(#)!

This is an example string.
=> Thisi isi ana examapale seterinigi.

abcdefghijklmnopqrstuvwxyz
=> abacadefegehijikiliminopoqorosotuvuwuxuyuzu

A pnm bnn
=> A panama banana

Tell me if you need more test cases!
=> Telele me ifi you neede more tesete casese!

Scoring

As this is code-golf, the answer with the lowest byte-count in each language wins (no answer will be accepted).

Retina, 48 bytes

i`(?<=([aeiou]).*?[^\W\d_aeiou])(?![aeiou])
$l$1

Try it online! Explanation: The lookahead searches for a point not followed by a vowel, while the lookbehind searches for an immediately preceding consonant and a previous vowel, which is then inserted in lower case.


Help, I've mixed my week up! My dog ate my calendar, and now my days are all mixed up. I tried putting it back together, but I keep mixing up the days of the week! I need some help putting my calendar back together, with the days in the correct order.

And since I need my calendar put together as fast as possible, don't waste my time by sending me superfluous bytes. The fewer bytes I have to read, the better!

Input

The days of the week, in any order. Input can be taken as a list of strings, or a space separated string, or any reasonable way of representing 7 strings (one for each day of the week).

The strings themselves are all capitalized, as weekdays should be, so the exact strings are:

Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Output

The days of the week, in sorted order (Monday - Sunday, because of course we adhere to ISO 8601). Output can be as a list of strings, or printed with some delimiter.

Disclaimer

Note that this is a kolmogorov-complexity challenge, with the added benefit of being able to use the input to shorten your code. You are not required to use the input if you don't want to. You are also free to use any approach, from a builtin datetime library to hard-coding the output.

Examples

To see example input and output, you can consult this python script.

Pyth, 7 bytes

o%CN258

Try it online!

Convert each string to a number via treating its ASCII codes as a base 256 number, then take that mod 258, and sort. This gives the mapping

['Monday', 49]
['Tuesday', 75]
['Wednesday', 89]
['Thursday', 99]
['Friday', 103]
['Saturday', 125]
['Sunday', 211]

Same length but less fun is

.P1314S

The 1314th permutation of the sorted input in lexicographic order.


Are They Similar Polygons? Task

Given the x,y coordinates (coordinates are guaranteed to be integers) of the vertices of two simple polygons in clockwise or anti-clockwise order. Output a Truthy value if both the polygons are similar otherwise a Falsy value

A simple polygon is a polygon that does not intersect itself and has no holes. That is, it is a flat shape consisting of straight, non-intersecting line segments or "sides" that are joined pairwise to form a single closed path. If the sides intersect then the polygon is not simple. Two edges meeting at a corner are required to form a an angle that is not not straight (180°)

Two polygons are similar if either polygon can be rescaled, repositioned, and reflected, so as to coincide precisely with the other polygon.

Testcases

Input

[(0, 0), (1, 0), (1, 1), (0, 1)]
[(-1, 0), (2, 1), (1, 4), (-2, 3)]

Graph

Output

Truthy

Input

[(2, 3), (0, 0), (4, 0)]
[(-3, 0), (-2, 2), (0, 1), (1, -1), (-1, -2), (-2, -2)]

Graph

Output

Falsy

Input

[(1, 4), (1, 3), (0, 2), (1, 1), (-3, 2)]
[(2, 0), (2, -1), (3, -1), (4, -2), (-2, -2)]

Graph

Output

Falsy

Input

[(-1, 0), (2, 1), (1, 4), (-2, 3)]
[(1, 4), (2, 1), (-1, 0), (-2, 3)]

Graph

Output

Truthy

Input

[(-2, 0), (-1, 1), (0, 1), (1, 3), (1, 0)]
[(5, 4), (4, 2), (3, 2), (2, 1), (5, 1)]

Graph

Output

Truthy

Input

[(2, 13), (4, 8), (2, 3), (0, 8)]
[(0, 0), (5, 0), (8, 4), (3, 4)]

Graph

Output

Falsy

Input

[(-1, 0), (-5, 3), (-5, 9), (-1, 6)]
[(0, 0), (5, 0), (8, 4), (3, 4)]

Graph

Output

Falsy

Input

[(0, 0), (1, 2), (1, 0)]
[(2, 0), (2, 2), (3, 0)]

Graph

Output

Truthy

Mathematica, 97 bytes (SBCS)

Or@@(Equal@@(a@u/#)&/@(a/@NestList[RotateLeft,v,Length@v]))
a@l_:=Norm[#〚1〛-#〚2〛]&/@l~Subsets~{2}

You can try it online!

The function a computes all the pairwise distances between any two vertices of the polygon.

The main function applies this to the first list and to every rotation of the second list, to try and find the corresponding vertices. The rotation of the second list is correct if all the corresponding distances have been scaled accordingly.

Thanks to @J42161217 for saving me some 3 bytes


Text-Twist - similar to boggle problem A similar play on the boggle problem from before (some text from that has been used below, edited to fit)
any code that solves the familiar "text-twist" game

Objective

7 letters are given at random, to which there is a minimum 1 word that uses all 7 letters, and multiple words using less (3 or more required)

The letters may be used in any order, however not duplicated (unless duplicates are included in the 7)

Your code should run for no more than 1 minute (60 seconds). At that time, it should have solved all results.

Final challenge score will be the character count of the program.
In the event of a tie, the winner will be the fastest output, decided by an average of 3 inputs, the same being given to both.
In the event there is still a tie, the winner will be whichever algorithm found more long (6+) words.

Rules / constraints

Please refer to wordlist.sourceforge.net for a word list (use ISPELL "english.0" list - the SCOWL list is missing some pretty common words).
This listing may be referenced in your code any way you wish.

Perl, 90 chars

$_++for@q{<>=~/./g};open E,"E";while(<E>){%p=%q;$.*=$p{$_}--for/./g;y///c>3&&$.&&print}

The program takes the list of letters as a line on standard input. The word list is referenced as a file in the current directory named "E". (Presumably this falls under the umbrella of "any way you wish".)

Some other assumptions I made that were not spelled out in the problem description:

that the goal was to produce a program (as opposed to a function);
that the input was case-sensitive;
that apostrophes and hyphens were not to be ignored;
that the program was required to not match on words in the word list that were too short.

Also, I wonder if the time limit given in the original description is necessary. Even when given a huge list of letters such that every word in "english.0" matches, my program still runs to completion in under 1s.


Draw an alphabet party hat Your task is to print this exact text:

            z
            yz
           xyz
           wxyz
          vwxyz
          uvwxyz
         tuvwxyz
         stuvwxyz
        rstuvwxyz
        qrstuvwxyz
       pqrstuvwxyz
       opqrstuvwxyz
      nopqrstuvwxyz
      mnopqrstuvwxyz
     lmnopqrstuvwxyz
     klmnopqrstuvwxyz
    jklmnopqrstuvwxyz
    ijklmnopqrstuvwxyz
   hijklmnopqrstuvwxyz
   ghijklmnopqrstuvwxyz
  fghijklmnopqrstuvwxyz
  efghijklmnopqrstuvwxyz
 defghijklmnopqrstuvwxyz
 cdefghijklmnopqrstuvwxyz
bcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz

Case does not matter.

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

Cheddar, 50 45 42 37 bytes

25|>0=>i->print" "*(i/2|0)+(65+i)@"90

Straightforward, but utilizes cheddar's consise ranging syntax (both numerical and alphabetical)

Try it online!

Explanation

25 |> 0 =>    // Map range [0, 26) (i.e. [25, 0] reversed) over....
   i ->
     print    // Prints in it's own line...
     " " * (i/2 |0) +     // Number of spaces is floor(n/2).
                          // `|0` for flooring is hack from JS
     (65 + i) @" 90       // Char code range is this

65 is char code for A and 90 for A


XKCD Bracket Probabilities Today's XKCD is a sports-tournament style bracket, where the contestants are well-known names, put into groups of possibly confusing names.
Give the probability that a given contestant will win the entire tournament, based on each contestant in a given round having an equal chance of winning that round.
Input
The name of a contestant.

XKCD likes to use all upper case, but you may use whatever case makes sense for you or make your input case insensitive.
You may assume all input names are valid.
Jeff Gordan is probably a misspelling of Jeff Gordon.  You may choose to accept either or both of these.
Some names include punctuation, e.g. H. G. Wells and Joseph Gordon-Levitt.  You may choose to accept names with or without punctuation (or both).  The above without punctuation would be H G Wells and Joseph Gordon Levitt
Similarly, you may choose to accept either Beyoncé or Beyonce or both
The Mister/Fred Astaire/Rogers line is a bit odd.  For this one, you must accept all of the following: Fred Rogers, Mister Rogers and Fred Astaire

Output
The probability of the given contestant winning the whole tournament, in rational form (e.g. 1/64)
Examples

Louis Armstrong will potentially play in 6 rounds, each with two contestants, so he has a 1/64 chance of winning.
Alan Rickman will potentially play in 7 rounds, the first with 3 contestants and the rest with 2 contestants, so he has a 1/192 chance of winning.

To save you the effort of typing in all the names from the image, explainXKCD already has them tabulated.  I've also dumped them to this pastebin.
Note the winning probabilities in the explainXKCD are wrong - they are twice as big as they should be because they are presumably forgetting the final round.  Thanks for pointing this out @Geobits.

CJam, 161 bytes

1'/l_"FRE"#\_'É#)\2b626%536%"òazíF.?§·»ùßóÿ÷ýÿÿ»×ï_ÿÿ¿ß÷ä¿ûïÿÏÅÿ¿ÿÿ~ÿþÿýó½ïÿþþ/ïþÿ®þü¾ùÿ®÷/"256b2b2*<1-,"ãÍÕý*ÔÞ)ð^sV? Ìöî²\ÅlÕáS{Á"260b5b=5,Z6t=2+1\?4?32*

This is a full program that expects uppercase input, with punctuation and accents exactly as shown in the pastebin.

Try it online in the CJam interpreter.

How it works

1'/      e# Push a 1 and a slash.
l        e# Read a line of input from STDIN.
_"FRE"#  e# Push 0 if the input starts with "FRE" and a truthy value otherwise.
\_'É#)   e# Push 1 if the input doesn't contain "É" and a falsy value otherwise.

         e# Now we hash the input:
\2b      e#     Apply base 2 conversion to turn the input into an integer.
626%536% e#     Take that integer modulo 626, then modulo 536.

"òazíF.?§·»ùßóÿ÷ýÿÿ»×ï_ÿÿ¿ß÷ä¿ûïÿÏÅÿ¿ÿÿ~ÿþÿýó½ïÿþþ/ïþÿ®þü¾ùÿ®÷/"256b2b2*

         e# Convert the string from base 256 to base 2 and repeat it.
         e# The resulting array, [1 1 1 1 0 0 1 0 0 ...], contains a 0 at index X
         e# if and only if there is a possible input with hash X.

<        e# Keep the binary values before the index of the input hash.
<1-,     e# Count the number of zeroes.

"ãÍÕý*ÔÞ)ð^sV?  Ìöî²\ÅlÕáS{Á"260b5b

         e# Convert the string from base 260 to base 5.
         e# The resulting array, [2 2 2 2 2 0 4 4 0 0 ...], contains a diffrent
         e# integer for every different probability. The input with the lowest hash
         e# corresponds to the first index, the one with the highest to the last.

=        e# Retrieve the integer corresponding to the input.
5,Z6t=   e# Retrieve the corresponding element from [0 1 2 6 4].
2+       e# Add two.
1\?      e# Select the result from above or 1 for BEYONCÉ.
4?       e# Select the result from above or 4 for and FRED.
32*      e# Multiply by 32.


Generalised Fortunate Prime Sequences The primorial \$p_n\#\$ is the product of the first \$n\$ primes. The sequence begins \$2, 6, 30, 210, 2310\$.
A Fortunate number, \$F_n\$, is the smallest integer \$m > 1\$ such that \$p_n\# + m\$ is prime. For example \$F_7 = 19\$ as:
$$p_7\# = 2\times3\times5\times7\times11\times13\times17 = 510510$$
Adding each number between \$2\$ and \$18\$ to \$510510\$ all yield composite numbers. However, \$510510 + 19 = 510529\$ which is prime.
Let us generalise this to integer sequences beyond primes however. Let \$\Pi(S,n)\$ represent the product of the first \$n\$ elements of some infinite sequence \$S\$. All elements of \$S\$ are natural numbers (not including zero) and no element is repeated. \$S\$ is guaranteed to be strictly increasing.
In this case, \$p_n\# = \Pi(\mathbb P,n)\$. We can then define a new type of numbers, generalised Fortunate numbers, \$F(S,n)\$ as the smallest integer \$m > 1\$ such that \$\Pi(S,n) + m \in S\$.
You are to take an integer \$n\$ and an infinite sequence of positive integers \$S\$ and output \$F(S,n)\$.
You may take input in any reasonable representation of an infinite sequence. That includes, but is not limited to:

An infinite list, if your language is capable of handling those (e.g. Haskell)
A black box function which returns the next element of the sequence each time it is queried
A black box function which returns two distinct values to indict whether it's argument is a member of that sequence or not
A black box function which takes an integer \$x\$ and returns the \$x\$th element of the sequence

If you have another method you are considering using, please ask in the comments about it's validity.
This is code-golf so the shortest code in bytes wins
Examples
I'll walk through a couple of examples, then present a list of test cases below.
\$n = 5, S = \{1, 2, 6, 24, 120, ...\}\$
Here, \$S\$ is the factorials from 1. First, \$\Pi(S, 5) = 1\times2\times6\times24\times120 = 34560\$. We then find the next factorial greater than \$34560\$, which is \$8! = 40320\$ and subtract the two to get \$m = 40320 - 34560 = 5760\$.
\$n = 3, S = \{6, 28, 496, 8128, ...\}\$
Here, \$S\$ is the set of perfect numbers. First, \$\Pi(S, 3) = 6\times28\times496 = 83328\$. The next perfect number is \$33550336\$, so \$m = 33550336 - 83328 = 33467008\$
Test cases
n
S
F(S, n)

5
{1,2,6,24,120,...} (factorials)
5760

3
{6,28,496,8128,...} (perfect numbers)
33467008

7
{2,3,5,7,11,...} (prime numbers)
19

5
{1,3,6,10,15,...} (triangular numbers)
75

Any n
{1,2,3,4,...} (positive integers)
2

9
{1,4,9,16,25,...} (squares)
725761

13
{4,6,9,10,14,...} (semiprimes)
23

Husk, 8 bytes
ḟ>1M<¹Π↑

Try it online! (Missing the testcase for perfect numbers because it was too slow, and the one for semiprimes because implementing the list of semiprimes is a challenge itself)
Takes as input S and n, where S is an infinite list.
Explanation
ḟ>1M<¹Π↑
       ↑     Take the first n elements from S
      Π       and get their product
   M ¹       For each element x in S
    <         subtract the product if it is smaller than x, return 0 if it is bigger
ḟ            Find the first element in this list
 >1           that is greater than 1


Produce the most digits of an irrational number with only 64 KB of memory Constraints:

Calculate any notable irrational number such as pi, e, or sqrt(2) to as many decimal digits as possible. If using a number not mentioned in the list above, you must cite how and where this number is used.
The memory used to store data in variables that the program reads from at any time in its computation may not exceed 64 kilobytes (216 = 65 536 bytes). However, the program may output as much data as it likes, provided it does not re-read the outputted data. (Said re-reading would count toward the 64 KB limit.)
The maximum size for code (either source or object code can be measured) is also 64 kilobytes. Smaller code is allowed, but does not provide more memory for computation or a better score.
The program must not accept any input.
Any format for output is allowed, as long as the digits are represented in decimal. Only the fractional portion of the number will be taken into account, so both 3.14159... and 14159... are both equivalent answers, the latter one being represented as "the fractional part of pi".
The number of decimal digits past the decimal point that your program outputs is your score. Highest score wins.

Python - 10157831 digits

import sys

sys.stdout.write("0.")
a = 0
while True:
    a += 1
    sys.stdout.write(str(a))

Prints 0.1234567891011121314151617181920..., which is the Champernowne constant in base 10, until the program runs out of memory.

When the program's counter a reaches a specific number x, it has printed out at least x digits (as every number has at least one digit), and more on the order of x log x digits. For x = 1010000, the binary data required to represent a would be about 4.1 kilobytes, which is well below the allotted limit.

Interesting to note - any computer running this program would run out of total memory long before it ever printed off even 10100 digits (let alone 1010000), due to there only being about 1080 particles in the observable universe and only about 1021 bytes of memory available for storage on all of Earth's data computing devices.

Wolfram Alpha says that the total number of digits printed is actually about 4.09776347957... × 10157831, assuming we can get all the way to 2524288 - 1 without running into memory issues with the bignum storage.


De-interleave log lines: HARD MODE In the face of some regrettable rules that turned the original into a glorified sorting task, I am posting a more challenging variant. Shout out to Luis Mendo for the suggestion of how to improve the original challenge.

You've inherited a server that runs several apps which all output to the same log.
Your task is to de-interleave the lines of the log file by source. Fortunately for you, the person who wrote all the apps was nice enough to leave tags indicating their source.
Logs
Each line will look something like this:
[app_name] Something horrible happened!

App tags are always between square brackets and will contain only alphanumeric characters and underscores.
App tags are nonempty
There may be other square brackets later on any given line, but none will form a valid tag.
There will always be at least one non-space character after a tag.
The log as a whole may be empty.
There is no limit to how many unique app tags will be present in the file.

In some cases, an app tag may be missing. When this is the case, the log line belongs to the most recently logged app.

The first line of the log will always begin with an app tag
A line beginning with [ is not necessarily tagged. If there is an invalid character between the initial square brackets or no ], then the line is not tagged.
No empty lines appear in the log

Expected Output
You should output several fully-separated logs with the app tags removed from each log line where they were present. You do not need to preserve leading whitespace on any log line.
Output logs must be in some sort of key-value mapping or reasonable equivalent. A non-exhaustive list of valid output formats:

A file named after the app tag for each app

You may assume that the output files do not already exist in the output directory in this case.

A dictionary/map/hash/whatever that uses app tags as keys and a newline-separated string of the log lines as values.
A long concatenated string separated by blank lines and preceded by app tags
A list of [key, value] lists
A JSON string with app tags as keys and arrays of log lines as values
A Markdown document with app tags as headers and leading #s of any line escaped with backslashes.
A Javascript function that takes a string as input and outputs the associated log as a newline-separated string.

Basically, if you can't tell which app the log lines came from, the output is invalid.
Example
An entire log might look like this:
[weather] Current temp: 83F
[barkeep] Fish enters bar
Fish orders beer
[stockmarket] PI +3.14
[PI announced merger with E]
[barkeep] Fish leaves bar
[weather] 40% chance of rain detected
[ I have a lovely bunch of coconuts

Which should output three different logs:
weather:
Current temp: 83F
40% chance of rain detected
[ I have a lovely bunch of coconuts

barkeep:
Fish enters bar
Fish orders beer
Fish leaves bar

stockmarket:
PI +3.14
[PI announced merger with E]

You are not given the names of the app tags ahead of time. You must determine them only by analyzing the log file.
Rules and Scoring

This is code-golf, so shortest code wins.
Standard rules and loopholes apply
Use any convenient IO format, provided that each input line is represented as a string, not a pre-parsed tag + message. Parsing is part of this challenge.
Output log lines for each app must appear in the same order that they did in the original log.
You may assume that the input log contains only ASCII characters.

Python 3.8, 95 bytes

import re
lambda x:[((t:=re.match(r'\[(\w*)\]',s)or t)[1],s.split(t[0])[-1].strip())for s in x]

Try it online!
(Expanded TIO example with input)
Explanation:
Python 3.8 is required for the := operator. This takes a list of strings as input, and outputs a list of (tag, body) tuples. First, it uses a Regex match to get the tag:
t:=re.match(r'\[(\w*)\]',s)or t)

This matches any initial sequence of word characters (alphanumeric + underscore) enclosed in square brackets, with the words as a capturing group. If the string does match this regex, t will be a match object with two elements: the full match and the group. For example, if the string is [tag] body, the match will have the elements [tag] and tag.
If the string does not match this regex, then re.match() returns None. The code becomes t = None or t, which is just t = t, so the tag keeps its value from the previous line. If the first line didn't have a match, this would cause an error, but we don't need to worry about that!
The code then constructs the tuple t[1], s.split(t[0])[-1].strip(), where t[1] is the capturing group (the tag without square brackets) and t[0] is the tag with square brackets. Splitting the string on the full tag isolates the body, whether or not the tag actually exists in the string.


Multiply using ***Real*** numbers Inspired by a restriction on What do you get when you multiply 6 by 9? (42)

By order of the President, we are no longer permitted to use confusing fake numbers (i.e. numbers other than integers from 0 to 99 inclusive), and are instead to use only real numbers, that is, those that are not fake.

Unfortunately, most maths are very unpatriotic at present and thus it is necessary to revolutionalize a new, revised, mathematics for the glory of the State.

Your task is to create a program or function which takes as its input two numbers and provides as its output their product.  Your program, obviously, must be consistent with Minitrue's standards for programmatic excellence.  Specifically:

You may use real numbers in your code; users of fake numbers will be referred to Miniluv
If a fake number is provided as input, you are to raise an error to that effect raised only in this case.  If your chosen language is incapable of error, you are to write a consistent Truthy or Falsy value to a different output stream than normal, this value being written to that output stream only in this case.
Your program must never output any fake numbers; users of fake numbers will by referred to Miniluv
Your program must output consistently with pre-Ministry math texts, except where those texts are influenced by thoughtcrime (i.e. where the input or output would be a fake number).  In those cases, you are free to define whatever truth you think best furthers the Party's goals, provided your output is consistent with above principles.
Your input is guaranteed to be either two real numbers, two fake numbers, or one real and one fake number

This is code golf; the shortest code in bytes wins.

Some test cases:

Input: 0, 3 Output: 0
Input: 2, 5 Output: 10
Input: 9, 11 Output: 99
Input: 10, 10 Output*: 5
Input: -1, 0 Output*: ERROR: THOUGHTCRIME COMMITTED
Input: 2, 2.5 Output*: ERROR: THOUGHTCRIME COMMITTED
Input: 99, 2 Output*: 5
Input: -1, 53 Output*: ERROR: THOUGHTCRIME COMMITTED

Test cases with an 'Output*' indicate that there are multiple valid outputs for that test case.

Please note that while your output in the case of a fake product from real numbers may be an error, it cannot be the same error as for fake input (unless both cases trigger), as explained in rule #2.

Python,  54  52 bytes

lambda a,b:[v for v in(a,b,a*b%-~99)if'd'>chr(v)][2]

An unnamed function raising an error if either of the inputs are fake otherwise returning the product of the inputs modulo 100 (always real and correct if the product itself is real).

Try it online!

How?

First creates a tuple of the inputs and their product modulo 100 using (a,b,a*b%-~99) where ~x computes -1-x and % is the modulo operator.

Then traverses that tuple creating a list of those values which are real numbers.

The test for real-ness is performed by first attempting to cast each value, v, to characters with chr(v) - which will raise a ValueError if v is not a non-negative integer less than 256, then checking the value is less than 100 by a less-than-comparison, <, to the 100th character, 'd'.

If both a and b are real the list will have three entries (the product modulo 100 is alway real), otherwise it will have less. The [...][2] attempts to get the item at the second index (third item), raising an IndexError if it does not exist.

Thus either input being fake results in either a ValueError or IndexError, while both inputs being real always succeeds and returns a real number, and if that product is itself real it is the returned value.


Create a World Cup guessing program As you know, the World Cup group stage is over, and from tomorrow the best 16 teams will commence the knockout stage:

Brazil (BRA)
Mexico (MEX)
Netherlands (NED)
Chile (CHI)
Colombia (COL)
Greece (GRE)
Costa Rica (CRC)
Uruguay (URU)
France (FRA)
Switzerland (SUI)
Argentina (ARG)
Nigeria (NGA)
Germany (GER)
United States (USA)
Belgium (BEL)
Algeria (ALG)

In the knockout stage, after each match the winner gets through to the next round, and the loser goes home (there are no draws). Click here to see more about the knockout stage.

You have been hired by golfbet.com, a new betting website because you are known to be good at both programming and sports betting. Your task is to write a program or function which can guess the winner of a match. Of course, everybody makes different guesses, it doesn't matter as long as your guesses are consistent.

If you don't want to guess, you can use the following guesses:

BRA
        BRA
CHI
                BRA
COL
        COL
URU
                        GER
FRA
        FRA
NGA
                GER
GER
        GER
ALG
                                        GER
NED
        NED
MEX
                NED
CRC
        CRC
GRE
                        ARG
ARG
        ARG
SUI
                ARG
BEL
        BEL
USA

The program has to output the same winner regardless the order of the to teams (the winner of the BRA-CHI match has to be the same as of the CHI-BRA match)
If a team loses, it cannot play any more matches. This means for matches that don't take place, you have to indicate so. For example if your program guesses Brazil to win the BRA-CHI match, then CHI-GER has to return "no result", because Chile won't play against Germany. See the link above for schedule.

For the sake of simplicity you don't have to deal with the bronze match (but you can of course).

Your program or function takes two strings as input: the 3-letter country code of the two teams and returns the country code of the winning team (you can use standard input/output, or two function parameters/return value). If the given two teams will not play according to your guesses, you must return something else (this can be anything but the country codes, eg empty string, null, error message). You can assume the input is correct (two different country codes which are in the list).

This is primarily a code-golf, so shortest program in bytes wins. However, nice and tricky solutions are also valuable.

Example (of course, you can make your own guesses):

input:
BRA
CHI
output:
BRA

input:
CHI
BRA
output:
BRA

input:
CHI
GER
output: no result

Python 2.x  - 368 283

Interesting challenge. Of course we need to get present rankings from the FIFA.
Brazil have the so-called "12th man" as they have home advantage therefore the weighting 12/11.

a='BRA CHI COL URU FRA NGA ALG GER MEX NED CRC GRE ARG SUI BEL USA'.split()
d=[1242*12/11,1026,1137,1147,913,640,858,1300,882,981,762,1064,1175,1149,1074,1035]
m={}
for n in[16,8,4,2]:
 j=0
 for k in range(0,n,2):
  s=a[k] if d[k]>d[k+1] else a[k+1]
  m[a[k]+' '+a[k+1]]=s
  a[j]=s
  j+=1
def f(s):
 try: print m[s]
 except: print 'no result'

Tips to shorten the above are welcome :-).

Improvements thanks to @TheRare and @MrLemon

a='BRA CHI COL URU FRA NGA ALG GER MEX NED CRC GRE ARG SUI BEL USA'.split()
d=15,6,10,11,4,0,2,14,3,5,1,8,13,12,9,7
m={}
for n in 16,8,4,2:
 j=0
 for k in range(0,n,2):s=a[k]if d[k]>d[k+1]else a[k+1];m[a[k]+' '+a[k+1]]=s;a[j]=s;j+=1
def f(s):print s in m and m[s]or'no result'

This leads to the following results:

BRA CHI: BRA
COL URU: URU
FRA NGA: FRA
ALG GER: GER
MEX NED: NED
CRC GRE: GRE
ARG SUI: ARG
BEL USA: BEL
------------
BRA URU: BRA
FRA GER: GER
NED GRE: GRE
ARG BEL: ARG
------------
BRA GER: BRA
GRE ARG: ARG
------------
BRA ARG: BRA

Example calls:

f('BRA MEX')
no result
f('BRA CHI')
BRA


King of the Hill: Robot Battle Your task here is to write an AI for a simple robot battle. The class to be implemented is provided at the bottom of this post, and source of the controller can be found here.

Requirements

Write a class which implements the abstract Bot class, provided at the bottom of this post
You must provide a 0-argument constructor, this must change the value of the Name field, but may not change any other inherited fields
Outside of the constructor, you may not change any of the inherited fields in any way
Your action method should, when called (it will be called once per turn cycle, with a copy of the 64 by 64 map as its argument), return one of the Action enum fields:

UP  to move up (towards y=0)
DOWN to move down
LEFT to move left (towards x=0)
RIGHT to move right
MINE to plant a mine and then move a random direction
PASS to pass

Within the passed map, 0 represents an empty cell, -1 represents a mined cell, and anything else denotes a cell occupied by a bot (each bot will be represented by its unique bot_id, you can get your bot's id by calling this.id())
A bot is eliminated in any of the following situations:

It moves out of the map
It moves into a cell occupied by a mine
Another bot moves into the cell it currently occupies
Its action method takes more than 50ms to respond
Its action method throws any exception that is not caught within its own bounds

To win

Have your bot be the last bot standing!

Additional Rules

The round is not allowed to last more than 1,000 turn cycles. If, after the 1,000th turn cycle, more than one bot is still standing, all of the surviving bots are considered to have tied that round.

Each time a new bot is submitted, it will, as soon as possible, be pitted in two two-bot, three three-bot, and three-four bot rounds; each time against randomly selected opponents.

Scoring

total score=1000*(wins+(1/3) ties - (1/12) losses)/roundsPlayed

The exceptions to this are that any bot that has played at least one round that it didn't lose is guaranteed at least one point, and no bot may have a negative score.

The class to be implemented:

import java.util.*;

public abstract class Bot {
    public static enum Action{
        UP,DOWN,LEFT,RIGHT,MINE,PASS;
    }
    public static final class Position{
        public int x;
        public int y;
        public String toString(){
            return "("+x+","+y+")";
        }
        public double distance(Position p){
            int dx=p.x-this.x;
            int dy=p.y-this.y;
            return Math.sqrt(dx*dx+dy*dy);
        }
        public Position(int x,int y){
            this.x=x;
            this.y=y;
        }
    }
    public String toString(){return name;}
    public Position p;
    public String name="";
    public abstract Action action(int[][] map);
    private int bot_id;
    public final int id(){return bot_id;}
    public final void register(List<Bot> a){
        a.add(this);
        bot_id=a.size();
    }
}

Leaderboard

The full match log may be read here

ProtectiveBot (6 wins, 6 ties, 1 loss)- 609 points
Albert (2 wins, 8 ties, 0 losses)- 467 points
Frozen (1 win, 8 ties, 0 losses)- 407 points
Cocoon (1 win, 3 ties, 3 losses)-250 points
Wanderlust (0 wins, 3 ties, 5 losses)- 73 points
MineThenBoom (0 wins, 2 ties, 11 losses)- 1 point
PatientBot (0 wins, 0 ties, 13 losses)- 0 points

Sample Bots

Simple Pathfinder: http://pastebin.com/raw.php?i=aNBf00VU

RandomBot: http://pastebin.com/raw.php?i=VD8iGaHC

Minelayer: http://pastebin.com/raw.php?i=sMN1zSa0

ProtectiveBot

A bunch of ideas rolled together to form something. There are a number of states that it can enter. Firstly, if there is no-one around them, it will build itself a cocoon which is just about indestructible, and sit in it for a while, killing anyone it can.

If there is someone close during startup, there is less then 200 turns left, or there is only one enemy bot remaining, the bot will enter a aggressive mode, which is essentially an enhanced pathfinder, attempting to trick its opponents. This mode uses a flood style pathfinding system at close range, and the same technique in the provided pathfinding example at long range.

If there are multiple instances of this bot in game, the bots will refrain from killing each other until the end.

Its big as well, weighing in at 527 741 lines. Compiling against Java 8. Also, have a graphic renderer of the battle system: https://github.com/j-selby/RobotBattleController

  I've reached the limit for how big these posts can be, see bot src at
  https://github.com/j-selby/RobotBattleController/blob/master/src/main/java/ProtectiveBot.java.
  Sorry...

Rev 3:

Threaded pathfinding. No more timeouts!
Detection of stalemates. TODO: Do something about them.
Full A* pathfinding. No more dumb stuff.
Checks OTHER bots positions for unfair play (trapping themselves in completely).

Rev 2:

Stopped bot being killed at corners
Smarter building logic
Will never do any move that could endanger us, excluding against other instances of ProtectiveBot.


Post-determined Array Sorting Input:

An array containing three integers: 0, 1 and 2 in any order (i.e. [2, 0, 1])
And a string of length >= 2 only containing alphabetic letters (both lower- and uppercase) and digits (i.e. a1B2c3)

Output:

Based on the array we sort and output the string.
How does this work?

The array indicates the order precedence of a-z, A-Z and 0-9, the first being 0; second being 1; and third being 2.
The individual characters of the string can then be ordered based on that.

Example:

Array: [2, 0, 1]
String: a1B2c3

Based on the array, we know our order precedence is 0-9a-zA-Z.
Based on that, we can convert and output the string: 123acB.

Challenge rules:

For the array you can choose to use 0-indexed or 1-indexed input, so [3, 1, 2] is also a valid input if you prefer to use 1-indexed arrays.
The string (both input and output) only contains valid characters: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
If your language doesn't support arrays (or if you choose to), you are free to use strings instead of arrays for the first parameter (i.e. 012, [0,1,2], etc.).

General rules:

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

Test cases:

[2, 0, 1]  &  a1B2c3             ->   123acB
[2, 1, 0]  &  aAaA909UuHWw9gh2   ->   02999AAHUWaaghuw
[2, 1, 0]  &  6Bx43              ->   346Bx
[1, 0, 2]  &  jfjf33g            ->   ffgjj33
[0, 2, 1]  &  AbC13              ->   b13AC
[1, 2, 0]  &  Qfl0l              ->   Q0fll
[0, 1, 2]  &  9870abcABC         ->   abcABC0789
[0, 2, 1]  &  test123            ->   estt123
[2, 0, 1]  &  WHAT               ->   AHTW
[2, 0, 1]  &  WhAt               ->   htAW
[1, 0, 2]  &  102BACbac          ->   ABCabc012

Python 2, 67 66 bytes

lambda s,k:`sorted(s,key=lambda c:`k.index(3-ord(c)/32)`+c)`[2::5]

Test it on Ideone.


Make a zigzag pattern Your task is to take in one integer input and print a zigzag pattern using slashes and backslashes.

The integer input determines the length of each zig and zag, as well as the number of zigs and zags
The pattern always starts from right to left

Test Cases

4->
   /
  /
 /
/
\
 \
  \
   \
   /
  /
 /
/
\
 \
  \
   \
2->
 /
/
\
 \
0->
1->
/
8->
       /
      /
     /
    /
   /
  /
 /
/
\
 \
  \
   \
    \
     \
      \
       \
       /
      /
     /
    /
   /
  /
 /
/
\
 \
  \
   \
    \
     \
      \
       \
       /
      /
     /
    /
   /
  /
 /
/
\
 \
  \
   \
    \
     \
      \
       \
       /
      /
     /
    /
   /
  /
 /
/
\
 \
  \
   \
    \
     \
      \
       \

Charcoal, 16 10 9 bytes

ＦＮ«↖Ｉθ→‖Ｔ

Try it online! Link is to verbose version of code.


Minimum insertions to make palindrome Today you will be doing another palindrome challenge!

So, your task today is to take a string, and determine the minimum amount of letters required to insert to turn it into a palindrome.

For example, let's take the string fishes.

In this, case the best way would be to add h if, so the result would be 3.

fishe s
     h if
---------
fishehsif

Now let's try with codegolf. Since there is a repeated o, we can just do:

  codeg  o lf
fl     ed c
-------------
flcodegedoclf

to get a result of 5.

Test cases

ppcg -> 2
codegolf -> 5
palindrome -> 9
stackexchange -> 8
programmingpuzzlesandcodegolf -> 20

Python, 112 bytes

d=lambda x,l,h:0if h<l else d(x,l+1,h-1)if x[l]==x[h]else-~min(d(x,l+1,h),d(x,l,h-1));e=lambda x:d(x,0,len(x)-1)

Very inefficient.

Try it online! You have to wait a minute for the last case to finish.

Call with e(<string>, 0, <length of string - 1>), like e("fishes", 0, 5)`.

Ungolfed (sort of) with explanation:

def minInsert(x, l, h):                # Declare func, arugments for x, l, h       # d=lambda x,l,h:
  if l >= h:                           # If l is the same or past h                #                 if h<l
    return 0                           #     then return 0                         #                0
  elif x[l] == x[h]:                   # If first and last character are the same  #                        else             if x[l]==x[h]
    return minInsert(x, l + 1, h - 1)  #     then return the min w/o first & last  #                             d(x,l+1,h-1)
  else:                                # If not, we shave off a character          #                                                      else
    a = minInsert(x, l, h - 1)         #     (last one)                            #                                                                d(x,l+1,h)
    b = minInsert(x, l + 1, h)         #     (first one)                           #                                                                           d(x,l,h-1)
    return min(a, b) + 1               #     and add one for the char we took off  #                                                          -~min(          ,          )


Is string X a subsequence of string Y? Given strings X and Y, determine whether X is a subsequence of Y. The empty string is regarded as a subsequence of every string. (E.g., '' and 'anna' are subsequences of 'banana'.)
Input

X, a possibly-empty case-sensitive alphanumeric string
Y, a possibly-empty case-sensitive alphanumeric string

Output

True or False (or equivalents), correctly indicating whether X is a subsequence of Y.

I/O examples
X      Y        output

''     'z00'    True
'z00'  'z00'    True
'z00'  '00z0'   False
'aa'   'anna'   True
'anna' 'banana' True
'Anna' 'banana' False

Criteria

The shortest program wins, as determined by the number of bytes of source code.

Example programs

Several programs that could be adapted are in this related posting.

Perl 5, 17 bytes (+1?), full program

s//.*/g;$_=<>=~$_

Try it online!
Invoke with the p flag to the perl interpreter, as in perl -pe 's//.*/g;$_=<>=~$_'.  Per the established scoring rules when this challenge was originally posted, this flag costs one extra byte.  Under more recent rules, AFAICT, it may be free.
Either way, the input strings should be supplied on separate newline-terminated lines on stdin.  Output (to stdout) will be 1 if the first input string is a substring of the second, or nothing at all if it's not.
Note that both input lines must have a newline at the end, or the program won't work correctly.  Alternatively, you can add the l command line flag to the invocation to make perl strip the newlines; depending on the scoring rules in effect, this may or may not cost one extra byte. Note that using this flag will also append a newline to the output.
Original version (snippet, 18 bytes / chars)
$x=~s//.*/g,$y=~$x

Input is given in the variables $x and $y, result is the value of the expression (in scalar context).  Note that $x is modified in the process.
(Yes, I know using $_ instead of $x would let me save four chars, but doing that in a snippet that feels a bit too cheesy for me.)
How does it work?
The first part, $x=~s//.*/g, inserts the string .* between each character in $x.  The second part, $y=~$x, treats $x as a regexp and matches $y against it.  In Perl regexps, .* matches zero or more arbitrary characters, while all alphanumeric characters conveniently match themselves.


Validate Loopy Solutions This is an additional challenge to the generate Loopy puzzles challenge. You might want to solve this challenge before attempting the harder challenge in the previous link.

The goal of this challenge is to validate the solution to a loopy puzzle. Please take all documentation on what a loopy puzzle is from the previous link. A solved loopy puzzle is formatted in a very similar way to the output of a valid submission to the “generate loopy puzzles” challenge and may look like this:

+-+-+ +-+ +-+ +
|   | | |2|3|
+-+ + + + + +-+
 2| | | |2|  3|
+ + +-+ + + +-+
 2|  2 1|3| |
+-+ +-+ +-+ +-+
|2  | |    1 2|
+ +-+ +-+ +-+ +
| |2 1 2|3|3| |
+ + +-+ +-+ +-+
| | |3|2   1
+ +-+ +-+-+-+-+
|        2 2  |
+-+-+-+-+-+-+-+

The path that makes up the solution is marked with | and - characters between the + characters.

Input specification

Your program shall receive a loopy puzzle with a solution formatted like the example above as input. Your program shall infer the size of the puzzle from the input. You may make the following assumptions about the input:

The puzzle has no less than 2 and no more than 99 cells in either direction
Thus, each line has a maximum length of 199 characters not including the newline character(s)
Thus, the input contains a maximum of 99 lines
each line may end after the last printable character or may be padded with whitespace characters so it has a length of up to 2·y + 1 characters where y is the number of cells in horizontal direction
each position with both x and y coordinates even contains a + character
positions horizontally or vertically adjacent to positions containing + characters contain either a whitespace character, are behind the end of line or contain a - character if horizontally adjacent or a | character if vertically adjacent
all other positions are either behind the end of line or contain one of the characters , 0, 1, 2, or 3
all lines are terminated with your platforms default newline character(s)
there is exactly one trailing newline

Input shall be received in one of the following ways:

From standard input
As the value of a parameter named p in an HTTP POST request
As the content of an HTML form
As the content of a file named p in an implementation-defined directory
In an implementation defined way at runtime if the former four are not available
Hard coded if your language provides no mean of receiving input

Output specification

Your program shall terminate for all inputs matching the input specification and shall compute whether the solution to the puzzle is correct. Your program shall output the result of the computation as a boolean value in one of the following ways:

As an exit status of either zero (solution is valid) or non-zero (solution is invalid)
As the character y (solution is valid) or n (solution is invalid) followed by zero or more arbitrary characters output in an implementation defined way

The behaviour of your program is unspecified when encountering input not formatted according to the input specification.

Scoring

The score of your program is the number of characters in its source except for omittable whitespace characters and omittable comments. You are encouraged to indent your submission so it's easier to read for the others and to comment your solution so its easier to follow.

Submissions that fail to follow the input or output specification or generate incorrect results are invalid.

C# 803 579bytes

Complete program, reads from STDIN, should cope with any common new-line scheme as long as it has line feeds. Thanks to HackerCow for pointing out that I don't have to append a new line in a different question, prompting me to remove it here and save 4 bytes

Golfed code:

using C=System.Console;class P{static void Main(){var D=C.In.ReadToEnd().Replace("\r","").Split('\n');int w=D[0].Length+2,h=D.Length+1,i=0,j,c,T=0,O=1,o,z,R=0;var B=new int[w,h];var S=new int[w*h*9];for(;i++<w-2;)for(j=0;j<h-2;B[i,j]=c)if((c=(D[j++][i-1]-8)%10)>5){c=5;T++;S[0]=i+j*w;}for(i=0;++i<w-1;)for(j=0;++j<h-1;)R=(i%2+j%2>1&(o=B[i,j-1]%2+B[i-1,j]%2+B[i+1,j]%2+B[i,j+1]%2)>0&o!=2)|((c=B[i,j])<4&c!=o)?7:R;for(o=h=0;o<O;B[i,j]=0)if(B[i=(c=S[o++])%w,j=c/w]>4){h++;S[O++]=(S[O++]=c-w-1)+2;S[O++]=(S[O++]=c+w-1)+2;z=j%2<1?w*2:2;S[O++]=c-z;S[O++]=c+z;}C.Write(h-R<T?"n":"y");}}

The code performs 3 checks, first checking the number of lines around each number and that each junction has 0 or 2 lines leading from it, then that all the lines are joined together.

Formatted code:

using C=System.Console;

class P
{
    static void Main()
    {
        var D=C.In.ReadToEnd().Replace("\r","").Split('\n');
        int w=D[0].Length+2,h=D.Length+1,i=0,j,c,T=0,O=1,o,z,R=0;
        var B=new int[w,h]; // this is the grid
        var S=new int[w*h*9]; // this is a list of joined up lines (stored as x+y*w)

        for(;i++<w-2;)
            for(j=0;j<h-2;B[i,j]=c)
                if((c=(D[j++][i-1]-8)%10)>5)
                { // we are a line
                    c=5;
                    T++; // increment line counter
                    S[0]=i+j*w; // set start of loop
                }

        for(i=0;++i<w-1;) // this loop checks the numbers and that every + has 0 or 2 lines leading from it
            for(j=0;++j<h-1;)
                R=(i%2+j%2>1&(o=B[i,j-1]%2+B[i-1,j]%2+B[i+1,j]%2+B[i,j+1]%2)>0&o!=2)|((c=B[i,j])<4&c!=o)?7:R; // set R to 7 (no significance) if check fails

        for(o=h=0;o<O;B[i,j]=0) // this loops through the list of joined lines adding more until the whole loop has been seen
            if(B[i=(c=S[o++])%w,j=c/w]>4)
            {
                h++; // increment "seen" counter
                S[O++]=(S[O++]=c-w-1)+2;
                S[O++]=(S[O++]=c+w-1)+2;
                z=j%2<1?w*2:2; // special for | and -
                S[O++]=c-z;
                S[O++]=c+z;
            }

        C.Write(h-R<T?"n":"y"); // check if R is greater than 0 or h is less than T and output appropriately
    }
}


Rectangular pseudo-fractal Goal

The program's goal is to draw an ASCII art rectangle repeatedly doubled in size, alternating horizontally and vertically.  Each time the rectangle doubles in size, the extra area is represented by a different character and the previous areas remain unchanged.  The two smallest sections contain one character each and may be in any corner.

The program accepts a single integer as input, defining the number of sections the full rectangle contains.

No other external resources or inputs are allowed.

Sample input and output

10

ABDDFFFFHHHHHHHHJJJJJJJJJJJJJJJJ
CCDDFFFFHHHHHHHHJJJJJJJJJJJJJJJJ
EEEEFFFFHHHHHHHHJJJJJJJJJJJJJJJJ
EEEEFFFFHHHHHHHHJJJJJJJJJJJJJJJJ
GGGGGGGGHHHHHHHHJJJJJJJJJJJJJJJJ
GGGGGGGGHHHHHHHHJJJJJJJJJJJJJJJJ
GGGGGGGGHHHHHHHHJJJJJJJJJJJJJJJJ
GGGGGGGGHHHHHHHHJJJJJJJJJJJJJJJJ
IIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJ
IIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJ
IIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJ
IIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJ
IIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJ
IIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJ
IIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJ
IIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJ

Selection criteria

The shortest code in a week wins the points.

APL, 25 chars/bytes*

{⍉⍣⍵⊃{a,⍺⍴⍨⍴a←⍉⍪⍵}/⌽⍵↑⎕A}

Exploded view

{                   ⍵↑⎕A}   ⍝ take the first ⍵ letters
    ⊃{           }/⌽        ⍝ fold over them, using the first one as initial accum. value
            a←⍉⍪⍵           ⍝    ensure the accum. is a table, transpose it and call it 'a'
        ⍺⍴⍨⍴                ⍝    make a table as large as 'a' filled with the next letter
      a,                    ⍝    append it to the right of 'a' and loop as new accumulator
 ⍉⍣⍵                        ⍝ transpose the result as many times as the original ⍵ number

Examples

      {⍉⍣⍵⊃{a,⍺⍴⍨⍴a←⍉⍪⍵}/⌽⍵↑⎕A}¨⍳8
A AB  AB  ABDD  ABDD  ABDDFFFF  ABDDFFFF  ABDDFFFFHHHHHHHH
      CC  CCDD  CCDD  CCDDFFFF  CCDDFFFF  CCDDFFFFHHHHHHHH
                EEEE  EEEEFFFF  EEEEFFFF  EEEEFFFFHHHHHHHH
                EEEE  EEEEFFFF  EEEEFFFF  EEEEFFFFHHHHHHHH
                                GGGGGGGG  GGGGGGGGHHHHHHHH
                                GGGGGGGG  GGGGGGGGHHHHHHHH
                                GGGGGGGG  GGGGGGGGHHHHHHHH
                                GGGGGGGG  GGGGGGGGHHHHHHHH

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
*: APL can be written in its own (legacy) single-byte charset that maps APL symbols to the upper 128 byte values. Therefore, for the purpose of scoring, a program of N chars that only uses ASCII characters and APL symbols can be considered to be N bytes long.


10, 10, 10... I hope? Preface

As I was shooting an archery 900 round earlier today (10 ends at 6 arrows an end, and 10 ends at 3 arrows an end, for a total of 90 arrows and a maximum score of 900), I thought of this challenge.

In archery (assuming that you are shooting on a FITA supplied target face [the piece of paper that you shoot at]), for each arrow you can claim a maximum score of 10. The target face contains 10 or 11 rings of decreasing diameter, nested inside one another. From the inner ring outward, these are counted from 10 points, to one point (and in the case of 11 rings, there is a secondary innermost ring that counts as 'X', which scores as 10 but is used in tie breaking cases as the higher value). Observe:

Of course, I am referring to the FITA Metric scoring, as seen in the above illustration. If you look closely, you may observe the innermost ring, which is a faded dotted line, whose score is not marked. That is the 'X' that I was referring to, but you will not have to pay heed to that unless competing for the bonus.

Challenge

Create a function (or full program, if the language doesn't support functions), that receives a perfectly square image as input (or image filename, if need be), containing some number of green (HEX #00FF00, RGB(0, 255, 0)) dots of some size, and returns the score. The image may contain data other than the green dots, but the green will always be the exact same shade.

You may imagine that the square image represents the target face, with the outermost ring touching at 4 points (top center, bottom center, right center, left center). The represented target face will always be of the same proportion, with all of the rings having a width of exactly 1/20th of the input target image's width. As an example, given an input image of input dimensions 400px by 400px, you may assume that each ring has an inner width of 20px, as illustrated below:

Clarifications

If touching two seperate rings, the higher of the two rings is counted
You do not have to automatically account for misses or the 'x' case, unless trying for the bonus
You may assume that no green circles are overlapping
You may also assume that no other pixels of that shade of green are in the image
The image will either be in a PNG, JPEG or PPM format (your choice)
External image processing libraries are allowed, if authored before the posting of this question
You may assume that all green circles on one target will have the same diameter
If shooting (hah) for the overlapping circles bonus, you may assume that at least one circle in the image does not have another overlapping
Standard loopholes are disallowed

Test cases

The following two cases should each score 52 (or in the case of bonuses, 52 with 1 'x' and 1 miss):

And this last test case should score 25:

Bonus

-25 bytes if you also return the number of misses (outside any of the rings) as well
-30 bytes if you also return the amount of Xs (assume that the innermost x is 3/100ths of the width of the image, and 10 is then 2/100ths of the width of the image. The 1-9 proportions remain unchanged)
-35% byte count if you account for overlapping circles

This is code golf, so the least bytes wins. Have fun!

Processing 2, 448-25=423 bytes

int x,y,w,b,v,c,m;color g;PImage i;void setup(){i=loadImage("f.png");w=i.width;size(w,w);g=#00ff00;image(i,0,0);b=v=x=y=c=m=0;loadPixels();while(y*w+x<w*w){if(pixels[y*w+x]==g){f(y,x);if(v>=0)c+=v;else m++;}v=-1;x++;if(x==w){x=0;y++;}}println(c+" "+m);}void f(int k,int l){pixels[k*w+l]=color(0);if(pixels[(k+1)*w+l]==g)f(k+1,l);if(pixels[k*w+l+1]==g)f(k,l+1);if(pixels[k*w+l-1]==g)f(k,l-1);k-=w/2;l-=w/2;b=10-(int)(sqrt(k*k+l*l)/(w/20));if(b>v)v=b;}

Reads in an image file f loops through the pixels until it finds green then flood fills the circle determining the point that is closest to the center. Then adds that score to a total.  if the score is negative, it is added to a miss counter.

The program will output 2 numbers, the first is the score and the second is the number of misses.

  int x,y,w,b,v,c,m;
  color g;
  PImage i;
void setup()
{
  i=loadImage("f.png");
  w=i.width;
  size(w,w);
  g=#00ff00;
  image(i,0,0);
  b=v=x=y=c=m=0;
  loadPixels();
  while(y*w+x<w*w)
  {
    if(pixels[y*w+x]==g)
    {
      f(y,x);
      if(v>=0)c+=v;
      else m++;
    }
    v=-1;
    x++;
    if(x==w){x=0;y++;}
  }
  print(c+" "+m);
}

void f(int k,int l)
{
  pixels[k*w+l]=color(0);
 if(pixels[(k+1)*w+l]==g)f(k+1,l);
 if(pixels[k*w+l+1]==g)f(k,l+1);
 if(pixels[k*w+l-1]==g)f(k,l-1);
 k-=w/2;
 l-=w/2;
 b=10-(int)(sqrt(k*k+l*l)/(w/20));
 if(b>v)v=b;
}

you can get processing here


Remove partial matching duplicate lines and retain longest line Write the shortest possible program to remove all partial matched duplicates from a list and only retain the longest lines. Sort order does not matter.
For following inputs, the intent is to search for the string reminder followed by a number and retain the longest unique reminder + number lines.
Some rules

reminder is a hard-coded word, case-sensitive.
All lines contain exactly one match.
There is always a space between reminder and the number.
Only positive, whole numbers are used in the matches (not necessarily a contiguous set).
Lines with same length for the same reminder are possible. It does not matter what line is chosen.
Sort order of output does not matter.

Inputs
A short reminder 1
This is the longest reminder 1 available
This is the longest reminder 2 available, different length
A short reminder 2
A short reminder 3
This is the longest reminder 3 available, another different length
Another short reminder 3
A reminder -1 but really a short reminder 42
This is the longest reminder but really a short reminder 42.

Expected output
This is the longest reminder 1 available
This is the longest reminder 2 available, different length
This is the longest reminder 3 available, another different length
This is the longest reminder but really a short reminder 42.

Shortest code wins

Background: this stackoverflow question

JavaScript (ES6),  85 82  79 bytes

a=>a.sort((a,b)=>-!b[a.length]).filter(s=>a[k=/reminder \d+/.exec(s)]^(a[k]=1))

Try it online!
How?
We first sort all strings from longest to shortest.
a.sort((a, b) =>
  -!b[a.length]  // 0 if 'b' is longer than 'a', -1 otherwise
)

We then filter the strings, keeping only the first occurrence of each reminder N key. The underlying object of the input array a[] is re-used to keep track of the keys that were already encountered.
.filter(s =>
  a[k = /reminder \d+/.exec(s)]
  ^
  (a[k] = 1)
)


PowerShell, 73 bytes

' '*48;46..0|%{" "*$_+-join[char[]](($x=79-$_)..($y=$x+$j++)+(++$y)..$x)}

Try it online!

Outputs the first whitespace-only line, then loops from 46 to 0. Each iteration, outputs the corresponding number of spaces and then a -joined together char-array of the appropriate symbols, via some calculations.


X greater than 3 with at least 2 difference between X and Y I am trying to golf down some C++. Is it possible to make this condition shorter?

X > 3 & X - Y > 1

(Apart from removing whitespace, of course.)

So, X is at least 4 but X >= Y + 2.

X and Y are integers in the [0,5] interval.

I have tried to find some bitwise formula but failed.

After brute forcing every useful combination of symbols under 9 characters, I've found there to be no smaller solution than x>3&x-y>1.

For fun here's some funky 9 character solutions the brute forcer found:

-x<~y>4>x
~y+x>2>>y
x*x-y*y>9
~y>x/~3*x
-3>>y>y-x
~y+x<<y>2

Brute forcing was done in Python, building top-down syntax trees where no child may have an operator with precedence lower than its parent according to C's rules. To cut down on possibilities I only allowed single digit literals, and no binary operator may have two constant children. I could not possibly think of any solution that would have a two digit literal, or one that builds a constant using a binary operator. Then each expression was evaluated for [0, 5] and if it matches it gets printed.


Multiply a string by a number! There was a challenge up a while ago about multiplying strings.  It showed us how we can multiply not only numbers, but also strings.  However, we still can't multiply a number by a string properly.  There has been one attempt to do so but this is obviously wrong.  We need to fix that!

Your Task:

Write a function or program that multiplies two inputs, a string and an integer.  To (properly) multiply an string by an integer, you split the string into characters, repeat each character a number of times equal to the integer, and then stick the characters back together. If the integer is negative, we use its absolute value in the first step, and then reverse the string. If the input is 0, output nothing (anything multiplied by 0 equals nothing).

Input:

A string that consists solely of printable ASCII characters and newlines, and an integer (possible negative).

Output:

The string multiplied by the integer.

Examples:

Hello World!, 3            --> HHHeeellllllooo   WWWooorrrlllddd!!!
foo, 12                    --> ffffffffffffoooooooooooooooooooooooo
String, -3                 --> gggnnniiirrrtttSSS
This is a fun challenge, 0 -->
Hello
World!, 2                  --> HHeelllloo

                               WWoorrlldd!!

Scoring:

This is code-golf, lowest byte count wins!

Jelly, 6 5 4 bytes

²Ɠxm

Try it online!

How it works

²Ɠxm  Main link. Argument: n (integer)

²     Yield n².
 Ɠ    Read and eval one line of input. This yields a string s.
  x   Repeat the characters of s in-place, each one n² times.
   m  Takes each |n|-th character of the result, starting with the first if n > 0,
      the last if n < 0.


The distance between circles Imagine you are given two lists of numbers which are to be interpreted as points on a circle of circumference 1000.  Let us say

circleA = [10, 24, 44, 175, 321, 579, 618, 841, 871, 979]
circleB = [270, 283, 389, 406, 435, 457, 612, 684, 692, 732]

To measure the distance between these two circles we do the following.

For the first point in circleA, starting from the left, we find the next biggest point in circleB.  So 10 finds 270 and is matched up with it.  Now, using 270, we skip to the next biggest point in circle A which is 321.  We then use 321 to find 389 and match up 321 and 389 and repeat until the end of circleA or we can't find a matching pair.

This gives us a list of pairs as follows.

[(10,270), (321, 389), (579,612), (618,684)]

We say the distance between circleA and circleB is just the average difference between pairs. That is (270-10 + 389-321+612-579+684-618)/4 = 106.75

Now comes the tricky part. As the point are on a circle, we can rotate circleB and recompute this distance.  The task is to compute the following value.

  For arbitrary inputs circleA and circleB, the task is to compute the
  average distance between circleA and all rotations of circleB.

In order to make it interesting I am setting this as fastest-code challenge. I will test with increasing size circles created using (in python)

import random
circumference = 1024
numberpoints = circumference/64
circleA = sorted(random.sample(range(circumference),numberpoints))
circleB = sorted(random.sample(range(circumference),numberpoints))

I will just double the size of circumference until the code takes more than 1 minute to run on my computer.  You output should be accurate to machine precision.

Please provide full instructions for how to compile and run your code on a linux machine.

A rotation simply means adding an offset modulo circumference and then resorting.  In python

rotatedcircleB = sorted([(c+offset)%circumference for c in circleB])

My first try at a fatest-code question. Problem is, I didn't try any optimization…

If the rotation part isn't correct, please tell me.

Also, I don't know how to time test the code, so I tried to use timeit module to run 1000 times in order to have a correct timing. I am not sure if I have to do that, or if it is your part :þ

Anyway, here is my code:

import random
circumference = 1024
numberpoints = circumference/64
circleA = sorted(random.sample(range(circumference),numberpoints))
circleB = sorted(random.sample(range(circumference),numberpoints))

####
from  bisect import bisect_left

def find_next(a, x):
    i = bisect_left(a, x)
    if i != len(a):
        return i, a[i]
    raise ValueError

def dist1(cA, cB):
    l = []
    p = cA[0]
    cA = cA[1:]
    while True:
        try:
            (i, n) = find_next(cB, p)
            l.append(n-p)
            cB = cB[(i+1):]
            (i, p) = find_next(cA, n)
            cA = cA[(i+1):]
        except:
            break
    return (sum(l)/len(l))

def rotate(circleB,i):
    return sorted([(c+i)%circumference for c in circleB])

def distAll(circleA, circleB):
    l = [dist1(circleA, rotate(circleB,i)) for i in xrange(circumference)]
    return sum(l)/circumference

if __name__ == '__main__':
    import timeit
    print(timeit.timeit("distAll(circleA,circleB)", setup="from __main__ import *", number=1000))


Subarrays With At Least N Distinct Integers Given a sequence of integers and an integer N, output the number of contiguous subsequences that contain at least N distinct integers. Each integer in the sequence is non-negative and will not be larger than the size of the sequence.

For example, with the sequence 1,2,2,3 and N=2, there are 5 contiguous subsequences that contain at least 2 distinct integers:

1,2
1,2,2
2,2,3
2,3
1,2,2,3

The asymptotic time complexity must be linearithmic in the size of the input sequence. (The time complexity must be at most amortized O(S*logS) where S is the size of the input sequence.)
Testcases:

Sequence
N
Output

1,2,3
2
3

1,2,2,3
2
5

6,1,4,2,4,5
3
9

1,1,2,2,2,3,4,4
4
4

8,6,6,1,10,5,5,1,8,2
5
11

https://pastebin.com/E8Xaej8f (1,000 integers)
55
446308

https://pastebin.com/4aqiD8BL (80,000 integers)
117
3190760620

JavaScript (ES6), 93 bytes
Saved 18 bytes thanks to @user81655
Saved 2 bytes thanks to @tsh
Expects (N)(sequence).

n=>C=a=>eval('for(i=j=a.length,c=s=0;~j;c+=c<n?(C[v=a[--j]]=-~C[v])<2:-!--C[s-=~j,a[--i]])s')

Try it online!


Plant trees in a park - As fast as you can! This challenge is inspired by this app. The test cases are borrowed from that app.

This is a fastest-code challenge, where the objective is to solve the largest test cases in the least amount of time. There are provided some smaller test cases, so that people might test their algorithms faster.

You'll be given a square input grid, of dimensions n-by-n where 9 <= n <= 12. This grid will be divided into n areas, where the cells of each area has a unique identifiers (I'll use lower case letters from a-l in the the text here, but you may choose whatever you like, for instance integers 1-12).

The input may look like this (optional input format):

aabbbbbcc
adddbbbcc
adeeecccc
adddefgcc
hhhdifggg
hdddifffg
hhhiifffg
hihiifffg
iiiiiiggg

Or, easier to visualize:

Challenge:

You are to place 2*n trees in this park, according to the following rules:

There shall be exactly 2 trees per column, and 2 trees per row
All areas shall have exactly 2 trees.
No trees can be adjacent to another tree, vertically, horizontally or diagonally

The solution to the layout above is:

Note: There is only one solution to each puzzle

Additional rules:

The input and output formats are optional

The output might for instance be a list of indices, a grid with 1/0 indicating if there's a tree in that position, or a modified version of the input where the trees are indicated

The execution time must be deterministic
The program must finish withing 1 minute at @isaacg's computer

Specs: 4 CPUs, i5-4300U CPU @ 1.9 GHz, 7.5G of RAM.

In case your program can't solve the two largest test case in one minute each then the time for the second largest (n=11) will be your score. You'll lose against a solution that solves the largest case.

Test cases:

I might edit this list if submissions seems to be customized to fit these test cases.

12-by-12:

--- Input ---
aaaaabccccdd
aaaaabccccdd
aaaaabbbbddd
eeeafffgbghh
eeaafffgbghh
eefffffggghh
eeefijffghhh
iieiijjjjkhh
iiiiijjjjkhk
lljjjjjjjkkk
llllllkkkkkk
llllllkkkkkk
--- Solution ---
aaaaabcccCdD
aaaaaBcCccdd
aAaaabbbbdDd
eeeaffFgBghh
eeAaFffgbghh
eefffffGgGhh
EeefijffghhH
iiEiIjjjjkhh
IiiiijjjjkHk
lljJjJjjjkkk
lLllllkkKkkk
lllLllKkkkkk

11-by-11:

--- Input ---
aaaaaaabbcc
adddabbbbcc
edddbbbbbbc
eddddbbbbbb
effffggghhh
effffgghhii
eefffjjhhii
eeeejjjhhii
eeejjjjkiii
jjjjjjkkiii
jjjjjkkkiii
--- Solution ---
aaAaaaabbCc
adddAbBbbcc
eDddbbbbbbC
eddDdBbbbbb
effffggGhHh
eFfffGghhii
eefFfjjhHii
EeeejjjhhiI
eeEjjjjKiii
JjjjJjkkiii
jjjjjkKkIii

10-by-10

--- Input ---
aaaaabccdd
aeaabbbccd
aeaabfbgcd
eeeaafggcd
eeeaafghcd
eeeiifghcd
ieiiigghcd
iiijighhcd
jjjjighhcd
jjjggghhdd
--- Solution ---
aaAaabccdD
aeaaBbBccd
aEaabfbgcD
eeeaaFgGcd
eEeAafghcd
eeeiiFghCd
IeiIigghcd
iiijigHhCd
JjJjighhcd
jjjgGghHdd

9-by-9

--- Input ---
aabbbbbcc
adddbbbcc
adeeecccc
adddefgcc
hhhdifggg
hdddifffg
hhhiifffg
hihiifffg
iiiiiiggg
--- Solution ---
aAbBbbbcc
adddbbBcC
adEeEcccc
AdddefgCc
hhhDiFggg
hDddifffG
hhhiIfFfg
HiHiifffg
iiiiiIgGg
--- Input ---
aaabbbccc
aaaabbccc
aaaddbcce
ffddddcce
ffffddeee
fgffdheee
fggfhhhee
iggggheee
iiigggggg
--- Solution ---
aaAbBbccc
AaaabbcCc
aaaDdBcce
fFddddcCe
fffFdDeee
fGffdheeE
fggfHhHee
IggggheeE
iiIgggGgg

JavaScript (ES6), 271 bytes

Takes input as an array of arrays of characters. Returns an array of bitmasks (integers) describing the position of the trees on each row, where the least significant bit is the leftmost position.

f=(a,p=0,r=[S=y=0],w=a.length)=>a.some((R,y)=>a.some((_,x)=>r[y]>>x&1&&(o[k=R[x]]=-~o[k])>2),o=[])?0:y<w?[...Array(1<<w)].some((_,n)=>(k=n^(x=n&-n))<=x*2|k&-k^k|n&(p|p/2|p*2)||r.some((A,i)=>r.some((B,j)=>A&B&n&&i<y&j<i))?0:(w=r[y],f(a,r[y++]=n,r),r[--y]=w,S))&&S:S=[...r]

Formatted and commented

f = (                                           // given:
  a,                                            //   - a = input matrix
  p = 0,                                        //   - p = previous bitmask
  r = [                                         //   - r = array of tree bitmasks
        S = y = 0 ],                            //   - S = solution / y = current row
  w = a.length                                  //   - w = width of matrix
) =>                                            //
  a.some((R, y) => a.some((_, x) =>             // if there's at least one area with more
    r[y] >> x & 1 && (o[k = R[x]] = -~o[k]) > 2 // than two trees:
  ), o = []) ?                                  //
    0                                           //   abort right away
  :                                             // else:
    y < w ?                                     //   if we haven't reached the last row:
      [...Array(1 << w)].some((_, n) =>         //     for each possible bitmask n:
        (k = n ^ (x = n & -n)) <= x * 2 |       //       if the bitmask does not consist of
        k & - k ^ k |                           //       exactly two non-consecutive bits,
        n & (p | p / 2 | p * 2) ||              //       or is colliding with the previous
        r.some((A, i) => r.some((B, j) =>       //       bitmask, or generates more than two
          A & B & n && i < y & j < i            //       trees per column:
        )) ?                                    //
          0                                     //         yield 0
        :                                       //       else:
          (                                     //
            w = r[y],                           //         save the previous bitmask
            f(a, r[y++] = n, r),                //         recursive call with the new one
            r[--y] = w,                         //         restore the previous bitmask
            S                                   //         yield S
          )                                     //
      ) && S                                    //     end of some(): return false or S
    :                                           //   else:
      S = [...r]                                //     this is a solution: save a copy in S

Test cases

This snippet includes an additional function to display the results in a more readable format. It is too slow to solve the last test case.

Expected runtime: ~5 seconds.

f=(a,p=0,r=[S=y=0],w=a.length)=>a.some((R,y)=>a.some((_,x)=>r[y]>>x&1&&(o[k=R[x]]=-~o[k])>2),o=[])?0:y<w?[...Array(1<<w)].some((_,n)=>(k=n^(x=n&-n))<=x*2|k&-k^k|n&(p|p/2|p*2)||r.some((A,i)=>r.some((B,j)=>A&B&n&&i<y&j<i))?0:(w=r[y],f(a,r[y++]=n,r),r[--y]=w,S))&&S:S=[...r]

format = (a, w) => a.map(n => [...('0'.repeat(w) + n.toString(2)).slice(-w)].reverse().join('')).join('\n')

console.log(format(f([
  [..."aabbbbbcc"],
  [..."adddbbbcc"],
  [..."adeeecccc"],
  [..."adddefgcc"],
  [..."hhhdifggg"],
  [..."hdddifffg"],
  [..."hhhiifffg"],
  [..."hihiifffg"],
  [..."iiiiiiggg"]
]), 9));

console.log(format(f([
  [..."aaabbbccc"],
  [..."aaaabbccc"],
  [..."aaaddbcce"],
  [..."ffddddcce"],
  [..."ffffddeee"],
  [..."fgffdheee"],
  [..."fggfhhhee"],
  [..."iggggheee"],
  [..."iiigggggg"]
]), 9));

console.log(format(f([
  [..."aaaaabccdd"],
  [..."aeaabbbccd"],
  [..."aeaabfbgcd"],
  [..."eeeaafggcd"],
  [..."eeeaafghcd"],
  [..."eeeiifghcd"],
  [..."ieiiigghcd"],
  [..."iiijighhcd"],
  [..."jjjjighhcd"],
  [..."jjjggghhdd"]
]), 10));


ID generator with no matching contiguous pairs Given 2 inputs (m=minimum starting id, n=number of ids), generate a sequential list of ids, starting at >=m, made up of the digits 0-9 where no 2 contiguous numbers are the same, e.g. 1232 is ok, 1233 is not (contains 2 '3's next to each other).

Example

for m=985, n=6, below shows what ids would be generated/skipped

...
985 - ok, 1st
986 - ok, 2nd
987 - ok, 3rd
# skip 0988 (contains '88')
989 - ok, 4th
# Skip 099x (contains '99')
# Skip 100x (contains '00')
1010 - ok, 5th
# Skip 1011 (contains '11')
1012 - ok, 6th
...

Output

Each ID should be printed on a new line, as for the above sequence:

985
986
987
989
1010
1012

Rules

Standard code-golf rules, lowest byte count wins

Brachylog, 11 10 bytes

{≤ṫẹ~ḅẉ}ᶠ⁾

Input is a list of two numbers.
Try it online!

Explanation

The built-in ḅ takes a list or string, like "1000220", and splits it into blocks of equal adjacent elements, like ["1","000","22","0"].
In this program, I apply the ~ operator to it, so it works in reverse: it takes a list of strings, checks that each string consists of repetitions of a single character and neighboring strings have different characters, and concatenates the list.
The predicate ≤ enumerates numbers starting from the first input in increasing order, and I check a condition on them, printing those that satisfy it and stopping when I've found enough.

{≤ṫẹ~ḅẉ}ᶠ⁾  Input is a pair, say [M=988,N=3].
{      }ᶠ⁾  Apply this predicate to M and compute the first N results.
 ≤          Take a number that is greater than or equal to M (first up is 988).
  ṫ         Convert it to string: "988"
   ẹ        Split it into substrings of length 1: ["9","8","8"]
     ~ḅ     Apply ḅ in reverse: fails, try next number.
       ẉ    If ḅ succeeds, print the resulting string and a newline.
            This counts as a result of the predicate.


Get the most dominant color! In this challenge, your task is to write a program that takes in an image and returns the most dominant color in it. Dominant color here means the color with which most of the image is covered (see the test cases for a better understanding).

Input

An image's path. You'll have to load that image in your program. You can take the input as STDIN, function argument or whatever suits your language. You may assume that the image will have only .png extension.

Output

The most dominant color in any format. (But it should be accurate, you can't return Red for #f88379). The type of output depends on you. If there is an equal distribution of colors in the image or there are more than one dominant color, then your program should return "Equal". You can show the output by printing on screen, logging on command line or console, or whatever suits you.

Test Cases

=> Red/#ff0000/rgba(255,0,0)

.

=> "Equal"

=> White (or the same color in any other format)

In these test cases, I have posted images rather than image paths, but you'll be given image paths only as input.

Note If your language contains a built-in for this, then you must NOT use it. Please add a screenshot or a link to a screenshot to prove that your program works.

This is code-golf, so the shortest answer in bytes wins!

Pyth, 18 bytes

FGITW.

?tJeM.MhZrS'Q8\=hJ

This is how it would theoretically work offline.

This is a proof that it works.

The two links differ by whether there is a "read file command" ' (single-quote).