Conway's game of life Description :

Given an array of strings representing a grid of cells

With the key :

0 = 'dead cell'
1 = 'live cell'

write a function that returns the next iteration following the rules of Conway's Game of Life .

Rules

Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
Any live cell with two or three live neighbours lives on to the next generation.
Any live cell with more than three live neighbours dies, as if by overpopulation.
Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

Examples :

["111" , "110" , "100"] //input
["101" , "001" , "110"] // output
/**
  * There will be other tests so no hardcoding.
**/

This is code golf shortest code wins. Good luck and have fun

Jelly,  40  38 bytes

z0j@€0,0µ⁺ṡ3Z€ṡ€3S€€⁺Ḥ
L€ḣ@"Ç+e€€7,9,6

A monadic link accepting and returning lists of lists of ones and zeros

Try it online!

How?

Cells will be alive in the next generation if:

it was alive in a neighbourhood (including itself) of three or four
it was dead in a neighbourhood of exactly three

Therefore if double the neighbourhood plus "was alive" is seven or nine (case 1) or six (case 2) then it will be alive next generation.

(For all other possible cases the sum of double the neighbourhood and "was alive" are other integers in the range [0,19])

z0j@€0,0µ⁺ṡ3Z€ṡ€3S€€⁺Ḥ - Link 1, neighbourhood counts * 2: board
        µ⁺             - perform this monadic link twice:
z0                     -   transpose with filler zero
     0,0               -   list [0,0]
  j@€                  -   join €ach with swapped arguments (surround each with zeros)
          ṡ3           - all overlapping sub-lists of length three (i.e. lists of rows)
            Z€         - transpose €ach
              ṡ€3      - all overlapping sub-lists of €ach of length three (i.e. 3x3 neighbourhoods)
                 S€€⁺  - repeated sum for €ach for €ach (neighbourhood sum)
                     Ḥ - double
                       - Note: the result includes counts of off-board areas filling right

L€ḣ@"Ç+e€€7,9,6 - Main link: board
     Ç          - call the last link (1) as a monad (get 2 * neighbourhood counts)
L€              - length of each row of the input board
  ḣ@"           - zip with head to index with swapped arguments
                - (i.e trim the neighbourhood counts to the shape of the input board)
      +         - add (vectorises) (i.e. 2 * neighbourhood count + was alive)
          7,9,6 - list = [7,9,6]
       e€€      - exists in? for €ach for €ach


Holy Hole In A Donut, Batman! Some characters are more holy than others. Using as few unholy letters as possible, display the statement above.

Challenge

Write a full program to print Holy Hole In A Donut, Batman! to STDOUT or closest alternative. If you can compress the input to reduce your score, go wild :)

Input

None

Output

Holy Hole In A Donut, Batman!

Rules

This is a code-challenge, and lowest score wins
The desired output can be read from a file, but that should then be counted towards your total.
Trailing newlines are fine in the output
Standard loopholes and T&C's apply

Scoring

Your score is your byte count, plus some modifiers:

Using holy characters 0469abdegopqrADOPQR@# count as 2 points each
Using extra holy characters 8B%$& are 1 point (no penalty)
Using unholy characters 12357cfhijklmnstuvwxyzCEFGHIJKLMNSTUVWXYZ!"^*()[]{}-=_+|\/?,.<>:;'~ carries a heavier penalty and count as 10 points per character.
Space, tab and newlines are 1 point (no penalty).
Any other characters not listed are 10 points.

*On my keyboard the key '$' and '&' are extra holy. Where font variations cause a character to become unholy, defer to the list above

The unmodified string Holy Hole In A Donut, Batman! scores 172
Ruby: puts "Holy Hole In A Donut, Batman!" scores 225

Score checker

@DeadChex has kindly put together a scoring script

Please do let me know if I need to clarify anything. I will update the list of characters if necessary - I've only included the obvious keys at this point. The idea is simple enough though - holes in characters are good.


I can give question number 1. a go:

++++++++++

The first series of +'s defines first memory cell (cell0) to be a loop counter to 10.

[>+++++++>++++++++++>+++>+<<<<-]

Above is the loop that executes 10 times. The loop adds 7 to cell1, 10 to cell2, 3 to cell3 and 1 to cell4 for each iteration. After 10 iterations we have the following in the first 5 memory cells: 0, 70, 100, 21, 10

>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

Above is kind of self explanatory, it just moves the memory pointer to the value that is closest to what is needed, does some minor inc's and dec's and outputs.


Bedevil your hangman opponent Task
You are playing Hangman, and your opponent uses a simple but effective strategy: Each turn, from the remaining letters, they guess the letter that appears most frequently across all possible words.  When multiple letters appear with the same maximum frequency, your opponent selects randomly among them.
That is, your opponent knows which dictionary (list of words) you've chosen your word from, and has computed a table showing how many times each letter of the alphabet appears in this dictionary.  Your opponent always chooses letters with higher frequency counts before letters with lower frequency counts.
Your goal is to write a program that will select a word that maximizes their average number of guesses.
This is code golf.
Input / Output
The input will be a list of words in any convenient format, per standard site IO rules (comma delimited string, array, lines of a file, etc).
The output will be a single word from that list that maximizes your opponent's average number of guesses.  If there is more than one such word, you may return any one of them.
Worked Example
If the input word list is:
one
wont
tee

The letter frequency table will be:
┌─┬─┬─┬─┬─┐
│e│t│o│n│w│
├─┼─┼─┼─┼─┤
│3│2│2│2│1│
└─┴─┴─┴─┴─┘

Your opponent will always guess e first, since it occurs most frequently.  Their second, third, and fourth guesses will be split randomly among the letters t, o, and n, and  w will always be guessed last.
Thus the word wont will always be completed last, on the 5th guess, and is the sole correct answer for this word list.
Notes

Words will contain only the 26 letters a through z.
If you want, you can use the uppercase alphabet instead.
When there is more than one correct answer, you may return any of them.  If you want, you can return all of them, but this is not required.

Test Cases
Each test case consists of two lines:

An input word list of space-separated words.
The expected output.  This will be a single word when there is only one correct answer, and a space-separated list when there is more than one.  Note that your program only needs to return one correct answer when there are multiple correct answers.

one wont tee
wont

aaa bbb ccc
aaa bbb ccc

oneword
oneword

thee lee
thee

tee lee
tee lee

three eon one holt
three holt

xeon threes eon one holt
threes

xeon threes eon one holt apple mango george any fine
fine

Python 2, 60 bytes

lambda l:min(l,key=lambda x:sorted(map(`l`.count,set(x)))+l)

Try it online!
Explanation
The idea is much like every other answer. In every word, we compute the frequency of each character. Then we take the word whose least frequent character occurs most often.
In the code, we sort the array as opposed to finding the minimum. Here is an example to show how this works: Input: thee lee baa. For each word, we compute a frequency table (duplicates are ignored): [(1, 1, 4), (1, 4), (1, 2)]. After sorting, the lexiocgraphically smallest list is (1, 1, 4), therefore the answer is thee.
There is also an edge case to consider: Input: a bc, which gives the following frequency table: [(1), (1, 1)]. The lexicographically smallest list would be (1), which is incorrect since the second list contains more 1s. I'll leave out the specifics of how the code resolves this issue


Print the prime factorization of the greatest common divisor of two numbers Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form.
Input
Command line args or 1 line of stdin okay, whatever's better for golf.
Output
Single space delimited with exponents (no additional spaces). Output nothing if the inputs are relatively prime.
Examples:
$ ./factorize 96 162
2^1 3^1

$ ./factorize 14 15

$ ./factorize 196 294
2^1 7^2

Rules

You may not use external resources, math libraries or built-in functions for factorization or GCD. Examples: Java, no java.lang.Math. ruby, no prime_division, perl, no factor, etc.

Python 3, 255 250  237 226 188 180 150 142 137 136 chars
a,b=map(int,input().split())
t,g='',1
while g<a:
 g,p=g+1,0
 if a%g+b%g<1:
  while a%g+b%g<1:a/=g;b/=g;p+=1
  t+='%d^%d '%(g,p)
print(t)

It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.


Generate excel column name from index This one comes from a real life problem. We solved it, of course, but it keeps feeling like it could have be done better, that it's too lengthy and roundabout solution. However none of my colleagues can think of a more succinct way of writing it. Hence I present it as code-golf.

The goal is to convert a nonnegative integer into a string the same way Excel presents its column headers. Thus:

0 -> A
1 -> B
...
25 -> Z
26 -> AA
27 -> AB
...
51 -> AZ
52 -> BA
...
16,383 -> XFD

It has to work at least up to 16,383, but beyond is acceptable too (no bonus points though). I'm looking forward most to the C# solution, but, as per traditions of code-golf, any real programming language is welcome.

Excel Formula:), 36 chars

=SUBSTITUTE(ADDRESS(1,A1,4),"1","")

Usage:

Sorry, couldn't resist ...


Tips for golfing in Clojure What are your tips for code golfing using Clojure?

The aim of this question is to collect a list of techniques that are specific to Clojure and can be used in general code-golfing problems.

Use reader syntax for lambdas.
So use

#(+ % %2 %3)

instead of

(fn [x y z] (+ x y z))

You can also eliminate whitespace some of the time:

#(if (< % 0) (- %) %)
#(if(< % 0)(- %)%)


Finding My Favorite Times I really like times that follow certain patterns. In particular, I like times where all the digits are the same, or all of the digits increase arithmetically by one from left to right. Further, I viscerally hate when people put letters in my times, so all of that AM/PM nonsense is dead to me. Thus, my favorite times are:

0000 0123 1111 1234 2222 2345

For my peace of mind, I need you to write me a single program that, given the current time as input, both: (A) if it is not now one of my favorite times, tells me both (i) how many minutes it's been since my last favorite time as well as (ii) how many minutes from now my next favorite time will occur; and (B) if it is now one of my favorite times, supplies a single 'signal value'.

Input

Your program should accept (by whatever method: function argument, stdin, command line argument, etc.) the current time, in any of the following formats:

A four-digit time as a string
An integer that can be zero-padded on the left to make a four-digit time as a string
A sequence of four (or fewer) integers, ordered such that the first integer in the sequence is the leftmost (significant) digit in the time input (e.g., 0951 could be validly represented as [0, 9, 5, 1] or [9, 5, 1])

Representing 0000 as a zero-length sequence is acceptable

In the case of a string input, it should only contain digits, no colons or other punctuation.  Inputs can be assumed to always be valid 24-hour times: HHMM, where 0 <= HH <= 23 and 0 <= MM <= 59. Disregard the possibility of a leap second.

Output

Your program must supply (function returns, stdout, etc. are all fine) either (A) or (B), as appropriate to whether or not the input value is a target time.

For (A):

Supply two numeric values in any sensible format, such as:

Single-string output with a suitable delimiter
Sequential integer/string outputs, e.g., bash printing two lines to stdout:

49
34

Length-two ordered return values, such as a Python list, a C array, etc.: [49, 34]

The values can come in either order. For example, both of the following would be valid outputs for an input of 1200:

49 34
34 49

The order and separator must be the same for all input values, however!

For (B):

Produce any otherwise unattainable result. The same result must be produced for all six of the target times, however. Infinite loops are excluded.

Sample Inputs/Outputs

YAY!!! is used here as a demonstrative example and is not prescriptive.

Input      Output
------    --------
 0000      YAY!!!
 0020      20 63
 0105      65 18
 0122      82 1
 0123      YAY!!!
 0124      1 587
 0852      449 139
 1111      YAY!!!
 1113      2 81
 1200      49 34
 1234      YAY!!!
 1357      83 505
 1759      325 263
 1800      326 262
 1801      327 261
 2222      YAY!!!
 2244      22 61
 2345      YAY!!!
 2351      6 9

This is code-golf, so shortest code in bytes wins. Standard loopholes are disallowed.

JavaScript (ES6), 87 83 bytes

Saved 4 bytes thanks to @l4m2

Takes input as a string. Returns either 0 or a 2-element array.

t=>[i=0,83,588,83,588,83,15].every(d=>(k=t-(t/25>>2)*40)>(j=i,i+=d))|i-k&&[k-j,i-k]

Test cases

let f =

t=>[i=0,83,588,83,588,83,15].every(d=>(k=t-(t/25>>2)*40)>(j=i,i+=d))|i-k&&[k-j,i-k]

console.log(f('0000')) // YAY!!!
console.log(f('0020')) // 20 63
console.log(f('0105')) // 65 18
console.log(f('0122')) // 82 1
console.log(f('0123')) // YAY!!!
console.log(f('0124')) // 1 587
console.log(f('0852')) // 449 139
console.log(f('1111')) // YAY!!!
console.log(f('1113')) // 2 81
console.log(f('1200')) // 49 34
console.log(f('1234')) // YAY!!!
console.log(f('1357')) // 83 505
console.log(f('1759')) // 325 263
console.log(f('1800')) // 326 262
console.log(f('1801')) // 327 261
console.log(f('2222')) // YAY!!!
console.log(f('2244')) // 22 61
console.log(f('2345')) // YAY!!!
console.log(f('2351')) // 6 9

How?

We do not care about the result of the .every() loop. Provided that the input is valid, it will always be falsy. What we're really interested in is when we exit this loop.

We exit as soon as we find a favorite time i (expressed in minutes) which is greater than or equal to the reference time k (the input time t converted in minutes). We then return 0 if i == k or the 2 delays otherwise.


Is a number divisible by each of its digits? My friend and I were working on a lab in our AP Computer Science class and decided to code golf one one the problems since we still had half the class free after we finished. Here is the question:

  Given a number n, is n divisible by each of its digits?

For example, 128 will pass this test- it is divisible by 1,2, and 8. Any numbers with a zero automatically disqualify the number. While you may use other languages and post solutions with them if you like, we are most interested in seeing how compact people can make the program in Java, as that is the language we use in the class. So far, we both have 51. Here is my current code:

public boolean dividesSelf(int n){for(int p=n;n%10>0;)n/=p%(n%10)>0?.1:10;return n<1;}
// 51 characters

// Breakdown:
// for(int p=n;         Saves one semicolon to put declaration into for loop
// n%10>0;)             Basic check-for-zero
// n/=                  Pretty simple, discarding one number off of n at a time
// p%(n%10)>0?          If p (the given value) is not divisible by n%10 (the current digit)...
// .1:10;               Divide by .1 (multiply by 10) so it fails the check next iteration. If it is divisible, divide by 10 to truncate the last digit
// return n<1           If the number was fully divisible, every digit would be truncated, and n would be 0. Else, there would still be non-zero digits.

Requirements

The method signature can be whatever you want. Just count the function body. Make sure, though, that the method returns a boolean value and only passes in one numeric parameter (not a string).

The code must be able to pass all of these cases (in order to stay true to the directions of the original question, only boolean true and false values count if the language supports booleans. If and only if your language does not have boolean variables you may represent false with 0 and true with any nonzero integer (preferably 1 or -1):

128 -> true
 12 -> true
120 -> false
122 -> true
 13 -> false
 32 -> false
 22 -> true
 42 -> false
212 -> true
213 -> false
162 -> true
204 -> false

Also, we didn't count whitespace, so feel free to do the same, unless the whitespace is essential to the working of the program (so newlines in Java don't count, but a single space between int and x=1 does count.)
Good luck!

Perl 6, 13

sub golf($_) {
   $_%%.comb.all
}

Uses the implicit variable $_ — $_ %% .comb.all is equivalent to $_ %% all($_.comb). %% is the "is divisible" operator, and comb with no additional argument returns a list of the characters in a string. As an example, if the argument is 123, then the function evaluates

123 %% all(123.comb)

which is

123 %% all(1, 2, 3)

junction autothreading makes it

all(123 %% 1, 123 %% 2, 123 %% 3)

which is

all(True, False, True)

which is false in boolean context because it's an "all" junction and clearly not all of its elements are true.

It should be possible to coerce the return value to Bool and hide the junction-ness from callers by making the function signature sub golf($_ --> Bool()), but coercions in function signatures don't work yet in Rakudo. The return value is still correctly true or false, it's just not True or False.


Identify the Eeveelutions Gah! It's a shame that Pokémon Sword and Shield won't introduce a new eeveelution. Let's mourn them with a code golf.

The objective is to, when given a type name as the input, output the name of the corresponding eeveelution.

When given Water, output Vaporeon.
When given Electric, output Jolteon.
When given Fire, output Flareon.
When given Psychic, output Espeon.
When given Dark, output Umbreon.
When given Grass, output Leafeon.
When given Ice, output Glaceon.
When given Fairy, output Sylveon.
All other input falls in don't care situation.

No other rules. Enjoy!

Python 2, 77 76 bytes

lambda s:'VFULJSGEalmeoylspaballaporrftvc'[hash(s)%3695%8::8]+'reon'[s<'V':]

Try it online!

In Python 2, the hash function consistently (across runs and also on different platforms) converts any immutable value into a 64-bit integer. By taking that integer first mod 3695, then mod 8, we get an integer 0<=i<8 (3695 was found by brute force checking all possible values upto 10000).

A common trick is used to encode a list of same-size strings into a single string and then using slicing via [i::8]to extract the strings without using .split or similar strategy. Only two options are not of length 4: Esp and Vapor. The former is handled by making it the last of the 8 strings encoded; and Vapor is handled using the final slicing 'reon'[s<'V':].


Compress data with context free grammars It is possible to compress some kinds of data, such as human text or source code, with straight-line grammars. You basically create a grammar whose language has exactly one word – the uncompressed data. In this task, you have to write a program that implements this method of data compession.

Input

The input is a string of not more than 65535 bytes length. It is guaranteed, that the input matches the regular expression [!-~]+ (i.e. at least one printable ASCII character excluding whitespace).

An example input is

  abcabcbcbcabcacacabcabab

Output

The output is a set of rules that form a grammar that describes exactly one word (the input). Each nonterminal is denoted by a decimal number greater than 9. The start symbol is symbol number ten. An example output corresponding to the example input is given below; its syntax is described further below:

10=11 11 12 12 11 13 13 11 14 14
11=a 12
12=b c
13=a c
14=a b

Each rule has the form <nonterminal>=<symbol> <symbol> ... with an arbitrary whitespace-separated number of symbols on the right side. Each output that obeys the following restrictions and derives exactly the input string is valid.

Restrictions

In order to stop people from doing strange things, a number of restrictions are taking place:

Each nonterminal must appear at least twice on the right side of a rule. For instance, the following grammar for the input abcabc is illegal because rule 12 appears only once:

10=12
11=a b c
12=11 11

No sequence of two adjacent symbols may appear more than once in all right-hand sides of all rules, except if they overlap. For instance, the following grammar for the input abcabcbc is illegal since the sequence bc appears twice:

10=11 11 b c
11=a b c

A valid grammar would be:

10=11 11 12
11=a 12
12=b c

Your program must terminate in less than one minute for each valid input that is not longer than 65535 bytes.
As usual, you may not use any facility of your language or any library function that makes the solution trivial or implements a large part of it.

Sample input

Generate sample input with the following C program.

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char **argv) {
  unsigned int i,j = 0,k;

  if (argc != 3
     || 2 != sscanf(argv[1],"%u",&i)
      + sscanf(argv[2],"%u",&k)) {
    fprintf(stderr,"Usage: %s seed length\n",argv[0]);
    return EXIT_FAILURE;
  }

  srand(i);

  while(j < k) {
    i = rand() & 0x7f;
    if (i > 34 && i != 127) j++, putchar(i);
  }

  return EXIT_SUCCESS;
}

The sample input generated by the program above will usually not result in good compression results. Consider using human text or source code as example input.

Winning criteria

This is code golf; the program with the shortest source code wins. For extra credit, write a program that reconstructs the input from the output.

GolfScript, 111 108 characters
1/{.}{:^1<{^1$/,2>.{;,)^<.0?)!}*}do-1<.,1>{^1$/[10):10]*0+\+}{;^}if(\}while][0]%.,,]zip{))9+`"="+\~" "*+}%n*

This is a quite clumsy approach using GolfScript. The second version performs much better than the initial one. It is much longer than the intended code but my implementation had nested do-loops and this caused issues with the interpreter.
Examples:
> abcba
10=a b c b a

> abcabcbc
10=11 11 12
11=a 12
12=b c

> abcabcbcbcabcacacabcabab
10=11 12 12 13 14 14 c 11 15
11=15 13
12=c b
13=14 b
14=c a
15=a b


Roots of Arbitrary Numbers One day, when I was bored in maths class, I learned of a neat trick for solving the real cube root of a number!

Let's use the number \$79,507\$ as an example.

First, take digit in the one's place and compare it to this table:

\begin{array} {|r|r|}
\hline
\text{Extracted Digit} &\text{Resulting Digit} \\
\hline
\text{1} &\text{1} \\
\text{2} &\text{8} \\
\text{3} &\text{7} \\
\text{4} &\text{4} \\
\text{5} &\text{5} \\
\text{6} &\text{6} \\
\text{7} &\text{3} \\
\text{8} &\text{2} \\
\text{9} &\text{9} \\
\text{0} &\text{0} \\
\hline
\end{array}

In this example, the Resulting Digit will be \$3\$ since the extracted digit is \$7\$.

Next, remove all digits that are less than \$10^3\$:

$$ 79507 → 79 $$

Then, find the largest perfect cube that does not exceed the input:

$$ 64 < 79 $$

\$64=4^3\$, thus the next digit needed is \$4\$.

Finally, multiply the digit found in the previous step by \$10\$ and add the Resulting Digit found in the first step:

$$ 10*4+3=43 $$

Thus, the cube root of \$79,507\$ equals \$43\$.

However, there a neat quirk about this trick: it doesn't apply to only cubed numbers.  In fact, it works with all \$n>1\$ where \$n\bmod2\ne0\$.

The steps mentioned above can be summed up in this generalization for an \$n\$ power:

Step 1) Take the digit in the one's place in the input.  Compare it to the one's place digit of the \$n\$th powers of \$1\$ to \$10\$, then use the corresponding digit.
Step 2) Remove all digits of the input less than \$10^n\$.  Compare the resulting number to the perfect powers definied in Step 1.  Use the \$n\$th root of the largest perfect power less than said number.  (Largest perfect power can exceed \$10^n\$)
Step 3) Multiply the number from Step 2 by 10 then add the number from Step 1.  This will be the final result.

Task

Given two positive integers \$n\$ and \$m\$, return the \$n\$th root of \$m\$.

Input:

Two positive integers \$n\$ and \$m\$.
\$m\$ is guaranteed to be a perfect \$n\$th power of an integer.
\$n\$ is guaranteed to be odd and greater than \$2\$.  (This method doesn't work if \$n\$ is even.)

Output:

The values calculated in steps 1 and 2.
The \$n\$th root of \$m\$.
Output can be on multiples lines or a list, whichever is more convenient.

Rules:

This is code-golf, so the fewer bytes, the better!
Standard I/O rules apply.
The output must be calculated using the aforementioned method.
No builtins allowed that already calculate this.  A prime example being TI-BASIC's x√ command.

Examples:

Input      | Output
-------------------
3, 79507   | 3
           | 4
           | 43
3, 79507   | [3, 4, 43]
5, 4084101 | 1
           | 2
           | 21
5, 4084101 | [1, 2, 21]

05AB1E, 18 bytes

Saved 1 byte thanks to Kevin Cruijssen

mθ=²¹°÷DÝ¹m@O<=ìï=

Try it online!


Floating over the integers As you may know, the typical binary floating point numbers in a computer language are quite different than the typical integer numbers in a computer language. Floating point numbers can represent a much larger range, and can represent fractional amounts, however there is a trade-off that is frequently elided.

The distance between integers is constant, and in fact the value of that constant is one. The distance between floating point numbers, however, is variable, and increases the further one travels down the number line, away from the origin at 0. At some point, that distance is so large that the floating point numbers start skipping over integers, and many integers that are technically less than the maximum value of the floating point numbers, cannot actually be represented by floating point numbers.

The challenge:

Write a program that when given the number n, will print out the first n positive integers that cannot be represented by a floating point number in your language of choice.

"First n positive integers" means, lowest in value, closest to the origin, and distinct from each other.
Infinite precision floating point numbers are not allowed.
It doesn't matter whether you choose 32 bit floats, 64 bits floats, or some other type of float, as long as it is a non-infinite precision floating point number in your language of choice, on your machine of choice.
Order of numbers does not matter
This is Code Goﬂ. Smallest number of characters wins.
Good luck and have fun

Example:

In Rust, using 32 bit floating point builtin type 'f32':

n=4, result = [16777217,16777219,16777221,16777223]

(updated - 1 order doesnt matter - 2 Golf->Goﬂ)

Perl 6, 28 characters

{grep({.Num+|0-$_},^∞)[^$_]}

Try it online!

This is actually 30 bytes, but the challenge is scored in characters.

This should work theoretically. This creates a lazy list of numbers that compares the default number type (with arbitrary precision) against the same number converted to a Num datatype, which is a 64-bit floating point number, and returns the first \$n\$ elements of the list

Here's a version starting at \$2^{53}-5\$


BIU numbers (or Sumdivized numbers) How to spot them
Take a positive integer k. Find its divisors. Find the distinct prime factors of each divisor. Sum all these factors together. If this number (sum) is a divisor of k (if the sum divides k) then, this number k, is a BIU number
Examples
Let's take the number 54
Find all the divisors: [1, 2, 3, 6, 9, 18, 27, 54]
Find the distinct prime factors of each divisor
NOTE: For the case of 1 we take as distinct prime factor 1
1  -> 1
2  -> 2
3  -> 3
6  -> 2,3
9  -> 3
18 -> 2,3
27 -> 3
54 -> 2,3

Now we take the sum of all these prime factors
1+2+3+2+3+3+2+3+3+2+3=27
27 divides 54 (leaves no remainder)
So, 54 is a BIU number.
Another (quick) example for k=55
Divisors: [1,5,11,55]
Sum of distinct prime factors: 1+5+11+5+11=33
33 is NOT a divisor of 55, that's why 55 is NOT a BIU number.
BIU numbers
Here are the first 20 of them:

1,21,54,290,735,1428,1485,1652,2262,2376,2580,2838,2862,3003,3875,4221,4745, 5525,6750,7050...

but this list goes on and there are many BIU numbers that are waiting to be descovered by you!
The Challenge
Given an integer n>0 as input, output the nth BIU number
Test Cases
Input->Output
1->1
2->21
42->23595
100->118300
200->415777
300->800175

This is codegolf.Shortest answer in bytes wins!

Jelly, 16 15 bytes

ÆDÆfQ€SS‘ḍ
1Ç#Ṫ

Try it online!

Woohoo for builtins (but they mysteriously hide from me sometimes so -1 byte thanks to @HyperNeutrino)

How it Works

ÆDÆfQ€SS‘ḍ - define helper function: is input a BIU number?
ÆD             - divisors
  Æf           - list of prime factors
    Q€         - now distinct prime factors
      SS       - sum, then sum again ('' counts as 0)
        ‘      - add one (to account for '')
         ḍ     - does this divide the input?

1Ç#Ṫ - main link, input n
  #     - starting at
1          - 1
        - get the first n integers which meet:
 Ç         - helper link
   Ṫ    - tail


Create your own Red and Black In the musical rendition of Les Miserables, a song appears called "Red and Black." Here is part of that song:

Red - the blood of angry men!
Black - the dark of ages past!
Red - a world about to dawn!
Black - the night that ends at last!

Source.
Your task is to turn input into a resounding "Red and Black" anthem.
Input
Text delimited by newlines, or a similar suitable text input. For example,
The blood of angry men!
The dark of ages past!
A world about to dawn!
The night that ends at last!

Empty input is undefined (out of scope).
Output
If the length (number of lines, or length of input array, or similar) of the input is odd, either output nothing or output falsey. Your submission may not output errors or attempt to output the correct output.
Otherwise, turn the input into a Red/Black lyric. Turn any uppercase letters at the start of a line to lowercase. Add Red plus a delimiter to the front of odd lines, and Black plus a (visible) delimiter to the front of even lines. The delimiter must also be surrounded in spaces, so the output looks uncrowded (and ungolfed ;) ).
You now have your output.
Test Cases
Output delimiter is -.
In:
The blood of angry men!
The dark of ages past!
A world about to dawn!
The night that ends at last!

Out:
Red - the blood of angry men!
Black - the dark of ages past!
Red - a world about to dawn!
Black - the night that ends at last!

In:
test test
1
[][][]
BBB

Out:
Red - test test
Black - 1
Red - [][][]
Black - bBB

In:
I feel my soul on fire!
The color of desire!
The color of despair!
Out:
falsey OR nothing

In:
Red - I feel my soul on fire!
Black - My world if she's not there!

Out:
Red - red - I feel my soul on fire!
Black - black - My world if she's not there!

V, 31, 30 bytes

êuòIRed -
IBlack -
òñFRdH

Try it online!

Hexdump:

00000000: 16ea 75f2 4952 6564 202d 201b 0a49 426c  ..u.IRed - ..IBl
00000010: 6163 6b20 2d20 1b0a f2f1 4652 6448       ack - ....FRdH

This is trivial in V, but the edge case of odd inputs makes it tricky because V doesn't really have conditionals. Thankfully, we can handle this at the relatively small cost of +6 bytes.


Tips for golfing in x86/x64 machine code I noticed that there's no such question, so here it is:
Do you have general tips for golfing in x86/x64 machine code? If the tip only applies to a certain environment or calling convention, please specify that in your answer.

Please only one tip per answer (see here).

mov-immediate is expensive for constants

This might be obvious, but I'll still put it here. In general it pays off to think about the bit-level representation of a number when you need to initialize a value.

Initializing eax with 0:

b8 00 00 00 00          mov    $0x0,%eax

should be shortened (for performance as well as code-size) to

31 c0                   xor    %eax,%eax

Initializing eax with -1:

b8 ff ff ff ff          mov    $-1,%eax

can be shortened to

31 c0                   xor    %eax,%eax
48                      dec    %eax

or

83 c8 ff                or     $-1,%eax

Or more generally, any 8-bit sign-extended value can be created in 3 bytes with push -12 (2 bytes) / pop %eax (1 byte).  This even works for 64-bit registers with no extra REX prefix; push/pop default operand-size = 64.

6a f3                   pushq  $0xfffffffffffffff3
5d                      pop    %rbp

Or given a known constant in a register, you can create another nearby constant using lea 123(%eax), %ecx (3 bytes).  This is handy if you need a zeroed register and a constant; xor-zero (2 bytes) + lea-disp8 (3 bytes).

31 c0                   xor    %eax,%eax
8d 48 0c                lea    0xc(%eax),%ecx

See also Set all bits in CPU register to 1 efficiently


Turn a string into a windmill The code on this site is rapidly being depleted. We need to invest in renewable strings. So you must write a program that takes a string and converts it into a windmill.
The Challenge
Let's take a simple wind-mill string as an example. Take the string abc. The pivot is the center character, in this case b. Since the string is 3 chars long, every output will be exactly three lines tall and three characters wide. Here is your output on step 1. (Note the whitespace)

abc

To get the next step, rotate each character around the pivot clockwise. Here is step 2:

a
 b
  c

Here are steps 3-8:

 a
 b
 c

  a
 b
c

cba

c
 b
  a

 c
 b
 a

  c
 b
a

And on the ninth step, it comes around full circle to the original string:

abc

Note that the b stayed in the same spot the whole time. This is because b is the pivot character. You must write a program or function that takes a string as input and repeatedly prints out this sequence until the program is closed.
Clarifications

All input strings will have an odd number of characters. (So that every windmill will have a pivot)

To keep the challenge simple, all strings will only contain upper and lowercase alphabet characters.

The output must be len(input_string) characters wide and tall.

It doesn't matter which step of the sequence you start on, just as long as you continue rotating and looping forever.

More Test IO:
Since the post is already pretty long, here is a link to  the output for "windmill":
Sidenote:
Since this is supposed to be a windmill, it would be awesome if you include some boilerplate code to animate it with a small time delay or a user input between each step. However, since some languages don't have time builtins, this is not mandatory. The competing part of your submission can just print the sequence as fast as possible.


APL (Dyalog Unicode), 55 48 bytes

≢⍸↑2≠/¨⊢∘g\3⍴⊂2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←⍉⍤2⍉∘⌽)⍣6~⎕

Try it online!
-7 bytes thanks to @ngn.
Improvements:

2 3 1⍉ → ⍉⍤2⍉: Replace "cycle the axes once" with "swap 1st and 3rd axes, then 2nd and 3rd"
{⍵(g⍵)(g g⍵)} → ⊢∘g\3⍴⊂: A scan that ignores the left arg and applies g to the right arg, so it works like this:

3⍴⊂x gives (x x x)
⊢∘g\3⍴⊂x gives (x)(x ⊢∘g x)(x ⊢∘g x ⊢∘g x)
which is the same as (x)(g x)(g g x) because:
  x ⊢∘g x
→ x ⊢ g x
→ x ⊢ (g x)
→ g x

APL (Dyalog Unicode), 55 bytes

{≢⍸↑2≠/¨⍵(g⍵)(g g⍵)}2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←2 3 1⍉⌽)⍣6~⎕

Try it online!
A full program that takes a 3D array. Uses the flood fill already used here. Another key idea is g←2 3 1⍉⌽, which effectively cycles through all six sides when applied with ⍣6 (repeat six times).
How it works
{≢⍸↑2≠/¨⍵(g⍵)(g g⍵)}2=2(g⊣(⌈∧⊢)/,)⍣6⍣≡(1,g←2 3 1⍉⌽)⍣6~⎕

~⎕                ⍝ Logical negation of the input
(1,g←2 3 1⍉⌽)⍣6   ⍝ Pad with a layer of ones on all six sides
2(g⊣(⌈∧⊢)/,)⍣6⍣≡  ⍝ Flood fill from the outside, changing 1s to 2s:
2(        ,)      ⍝   Prepend 2 on the last axis
   ⊣(⌈∧⊢)/        ⍝   Pairwise lcm(max(x,y),y) over the last axis
                  ⍝   Effectively, propagate 2 to an adjacent 1 on the right
  g               ⍝   Cycle the orientation once
            ⍣6⍣≡  ⍝   Repeat 6 times until the flood fill is complete
2=                ⍝ Map 2s to 1s, and anything else to 0s
{⍵(g⍵)(g g⍵)}     ⍝ Construct 3 arrays so that each axis becomes the last axis
2≠/¨              ⍝ Extract faces (where 0 and 1 are adjacent) for each array
≢⍸↑               ⍝ Count ones in all arrays


Conjugate in the Spanish imperfect / Conjugue en el imperfecto de indicativo Given an input of a Spanish verb in its infinitive form, output the verb
conjugated in all 6 forms of the indicative imperfect.

To conjugate an infinitive in the imperfect, remove the infinitive ending (-ar,
-er, -ir, and sometimes -ír) and add the imperfect endings listed below. There
are three irregular verbs in the imperfect, also listed below.

Verb ending    Replace with...
--------------------------------------------------------
-ar            -aba, -abas, -aba, -ábamos, -abais, -aban
-er, -ir, -ír  -ía,  -ías,  -ía,  -íamos,  -íais,  -ían

Irreg. verb    Conjugations
--------------------------------------------------------
ser            era,  eras,  era,  éramos,  erais,  eran
ver            veía, veías, veía, veíamos, veíais, veían
ir             iba,  ibas,  iba,  íbamos,  ibais,  iban

For the purposes of this challenge, use capital letters instead of accented
letters (á becomes A, é becomes E, and í becomes I). This is only because
accented letters are 2 bytes in UTF-8, but they can be different in other
encodings, and I'd rather not have to deal with any of that and stay within
printable ASCII instead.

Infinitive verbs will always be three or more characters long with the sole
exception of the verb ir, will never contain accented letters with the
exception of verbs that end in -ír, and will always end in either -ar, -er,
-ir, or -ír.  Reflexive verbs do not need to be handled.

Output may be in either the form of a whitespace-/comma-separated string (so
printing each conjugation to STDOUT on its own line is okay) or an
array/list/etc.

Since this is code-golf, the shortest code in bytes wins.

Test cases:

In       Out
---------------------------------------------------------------
hablar   hablaba hablabas hablaba hablAbamos hablabais hablaban
comer    comIa comIas comIa comIamos comIais comIan
vivir    vivIa vivIas vivIa vivIamos vivIais vivIan
sonreIr  sonreIa sonreIas sonreIa sonreIamos sonreIais sonreIan
ser      era eras era Eramos erais eran
ver      veIa veIas veIa veIamos veIais veIan
ir       iba ibas iba Ibamos ibais iban

Retina, 100 82 bytes

\B[^a]r$
I
r$
b
^vI$
veI
^sI$
er
$
a
$
 $_s $_ $_mos $_is $_n
T`l`L`.(?=[^I]amos )

Try it online. Unfortunately, due to the use of $_ it's not possible to modify the code to run all tests at once, so you'll have to copy in the individual verbs. I'm working on a new feature that will make this possible though.

Explanation

\B[^a]r$
I

We start by turning all endings which aren't ar into I, provided the input isn't the irregular verb ir. That takes care of the -er, -ir, -ír conjugations, messes up the irregular verbs ser and ver (but shortens them in the process), and leaves only ir and -ar with a trailing r.

r$
b

If the word still ends in r, we replace that with a b. We've now covered all standard conjugations as well as the irregular verb ir.

^vI$
veI

This fixes the irregular verb ver which has been turned into vI in the first stage.

^sI$
er

This fixes the irregular verb ser which has been turned into sI in the first stage. Now we've modified all possible stems correctly. All that's left to do is append all the possible endings, and then fix the accent for the first person plural in some cases.

$
a

First we append an a to the stem, because that's always part of all endings.

$
 $_s $_ $_mos $_is $_n

This makes use of the rarely seen $_ which inserts the entire string into the substitution (regardless of what was matched). This is actually very useful when duplicating strings, as are $` and $', which are also quite underappreciated.

Before this stage, we've got the first person singular in the string. We now append the other conjugations, by matching the end of the string with $ and building the other forms by appending the appropriate suffixes to the first person singular.

T`l`L`.(?=[^I]amos )

Finally, we fix the accent for the first person plural if applicable. This only needs to be done for a vowel, two characters in front of the -amos unless the character in between is I. So we match such a character and then use a transliteration stage to convert lower to upper case. This makes use of the new character classes l and L which I only added yesterday. They expand to a-z and A-Z respectively, so that new feature saves 4 bytes here.


Finding Factorials with Gamma Introduction

We know that the factorial notation is valid for all natural numbers. However, Euler had extended it for all positive real numbers, as well as for complex numbers by defining a function, which is known as the Gamma Function. It is represented by Γ.

Challenge

You will be given a non-negative floating point number, say 'n' (with a maximum of 2 decimal places in it), and you need to output the factorial of that number correct to at least 3 decimal places. Assume all inputs to be valid, and n <= 7.

Now talking about Gamma function, there is an integral which can be used to find the value of any factorial. You may choose to use it. You can find more information here. The Gamma function is recursive in nature. One important property, which would probably be useful to you is:

Γ(n) = (n-1)! , which means that, n! = Γ(n) . n

Also note that we really do not need to know Γ(n) for all values of n. For instance, look at the number 4.5 - we can write its factorial as:

4.5! = 4.5 * 3.5 * 2.5 * 1.5 * 0.5! = 59.0625 * 0.5!

So here we need only the value of 0.5! , which means the value of Γ(1.5). Also, similarly, we can find the factorial of any decimal if we know the values of factorials of numbers between 0 and 1, i.e, values of gamma function of numbers between 1 and 2. You need it, so that is why there is a table below for your help:

Using this table, we can see that 0.5!, i.e, the value of Γ(1.5) = 0.88623, which gives our result: (4.5)! = 59.0625 * 0.88623 = 52.3429594 , which is indeed a good result. Similarly,

(5.7)! = (5.7)*(4.7)*(3.7)*(2.7)*(1.7)*(0.7)! = 454.97457 * 0.90864 = 413.408093

Also, if you do not wish to use the table for calculating the gamma function, here is a simple integral to help you out:

Remember that you can provide your answers only up to 3 decimal places if you want to. But the value should have minimum error. Like, +- 0.003 is acceptable.

You are free to decide in what way you want to compute the factorial - whether by the integral, or by the table, or using any other method.

Examples

Please note that here the answer is correct to 3 decimal places.

2.4 -> 2.981
3.9 -> 20.667
2.59 -> 3.675
1.7 -> 1.545
0.5 -> 0.886

Scoring

This is code-golf, so the shortest code wins!

Community wiki for built-in solutions

This answer is intended to collect answers that are simply built-ins. It's a community wiki, so anybody can edit in without approval. Go ahead and include any built-in only solution here, following xnor's proposal and according to our consensus.

Jelly, 1 byte

!

Try it online!

J , 1 byte

!

Try it online!

2sable, 1 byte

!

Try it online!

Pyth, 2 bytes

.!

Try it online!

R, 9 bytes

factorial

Try it online!

Stax, 2 bytes

|F

Try and debug online!

Wolfram Language (Mathematica), 3 bytes

#!&

Try it online!


Convert a string to sentence case Input:

A string (or the closest thing to that in your language)

Output:

The same string but converted to sentence case

Rules:

For this challenge, sentence case can be considered "The first letter of each sentence is capitalized. The rest are lowercase." (i.e. proper nouns do not have to be capitalized)
If the input does not include a period, it is treated as one sentence.
The other 2 punctuation marks used to end a sentence in english (? and !) can be considered periods
If a letter immediately follows a punctuation mark the same rules still apply (i.e. the first letter is capitalized and all following letters are lowercased until the next punctuation mark)

Sample test cases:

"hello world." // "Hello world."

"CODEGOLF IS FUN." // "Codegolf is fun."

"no period" // "No period"

"the ball was red. so was the balloon." // "The ball was red. So was the balloon."

"I love codegolf.stackexchange.com" // "I love codegolf.Stackexchange.Com"

"heLLo! hOW are yOU toDay? hOpEfulLy yOu are okay!" // "Hello! How are you today? Hopefully you are okay!"

This is code-golf, so the shortest code wins!

05AB1E, 3 bytes

l.ª

Try it online!

Nothing like a good old built-in answer! This converts the string to lowercase and then performs sentence case.


Enumerate an array, grouping duplicates The objective of this challenge is to take an array of positive integers, and enumerate its indices, grouping like elements.

An enumeration without any duplicates is done by just outputting an array of pairs (value, index), for example, [3, 4, 13, 9, 2] => [[3,1],[4,2],[13,3],[9,4],[2,5]].

However, if a given element appears a second time, it isn't given its own pair, but is instead added to the group of its first occurrence. If in our above example we replaced the 9 with 3, then in the output we would remove [9,4] and replace [3,1] with [3,1,4].

In the output, groups must be ordered by their first occurrence, and indices must be in ascending order. The element must be first in a group, before its indices. Output may be 0 or 1 indexed. You may assume the array has at least one element.

Test cases:

Input           | Output (One-indexed)
[3, 2, 2, 3]    | [[3, 1, 4], [2, 2, 3]]
[17]            | [[17, 1]]
[1, 1]          | [[1, 1, 2]]
[1, 1, 2]       | [[1, 1, 2], [2, 3]]
[1, 2, 3, 4]    | [[1, 1], [2, 2], [3, 3], [4, 4]]
[1, 1, 1, 1]    | [[1, 1, 2, 3, 4]]

This is code-golf, fewest bytes wins!

Dyalog APL, 5 bytes

(⊂,)⌸

Try it online!

,⌸ for 2 bytes almost works, but has trailing zeroes :/


Mix pi and e to make pie! Everybody knows pi the mathematical constant, the ratio of a circle's circumference to its diameter.

3.14159265358979323846264338327950288419716939937510...

You probably also know e the mathematical constant, the base of a natural logarithm.

2.71828182845904523536028747135266249775724709369996...

But... do you know pie? It is one of the most important constants (to me). It is the digits of pi and e interleaved.

32.1741185298216852385485997094352233854366206248373...

As a decimal expansion:

3, 2, 1, 7, 4, 1, 1, 8, 5, 2, 9, 8, 2, 1, 6, 8, 5, 2...

This is OEIS sequence A001355.

  KEYWORD: nonn,base,dumb,easy

It is a very dumb sequence.

Challenge

Write a program/function that takes a non-negative integer n and outputs the nth digit of pie.

Specifications

Standard I/O rules apply.
Standard loopholes are forbidden.
Your solution must work for at least 50 digits of each constant which means it should work for at least a 100 terms of the sequence (please, try not to hardcode :P).
The output for 2 or 3 is not a decimal point.
Your solution can either be 0-indexed or 1-indexed but please specify which.
This challenge is not about finding the shortest approach in all languages, rather, it is about finding the shortest approach in each language.
Your code will be scored in bytes, usually in the encoding UTF-8, unless specified otherwise.
Built-in functions that compute this sequence are allowed but including a solution that doesn't rely on a built-in is encouraged.
Explanations, even for "practical" languages, are encouraged.

Test cases

These are 0-indexed.

Input   Output

1       2
2       1
11      8
14      6
21      4
24      9
31      5

In a few better formats:

1 2 11 14 21 24 31
1, 2, 11, 14, 21, 24, 31

2 3 12 15 22 25 32
2, 3, 12, 15, 22, 25, 32

Mathematica, 50 bytes
1-indexed
(Riffle@@(#&@@RealDigits[#,10,5!]&/@{Pi,E}))[[#]]&


Distance Between Two Points Travelling on a Polar Graph Chart Brief Problem Explanation

Write a program to find the minimum distance between two points traveling only on rays emanating from the origin and circles centered on the origin.

Explanation of Premise

Now let's imagine we are on a plane, and on this plane we are only allowed to travel in special ways. We are allowed to travel on any ray emanating from the origin.

We can also travel on any circle centered at a circle

Now our goal is to travel from one point on this plane to another. However, we can't just travel in a simple Euclidian path, we can only do this if the points happen to fall on a ray emanating from the center.

We can travel on this one because it falls on a one of our rays.

We can also travel on circles centered at the origin.

Examples

Now here is the challenge:

We've got to get from one point to another in the shortest path; often this is a combination of traveling on circles and rays.

This, however, it could also be traveling on two rays.

Sometimes there exist two paths that travel the minimum distance.

Problem

Your challenge is to write a program that when given two points will give us the minimum distance between them if we follow these rules. The inputs can be given in either rectangular or polar forms and the output ought to be one number, the distance between.

Test Cases

(with rectangular input)

(1,1) (1,-1) -> ~ 2.22144
(0,0) (1, 1) -> ~ 1.41421
(1,0) (-0.4161 , 0.90929) -> ~ 2
(1,1) (1, 0) -> ~ 1.19961
(1,2) (3, 4) -> ~ 3.16609

Haskell, 49 48 bytes

(a!q)c r=min(q+r)$abs(q-r)+acos(cos$a-c)*min q r

Usage:

> let rect2polar (x,y)=(atan2 y x, sqrt(x^2+y^2))
> let test c1 c2=let [(a1,r1),(a2,r2)]=rect2polar<$>[c1,c2] in (a1!r1)a2 r2
> test (1,0) (-0.4161, 0.90929)
1.9999342590038496

Thanks to @Zgarb for saving a byte


Coat of Many Colours Challenge
Given a list of unique colour names as input, sort them in the order that they first appear in Joseph's Amazing Technicolour Dreamcoat.

Example
Input:  green, blue, red, brown
Output: red, green, brown, blue

The full list of colours, in order, is:
 1. red
 2. yellow
 3. green
 4. brown
 5. scarlet
 6. black
 7. ochre
 8. peach
 9. ruby
10. olive
11. violet
12. fawn
13. lilac
14. gold
15. chocolate
16. mauve
17. cream
18. crimson
19. silver
20. rose
21. azure
22. lemon
23. russet
24. grey
25. purple
26. white
27. pink
28. orange
29. blue

Or as an array of strings:
["red","yellow","green","brown","scarlet","black","ochre","peach","ruby","olive","violet","fawn","lilac","gold","chocolate","mauve","cream","crimson","silver","rose","azure","lemon","russet","grey","purple","white","pink","orange","blue"]

Rules

You may take input by any reasonable, convenient means (e.g., an array of strings, a delimited string, individual strings) as long as it's permitted by our standard I/O rules, but please specify your input method in your answer.
You may do the same for your output.
The input will only ever contain colours from the above list.
Your solution should be able to handle empty inputs.
You may choose whether all words in the input are consistently uppercase, lowercase or title case but your output's casing must match your input's.
This is code-golf so lowest byte count in each language wins.
As always, standard loopholes are forbidden.

Test cases
Input:  []
Output: []

Input:  ["green", "blue", "red", "brown"]
Output: ["red", "green", "brown", "blue"]

Input:  ["gold", "grey", "green"]
Output: ["green", "gold", "grey"]

Input:  ["ruby","yellow","red","grey"]
Output: ["red", "yellow", "ruby", "grey"]

Input:  ["gold", "green", "fawn", "white", "azure", "rose", "black", "purple", "orange", "silver", "ruby", "blue", "lilac", "crimson", "pink", "cream", "lemon", "russet", "grey", "olive", "violet", "mauve", "chocolate", "yellow", "peach", "brown", "ochre", "scarlet", "red"]
Output: ["red", "yellow", "green", "brown", "scarlet", "black", "ochre", "peach", "ruby", "olive", "violet", "fawn", "lilac", "gold", "chocolate", "mauve", "cream", "crimson", "silver", "rose", "azure", "lemon", "russet", "grey", "purple", "white", "pink", "orange", "blue"]

PowerShell, 262 155 151 127 125 95 bytes

$args|sort{"rlyegwbrscbrocpyrvo lvnfaldgccvmacmcvseraolsrygpptwkpnoeb".indexof((-join$_[3,0]))}

Try it online!

Naive approach. PowerShell sort-object can sort based on a script block that gets executed for every object. Here we're simply getting the .IndexOf() the color from a string, which will assign a numerical value to each color, and then sorts based on those numbers. The string is constructed from the fourth and first letters of each color to ensure uniqueness. Output is implicit.

-4 bytes thanks to Shaggy.
-2 bytes thanks to mazzy.
A whopping -30 bytes thanks to KGlasier.


Fix a broken random function A friend has an add-on card in their computer which generates a perfectly random number from 1 to 5 inclusive. Unfortunately, they spilt cola on it somehow, and it now generates only 2's for all numbers from 1 to 4. Luckily the randomness is preserved, but 2 has a probability of 80% and 5 has a probability of 20%, and there are no 1's, 3's or 4's generated. Using this random source (call it BrokenRand() or something similar), write a working random number generator which produces numbers from 1 to 5 each with an equal 20% probability with the same perfect randomness as the original source.

Shortest program wins. Bonus points awarded for the minimum number of calls to BrokenRand impartially by a demographically-selected customer service focus consultancy, broken down by age and sex - i.e. me.

JavaScript - 69 characters

This uses the von Neumann extractor to generate unbiased bits; the general algorithm is also described on the HotBits website. Three bits are used to form a number from 0 to 7. All numbers 5 and above are discarded, and 1 is added to each of the rest before they are printed. I made a simulation to show that this is not heavily biased.

You need to provide your own function r() to access the RNG.

 for(;;v<5&&alert(v+1))for(v=i=0;i<3;a-b&&(v*=2,v+=a<b,i++))b=r(a=r())


Is the writer a man or woman? One problem on a website like this is that you often don't know if you are talking to a male or female. However, you have come up with a simple NLP technique you can use to determine the gender of the writer of a piece of text.

Theory

About 38.1% of letters used in English are vowels [a,e,i,o,u] (see References below, y is NOT a vowel in this case). Therefore, we will define any word that is at least 40% vowels as a feminine word, and any word that is less than 40% vowels as a masculine word.

Beyond this definition we can also find the masculinity or femininity of a word. Let C be the number of consonants in the word, and V be the number of vowels:

If a word is feminine, it's femininity is 1.5*V/(C+1).
If a word is masculine, it's masculinity is C/(1.5*V+1).

For example, the word catch is masculine. Its masculinity is 4/(1.5*1+1) = 1.6.  The word phone is feminine. Its femininity is 1.5*2/(3+1) = .75.

Algorithm

To figure out the gender of the writer of a piece of text, we take the sum of the masculinity of all the masculine words (ΣM), and the sum of the femininity of all the feminine words (ΣF). If ΣM > ΣF, we have determined that the writer is a male. Otherwise, we have determined that the writer is a female.

Confidence Level

Finally, we need a confidence level. If you have determined that the writer is female, your confidence level is 2*ΣF/(ΣF+ΣM)-1. If you have determined that the writer is male, the confidence level is 2*ΣM/(ΣF+ΣM)-1.

Input

Input is a piece of English text including punctuation. Words are all separated by spaces (You don't have to worry about new-lines or extra spaces). Some words have non-letter characters in them, which you need to ignore (such as "You're"). If you encounter a word that is all non-letters (like "5" or "!!!") just ignore it. Every input will contain at least one usable word.

Output

You need to output an M or F depending on which gender you think the writer is, followed by your confidence level.

Examples

There's a snake in my boot.

Gender + masculinity/femininity of each word: [M1.0,F1.5,F.75,F.75,M2.0,F1.0]
ΣM = 3.0, ΣF = 4.0
CL: 2*4.0/(4.0+3.0)-1 = .143
Output: F .143

Frankly, I don't give a ^$*.

[M2.4,F1.5,M1.2,F1.0,F1.5], ΣM = 3.6, ΣF = 4.0, CL: 2*4.0/(4.0+3.6)-1 =  .053, Output: F .053

I'm 50 dollars from my goal!

[F.75,M1.25,M1.2,M2.0,F1.0], ΣM = 4.45, ΣF = 1.75, CL: 2*4.45/(4.45+1.75)-1 = .435, Output: M .435

References

Percentage of vowels in English dictionary words (38.1%)
Percentage of vowels in English texts (38.15%)

Python 3, 320 317 307 286 253 189 bytes

h=S=0
for v in input().split():V=sum(map(v.count,'aeiouAEIOU'));C=sum(x.isalpha()for x in v);H=V<.4*C;C-=V;K=[1.5*V/(C+1),C/(1.5*V+1)][H];h+=K*H;S+=K-K*H
print('FM'[h>S],2*max(S,h)/(S+h)-1)

Try it online!

Ungolfed:

def evaluateWord(s):
    V = len([*filter(lambda c: c in 'aeiou', s.lower())])
    C = len([*filter(lambda c: c in 'bcdfghjklmnpqrstvxzwy', s.lower())])
    isMasculine = V < 0.4*(V+C)
    return C/(1.5*V+1) if isMasculine else 1.5*V/(C+1), isMasculine

def evaluatePhrase(s):
    scores = []
    for word in s.split():
        scores.append(evaluateWord(word))
    masc = 0
    fem = 0
    for score in scores:
        if score[1]:
            masc += score[0]
        else:
            fem += score[0]
    return ('M', 2*masc/(fem+masc)-1) if masc > fem else ('F', 2*fem/(fem+masc)-1)

print(evaluatePhrase("There's a snake in my boot."))


Binary representation of a number is palindrome or not? Write a full program  to find whether the binary representation of a number is palindrome or not?

Sample Input
5

Sample Output
YES

Print YES if binary representation is palindrome and NO otherwise.

Python - 46 chars

n=bin(input())[2:]
print'YNEOS'[n!=n[::-1]::2]


Too many pawns on a chess board Given an integer 2n, find the number of possible ways in which 2n^2 black pawns and 2n^2 white pawns can be arranged on a 2n by 2n chess board such that no pawn attack another.

A black pawn can attack only a white pawn, and vice versa.
The usual chess rules of attacking follow, i.e, white pawns attack squares immediately  diagonally in front, and the black pawns attack squares immediately diagonally backward (as seen by the white observer).
All rotation, reflections count as distinct.

The program that can output all possible configurations for the highest value of 2n in 120 seconds wins.
(All programs are welcome, though)

For example, Alice's program can deal with upto n=16 within 120 seconds while Bob's can deal with upto n=20 within the same time. Bob wins.

Platform: Linux 2.7GHz @ 4 CPUs

Java, n=87 on my machine
The result for n=87 is
62688341832480765224168252369740581641682638216282495398959252035334029997073369148728772291668336432168

import java.math.BigInteger;

public class NonattackingPawns {

    static BigInteger count(int n) {
        BigInteger[][] a0 = new BigInteger[n+1][n*n+1], a1 = new BigInteger[n+1][n*n+1], tm;

        for(int h = 0; h <= n; h++) a0[h][0] = h%2==0? BigInteger.ONE: BigInteger.ZERO;

        for(int c = 1; c <= 2*n; c++) {
            int minp = 0;
            for(int h = 0; h <= n; h++) {
                java.util.Arrays.fill(a1[h], BigInteger.ZERO);
                if(h>0) minp += c >= 2*h-c%2 ? 2*h - c%2 : c;

                int maxp = Math.min(n*(c-1)+h, n*n);
                for(int p = minp; p <= maxp; p++) {
                    BigInteger sum = a0[h][p-h];

                    if(c%2==1 && h>0)
                        sum = sum.add(a0[h-1][p-h]);
                    else if(c%2==0 && h<n)
                        sum = sum.add(a0[h+1][p-h]);

                    a1[h][p] = sum;
                }
            }
            tm=a0; a0=a1; a1=tm;
        }
        BigInteger[] s = new BigInteger[n*n+1];
        for(int p = 0; p <= n*n; p++) {
            BigInteger sum = BigInteger.ZERO;
            for(int h = 0; h <= n; h++) sum = sum.add(a0[h][p]);
            s[p] = sum;

        }

        BigInteger ans = BigInteger.ZERO;
        for(int p = 0; p < n*n; p++) ans = ans.add(s[p].multiply(s[p]));
        return ans.shiftLeft(1).add(s[n*n].multiply(s[n*n]));
    }

    public static void main(String[] args) {
        for(int n = 0;; n++) {
            System.out.println(n + " " + count(n));
        }
    }

}

This currently uses a dynamic programming scheme taking O(n^4) operations to calculate the ways to place p pawns on the squares of one color for 0 <= p <= n^2. I think it should be possible to do this much more efficiently.
Check out the results here.
Explanation
In a valid solution, the lowermost white pawns in each column must form a zigzagging line like this:

That is, the height of the line in column c must be +/- 1 from its position in column c - 1. The line can also go onto two imaginary rows above the top of the board.
We can use dynamic programming to find the number of ways to draw a line on the first c columns that includes p pawns on those columns, is at height h on the cth column, using the results for column c - 1, heights h +/- 1, and number of pawns p - h.


THIS ... IS ... FORTRESS! Fortress was a language being developed by the Sun Programming Language Research Group (R.I.P. Fortress) that had a unique property to it, it was possible to render ("Fortify") programs in different font-styles (i.e. blackboard bold, bold, italics, roman, etc. ). The goal is to represent a one-char Fortress variable in HTML markup.

Here's how the fortification of one-char variables worked (simplified/modified from documentation for code-golfing purposes):

If the variable is a repeated capital (i.e. ZZ), it becomes formatted in blackboard bold (ℂℍℕℙℚℝℤ)
If the variable is preceded by an underscore, the variable is rendered in roman font (left alone)
If the variable is followed by an underscore, the variable is rendered in bold font (v)
If the variable is neither preceded nor followed by an underscore, the variable is rendered in italic font (v)
The codepoints of the blackboard bolds are: :1D538, :1D539,  ℂ:2102, :1D53B, :1D53C, :1D53D, :1D53E, ℍ:210D, :1D540, :1D541, :1D542, :1D543, :1D544, ℕ:2115, :1D546, ℙ:2119, ℚ:211A, ℝ:211D, :1D54A, :1D54B, :1D54C, :1D54D, :1D54E, :1D54F, :1D550, ℤ:2124. These count as one byte each in your program (if your language of choice can handle these characters at all)

Input will be either a repeated ASCII capital, or a single ASCII letter with either no underscore, a leading underscore, or a trailing underscore (AKA _a_ will not be an input). This is code-golf so lowest byte count wins!

Test cases:

a => a
BB =>
c_ => c
_d => d
E => E
G_ => G
_H => H
ZZ => ℤ

Links: Specification, Direct download of version 0.1 alpha.

Reference implementation (This would be in Fortress, but Fortress doesn't like most of the doublestruck characters, so this implementation is in D):

dstring fortify(string arg) {
    import std.string, std.conv;

    alias D = to!dstring; //Convert to a string that accepts the unicode needed
    dstring BB = "ℂℍℕℙℚℝℤ"d; //blackboard bold capitals
    string UC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //normal ASCII capitals

    if(arg.length == 1)
        return D("" ~ arg ~ "");
    if(arg[0] == a[1])
        return D(BB[UC.indexOf(arg[0])]);
    if(arg[0] == '_')
        return D(arg[1]);
    return D("" ~ arg[0] ~ "");
}

Python 3.6, 159 131 128 bytes

1 byte saved thanks to @Zacharý

3 bytes saved thanks to @VаlueInk

28 bytes saved thanks to @Rod

lambda s:len(s)<2and f"{s}"or s[0]==s[1]and"ℂℍℕℙℚℝℤ"[ord(s[0])-65]or[f"{s[0]}",s[1]][s[0]=='_']

Try it online!


Growing Manhattan Ameobas An ***ameoba graph**** is a type of tree whose nodes all have values from 0 to some non-negative integer N, and any particular node with value x < N connects to x+1 distinct nodes with values x+1.

Ameoba graph for N = 3: (Denoted A3)

Note that the 2's are not allowed to share any of the 3's; exactly three 3's must "belong" to each 2.

Challenge

Your task is to inductively "grow" these ameoba graphs in a 2-dimensional grid by greedily minimizing the Manhattan distance between nodes:

Base case: A0 is simply the graph 0.
Inductive step: AN+1 is generated by iteratively placing the new N+1 valued nodes as close as possible to the N values nodes in the existing AN structure. (It can only be as close as possible since the closest spots may already be filled.)

For the inductive step the general procedure you must follow is:

for each existing node P with value N:
    for each new N+1 valued node Q you need to connect to P: //this loops N+1 times
        find the set of vacant spots that are minimally distant from P //by Manhattan distance
        place Q in any of these vacant spots

(A different procedure with indistinguishable output is fine.)

Growth example for A4:

A0 is always the same:

0

For A1 I happen to put the 1 to the right of the 0 (it has to go on one of the 4 open sides):

01

For A2 I happen to put the two 2's above and to the right of the 1:

 2
012

For A3 I find that one of the six 3's I must place cannot be directly next to a 2, so I put in one of the next closest places:

 3
323
0123
  33 <-- this 3 is distance two away from its 2

The process continues in A4. Note that I'm iterating over each 3 and placing four 4's next to it or as close as possible, then moving to the next 3 (the order of 3's does not matter):

 444
443444
4323444
4012344
 44334
  4444
   44

Always keep in mind that nodes cannot be "shared".

Program

The program you write must take in a number from 0 to 8 (inclusive) and output a valid ameoba graph of it, using the inductive growth pattern explained above.

What happens beyond 8 does not matter.

(A8 contains 46234 nodes which is pushing it. Anything beyond A8 would be too far. Thanks to Martin Büttner for noticing this.)

The input should come from stdin or the command line and output should go to stdout or a file.

Examples (taken directly from above)

Input: 0
Output:

0

Input: 1
Output:

01

Input: 2
Output:

 2
012

Input: 3
Output:

 3
323
0123
  33

Input: 4
Output:

 444
443444
4323444
4012344
 44334
  4444
   44

* These type of graphs might already have a name. I admit I just made them up. ;)

Mathematica, 353 288 285 275 bytes

n=Input[];f@_=" ";g={z={0,0}};i=f@z=0;For[r=Range,i++<n,g=Reap[(j=i;o={};For[d=0,j>0,o=Rest@o,If[o=={},o=Join@@({e={#,d-#},-e,e={d-#,-#},-e}&/@r@++d)];If[f[c=#&@@o+#]==" ",f@c=i;Sow@c;--j]])&/@g][[2,1]]];Riffle[(x=#;ToString@f@{x,#}&/@m~r~M)&/@r[m=Min@{g,0},M=Max@g],"
"]<>""

Ungolfed:

n = Input[];
f@_ = " ";
g = {z = {0, 0}};
i = f@z = 0;
For[r = Range, i++ < n,
  g = Reap[(
        j = i;
        o = {};
        For[d = 0, j > 0, o = Rest@o,
         If[o == {},

          o = Join @@ ({e = {#, d - #}, -e, e = {d - #, -#}, -e} & /@
              r@++d)
          ];
         If[f[c = # & @@ o + #] == " ",
          f@c = i;
          Sow@c;
          --j
          ]
         ]
        ) & /@ g
     ][[2, 1]]
  ];
Riffle[(
     x = #;
     ToString@f@{x, #} & /@ m~r~M
     ) & /@ r[m = Min@{g, 0},
    M = Max@g
    ], "
  "] <> ""

Here is an example output for n = 5:

      5
     5555
    555555
   5555555
  555555555
 55555555555
5555554445555
5555544444555
 5555443305555
 55554432144555
 55555443234555
  5555544344555
   555554445555
    5555555555
      5555555
       55555
       55

Input 8 takes about 4.5 minutes.

For a quick breakdown of my algorithm:

I'm using two look-up tables, f and g. The first one is just a sparse map containing the non-empty cells. The latter is a list containing all coordinate pairs for each cell-value (I think I don't even need to keep track of old ones here). I'm iterating through the coordinates in g to extend every cell from the last iteration. To do that I iterate over Manhattan distances, creating all possible vectors for each distance, and checking if the resulting cell is still empty (in which case I fill it). Repeat until enough new cells have been created.

When I'm done, I find the minimum and maximum coordinate in g and I create an appropriate grid, which is filled by looking up the cells in f. The rest is just joining everything into a single string with line breaks.


Dice Paths on a Grid You place a standard die at the origin of a 2D grid that stretches infinitely in every direction. You place the die such that the 1 is facing upwards, the 2 is facing in the negative y direction, and the 3 is facing in the positive x direction, as shown in the figure below:

You then proceed to execute a series of moves with the die by rotating it 90 degrees in the direction of motion. For example, if you were to first rotate the die in the negative x direction, a 3 would be upwards, the 2 would be facing in the negative y direction, and a 6 would be facing in the positive x direction.
The series of moves +y, +y, +x, +x, -y is shown in the figure below, along with the net of the die for clarification (sometimes the net is called a 'right-handed die').

We then proceed to read off the top face of the die after every move. In this case it would read 2, 6, 4, 1, 2, which we call a dice path. Note we do not include the top face of the die in its initial position, but it is always 1.
If the path of the die is such that it returns to the square it started on at the end of its movement, we call this a dice path that returns to the origin.
Challenge
Given a nonempty dice path as input (in a list or any other reasonable format), print a truthy value if the dice path returns to the origin, and a falsy value otherwise. Note that:

The truthy values and falsy values you output do not have to be consistent, but you can't swap them (eg. output a falsy value for a path that returns to the origin and a truthy value otherwise)
The input will be well formed and represent a valid dice path.
There is no limit to how far the die can stray from the origin.

Test Cases
Path                            -> Output
2,1                             -> true
3,1                             -> true
5,4,1,5                         -> true
2,4,1,2                         -> true
4,2,4,1                         -> true
2,4,6,2,4,6,5,4                 -> true
2,4,5,1,4,5,3,6,5,1             -> true
5,6,2,3,5,4,6,3,1,5,6,2         -> true
2,4,1,3,5,1,3,5,6,3,5,6,4,5,6,2 -> true
2                               -> false
4,5                             -> false
5,1,2                           -> false
5,6,2,1                         -> false
5,4,6,5,4,6                     -> false
5,6,4,1,5,4,2,6,5,4             -> false
5,1,2,1,5,6,5,1,2,6,4           -> false
4,6,3,1,5,6,2,1,3,6,4,1         -> false

Scoring
Shortest code in bytes wins.

JavaScript (ES6),  142 ... 122  121 bytes
Expects an array of characters, e.g. ['5','1','2']. Returns 0 or 1.
a=>a.map(n=>D=D.map((_,i)=>D['504405076067'[d*6+i>>1]^i],p+=[w=a.length,-w,1,-1][d=D.indexOf(n)]),p=0,D=[...'254316'])|!p

Try it online!
How?
The array D[] holds the face values in the following order:
 index |    0   |    1   |    2   |    3   |    4   |    5
-------+--------+--------+--------+--------+--------+--------
 face  |  front | behind |  left  |  right |   top  | bottom

We start with D = ['2','5','4','3','1','6'], which is the initial orientation of the die as described in the challenge, using this encoding.
The direction d of the next move is the 0-indexed position of the new top face in D[]:
 index (d) |   0   |   1   |   2   |   3
-----------+-------+-------+-------+-------
 direction |  up   |  down | right |  left

When moving towards direction d, the i-th face in the updated die is the face at the following position in the previous die:
   i = | 0 | 1 | 2 | 3 | 4 | 5
-------+---+---+---+---+---+---
 d = 0 | 5 | 4 | 2 | 3 | 0 | 1
 d = 1 | 4 | 5 | 2 | 3 | 1 | 0
 d = 2 | 0 | 1 | 5 | 4 | 2 | 3
 d = 3 | 0 | 1 | 4 | 5 | 3 | 2

This table is encoded with the following expression:
'504405076067'[d * 6 + i >> 1] ^ i

Try it online!
At each iteration, we update D[] and the position p. We add \$\pm 1\$ to \$p\$ when moving horizontally, or \$\pm w\$ when moving vertically, where \$w\$ is the length of the input array (an upper bound of the distance that can be traveled in a single direction). We test whether we're back to our starting point at the end of the process.


CJam, 64 59 58 56 54 bytes

Thanks to Dennis for saving 2 bytes.

{_80-zG-z8<{80>"LA"=}{_"X8�"f>[-14_AAGH].*+:+Imd)}?}

Try it online!

Leaves either period and group or a single character on the stack.

Explanation

There are two main ideas here:

First, we deal with the Lanthanides and Actinides. We have the condition 56 < x < 72 for Lanthanides and 88 < x < 104 for Actinides. Both of these can be expressed as a single comparison by taking an absolute difference to the centre of the range: the inequalities become |x - 64| < 8 and |x - 96| < 8, respectively. But these are still very similar, and doing the two comparisons separately is expensive. So we apply the same idea of checking a symmetric range, by taking another absolute difference with the centre between the two ranges, 80, first: ||x-80| - 16| < 8. This condition indicates that the atom is either a Lanthanide or an Actinide, but distinguishing between these two cases is then as trivial as comparing against 80 (or some other value between the ranges).
Since the output is really an index in a table of width 18, an obvious approach is to try base-converting the value to base 18, so that the two digits give group and period. To do that, we need to shift some values around though. All the we really need to do is to add the gaps in periods 1, 2 and 3 and close the gaps in periods 6 and 7. It's easiest to do this from the end, so that the values of the other gaps aren't affected (and keep their values).

_            e# Make a copy of the input, to figure out whether the output
             e# should be L or A.
80-z         e# Absolute difference from 80.
G-z          e# Absolute difference from 16.
8<           e# Check whether the result is less than 8.
{            e# If so...
  80>        e#   Check whether the input is greater than 80.
  "LA"=      e#   Select 'L or 'A accordingly.
}{           e# ...otherwise...
  _          e#   Duplicate input again.
  "X8"    e#   Push a string with character codes [88 56 12 4 1].
             e#   These are the values just before the gaps.
  f>         e#   Compare the input to each of these.
  [-14_AAGH] e#   Push [-14 -14 10 10 16 17]. These are the changes we need to
             e#   make to remove or insert the gaps corresponding to the above
             e#   positions. Note that the 17 doesn't get paired with an offset.
             e#   It's a constant offset to itself, which is equivalent to
             e#   decrementing the input (to make it zero based) and adding 18
             e#   to make the increment the period and make it 1-based.
  .*         e#   Multiply each gap by whether it's before the input value.
  +:+        e#   Add all of the applicable gaps to the input value.
  Imd        e#   Divmod 18, gives 1-based period and 0-based group.
  )          e#   Increment the group to make it one-based.
}?


Can this polyomino tile the toroidal grid? Inspired by certain puzzles on Flow Free: Warps.
Background
We all know that L-triominos can't tile the 3x3 board, and P-pentominos can't tile the 5x5 board. But the situation changes if we allow the board to wrap around in both dimensions:
L-triominos can tile 3x3 toroidal grid
The 3rd tile wraps around through all four edges.
┌ ┌─┐ ┐
  │ │3
┌─┤ └─┐
│ │2  │
│ └─┬─┘
│1  │
└───┘ ┘

P-pentominos can tile the 5x5 toroidal grid
The 5th tile wraps around through all four edges.
┌ ┌───┬─┐ ┐
  │   │ │
┌─┘   │ └─┐
│  1  │2  │
├─────┤   │
│  3  │   │
│   ┌─┴─┬─┤
│   │   │ │
└─┬─┘   │ ╵
  │  4  │5
└ └─────┘ ┘

Note that, in both cases, wrapping around in only one dimension doesn't allow such tiling.
In case the Unicode version is hard to read, here is the ASCII version:
3 2 3
1 2 2
1 1 3

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

Challenge
Given a polyomino and the size (width and height) of the toroidal grid, determine if the polyomino can tile the toroidal grid. The polyomino can be flipped and/or rotated.
A polyomino can be given in a variety of ways:

A list of coordinates representing each cell of polyomino
A 2D grid with on/off values of your choice (in this case, you cannot assume that the size of the grid defining the polyomino matches that of the toroidal grid)

The output (true or false) can be given using the truthy/falsy values in your language of choice, or two distinct values to indicate true/false respectively.
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
The polyomino is given as the collection of # symbols.
Truthy
# (singleton, a.k.a. monomino)
5x7 (or any size)
--------
## (domino)
4x3 (or any even size)
--------
#
## (L-triomino)
3x3 (as shown above)
--------
##
### (P-pentomino)
5x5 (as shown above)
--------
##
 ## (Z-tetromino)
4x4 (left as an exercise to the reader)
--------
###
#
# (V-pentomino)
5x5
--------
####
   #
   ### (a polyomino larger than the grid is possible)
4x4
--------
###
  ###
    ### (single polyomino can cover the entire grid, and can wrap multiple times)
3x3

Falsy
## (domino)
3x5 (or any odd sizes)
--------
###
#
1x8
--------
# #
### (U-pentomino)
5x5

Python 2, 300 265 163 bytes
-35 bytes after suggestions from @xnor, @ovs, and largely @user202729 (removing evenly divisible check allowed for a one-liner + lambda)
-102 bytes following encouragement + general suggestions by @user202729

lambda l,w,h:all(w*h-len({((e-(p&4)*e//2)*1j**p+p/8+p/8/w*1j)%w%(1j*h)for e in l for p in c})for c in combinations(range(8*w*h),w*h/len(l)))
from itertools import*

Takes input as a list of complex coordinates of each cell of the polyomino. Outputs False for Truthy and True for Falsey (quirky de Morgan optimization).
Try it online with many testcases. Since this brute-forces, I have commented out a few cases to run fast enough for TIO.
Thoroughly commented:
lambda l,w,h:
    all(                        # we want any configuration to work, but De Morgan gives any(L==len) <==> not all(L!=len) <==> not all(L-len)
        w*h-len(                      # if two polyominos in a configuration overlap, then there are duplicate cells
                                    #   so the length of the set is less
                {                   # create a set consisting of each possible position+orientation of L/len(l) polyominos:
                    (                   # here, e is a single cell of the given polyomino
                        (               # reflect e across the imaginary axis if p >= 4 (mod 8)
                            e-          # e-e.real*2 = e-e//.5 reflects across the Im axis
                            p&4             # Only reflect if the 2^2 bit is nonzero: gives 4* or 0* following
                            *e//2           # floor(z) = z.real when z is complex, so
                        )                   # e//2 (floor division) gives z.real/2 (complex floor division only works in Python 2)
                        *1j**p          # rotate depending on the 2^0 and 2^1 bits. i**x is cyclic every 4
                        +p/8              # translate horizontally (real component) by p>>3 (mod this later)
                        +p/8/w*1j           # translate vertically (im component) by p>>3 / w
                    )%w%(1j*h)          # mod to within grid (complex mods only work in Python 2)
                    for e in l      # find where each cell e of the given polyomino goes
                    for p in c      # do this for each c (each set of position+orientation integers)
                }
        )
        for c in combinations(           # iterate c over all sets of w*h/len(l) distinct integers from 0 to 8*L-1
            range(8*w*h)              # each of these 8*L integers corresponds to a single position/orientation of a polyomino
                                    # Bits 2^0 and 2^1 give the rotation, and 2^2 gives the reflection
                                    # The higher bits give the position from 0 to L=w*h-1  ==> (0,0) to (w-1,h-1)
            ,w*h/len(l)        # w*h/len(l) is the number of polyominos needed since len(l) is the number of cells per polyomino
                                    # can't switch to *[range(8*w*h)]*(w*h/len(l)) because Python 3 does not allow short complex operations as above
        )
    )
from itertools import*

A new 169-byte solution that replaces combinations with recursion:
g=lambda l,w,h,k=[]:all(g(l,w,h,k+[((e-(p&4)*e//2)*1j**p+p/8+p/8/w*1j)%w%(1j*h)for e in l])for p in range(8*w*h))if w*h>len(k)else len(set(k))-w*h
from itertools import*

This has the advantage of removing combinations (12 characters on its own) and one for loop, but the self-invocation takes many bytes. Currying would not save length.


Convert degrees to one of the 32 points of the compass The 32-point compass is... interesting, to say the least.

By Denelson83 (Own work) [GFDL or CC-BY-SA-3.0], via Wikimedia Commons

Your challenge is to take a degree measure, and convert it into a direction on the 32-point compass.

Each direction is 11.25 (360 / 32) degrees farther than the previous. For example, N (north) is 0 degrees, NbE (north by east) is 11.25 degrees, NNE (north-northeast) is 22.5 degrees, etc.

As for how you're supposed to get the directions,

0 degrees is N, 90 degrees is E, 180 degrees is S, and 270 degrees is W.

These are called cardinal directions.

The halfway points between the cardinal directions are simply the cardinal directions they're between concatenated. N or S always go first, and W or E always are second.

These are called ordinal directions.

The halfway points between the cardinal and ordinal directions are the directions they're between concatenated, again, with a "-" in between. Cardinal directions go first, ordinal second.

These are called secondary-intercardinal directions.

The halfway points between secondary-intercardinal directions and other directions are the other directions "by" the cardinal direction they're closest to (other than the one directly next to them, of course).

I have no idea what these are called :P

If all this explanation hurts your brain as much as mine, you can refer to this chart:

1   North               N
2   North by east       NbE
3   North-northeast     NNE
4   Northeast by north  NEbN
5   Northeast           NE
6   Northeast by east   NEbE
7   East-northeast      ENE
8   East by north       EbN
9   East                E
10  East by south       EbS
11  East-southeast      ESE
12  Southeast by east   SEbE
13  Southeast           SE
14  Southeast by south  SEbS
15  South-southeast     SSE
16  South by east       SbE
17  South               S
18  South by west       SbW
19  South-southwest     SSW
20  Southwest by south  SWbS
21  Southwest           SW
22  Southwest by west   SWbW
23  West-southwest      WSW
24  West by south       WbS
25  West                W
26  West by north       WbN
27  West-northwest      WNW
28  Northwest by west   NWbW
29  Northwest           NW
30  Northwest by north  NWbN
31  North-northwest     NNW
32  North by west       NbW

Here is a more detailed chart and possibly better explanation of the points of the compass.

Your challenge is to take input in degrees, and output the full name of the compass direction it corresponds to, along with its abbreviation.

Test cases:

Input  Output
0      North N
23.97  North-northeast NNE
33.7   Northeast by north NEbN
73.12  East-northeast ENE
73.13  East by north EbN
219    Southwest by south SWbS
275    West W
276    West by north WbN
287    West-northwest WNW

All capitalization must be preserved, as in the test cases. Maximum number of decimal places is 2. All input numbers will be greater than or equal to 0, and less than 360. If a decimal point is present, there will be digits on both sides (you don't have to handle .1 or 1.).

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

Javascript 470 453 438 434 432 421 404

s=String;s.prototype.a=s.prototype.replace;var a=prompt()/11.25,a=a+0.5|0,b,k,c=a,d=c%8,c=c/8|0,e=["north","east","south","west"],f,g,h;f=e[c];g=e[(c+1)%4];h=f==e[0]|f==e[2]?f+g:g+f;b="1;1 by 2;1-C;C by 1;C;C by 2;2-C;2 by 1".split(";")[d].a(1,f).a(2,g).a("C",h);k=b.a(/north/g,"N").a(/east/g,"E").a(/south/g,"S").a(/west/g,"W").a(/by/g,"b").a(/[\s-]/g,"");b=b[0].toUpperCase()+b.slice(1);alert(b+" "+k)

You can copy this code to your console and execute it. It prompts you for the degrees input and outputs the result with alert();

Ungolfed Javascript can be found at this fiddle:
http://jsfiddle.net/AezL3/11


ASCII art 3D StreetView Input:

You get a series of integers (fed via stdin or prompt).
Every pair of integers in this series represents a building's
WIDTH [valid range: 1..10] and HEIGHT [valid range: 0..10]
Assume input to be well-formed.

Sample input (the second line is for demonstration purposes only):

1 2 1 1 1 0 2 4 1 3 1 2 2 1
W H W H W H W H W H W H W H

Corresponding sample output:

                 ______
               /______ /|
              |       | |__
              |       |/__ /|
     __       |       |   | |__
   /__ /|     |       |   |/__ /|
  |   | |__   |       |   |   | |______
  |   |/__ /| |       |   |   |/______ /|
  |   |   | |_|       |   |   |       | |
  |_o_|_o_|/__|_o_____|_o_|_o_|_o_____|/
  -------------------------------------
 -  -  -  -  -  -  -  -  -  -  -  -  -
-------------------------------------

Rules:

The buildings

A basic building block looks like this (1 W, 1H)

   __
 /__ /| (base cube is borrowed from the one at this question:
|   | |  http://stackoverflow.com/questions/1609702/code-golf-playing-cubes)
|___|/

Our view is (ahum) ~3D so neighbouring buildings may hide parts of others.
Buildings are 'logically' rendered from left to right.
The first building is preceded by two spaces to it's left.
You render every building by applying the WIDTH and HEIGHT
to the dimensions of the base cube (do have a look at the sample output provided!).
For reference: number of characters from the left to the right 'wall' (for a building with W > 1): (W*5)-(W-1).
Buildings with Height > 0 have ONE door (which is depicted by the character o and is
located at two characters from the 'left' wall on the 'bottom' row ).

The road:

The road consists of three parts which we'll call 'top', 'middle' and 'bottom'.
The 'top' part and 'bottom' part are identical apart from the fact that
the 'top' part is preceded by two spaces.
The middle part is preceded by one space and consists of a repetition of the
following pattern: '-  '
Length is to be determined by the total width of the combined buildings: the most rightmost part of the road corresponds with the position of the 'right' wall of the 'last' building.

Winners:

This is code-golf! The winner is the qualifying contestant with the shortest solution (by source code count). The source must consist solely of printable ASCII characters. Have fun!

Imaginary bonus points for (random) windows, cars or pedestrians.

Feel free to comment if the specifications are not clear!


One goes up, the other comes down Introduction

In this challenge, your task is to decide whether a given sequence of numbers can be separated into two subsequences, one of which is increasing, and the other decreasing.
As an example, consider the sequence 8 3 5 5 4 12 3.
It can be broken into two subsequences as follows:

  3 5 5   12
8       4    3

The subsequence on the first row is increasing, and the one on the second row is decreasing.
Furthermore, you should perform this task efficiently.

Input

Your input is a non-empty list L of integers in the range 0 – 99999 inclusive.
It is given in the native format of your language, or simply delimited by spaces.

Output

Your output is a truthy value if L can be broken into an increasing and a decreasing subsequence, and a falsy value otherwise.
The subsequences need not be strictly increasing or decreasing, and either of them may be empty.

Rules and bonuses

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
Furthermore, brute forcing is forbidden in this challenge: your program must run in polynomial time in the length of the input.

You are not required to actually return the two subsequences, but there is a bonus of -20% for doing so.
To make the bonus easier to claim in statically typed languages, it is acceptable to return a pair of empty lists for the falsy instances.

Test cases

Given in the format input -> None for falsy inputs and input -> inc dec for truthy inputs.
Only one possible pair of subsequences is given here; there may be more.

[4,9,2,8,3,7,4,6,5] -> None
[0,99999,23423,5252,27658,8671,43245,53900,22339] -> None
[10,20,30,20,32,40,31,40,50] -> None
[49,844,177,974,654,203,65,493,844,767,304,353,415,425,857,207,871,823,768,110,400,710,35,37,88,587,254,680,454,240,316,47,964,953,345,644,582,704,373,36,114,224,45,354,172,671,977,85,127,341,268,506,455,6,677,438,690,309,270,567,11,16,725,38,700,611,194,246,34,677,50,660,135,233,462,777,48,709,799,929,600,297,98,39,750,606,859,46,839,51,601,499,176,610,388,358,790,948,583,39] -> None
[0,1,2,3,4] -> [0,1,2,3,4] []
[4,3,2,1,0] -> [] [4,3,2,1,0]
[1,9,2,8,3,7,4,6,5] -> [1,2,3,4,6] [9,8,7,5]
[71414,19876,23423,54252,27658,48671,43245,53900,22339] -> [19876,23423,27658,48671,53900] [71414,54252,43245,22339]
[10,20,30,20,30,40,30,40,50] -> [10,20,20,30,40,40,50] [30,30]
[0,3,7,13,65,87,112,43,22,1] -> [0,3,7,13,65,87,112] [43,22,1]
[7,4,4,7,4,7,7,4,7,4,4,4,7,7] -> [7,7,7,7,7,7,7] [4,4,4,4,4,4,4]
[7,997,991,957,956,952,7,8,21,924,21,923,22,38,42,44,920,49,58,67,71,83,84,85,917,89,907,896,878,878,90,861,115,860,125,128,140,148,858,155,160,836,164,182,826,191,824,805,195,792,205,782,206,210,769,213,756,748,214,745,724,701,234,241,693,268,685,293,679,297,334,671,336,669,341,652,356,648,362,364,370,375,386,630,622,388,389,618,398,408,468,615,470,533,611,539,544,609,586,582,572,565,547,602,536,619,624,528,512,631,640,649,669,671,677,505,678,723,743,489,489,473,454,757,446,445,758,759,764,445,431,770,429,426,418,409,790,383,379,366,363,791,358,795,809,827,835,356,353,841,844,333,867,323,317,879,311,881,309,896,282,281,897,263,904,237,236,226,202,195,914,186,177,917,920,157,926,936,154,138,943,131,945,100,98,947,957,964,95,973,989,57,43,32,21,16,13,11,8,0] -> [7,7,8,21,21,22,38,42,44,49,58,67,71,83,84,85,89,90,115,125,128,140,148,155,160,164,182,191,195,205,206,210,213,214,234,241,268,293,297,334,336,341,356,362,364,370,375,386,388,389,398,408,468,470,533,539,544,586,602,619,624,631,640,649,669,671,677,678,723,743,757,758,759,764,770,790,791,795,809,827,835,841,844,867,879,881,896,897,904,914,917,920,926,936,943,945,947,957,964,973,989] [997,991,957,956,952,924,923,920,917,907,896,878,878,861,860,858,836,826,824,805,792,782,769,756,748,745,724,701,693,685,679,671,669,652,648,630,622,618,615,611,609,582,572,565,547,536,528,512,505,489,489,473,454,446,445,445,431,429,426,418,409,383,379,366,363,358,356,353,333,323,317,311,309,282,281,263,237,236,226,202,195,186,177,157,154,138,131,100,98,95,57,43,32,21,16,13,11,8,0]

Pyth, 34 bytes

.N|!N|&ghNT:tNhNY&gYhN:tNThN:QZ^T5

Test Suite

Uses memoized recursion to keep the runtime down. Defines a 3 input function :, which takes inputs `list suffix, end of increasing sequence, end of decreasing sequence.


Remove duplicates from a String Inspired by this unassuming StackOverflow question.
The idea is simple; given a String and an array of Strings, remove any instances of words in the array (ignoring case) from the input String other than the first, along with any additional whitespace this may leave. The words must match entire words in the input String, and not parts of words.
e.g. "A cat called matt sat on a mat and wore a hat A cat called matt sat on a mat and wore a hat", ["cat", "mat"] should output "A cat called matt sat on a mat and wore a hat A called matt sat on a and wore a hat"
Input

Input can be taken as either a String, and an array of Strings or an array of Strings where the input String is the first element. These parameters can be in either order.
The input String may not be taken as a list of space-delimited Strings.
The input String will have no leading, trailing or consecutive spaces.
All input will only contain characters [A-Za-z0-9] with the exception of the input String also including spaces.
The input array may be empty or contain words not in the input String.

Output

The output can either be the return value from a function, or printed to STDOUT
The output must be in the same case as the original String

Test cases
the blue frog lived in a blue house, [blue] -> the blue frog lived in a house
he liked to read but was filled with dread wherever he would tread while he read, [read] -> he liked to read but was filled with dread wherever he would tread while he
this sentence has no matches, [ten, cheese] -> this sentence has no matches
this one will also stay intact, [] -> this one will also stay intact
All the faith he had had had had no effect on the outcome of his life, [had] -> All the faith he had no effect on the outcome of his life
5 times 5 is 25, [5, 6] -> 5 times is 25
Case for different case, [case] -> Case for different
the letters in the array are in a different case, [In] -> the letters in the array are a different case
This is a test Will this be correct Both will be removed, [this,will] -> This is a test Will be correct Both be removed

As this is code golf, lowest byte count wins!

R, 84 bytes

function(s,w,S=el(strsplit(s," ")),t=tolower)cat(S[!duplicated(x<-t(S))|!x%in%t(w)])

Try it online!

Less than 100 bytes on a string challenge that's not also kolmogorov-complexity?

Explanation:

After we break up the string into words, we need to exclude those that are

duplicates and
in w

or alternatively, turning that on its head, keeping those that are

the first occurrence of a word OR
not in w.

duplicated neatly returns logical indices of those that are not the first occurrence, so !duplicated() returns indices of those which are first occurrences, and x%in%w returns logical indices for x of those which are in w. Neat.


Is today a real weekday? Feb. 6 was a real weekday. Because it lies in the 6th week of the year.
So a real weekday is a day with a a day number that equals the week number.

But not all country have the same counting of weeks. in Germany a week starts with Monday and ends on Saturday in the US they start on Sunday.

Write a program that checks a given date (the format your program likes the best) and a weekstart ('S' or 'M') whether it is a real weekday.

Too simplify things a bit we assume January 1st is always a real weekday because it is in the first week. In Germany it is the last day of week 52)

Some examples of real weekday for a start on Monday:

 2017-01-01
 2017-02-07
 2017-04-17

Some examples of real weekday for a start on Sunday:

2017-01-01
2017-02-06
2017-04-16

Example:

2017-04-16 S Output: YES
20170416M Output: 0

How you enter the Date does not matter, as long as it is human readable. The start day can be given by M or S or 1 or 0.
the Output is a printed boolean Yes, not or Y,N or 0,1

Shortest code wins!

Its my first question I put on this forum, so I'd be happy to hear some comments.

MATLAB, 53 bytes
d=datetime(input(''));week(d-(input('')=='M'))==d.Day

This answer accepts the first input as a string '2017-02-06' and the second input as a string (either 'S' or 'M').

It constructs a datetime object from the first input and saves it in d. We then compute the week number (but first we subtract 1 day from the date if the second input is an 'M' since week uses Sundays by default) and then we compare this week number to the day of the datetime object to yield a boolean.


Create a Winter Bash 2015 hat reminder Input

Two dates, each comprising of a month (Dec or Jan) and a day (01-31). These will be given as 4 integers (12 01 01 01, for example), in any reasonable format you choose (leading zeroes, no leading zeroes, list, individual inputs, list of lists, etc.). The first date is supposed to represent today's date.

Output

If the second input date is Dec 14, output Sufganiyot
If it is Dec 18, output A new hope
For Dec 23, The airing of grievances
For Dec 25, O Tannenbaum
For Dec 31 or Jan 1, Auld Lang Syne
Otherwise output Try some other day! (in which case you will not compare the dates, see below)

This is followed by

, Go and get it! if the first and second input dates are same.
, Wait for it! if the first date comes before the second date.
, But you missed it! if the first date comes after the second date.

Sample runs

Dec 23 Dec 23 -> The airing of grievances, Go and get it!

Dec 28 Jan 1 -> Auld Lang Syne, Wait for it!

Dec 18 Dec 17 -> Try some other day!

Jan 25 Dec 25 -> O Tannenbaum, But you missed it!

Score

This is code golf, so shortest code in bytes wins.

Java, 400 340 333 - 139 = 261 201 194 bytes

I considered these characters "convenient":, Go and get it!, Wait for it!, But you missed it!Try some other day!Auld Lang SyneO TannenbaumThe airing of grievancesA new hopeSufganiyot

Here is the code (called with s(first month number, first month date, second month number, second month date)):

String s(int a,int b,int c,int d){String x="";int e=(a*b!=1)?a*b:372;if(e==372)x="Auld Lang Syne";if(e==216)x="A new hope";if(e==276)x="The airing of grievances";if(e==300)x="O Tannenbaum";if(x=="")return"Try some other day!";int f=(c==1)?372*d:c*d;return x+", "+((e>f)?"Wait for it...":(e<f)?"But you missed it!":"Go and get it!");}

Ungolfed:

static String v(int a,int b,int c,int d){
    String x="";
    int e=(a*b!=1)?a*b:372;
    if(e==372)x="Auld Lang Syne";
    if(e==216)x="A new hope";
    if(e==276)x="The airing of grievances";
    if(e==300)x="O Tannenbaum";
    if(x=="")return"Try some other day!";
    int f=(c==1)?372*d:c*d;
    return x+", "+((e>f)?"Wait for it...":(e<f)?"But you missed it!":"Go and get it!");
}