Programming Tetris Blocks (Literally) In the game Tetris, there are 7 types of bricks or Tetriminoes, which are mathematically known as tetrominoes because they are all made with 4 square segments:

The have the names I, J, L, O, S, T, and Z, that correspond to their approximate shapes. Counting 90° rotations, there are 19 unique shapes in total:

I
I
I
I

IIII

 J
 J
JJ

JJJ
  J

JJ
J
J

J
JJJ

L
L
LL

  L
LLL

LL
 L
 L

LLL
L

OO
OO

 SS
SS

S
SS
 S

TTT
 T

T
TT
T

 T
TTT

 T
TT
 T

ZZ
 ZZ

 Z
ZZ
Z

Challenge

Write a rectangular block of code that acts as the base segment these 19 shapes are made from. When this code is arranged into one of the shapes, a program should be formed that outputs the single uppercase letter associated with that shape. This must work for all 19 shapes.

The leading empty areas present in some of the 19 shapes are filled in entirely with spaces (). The trailing empty areas are not filled with anything (so the programs are not always exactly rectangular).

Example

Suppose this was your code block:

ABC
123

Then either arrangement of the block into the S Tetris piece would be a program that prints S:

   ABCABC
   123123
ABCABC
123123

ABC
123
ABCABC
123123
   ABC
   123

(Notice that all leading empty space is filled with space characters, and that no lines have any trailing spaces.)

The same idea applies to all 6 other pieces and their respective rotations.

Notes

All 19 final programs are to be run in the same programming language.
If desired, you may add a single trailing newline to all programs (not just some, all or none).
Your code block may contain any characters (including spaces) that aren't line terminators.
Output the letter to stdout (or your language's closest alternative) with an optional trailing newline.

Scoring

The submission whose code block has the smallest area (width times height) wins. This essentially means the shortest code wins, which is why this is tagged code-golf. Tiebreaker goes to the highest voted answer.

The ABC\n123 example has area 3×2 = 6.

Snippet

Given a code block, this snippet will generate all 19 programs:

Code Block:
<textarea id='input' rows='8' cols='64'>ABC&#010;123</textarea>
<button type='button' onclick='go()'>Go</button>

All 19 Programs:
<textarea id='output' rows='24' cols='64'></textarea>

<>< (Fish) - 12 * 32 = 384

I was planning to go for a more elegant solution, but I somehow ended up with this, which is pretty brute-force:

c  0  g84*%\
c2*0  g84*%\
0  84*g84*%\
c  84*g84*%\
c2*84*g84*%\
0  88*g84*%\
c  88*g84*%\
?v         \
;>?v~~?vv
"L" o;  >
"S" o; >~?v
"T" o;    >
;  >~?v"L"o
;     >"J"o
?v         \
 >~?v~~?vv
"I"  o;  >
"J"  o; >
    \~~?vv
"T"  o;  >
"Z"  o; >
?v         \
 >?v"J"o;
   >?v"Z"o;
"L"o;>?!v
"J"o;   >?v
"T"o;     >
?v?v"I"o;  >
   >"L"o;
 >?v"T"o;
   >?v"O"o;
     >"S"o;

It's pretty simple, it checks the code in a 3x3 square for text and uses the results to see which tetrimino corresponds to the code's shape. I didn't take a lot of effort to golf it yet.

Try the code here (after using the snippet to shape it like a tetrimino)

Example of code in shape Z (v1) here


Practical Golf - US States My family has an e-commerce business. On our own site, we force people to choose their state from a dropdown menu when they enter their address, but through some other channels we use, customers can enter anything they want into the box.

My mom loves the invoice templates I made for her, which are automagically generated. But because they're so pretty and balanced, she can't stand it when people WRITE OUT the names of their states, or worse, write something like "new jersey." She says it ruins the look.

My dad likes code to be lightweight. So rather than using a switch-case block, he wants a leaner solution.

So the challenge is to make a short function that takes the possible inputs and returns a two letter abbreviation (capitalized, for Mom). We're going to make a (faulty) assumption that our users can spell and always put a space in the name (where needed) or pass in the correct abbreviation. The scope is the 50 US states.

New York
new york
NY
ny

are all acceptable inputs for New York, and should output NY.

If something like New Yrok is passed in, the function can return the original value.

You can use any common language. This is a popularity contest, so the one with the most votes at the end of a week wins. I assume that this will favor novelty and utility.

EDIT: The description is story fluff, but I was working a similar project and thought that there must be a more interesting way to do it. I can do the project myself (already did) but I thought this was a good place for a more interesting challenge. By "Any common language" I was excluding custom languages/libraries designed for this challenge - I was trying to look for novel methods, rather than free code help. I figure everyone has done this at some point, but it would be fun to do it in an unusual way. I find that the most interesting projects are the ones where you tackle everyday tasks in new and interesting ways - that's why this is a popularity contest rather than golf.

Ruby

Thought it would be interesting to extract the state abbreviations without writing any of the names or abbrevations explicitly. This one does not take misspelling of the input into consideration, because we don't care about such thing here on codegolf.SE, rihgt?

def f(s)
  [
    /(.).* (.)/,              # two words
    /^([CDGHKLPV]).*(.)$/,    # first and last letter
    /^(.).*([ZVX])/,          # unique letter
    /^([NFOUW])(.)/,          # two first letters
    /^(.)([DNR])/,            # unique second letter
    /^(.).*(L|N)\2/,          # double letters
    /^(.).SS(A|O)/,           # double S before the one used
    /^(.).*?[SNW](.)/,        # identified by the letters before them
    /(.)(.)/                  # two first letters

  ].find { |r| r =~ s.upcase }
  $1+$2
end

It took a conciderable time to figure out clever patterns to match all the states. The order of the patterns is important -- each consecutive pattern applies to the remaining states that were not matched by a previous pattern:

All states with two words in them use the initial letters of the two words:

  New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Rhode Island, South Carolina, South Dakota, West Virginia

All states beggining with any letter in {CDGHKLPV} use the first and last letter in the name:

  California, Colorado, Connecticut, Delaware, Georgia, Hawaii, Kansas, Kentucky, Louisiana, Pennsylvania, Virginia, Vermont

Of the remaining states, the letters {ZVX} are unique:

  Arizona, Nevada, Texas

All remaining states beginning with {FNOUW} use the two first letters.

  Florida, Nebraska, Ohio, Oklahoma, Oregon, Utah, Washington, Wisconsin, Wyoming

Then, {DNR} are unique as second letters:

  Arkansas, Indiana, Idaho

It's really getting hard to make general patterns, but...

Only three remaining states use double N or L, and the double letter is used in the state abbreviation:

  Tennessee, Minnesota, Illinois

A or O after double S is unique to

  Massachusetts and Missouri

Whenever {SNW} appear before other letters in the remaining state names, the letters after them are used in the abbreviations:

  Alaska, Maryland, Maine, Mississippi, Montana, Iowa

Two left. These use the two first letters:

  Alabama, Michigan

It can be golfed of course:

Ruby 2 – 191 165 154 characters

Another 26 characters off by uglifying the regexes a bit. Also, one of the original regexes turned out to be redundant!

gets;[/.* (.)/,/^[CDGHKLPV].*(.)$/,/.*([ZVX])/,/^[NFOUW](.)/,/^.([DNR])/,/.*(L|N)\1/,
/.*SS(A|O)/,/.*?[SNW](.)/,/.(.)/].find{|r|$_.upcase=~r}
puts $&[0]+$1


Home improvement for the Minotaur Home improvement for the Minotaur

The cretan labyrinth is quite easy to draw. Just start with a symmetric shape (here in red). Let us call all the endpoints of those lines 'nodes'. Then you begin drawing the arches (black): The first one alway begins in the top middle node and connects to the node next to it on the right side, then the two nodes closest to the previous arch are connected. This is repeated untill all nodes are covered.

Now we can generalize this concept: We can easily generate new initial patterns by adding more L shapes. I enumerated the initial shapes as follows:

The most left pattern will produce a cretan labyrinth of degree 0. The next one will create a cretan labyrinth of degree 1 (the original one) etc.
Task
Given a nonnegative integer n, your program should output the ascii representation of a cretan labyrinth of degree n, that is shown in the following examples. Trailing spaces/newlines do not matter. You have to include a short explanation of how your code works.
Examples
The output for the original cretan labyrith (degree 1) is following:
+-----------------------------+
| +-------------------------+ |
| | +---------------------+ | |
| | | +-----------------+ | | |
| | | | +-------------+ | | | |
| | | | | +---------+ | | | | |
| | | | | | +-----+ | | | | | |
| | | | | | | +-+ | | | | | | |
| | | | | + | | | + | | | | | |
| | | | +---+ | +---+ | | | | |
| | | +-------+-------+ | | | |
| | +-------+ | +-------+ | | |
| +-------+ | | | +-------+ | |
+-----------+ | +-----------+ |
              +---------------+

Initial pattern:
+ | | | +
--+ | +--
----+----
--+ | +--
+ | | | +

The cretian labyrinth of degree 0 should look like so:
+-------------+
| +---------+ |
| | +-----+ | |
| | | +-+ | | |
| | + | + | | |
| +---+---+ | |
+---+ | +---+ |
      +-------+

Initial pattern:
+ | +
--+--
+ | +

Perl 5, 349 bytes

say$p="| "x$_,"+","-"x(16*$n-4*$_+13),"+ $p"for 0..4*($n=pop)+3;say$p="| "x(3*$n+2),"+ | ","| "x2x$n,"+ $p|";$p=~s/..//,$q="-"x(4*$_-1),say"$p+$q+ ","| "x(2*$n-2*$_+1),"+$q+ $p|"for 1..$n;$p=~s/..//;say$p,("+---"."-"x4x$n)x2,"+ $p|";$p=~s/..//,$q="-"x(4*$n+3)."-"x4x$_,say"$p+$q+ | ","| "x2x($n-abs$_),"+$q+ $p|"for-$n..$n;say" "x(8*$n+6),"+----$q+"

(Pass n as a command line argument.)

Computes the maze line-by-line in six sections:

first 4n + 4 lines,
next line (the only line with no -),
next n lines,
next line (the line at the middle of the initial pattern),
next 2n + 1 lines,
final line (the line with leading spaces).


Anagram Quines (Robbers' Thread) This is a cops-and-robbers challenge the Cops' Thread can be found here
Your challenge, as robbers is to take outputs from the cops' thread and find anagrams of the output that when run as a program output the original output provided.
The winner will be the person with the most valid cracks on this question.
Rules

You may not crack answers marked as safe with a provided program.

If a cop provides a language that the intended solution is in you must crack it in that particular language, if they choose not to you may crack it in any competing language.

Standard rules for Quines apply.

Cracks must not be perfect Quines. i.e. they must not output their exact source but a reordering of it (the order is provided by the cop).


Insert semi-sorted into unsorted array Welcome to your first day at PPCG Inc. As our newest junior assistant document sorter, you are responsible for making sure all documents we sent down to you are archived in alphabetical order. It's so easy a monkey can do it. Well, metaphorically speaking, as we did hire a monkey to do it. Guess what? Turns out monkeys lack an understanding of our alphabet. Anyway, there's no time to fix the mess there is right now, so just try to not make the situation any worse, ok? Then get to it! If you get hungry, there's bananas over by the water cooler. Good luck!

Job Description

Input

You will receive a list of strings (the archive) and a string that needs to be added to that list (the document)
All strings will contain only uppercase letters, lowercase letters and spaces
Strings will always start and end with a letter

Task

Determine the target position of the document: the position it should receive in the archive. The target position can be determined as follows:

For each position:

Count the amount of strings in the archive before that position that are alphabetically before the document
Count the amount of strings in the archive after that position that are alphabetically after the document
Define the score of the position as the sum of the above two counts

The target position of the document is the position with the highest score
In case of a tie, all positions with the highest score are equally valid as target position. Only one needs to be selected.

When sorting:

Uppercase and lowercase letters are equivalent
Spaces come before letters

Output

The archive with the document added to it in any form

OR

The target position of the document, in either a 0-based or 1-based index

Job evaluation

Fewest bytes wins!

Example I/O

Archive:
    Applebuck Season
    Friendship is Magic
    The Ticket Master
    Griffon the BrushOff
    Boast Busters
    Bridle Gossip

Document: Dragonshy

Position scores (0-based index):
0: 0 + 3 = 3
1: 1 + 3 = 4
2: 1 + 2 = 3
3: 1 + 1 = 2
4: 1 + 0 = 1
5: 2 + 0 = 2
6: 3 + 0 = 3

Target position: 1

JavaScript (ES6), 81 bytes

(a,d)=>a.map((e,i)=>d[l="toLowerCase"]()<e[l]()?s--:++s>m&&(++m,p=++i),m=s=p=0)|p

Ungolfed:

function position(archive, document) {
    var score = 0;
    var max = 0;
    var pos = 0;
    var i = 0;
    while (i < archive.length) {
        if (archive[i++].toLowerCase() > document.toLowerCase()) {
            score--;
        } else {
            score++;
            if (score > max) {
                max++;
                pos = i;
            }
        }
    }
    return pos;
}

Edit: Saved a lot of bytes thanks to @user81655.


The Great Pyramid of ASCII Introduction
It's 2600 BC and people are building pyramids now. They already made the basis of the pyramid but don't know how to continue. So, they called you for help.
The rules of making a pyramid is quite simple. For the layer above the previous layer, all you need to do is follow this step-by-step hand guide:

Cut the edges off the previous layer.

Above the / character, there must be a \ character and vice versa. This applies to every character except the edges.

The leftmost character is always a / and the rightmost character is always \.

Let's take an example of a basis for a pyramid:
//\/\/\\

We cut off the edges, leaving:
 /\/\/\

We change the forward slashes with backward slashes and vice versa:
 \/\/\/

The leftmost character is always a / and the rightmost character is always a \, so we change that:
 //\/\\

We place this layer on the previous layer:
 //\/\\
//\/\/\\

We continue until the top is reached (which looks like /\). So, eventually we get:
   /\
  //\\
 //\/\\
//\/\/\\

This is what you need to output.
The task
Given the basis of a pyramid (with a length greater than 3), output the full pyramid. You can safely assume that the leftmost character is / and the rightmost character is a \. You can also assume that the length of the basis is always even. The use of trailing spaces is allowed. The use of leading spaces is also allowed, as long as the pyramid stays in place. The use of 1 trailing and 1 leading newlines is allowed.
Test cases
Input: /\\\
Output:
 /\
/\\\

Input: //\\///\/\
Output:
    /\
   /\\\
  /\///\
 ///\\\/\
//\\///\/\

Input: /////////////\
Output:
      /\
     /\\\
    /////\
   /\\\\\\\
  /////////\
 /\\\\\\\\\\\
/////////////\

This is code-golf, so the submission with the least amount of bytes wins!


Random Golf of the Day #3: Integer Partitions About the Series

First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information about the series in the first post.

Although I have a bunch of ideas lined up for the series, the future challenges are not set in stone yet. If you have any suggestions, please let me know on the relevant sandbox post.

Hole 3: Integer Partitions

Time to increase the difficulty a bit.

A partition of a positive integer n is defined as a multiset of positive integers which sum to n. As an example if n = 5, the following partitions exist:

{1,1,1,1,1}
{2,1,1,1}
{2,2,1}
{3,1,1}
{3,2}
{4,1}
{5}

Note that these are multisets, so there is no order to them, {3,1,1}, {1,3,1} and {1,1,3} are all considered identical.

Your task is, given n, to generate a random partition of n. Here are the detailed rules:

The distribution of partitions produced must be uniform. That is, in the above example, each partition should be returned with probability 1/7.

Of course, due to the technical limitations of PRNGs, perfect uniformity will be impossible. For the purpose of assessing uniformity of your submission, the following operations will be regarded as yielding perfectly uniform distributions:

Obtaining a number from a PRNG (over any range), which is documented to be (approximately) uniform.
Mapping a uniform distribution over a larger set of numbers onto a smaller set via modulo or multiplication (or some other operation which distributes values evenly). The larger set has to contain at least 1024 times as many possible values as the smaller set.

Since the partitions are multisets you may return them in any order, and this order does not have to be consistent. However, for the purpose of the random distribution, the order is ignored. That is, in the above example, {3,1,1}, {1,3,1} and {1,1,3} together must have a probability of 1/7 of being returned.
Your algorithm must have a deterministic runtime. In particular, you cannot generate random multisets and reject them if they don't sum to n.
Your algorithm's time complexity must be polynomial in n. In particular, you cannot simply generate all partitions and select a random one (since the number of partitions grows exponentially with n). You may assume that the PRNG you're using can return uniformly distributed values in O(1) per value.
You must not use any built-in function which solves this task.

You may write a full program or a function and take input via STDIN or closest alternative, command-line argument or function argument and produce output via return value or by printing to STDOUT (or closest alternative).

You may assume that n ≤ 65 (such that the number of partitions is less than 221). Output may be in any convenient, unambiguous list or string format.

If you submit a function, please consider also providing a little test program which calls the function a number of times and prints the results. It's okay if the parameters have to be tweaked in the code. This is just so people can check that the solution is at least approximately uniform.

This is code golf, so the shortest submission (in bytes) wins. And of course, the shortest submission per user will also enter into the overall leaderboard of the series.

Leaderboard

The first post of the series generates a leaderboard.

To make sure that your answers show up, please start every answer with a headline, using the following Markdown template:

# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

# Ruby, <s>104</s> <s>101</s> 96 bytes

(The language is not currently shown, but the snippet does require and parse it, and I may add a by-language leaderboard in the future.)

Python 2, 179 bytes
from random import*
m=r=input();i=q=r+1;h=[1]+[0]*q*q;exec"h[i]=h[i+~q]+h[i-i%q*q];i+=1;"*r*q
while r:
 x=random()*sum(h[r*q:r*q-~m]);m=0
 while x>0:m+=1;x-=h[r*q+m]
 print m;r-=m

I used formula (39) from this Knuth extract, which gives the number of partitions of n that have exactly m parts. This happens to equal the number of partitions of n that have m as the maximum element, which is the interpretation I'm using. The elements of the partition are generated from greatest to least. At each stage the formula is reused with the current remainder of n and maximum allowed element.


Capture on the Pawn Chessboard You should write a program or function which receives a string representing a chessboard with only pawns as input and outputs or returns whether any capture is possible on the board.

Input is in a FEN-like notation describing positions of white and black pawns with no other pieces present. You should decide if there is a pawn which can capture an enemy one.

  Each rank is described, starting with rank 8 and ending with rank 1; within each rank, the contents of each square are described from file "a" through file "h". Each pawn is identified by a single letter (white pawn = "P", black pawn = "p", ). Empty squares are noted using digits 1 through 8 (the number of empty squares), and "/" separates ranks. (partially taken from Wikipedia)

For example

8/pppppppp/8/8/4P3/8/PPPP1PPP/8

describes the board

--------

pppppppp

    P

PPPP PPP

--------

A white pawn can capture a black one if the black one is positioned diagonally up from it (black is up-left or up-right) and a black pawn can capture a white one if the white one is diagonally below from it (white is down-left or down-right). No other capture move (en passant) should be considered.

Input

A FEN-like string consisting of the characters 12345678pP/.
The input describes the pawns of a valid chess game position. This means (among other more complex constraints) there will be at most 8 pawns for each side and no pawns on ranks 1 and 8.

Output

If there is a possible capture for either side you should output a truthy value and a falsy value otherwise.

Examples

Inputs with truthy output (one per line)

8/7p/6P1/8/8/8/8/8
8/8/p7/1P6/3P3p/8/8/8
8/2P5/8/4P1p1/2p2P2/3p4/3p1P2/8
8/P7/8/5P2/2pp4/3P2p1/3pP3/8
8/P7/p7/p1P1P3/1P3p2/8/1p6/8
8/4p1P1/2P2P1P/2p1pPpp/8/6P1/pP1p4/8

Inputs with falsy output (one per line)

8/8/8/8/8/8/8/8
8/7P/6p1/8/8/8/8/8
8/7p/7P/8/8/8/8/8
8/pppppppp/8/8/8/8/PPPPPPPP/8
8/p7/8/1p6/5P2/8/8/8
8/p7/P7/2P1p1p1/2p5/8/PP6/8

This is code golf so the shortest entry wins.

Retina, 33 29 bytes

T`d`w
)`\d
$0.
_

p.{7}(..)?P

To run the code from a single file, use the -s flag.

Should be easily beatable by something like Perl where the expansion of digits into strings of spaces (or other characters) doesn't take up 17 bytes.

The output is positive (truthy) if there is a possible capture and zero (falsy) if there isn't.

Explanation

T`d`w
)`\d
$0.

This is a loop of two stages. The first one is a transliteration stage which decrements each digit, and turns zeroes to underscores. Why? Because d and w expand to the following two lines:

0123456789
_0123456789AB...YZab...yz

If the target set of a transliteration stage is longer than the source set, the extraneous characters are ignored, hence the decrementing behaviour (honestly, it was just luck that I decided to put the underscore in front of the digits when expanding the w character class).

Then the second stage is a replacement, which appends a . to each digit. That means that for each digit n, n periods are added before that digit is turned into an underscore.

_
<empty>

This just gets rid of the underscores.

p.{7}(..)?P

Finally, we find the matches. Since we're ignoring en passant, captures are only possible if there is a p and then a P diagonally below it. In the linear string, this simply means that there must be 7 or 9 characters between the two pawns. This matched with .{7}(..)? (i.e. match 7 characters and then, optionally, match another two).

Such a match stage returns the number of matches it found.


Build a fewest-moves freecell solver In the game of Freecell, you are tasked with building four foundation piles in suit from ace to king, on a layout where you build downward in alternating colours. However, you can only build one card at a time, so you are given four "free cells" each of which can contain one card to help you move entire sequences. The idea is that you weave individual cards in and out of the free cells as required to help you solve the game.

Your task is to build a program that will solve these games in the fewest moves possible.

Your program will take as input a sequence of 52 cards, in the following format:

2S 9H 10C 6H 4H 7S 2D QD KD QC 10S AC ...

Which will be dealt in the initial layout in this order:

01 02 03 04 05 06 07 08
09 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52

And return a list of moves to solve the game. Each move will be in this format:

A number representing the pile number (1 through 8), or a free cell (A to D), representing the source pile.
Another number or letter representing the destination pile or free cell, or F for the foundation of that suit.

The output will look something like this:

18 28 3A 8B 8C 85 B5 35 4F etc.

Once a card is put into the foundation, it cannot be removed. Since only one card is moved at a time, moving a sequence of 3 cards requires 5 moves, and a sequence of 5 cards requires 9 moves.

If a game is unsolvable, your program should indicate as such. However, your program must be able to solve any solvable game.

Your program will be judged on the 32,768 deals found in the original Microsoft FreeCell program. In order to be valid, your program must successfully solve every deal except deal #11,982, which is unsolvable. Your score will be the total number of moves it takes to solve these 32,767 deals, with shorter code being a tie-breaker.

A file with all the decks in the format required by the above specification is available for download here (5.00 MB file): https://github.com/joezeng/pcg-se-files/raw/master/freecell_decks

C 64,643 bytes, Score: ~6.5 million
The following Stack Snippet (courtesy of Mego) outputs all of the code as a single standalone C file:

$("#a").text(pako.inflate(atob('[encoded data, 7512 characters]'), {to: 'string'}));
<script src="https://cdn.rawgit.com/nodeca/pako/master/dist/pako.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<pre id="a">

</pre>

Download the original source here.
Use GCC and run make then using the guideline in the readme.
My formatting is bad (all the different files are in one code block) and this could be golfed more (12k bytes tho). Any help would be loved!
Some of the code is not mine. I used it from a un-copyrighted source. I however fixed the input/output method to be within the challenge (a long task since I am horrible at C (5ish hours)). I also had to re-write much of the code and debug everything. Many thanks to my Dad for helping out and being a rubber duck (and pointing out my memory management errors) and for everyone on TNB who dealt with my angry rants about segfaults and C.


For a given period, getting the smallest list of dates, using jokers Consider a date formatted in YYYY-MM-DD.
You can use the joker * at the end of the date string. E.g. 2016-07-2* describes all the dates from 2016-07-20 to 2016-07-29.

Now, consider a period represented by a start date and an end date.

The algorithm must find the smallest possible list of dates representing the period.

Let's use an exemple. For the following period:

start date: 2014-11-29
end date: 2016-10-13

The algorithm must return an array containing the following list of dates:

2014-11-29
2014-11-30
2014-12-*
2015-*
2016-0*
2016-10-0*
2016-10-10
2016-10-11
2016-10-12
2016-10-13

PHP, 541 343 bytes
I wanted to get the algorithm working in the first place; but golfing it down was actually far more fun than I expected (especially browsing the supported date & time formats).
Three major actions saved about 130 bytes; but the 70 bytes from minor golfings
(which also rendered one of the large steps obsolete) carried a lot of fun.
for($a=($f=strtotime)($argv[1]);!$p=$a>$z=$f($argv[2]);$a+=86400){$x=$z<$e=$f(Dec31,$a);(101<$q=date(md,$a))?$q-1001|$x?:$a=$e+$p="1*":($x?($t=$f(IX30,$a))>$z?:$a=$t+$p="0*":$a=$e+$p="*");$p?:($q%100>1|$z<($t=$f(date(Ymt,$a)))?$q%10>0&$q%100>1|$z<($t=min($t,$a+777600))?:$a=$t+$p="m-$q[2]*":$a=$t+$p="m-*");echo date("Y-".($p?:"m-d"),$a),"
";}

takes input from command line arguments. Run with -nror test it online.
notes

prints Y-m-3* for Y-m-30; add 7 bytes to fix: Insert |$a==$t after 777600)).
throws warnings in PHP 7.1; add 5 bytes to fix: Replace +$p with +!$p.
A breakdown and some golfings explained are ready to be posted;
but I´ll wait a bit to see if someone else submits before I spoil.


Draw the combinations that add up to 100 You have a box with a single digit number in each corner:

1|2
---
3|4

If we concatenate the digits along rows left to right, we get 12 and 34. If we concatenate the digits along columns top to bottom, we get 13 and 24. If we add all of these numbers, we get 12+34+13+24 = 83.

Challenge

Write a program to print all such boxes where the sum calculated as above is equal to 100.

Assuming each corner contains a single digit number between 1 and 9, there are 9 combinations: 1157, 1247, 1337, 1427, 1517, 2138, 2228, 2318, and 3119. (Note that there are 25 combinations if we include 0, but we're not for this challenge.)

Note that the example 1234 doesn't work since 12+34+13+24 does not equal 100.

Input

None

Output

Answer boxes in the following format:

A|B
---
C|D

Output should be printed to STDOUT or closest alternative.

Rules

AB + CD + AC + BD = 100
Each corner will contain the positive integers 1-9 only.
0 is excluded.
Numbers can be used more than once.
You need to draw the boxes, as above. (A|B\n---\nC|D\n)
You need to output all valid answers.
An additional trailing newline is fine.
code-golf, so shortest code in bytes wins.
Standard loopholes and T&C's apply.

This is my first submission so please do let me know if I need to clarify anything.

Pyth, 42 38 34 bytes
V^ST4IqC\ds*VNsM^,T1 2Xj\|N3"
---

The trailing newline in the code is important. The main reason I'm competitive is because I use the vector dot product of [1, 1, 5, 7] and [20, 11, 11, 2] and compare it to 100.


Count how many months are having a full 31 days by counting knuckles How many of you that still use your own knuckle to determine whether a month is having a full 31 days or less?
You job is to write a program to count how many months, in a month range, are having a full 31 days and how many are having less than 31 days by "counting the knuckles".

Courtesy: amsi.org.au

Input
A pair of months, the first of which doesn't have to come chronologically before the second, given in any suitable format. For instance: 201703 201902 — March 2017 to February 2019. Please describe the input format you choose. Note that the input must be able to include all years from 1 to 9999. The range of months specified includes both the starting and ending months.
Output
Two integers: the number of months in the given range with 31 days and the number of months in the range with less than 31 days.
Example: 14 10 — 14 knuckles, 10 grooves (it means that in that month range we have 14 months that have a full 31 days, and 10 months that have less than 31 days).
For an input where the second month in the range comes chronologically before the first, for example 201612 201611, you have to output a pair of zero.
Examples of input and output
| Input         | Output      |
|---------------|-------------|
| 201703 201902 | 14 10       |
| 201701 202008 | 26 18       |
| 000101 999912 | 69993 49995 |
| 201802 201803 | 1 1         |
| 201601 201601 | 1 0         |
| 201612 201611 | 0 0         |

Rules

You may choose any language you like
One input per line
This is code-golf, so shortest code in bytes wins!
The winner will be chosen in April 9
Standard loopholes apply
PS: this is my first question in PCG, it might have some inconsistencies. Feel free to edit and confirm what's unclear for you.

Jelly, 21 bytes

ḅ12r/ị7RḂṁ12¤żC$S×⁼Ṣ$

Takes input like [[y, m], [y, m]].

Try it online!

How it works

ḅ12r/ị7RḂṁ12¤żC$S×⁼Ṣ$  Main link. Argument: [[a, b], [c, d]]

ḅ12                    Unbase 12; yield [x, y] := [ 12a + b, 12c + d].
   r/                  Reduce by range; yield [x, ..., y].
           ¤           Combine the five links to the left into a niladic chain.
      7                  Set the return value to 7.
       R                 Range; yield [1, 2, 3, 4, 5, 6, 7].
        Ḃ                Bit; yield [1, 0, 1, 0, 1, 0, 1].
         ṁ12             Mold 12; repeat the Booleans to create an array of length
                         12. Yields [1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1].
     ị                 At-index; yield the elements of the array to the right at
                       the indices (1-based and modular) of the array to the left.
               $       Combine the two links to the left into a monadic chain.
              C          Complement; map t -> 1-t over the array.
             ż           Zip the original array with the complements.
                S      Take the sum of each column.
                    $  Combine the two links to the left into a monadic chain.
                  Ṣ      Sort [[a, b], [c, d]].
                   ⁼     Compare the result with [[a, b], [c, d]], yielding 1 if
                         the input is sorted, 0 if not.
                 ×     Multiply the results to both sides.


The sum of some parts Challenge
Given a list of keys and values, and a target n, return all sets of keys where the sum of their values equals or exceeds n.
Input
Input will be like this:
[["Part 1", 20], ["Part 2", 15], ["Part 3", 14.75], ["Part 4", 3]], 30

Input consists of a list with keys (which can be any kind of string) and values (which can be any kind of decimal). Also, a number n is supplied as the target.
You may take these inputs in any format you like, in any order etc. It needs to support strings, numbers (with decimal precision and possibly negative).
The target might be positive, negative or zero. The list will always contain at least 1 KV-pair.
Each key is guaranteed to be unique. Each value <> 0. Different keys can have the same value. It is not guaranteed that a list holds a satisfactory combination.
Output
The expected output is a list of lists with all keys that have a combined value >=n. Each set that manages to satisfy this condition needs to be shown in a clearly distinguishable group, for example by separating them with brackets or newlines.
Sample output for the above input:
Part 1, Part2
Part 1, Part 3
Part 1, Part2, Part 3
Part 1, Part2, Part 4
Part 1, Part3, Part 4
Part 1, Part2, Part 3, Part 4
Part2, Part 3, Part 4

Note that each combination needs to be unique. The output doesn't need to be sorted, but part 1, part 2 is considered a duplicate of part 2, part 1 and should not be shown twice.
Additional rules

Standard loopholes are forbidden
Answer must be a full program or a function, not a snippet or a REPL-entry.
code-golf, shortest answer in bytes wins.

05AB1E, 10 bytes

æʒø`O²‹_i,

Try it online!

Explanation

æ           # compute powerset of input
 ʒ          # filter out falsy values (we don't actually filter, it just saves a byte)
  ø         # zip into a list of keys and a list of values
   `        # push separately to the stack
    O       # sum values
     ²‹_i   # if not less than input_2
         ,  # print list of keys


Minecraft Chest Placement The video game Minecraft is all about placing and removing different types of blocks in the 3D integer lattice that makes up the virtual world. Each lattice point can contain exactly one block or be empty (an "air" block officially). In this challenge, we will only be concerned with one horizontal 2D plane of the 3D world, and one type of block: chests.

Chests let players store items. When two chests are orthogonally adjacent in the same horizontal plane, their textures link up and a double chest with twice the capacity forms. Nothing bigger than a double chest can be made; there are no triple chests nor quadruple chests.

A chest block can only be placed in an empty lattice point if its four orthogonally adjacent points are all empty, or if exactly one contains a chest block that is not already part of a double chest. These placement rules ensure that there can never be any ambiguity about which chest blocks link to form double chests.

For example, suppose . is empty space and C is a chest: (The numbers are also empty space and just for identification purposes.)

.......C..
.1.C2.C3..
........5C
.CC4..CC..
..........

A chest can be placed in spot 1 because its 4 neighbors are empty.
A chest can be placed in spot 2 because the neighboring chest is not (yet) part of a double chest.
A chest can't be put in spot 3 because there would be ambiguity over how the double chest forms.
A chest can't be placed in spot 4 because the neighboring chest is already part of a double chest.
A chest can be placed in spot 5. The diagonally neighboring double chest doesn't affect anything.

Assuming the area beyond the grid is empty, changing every . in the grid to a * if a chest could be placed there results in this:

******.C**
***C**C.**
*..***..*C
.CC.*.CC.*
*..***..**

Not all of the * spaces can be occupied with chests at the same time of course, but if you only had one chest, it could be placed in any of them.

Challenge

Write a program or function that takes in a . and C grid, and changes every . to a * if a chest could be placed there, printing or returning the resulting grid.

Input can be from stdin or a file or as a string argument to a function.
You may assume the input is well formed - i.e. a perfectly rectangular grid of text, at least 1 character wide and tall, only containing . and C You may optionally assume there is a trailing newline after the last row (and there may be one in the output).
You may assume the arrangement of chests in the input is consistent with the rules above. There will never be ambiguities about which chests form double chests.
If desired, you may use any three distinct printable ASCII characters in place of ., C, and *. You may not use something else in place of newlines.
All the chests are normal chests. Not trapped chests or ender chests.

Scoring

The submission with the fewest bytes wins.

For a Minecraft related challenge that's a bit more challenging, try Nether Portal Detection.

CJam, 82 76 66 62 58 54 bytes

qN/::~4{[8_]f/[9_]f*z{[{1$8-g)+}*]W%}%}*{_8<\2<8?}f%N*

Input format expects 0 for air cell and 8 for a chest cell. Output contains 1 for all cells that can be placed with a Chest.

UPDATE : Fixed a bug. Increased by 3 bytes :( golfed further :) . 4 bytes saved thanks to @Sp3000

Example input:

0000000800
0008008000
0000000008
0880008808
0000000000

Output:

1111110811
1110018010
1008800108
0880088008
1008800110

I think I am done golfing for now...

Explanation

qN/::~                   "This part converts the input into array of integer array";
qN/                      "Split input on new line";
   ::~                   "Parse each character in each row as integer";

4{[8_]f/[9_]f*z{[{1$8-g)+}*]W%}%}*

4{   ...z{       W%}%}*  "Run the logic 4 times, first, columns in correct order, then,";
                         "columns in reverse order, then for rows";
  [8_]f/[9_]f*           "Convert adjacent chests represented by two 8 into two 9";
                         "This happens for all the rows in the columns iterations and";
                         "for all the columns in the rows iterations";
  {               }%     "For each row/column";
   [{        }*]         "Reduce and wrap it back in the array";
     :I8-                "Store the second number in I, remove 8 from it";
         g               "Do signum. Now we have -1 for < 8 number, 0 for 8 and 1 for > 8";
          )+I            "Increment to get 0, 1 & 2. Add it to first number and put I back";

{_8<\2<8?}f%N*           "This part converts the output from previous iterations";
                         "to 3 character based final output and prints it";
{        }f%             "Map each row using the code block";
 _8<   8?                "If the value is greater than 7, make it 8, else:";
    \2<                  "If the value is greater than 1, make it 0, else 1";
            N*           "Join the arrays using new line";

Try it online here


Help the poor Cryptographers - DLP Edition Introduction and Motivation
I'm mainly active on Cryptography.SE and as such have already stumbled across the question: "How the hell am I supposed tools like cado-nfs to do stuff!?". They are super-complicated tools for a super-complicated task: Factoring large integers and computing large-scale discrete logarithms.
Now I'm standing here (in a metaphoric sense) and I am asking you:
Please give us poor cryptographers a usable tool. :(
This question in particular is about the discrete logarithm problem which was broken by Logjam, is frequently used in the world of online security and you're supposed to solve it (as far as current technology goes)!
Specification
Input
Your input will be three (potentially) large numbers: A generator, a prime and an argument. The integer encoding should be hex or decimal big-endian. Additionally you may require arbitrary generator and prime dependent state (a bunch of pre-calculations and stuff). The generators, primes and arguments for the score evaluation will not be public. But there will be several arguments for one set of generators and primes so caching does make sense here.
Output
The output is supposed to be one (potentially large) integer, the discrete logarithm of the argument to the base of the generator in the field defined by the prime. Additionally you may output intermediate state that will speed-up future calculations.
What to do?
Using any library, tool and language you like (no online-services), hit the lowest time of execution for calculating the (correct) discrete logarithm. The parameters will be:

There will be three pairs of random (safe) prime and an appropriate (small) generator
Each pair will receive three distinct (random) arguments, for the latter two, intermediate state will speed things up significantly
The tests will be run on an AWS EC2 c4.large instance
The tests will use 332-bit (100 decimal digit) primes and arguments

Who wins?
This is fastest-code so the fastest code wins!
Submissions are evaluated earliest three days after lack of activity (these evaluations cost money!) and clearly inefficient submissions will not be evaluated at all.
OS: The submittant has the choice between the default Amazon-provided OSes which are Windows Server (2003 R2 - 2012 R2 Base), Red Hat Enterprise Linux 7.2, SUSE Linux Enterprise Server 12 SP1, Ubuntu Server 14.04 LTS, Debian 8 Jessie (community AMI), CentOS (6 or 7; community AMI) additionally the submittant can link to or provide instructions on using / creating a custom Amazon Machine Image (AMI) for testing
Installation instructions or links to those need to be provisioned.
(Potentially) Helpful resources:

Cado-NFS
The GNFS, the mainly used algorithm for this

Cado-nfs is the right tool to use.

It provides abstract enough way of handling any case, but relies on input specific optimizations that cannot be done by the program anyway.

There is no general (applicable to anything with same efficiency) solution (even theoretical one) for NFS that can be implemented in program at the moment.

Judging by the work done in CADO-nfs, simply coming up with a good enough algorithm for just 100 digit number would take several months of research before any programming can be done.

You should ask around on CADO-nfs forums, there were at least couple of tests mentioning 103-104-digit algorithms, that might be more useful.

If nfs is not a strict requirement, you could mention it in question.
Sadly, I cannot comment yet; and no, I am far from specialist in any of the areas.


Print the sizes of intervals inside of a piece of music Background

In Western music, every single music note has an assigned name. Within each octave, there are twelve unique notes in the following order: "C C#/Db D D#/Eb E F F#/Gb G G#/Ab A A#/Bb B C", where the final C is one octave above the first.

To tell the difference between notes of different octaves, a number (for this challenge restricted to a single digit) is appended to the end of the note name. Thus, C5 is the note that is one octave above C4. Bb6 is above B5.

An important fact is that B5 and C6 are notes that are right next to each other, and that C0 and B9 are the lowest and highest notes.

Between any two notes, there is a distance which is the number of semitones between them. Bb4 is one semitone below B4, which is itself one semitone below C5. There are twelve semitones in an octave, so Bb4 is a distance of 12 from A#3 since it is an octave above it (notice how a single note can have up to two names).

The Challenge

Your challenge is to write the shortest possible program that can take a list of music notes from STDIN and print the list of interval changes to STDOUT.

Input will be a space-separated list of music notes. Each note will consist of an uppercase letter A-G, an optional b or # sign, and a single digit number. You will not have to deal with E#/Fb or B#/Cb. Example input:

C4 D4 E4 F4 G4 A4 B4 C5 C4

Output will be a space-separated list of integers which represent the distance between each successive note, always prefixed with an + or - to show whether the note was ascending or descending relative to the one before it. There will always be one less number outputted than notes inputted. Example output for the above input:

+2 +2 +1 +2 +2 +2 +1 -12

Some more example inputs:

E5 D#5 E5 B4 E5 F#5 E5 B4
C0 B0 Bb1 A2 G#3 G4 F#5 F6
G4 Ab4 Gb4 A4 F4 A#4

And their corresponding outputs:

-1 +1 -5 +5 +2 -2 -5
+11 +11 +11 +11 +11 +11 +11
+1 -2 +3 -4 +5

Rules and Restrictions

The winner is determined by the number of characters in the source code
Your program should consist of only printable ASCII characters
You are not allowed to use any sort of built-in function that is related to music or sound
Other than that, standard code golf rules apply


Tips for golfing in Logo Logo is a programming language that was designed back in 1967 that has great potential for creating graphics in relatively few bytes compared to other languages.

Logo is an educational programming language that utilizes Turtle Graphics.

There are multiple interesting implementations of Logo including:

Apple Logo
Atari Logo
LibreLogo (my personal favorite)
Texas Instruments Logo
UCBLogo
And many others...

In addition, multiple Logo interpreters can be found online.

This page is intended to be a hub for code golf tips regarding any implementation of the Logo programming language.

Source: The Great Logo Adventure (1998) by Jim Muller


Flippign Lettesr Aroudn In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.
Your task, if you wish to accept it, is to write a program that flips the last two letters of each word in a given string (so the word Thansk turns into Thanks). A word is a sequence of two or more letters in the English alphabet delimited by a single space.

The string / list of characters you receive as input is guaranteed to only contain alphabetic characters and spaces (ASCII [97 - 122], [65 - 90] and 32).

You can take input and provide output through any standard method, in any programming language, while taking note that these loopholes are forbidden by default.

The output may have one trailing space and / or one trailing newline.

The input will always contain words only (and the corresponding whitespace) and will consist of at least one word.

This is code-golf, so the shortest submission (scored in bytes), in each language wins!
Test cases
Note that the strings are surrounded with quotes for readability.

Input -> Output

"Thansk"                                 -> "Thanks"
"Youer welcoem"                          -> "Youre welcome"
"This is an apple"                       -> "Thsi si na appel"
"Flippign Lettesr Aroudn"                -> "Flipping Letters Around"
"tHe oDd chALlEneg wiht swappde lettesR" -> "teH odD chALlEnge with swapped letteRs"

Or, for test suite convenience, here are the inputs and their corresponding outputs separately:

Thansk
Youer welcoem
This is an apple
Flippign Lettesr Aroudn
tHe oDd chALlEneg wiht swappde lettesR

Thanks
Youre welcome
Thsi si na appel
Flipping Letters Around
teH odD chALlEnge with swapped letteRs

Thanks to DJMcMayhem for the title. This was originally a CMC.

V, 4 5 bytes

òeXp

Try it online!

|| denotes the cursor

The buffer starts with |w|ord and more words and the cursor being on the first character.

Recursively ò

go to the end of a word

wor|d| and more words

remove X the character to the left of the cursor

wo|d| and more words

paste it over the next character

wod|r| and more words

Implicit ending ò, repeat the same process for other words until the end of the buffer is reached


Shortest code that return SIGSEGV among the given languages I come across a question in a coding competion

"write  a code that returns SIGSEGV(Segmentation fault )   " .

Points were given on the basis of length of code.
The prgramming languages available  were asm,c,c++,java .

I knew c language better  and submitted my code as

   main(){char *c="h";c[3]='j';}

But others solve it in shorter length  than me .  How it is possible ?  Can any one explain plz.

Platform UBUNTU 10.04

bending the rules a bit ; the C linker doesn't care if 'main' is a function or not :

int main=0;

indeed, the default type is 'int' and the default global initialiser is 0 :

main;


Multiply numerical polynomials A numerical polynomial is a polynomial \$p\$ in one variable with rational coefficients such that for every integer \$i\$, \$p(i)\$ is also an integer. The numerical polynomials have a basis given by the binomial coefficients:
$$p_n = {x \choose n} = \frac{x(x-1)\cdots(x-n+1)}{n!}$$
For instance:
\$p_0 = 1\$
\$p_1 = x\$
\$p_2 = \frac{x(x-1)}{2} = \frac{1}{2}x^2 - \frac{1}{2}x\$
\$p_3 = \frac{x(x-1)(x-2)}{6} = \frac{1}{6}x^3 - \frac{1}{2}x^2 + \frac{1}{3}x\$
The product of any two numerical polynomials is a numerical polynomial, so there are formulas expressing \$p_m\times p_n\$ as a linear combination of \$p_0, p_1, ..., p_{m+n}\$.
Your job is to produce these formulas.
Goal:
Input: A pair of positive integers \$m\$ and \$n\$
Output: The list of integers \$[a_1,...,a_{m+n}]\$ of length \$m+n\$ such that
$$p_m\times p_n = \sum_{i=1}^{m+n} a_ip_i$$
This is code golf, so shortest code wins.
Examples:
Input: (1,1)
We have \$p_1 = x\$, so \$p_1\times p_1 = x^2\$. The leading term is \$1x^2\$, and the leading term of \$p_2\$ is \$\frac{1}{2!}x^2\$, so we set \$a_2 = \frac{2!}{1} = 2\$. Subtracting off \$2p_2\$ we have \$p_1\times p_1-2p_2 = x^2 - (x^2 - x) = x\$. Thus, we see that \$p_1\times p_1 = p_1 + 2p_2\$, so the output should be \$[1,2]\$.
Input: (1,2)
\$p_2 = \frac{1}{2}x(x-1)\$, so \$p_1\times p_2 = \frac{1}{2}x^2(x-1)\$, which has leading term \$\frac{1}{2}x^3\$. The leading term of \$p_3\$ is \$\frac{1}{3!}x^3\$, so we set \$a_3 = \frac{3!}{2} = 3\$. \$p_1\times p_2 - 3p_3 = x^2-x = 2p_2\$, so we deduce that \$p_1\times p_2=0p_1 + 2p_2 + 3p_3\$, so the output should be \$[0,2,3]\$.
Input (2,2)
The leading term of \$p_2^2\$ is \$\frac{1}{4}x^4\$, so we start with \$p_2^2-\frac{4!}{4}p_4\$. This has leading term \$x^3\$, so we subtract off \$\frac{3!}{1}p_3\$ to get \$p_2^2-\frac{4!}{4}p_4-\frac{3!}{1}p_3\$. This expression turns out to be equal to \$p_2\$, so rearranging we get that \$p_2^2 = 0p_1+p_2+6p_3+6p_4\$, so the output should be \$[0,1,6,6]\$.
Test Cases:
(1,1) ==> [1,2]
(1,2) ==> [0,2,3]
(1,3) ==> [0, 0, 3, 4]
(1,4) ==> [0, 0, 0, 4, 5]
(2,2) ==> [0, 1, 6, 6]
(2,3) ==> [0, 0, 3, 12, 10]
(2,4) ==> [0, 0, 0, 6, 20, 15]
(3,4) ==> [0, 0, 0, 4, 30, 60, 35]
(4,4) ==> [0, 0, 0, 1, 20, 90, 140, 70]

Haskell, 74 bytes

a%b|let a?i|a<1=0^(i-b)^2|d<-a-1=div(i*d?(i-1)-(d-i)*d?i)a=map(a?)[1..a+b]

Try it online!

Uses a recursive formulation I found. Let \$g_b(a,i)\$ be the coefficient of \$p_i\$ in \$p_a p_b\$, which is implemented in the code by a?i (with b fixed). We can express \$g_b\$ recursively as

$$g_b(a,i)=\frac{i\cdot g_b(a-1,i-1)-(a-1-i)\cdot g_b(a-1,i-1)}{a}$$

with base case
$$g_b(0,i)=
\begin{cases}
1,\text{ if }b=i\\
0,\text{ otherwise}\\
\end{cases}
$$

The base case corresponds to the expansion for \$p_b\$, which has a single nonzero coefficient of \$p_i\$ at \$i=b\$. The code implements this indicator function as 0^(i-b)^2.

The code has guards belonging to the definition of ? in the let binding. It's perhaps easier to read as the following (non-working) code where the definition of a?i expects b as a global variable. Perhaps confusingly, the a in the definition of ? is not always the same as the input to %, since it recurses down.

a?i|a<1=0^(i-b)^2|d<-a-1=div(i*d?(i-1)-(d-i)*d?i)a
a%b=map(a?)[1..a+b]

The main function % lists the coefficients for each i from 1 to a+b. It's possible to code the recursion in % directly by zipping shifted lists, but I did not find a short way to do it especially with the dependence on the position i.


Stopwatch for Alphabets Implement Stopwatch for typing Alphabets

Alphabets = "a b c d e f g h i j k l m n o p q r s t u v w x y z".

Note

The program should run infinitely and should stop only when Esc button is pressed.
The stopwatch starts with keystroke "a" and ends with keystroke "z"
Output is the time taken to type the Alphabets correctly (ie. time take for 51 keystrokes)
If an illegal character occurs then stopwatch should stop and print "Failed"
If a new record is set then print "!!New record!!," TimeTaken

where, TimeTaken = time taken to print alphabets correctly.

Winner: One with the shortest code.

Mathematica, 303

Here with white-space and expanded symbols.
Everything happens in the Switch statement of the EventHandler where I pattern match {pressed key, next letter}.

Might want to replace the Quit with something less sinister before hitting escape:

z := AbsoluteTime[];
f = "a"; y = Dynamic;
DynamicModule[{
  a = f~CharacterRange~"z", c = 1, d = f, r = \[Infinity]},
 EventHandler[
  y@d~InputField~String,
  "KeyDown" :> Switch[
    {CurrentValue@"EventKey", a[[c]]},
    {f ..},
      t = z; c++; d = y@a[[c]],
    {"z" ..},
      t = z - t;
      d = If[t < r,
         r = t; "!!New record!!,",
         ""] ~~ ToString@t;
      c = 1,
    {a_, a_},
      c++,
    {"\[RawEscape]", _}, Quit[],
    _, d = "Failed"; c = 1]]]


Print the lyrics to "Twinkle Twinkle Little Star" Your goal is to print the lyrics to the song "Twinkle Twinkle Little Star" as each note is played.
The computer's microphone will hear notes. If the pitch (but not necessarily the length) of the note is correct, print the appropriate syllable. Otherwise, do nothing. Each note will be at least half a second long, and there will be a break of at least a quarter of a second between notes.
Use the musical notes provided here, and the following lyrics: (Vertical lines represent syllable breaks.)

Twin|kle, twin|kle, lit|tle star,
How I won|der what you are.
Up a|bove the world so high,
Like a dia|mond in the sky.
Twin|kle, twin|kle, lit|tle star,
How I won|der what you are.

A recording of the music can be found here.
Example
The computer hears a middle C and prints "Twin"
It hears another middle C and prints "kle,"
Then it hears another middle C (wrong note) and does nothing.
Then it hears the G above middle C and prints "twin" and so on.
Rules

Punctuation must be as shown.
Spacing must be as shown (with spaces and newlines).
The whitespace may be printed along with either the previous or the next syllable.

Python 3 - Partial solution (760 742 734 710 705 657 characters)
(Last edit; I promise)
This seems like a really, pretty, very hard problem (especially recognizing where the notes start or end). Automatic transcription of music seems like an open research topic (not that I know anything about it). So here's a partial solution that doesn't do any note segmentation (eg it prints "Twinkle" all at once when it hears the frequency) and probably only works for that specific ogg file:
A=-52
F=44100
C=4096
import pyaudio as P
import array
import scipy.signal as G
import numpy as N
import math
L=math.log
i=0
j=[9,2,0,2,4,5,7,9]
k=[2,4,5,7]
n=j+k+k+j
w="Twinkle, |twinkle, |little |star,\n|How I |wonder |what you |are.\n|Up a|bove the |world so |high,\n|Like a |diamond |in the |sky.\n".split('|')
w+=w[:8]
e=P.PyAudio().open(F,1,8,1,0,None,0,C)
while i<24:
 g=array.array('h',e.read(C));b=sum(map(abs,g))/C
 if b>0 and 20*L(b/32768,10)>A:
  f=G.fftconvolve(g,g[::-1])[C:];d=N.diff(f);s=0
  while d[s]<=0:s+=1
  x=N.argmax(f[s:])+s;u=f[x-1];v=f[x+1]
  if int(12*L(((u-v)/2/(u-2*f[x]+v)+x)*F/C/440,2))==n[i]+15:print(w[i],end='',flush=1);i+=1

This requires...

Python 3 (tested with 3.3 on Windows 64 bit... should work on Mac/Linux in theroy)
PyAudio (I used the windows binary package from here, since the windows binary packages from the PyAudio page didn't work)
SciPy and NumPy (I used scipy-stack from the same site)

Change the A=-52 (minimum amplitude) on the top line depending on your microphone, ammount of ambient sound, how loud the song is playing, etc. On my microphone, less than -57 seems to pick up a lot of extraneous noise and more than -49 requires you play it very loud.
This could be golfed a LOT more; I'm sure there are ways to save a bunch of characters on the words array in particular. This is my first non-trivial program in python, so I'm not very familiar with the language yet.
I stole the code for frequency detection via autocorrelation from https://gist.github.com/endolith/255291
Ungolfed:
import pyaudio
from array import array
import scipy.signal
import numpy
import math
import sys

MIN_AMPLITUDE = -52
FRAMERATE = 44100

def first(list):
    for i in range(len(list)):
        if(list[i] > 0):
            return i
    return 0

# Based on: https://en.wikipedia.org/wiki/Decibel#Acoustics
def getAmplitude(sig):
    total = 0;
    elems = float(len(sig))
    for x in sig:
        total += numpy.abs(x) / elems
    if(total == 0):
        return -99
    else:
        return 20 * math.log(total / 32768., 10)

# Based on: https://en.wikipedia.org/wiki/Piano_key_frequencies
def getNote(freq):
    return int(12 * math.log(freq / 440, 2) + 49)

# --------------------------------------------------------------------------
# This is stolen straight from here w/ very slight modifications: https://gist.github.com/endolith/255291
def parabolic(f, x):
    return 1/2. * (f[x-1] - f[x+1]) / (f[x-1] - 2 * f[x] + f[x+1]) + x

def getFrequency(sig):
    # Calculate autocorrelation (same thing as convolution, but with
    # one input reversed in time), and throw away the negative lags
    corr = scipy.signal.fftconvolve(sig, sig[::-1], mode='full')
    corr = corr[len(corr)/2:]

    # Find the first low point
    diffs = numpy.diff(corr)

    # Find the next peak after the low point (other than 0 lag). This bit is
    # not reliable for long signals, due to the desired peak occurring between
    # samples, and other peaks appearing higher.
    # Should use a weighting function to de-emphasize the peaks at longer lags.
    start = first(diffs)
    peak = numpy.argmax(corr[start:]) + start
    return parabolic(corr, peak) * (FRAMERATE / len(sig))
# --------------------------------------------------------------------------

# These are the wrong keys (ie it is detecting middle C as an A), but I'm far too lazy to figure out why.
# Anyway, these are what are detected from the Wikipedia .ogg file:
notes = [73,          66,           64,       66,         68,       69,        71,          73,       66,     68,          69,         71,         66,        68,         69,        71      ]
words = ["Twinkle, ", "twinkle, ", "little ", "star,\n",  "How I ", "wonder ", "what you ", "are.\n", "Up a", "bove the ", "world so ", "high,\n", "Like a ", "diamond ", "in the ", "sky.\n"]
notes += notes[:8]
words += words[:8]

pa = pyaudio.PyAudio()
stream = pa.open(format=pyaudio.paInt16, channels = 1, rate = FRAMERATE, input = True, frames_per_buffer = 4096)
idx = 0
while(idx < len(notes)):
    # Read signal
    sig = array('h', stream.read(4096))
    if(getAmplitude(sig) > MIN_AMPLITUDE):
        note = getNote(getFrequency(sig))
        if(note == notes[idx]):
            sys.stdout.write(words[idx])
            sys.stdout.flush()
            idx += 1


Is it a turtle prime? As we all know, it's turtles all the way down. But is it primes all the way down too?

A number is considered a "turtle-prime" if it satisfies the following conditions:

1) It is prime.
2) It is possible to remove a single digit leaving a prime number.
3) Step 2 can be repeated until left with a single digit prime.

For example, 239 is a "turtle-prime", as it can be reduced to 23 then either 2 or 3, both of which are prime. It also can be reduced to 29 then 2. 151 is not a turtle prime, as it reduces to 15 (not prime), 51 (not prime), or 11. 11 is prime, but can only reduce to 1, which is not.

Given a positive integer, determine if it is a "turtle-prime". Your output can be in any form so long as it gives the same output for any truthy or falsey value.

Test cases:

input -> output
1     -> false
2     -> true
17    -> true
19    -> false
239   -> true
389   -> false

Scoring

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

Haskell, 104 102 99 98 97 95 91 bytes

p x=product[2..x-1]^2`mod`x>0
f[]=1>0
f x|y<-zip[0..]x=or[f[snd b|b<-y,b/=a]|a<-y,p$read x]

Try it online!

Explanation

First we set up a primality test

p x=product[2..x-1]^2`mod`x>0

This uses Wilson's Theorem to determine the primality of an input.

We then declare a base case, which will assert that the empty string is truthy.

f[]=1>0

Now we define the actual function

f x|y<-zip[0..]x=or[f[snd b|b<-y,b/=a]|a<-y,p$read x]

We use a pattern guard to bind zip[0..]x to y, because we need to use it twice later.  We then assert the answer is

or[f[snd b|b<-y,b/=a]|a<-y,p$read x]

[[snd b|b<-y,b/=a]|a<-y] is all of the numbers that are a digit removed from our input.  So we are asserting that at least one of these numbers is truthy for f.  In order to ensure that composite numbers are falsy we add in prime$read x.  If the number is not prime the list will become empty and the any of a empty list is false.


Print the Greek national anthem In March 25, 1821, Greece fought its great war of independence. In order to honor this, your task is to print the Greek national anthem:

Σε γνωρίζω από την κόψη
του σπαθιού την τρομερή.
Σε γνωρίζω από την όψη
που με βιά μετράει τη γη.
Απ' τα κόκκαλα βγαλμένη,
των Ελλήνων τα ιερά!
Και σαν πρώτα ανδρειωμένη,
χαίρε ω χαίρε Λευτεριά!
Και σαν πρώτα ανδρειωμένη,
χαίρε ω χαίρε Λευτεριά!
Και σαν πρώτα ανδρειωμένη,
χαίρε ω χαίρε Λευτεριά!

This is my own version of the anthem (punctuation, capitalization), although the lyrics are the original.

Any builtins printing or returning this text are forbidden, just in case.
The printed text must be exactly as above, with an optional trailing newline.
The output must be in UTF-8, unless it can't be supported at all, in which case the output must be encoded in the closest supported alternative.

Jelly, 180 174 163 bytes

60r26;“WSNME‘ȷ_Ọ;“ ¶.',!”“¢Iç÷ṀDė3H⁷'UBV“ñẸḣY]ṭżẸ-dƒjṭ{^ṣ8ḞkƊK“ẈḊbƝÑk?Æ.)Aɱ3ẎƬṠ⁵ʂ÷Gẏp⁴ṇ1ẸR ¬,F°0>ST$[?ṘȦŀẎcFẈṃijȯÆḋ“¦ḟw2ðƊhSẏ¥ẏ5ƒẉɦ⁺Ʋ⁴Ɓ¦ÞIzƥṙḊOḊ-÷~øWḤ0ṃ’ṃ€6676ḃ4¤ị

Try it online!


Counting generalized polyominoes This challenge will have you count pseudo-polyforms on the snub square tiling.

I think that this sequence does not yet exist on the OEIS, so this challenge exists to compute as many terms as possible for this sequence.

Update: this is now on the OEIS as A309159: Number of generalized polyforms on the snub square tiling with n cells.

Definitions

The snub square tiling is a semiregular tiling of the plane that consists of equilateral triangles and squares.

A pseudo-polyform on the snub square tiling is a plane figure constructed by joining together these triangles and squares along their shared sides, analogous to a polyomino. Here is an example of a six-cell and an eight-cell pseudo-polyform:

Examples

For n = 1 there are two 1-cell pseudo-polyforms, namely the square and the triangle:

For n = 2 there are two 2-cell pseudo-polyforms, namely a square with a triangle and two triangles.

For n = 3 there are four 3-cell pseudo-polyforms.

Challenge

The goal of this challenge is to compute as many terms as possible in this sequence, which begins 2, 2, 4, ... and where the n-th term is the number of n-cell pseudo-polyforms up to rotation and reflection.

Run your code for as long as you'd like. The winner of this challenge will be the user who posts the most terms of the sequence, along with their code. If two users post the same number of terms, then whoever posts their last term earliest wins.

(Once there are enough known terms to prove that this sequence does not already exist in the OEIS, I'll create an entry in the OEIS and list the contributor as a co-author if he or she desires.)

Haskell

Now that not only the comments document that Peter Taylor was the first one to give enough terms to search on OEIS, I can give my results.

( 1 - 10) 2, 2, 4, 10, 28, 79, 235, 720, 2254, 7146,
(11 - 15) 22927, 74137, 241461, 790838, 2603210,
(16 - 18) 8604861, 28549166, 95027832,
(19 - 22) 317229779, 1061764660, 3562113987, 11976146355

Earlier, I counted hexagonal polyominoes. Except for some optimizations, what I'm doing here is very similar.

The elements of the tiling are represented like this:
You can go in an almost straight line from left to right
(in the first picture), alternating between squares and
rectangles. There are almost parallel further lines,
wiggling in opposite directions. Together, they miss
some triangles.
There are similar almost straight parallel lines from
bottom to top, containing the missing triangles.
Now ignore the wiggling and use a Cartesian coordinate
system, but only use odd numbers for the coordinates of the squares.
Then the triangles naturally get coordinate pairs with one even
and one odd coordinate. Pairs with both coordinates even
don't represent elements of the tiling.

(You could as well use even numbers for the coordinates
of the squares. I guess I decided this way because I thought
about reflection before rotation.)

Save the program in a file with a name like cgp.hs and compile with ghc -O2 -o cgp cgp.hs. It takes either one numeric command line argument and computes the number of polyominoes of that size, or none, in which case it computes values until stopped.

{-# LANGUAGE BangPatterns #-}

import Data.List(sort)
import qualified Data.Set as S
import System.Environment(getArgs)

data Point = P !Int !Int deriving (Eq,Ord)

start :: Point
start = P 1 1

redsq :: Point -> Bool
redsq (P x y) = (x+y) `mod` 4 == 2

neighs :: Point -> [Point]
neighs (P x y) =
  case (even x, even y) of
    (False,False) -> [P x (y+1), P (x+1) y, P x (y-1), P (x-1) y]
    (True, False) -> (P x (c y (x+y+1))) : opt [P (x-1) y, P (x+1) y]
    (False,True ) -> (P (c x (x+y-1)) y) : opt [P x (y-1), P x (y+1)]
  where
    opt = filter ok
    ok p = p>start || not (redsq p)
    c z m = if m `mod` 4 == 0 then z+2 else z-2

count :: S.Set Point -> S.Set Point -> [Point] -> Int -> Int -> Int -> Int -> Int
count use _    _            0 c r y =
  if check (S.toAscList use) (y==r)
    then c+1
    else c
count _   _    []           _ c _ _ = c
count use seen (p:possible) n c r y =
  let !c' = count use seen possible n c r y
      new = filter (`S.notMember` seen) $ neighs p
      !r' = if redsq p then r+1 else r
      !y' = if redsq (mirror p) then y+1 else y
      !n' = n-1
  in if r'+n' < y'
       then c'
       else count (S.insert p use) (foldr S.insert seen new) (new++possible)
                  n' c' r' y'

class Geom g where
  translate :: Int -> Int -> g -> g
  rot :: g -> g
  mirror :: g -> g

instance Geom Point where
  translate dx dy (P x y) = P (dx+x) (dy+y)
  rot (P x y) = P (2-y) x    -- rotate around (1,1)
  mirror (P x y) = P x (-y)

instance (Geom g, Ord g) => Geom [g] where
  translate x y = map $ translate x y
  rot = sort . map rot
  mirror = sort . map mirror

normalize :: [Point] -> [Point]
normalize pol = let (P x y) = head (filter redsq pol)
                in translate (1-x) (1-y) pol

check :: [Point] -> Bool -> Bool
check pol !cm = let rotated = take 4 $ iterate rot pol
                    mirrored = if cm then map mirror rotated else []
                    alts = map normalize (tail rotated ++ mirrored)
                in all (pol<=) alts

f :: Int -> Int
f 0 = 1; f 1 = 2; f 2 = 2
f n = count S.empty S.empty [start] n 0 0 0

output :: Int -> IO ()
output n = putStrLn $ show n ++ ": " ++ show (f n)

main = do args <- getArgs
          case args of
            []  -> mapM_ output [1..]
            [n] -> output (read n)

Try it online!


Quoted rational numbers Quote notation is a way of expressing rational numbers based on the concept of \$p\$-adic numbers, written in the form \$x'y\$.
The quote indicates that the number to it's left (\$x\$) is "repeated" infinitely to the left, then prefixed to the number on the right (\$y\$). For example \$3' = \: ...3333\$ and \$764'31 = \: ...76476431\$. We can then consider the geometric series:
$$\cdots + 10^{3k} + 10^{2k} + 10^{k} + 10^{0} = \frac 1 {1 - 10^k}$$
By setting \$k\$ to be equal to the number of digits of \$x\$, we can transform this "infinite" number into a value which converges:
$$\begin{align}
3' & = \: ...333
& 764'31 & = \: ...76476431 \\
   &
& & = 31 + 764'00 \\
   & = \cdots + 3\cdot10^3 + 3\cdot10^2 + 3\cdot10^1 + 3\cdot10^0
& & = 31 + 100 \times 764'\\
   & = 3(\cdots + 10^3 + 10^2 + 10^1 + 10^0)
& & = 31 + 100 \times 764(\cdots + 10^9 + 10^6 + 10^3 + 10^0)\\
   & = 3\left( \frac 1 {1 - 10} \right)
& & = 31 + 76400\left( \frac 1 {1 - 10^3} \right) \\
   & = \frac {3} {-9}
& & = 31 - \frac {76400} {999}\\
   & = - \frac 1 3
& & = - \frac {45431} {999}
\end{align}$$
Note that \$9'0 \ne 9'\$ as the first equals \$-10\$ and the second \$-1\$. Additionally, note that leading zeros on \$y\$ do affect the output: \$81'09 = -\frac {801} {11} \ne \frac {9} {11} = 81'9\$ Therefore, a value after the \$'\$ (\$y\$) may be omitted in the input.
You are to take, in any reasonable format, up to 2 non-negative integers \$x\$ and \$y\$, and output the fraction \$\frac a b\$ represented by \$x'y\$. Reasonable formats include:

A string, delimited by a non-digit character, such as ', e.g. 9' or 9'0. The string will always begin with a digit; if there is no \$x\$ value, it will be a \$0\$ (e.g. 0'3)
A list of either 1 or 2 non-negative integers, represented as strings or lists of digits. If there is only 1, it represents \$x'\$. 2 integers represent \$x'y\$.
A list of 2 elements. The last element may be either a non-negative integer (as a string or digit list), or a consistent value that is not a non-negative integer (e.g. null or None or -1 etc.) that indicates that there is no \$y\$ value. The first value will always be a non-negative integer.

This is not an exhaustive list, if you have another method, feel free to ask.
You may output the two integers \$a\$ and \$b\$ instead of the fraction \$\frac a b\$. The fraction must be exact, and fully simplified (i.e. \$a\$ and \$b\$ are coprime). If \$b\$ is 1, outputting just \$a\$ is acceptable. For negative outputs, if outputting \$a\$ and \$b\$ separately, either may have the negative sign, but not both.
You may input and output in any convenient method. This is code-golf so the shortest code in bytes wins.

Modified from the linked Wikipedia page:

Let \$x\$ and \$y\$ be sequences of digits, as in \$x'y\$
Let \$z\$ be the digit \$1\$ followed by a sequence of zeros of the same length as \$y\$.
Let \$w\$ be a sequence of \$9\$s of the same length as \$x\$.
Then the number represented by \$x'y\$ is given by \$y-\frac{xz}w\$

Test cases
x'y    = a / b
31'491 = 17609 / 99
844'80 = -4480 / 999
4'128  = -2848 / 9
247'0  = -2470 / 999
0'716  = 716 / 1
592'   = -16 / 27
3'45   = 35 / 3
9'7    = -3 / 1
9'     = -1 / 1
3'0    = -10 / 3
764'31 = -45431 / 999
81'09  = -801 / 11
81'9   = 9 / 11
123456' = -41152 / 333333

J, 25 bytes
(%-.)~/@(10^#&>)#.10#.&>]

Try it online!
Takes a boxed 2-item vector containing the digit vectors of \$x\$ and \$y\$, and returns a rational number. The digits must be given in extended precision. \$y\$ may be an empty vector. I guess it's pretty well golfed when Jelly is at 20 bytes :)
How it works
Uses the formula at the end of the challenge. If we define \$\#x\$ as the number of digits of \$x\$,
$$
z = 10^{\#y}, \quad w=10^{\#x}-1, \quad x'y = -\frac{z}{w}x+y,
$$
and observe that the result is the same as the 2-vector \$[x,y]\$ evaluated in base \$-\frac{z}{w}\$.
(%-.)~/@(10^#&>)#.10#.&>]    NB. Monadic train; input = (digits of x;digits of y)
                  10#.&>]    NB. Evaluate each in base 10 to get [x,y]
                #.           NB. Evaluate in base...
        (10^#&>)    NB. 10 raised to the power of length of each; [10^#x, 10^#y]
(%-.)~/@            NB. (10^#y) / (1 - 10^#x) = -z/w

J, 23 bytes
(%-.)~&(10x^#)#.,&{.&".

Try it online!
Modification of Jonah's solution to use the same base trick. This one is a dyadic function accepting plain strings as its two args. One caveat is that eval(".) of an empty string is an empty vector, so we need to make it a 0 explicitly using {..


Orientation Oriented Programming Write a program for a specific language that in different orientations performs different tasks.
Your code should have at least two non-empty lines and at least two non-empty columns and should complete at least one challenge from each category of challenges below when oriented in different ways.
Orientations
Your code can be arranged eight different ways, original and three ninety degree rotations and each reversed, eg:
$_=     $@$      /$     =.
@F.     /F_     .F@     _F/
$/       .=     =_$     $@$

=_$      .=     $/      $@$
.F@     /F_     @F.     _F/
 /$     $@$     $_=     =.

Here's a generator (thanks to @fireflame241!)
Tasks
string

"Hello, World!"
Covfefify a string
No A, just CAPS LOCK
Don't google "google"
1, 2, Fizz, 4, Buzz

number

Is this number a prime?
Fibonacci function or sequence
You're on a 8 day streak!
Count up forever
Am I a Rude Number?

kolmogorov-complexity

Sing Happy Birthday to your favourite programming language
Print a Tabula Recta!
Sing Baby Shark
Build me a brick wall!
Hare Krishna Hare Krishna Krishna Krishna Hare Hare

quine

A program that is a proper quine.
Program that creates larger versions of itself (quine-variant)
Print your code backwards - reverse quine
Print the last, middle and first character of your code
Mirror quine (or my head hurts) - This counts as two rotations!

ascii-art

Do you want to code a snowman?
It's my Birthday :D
In Honor of Adam West
5 Favorite Letters
It took me a lot of time to make this, pls like. (YouTube Comments #1)

Scoring
Your score will be the number of different tasks solved by your code (higher is better) with code length as a tie-breaker (lower is better).
Rules

All programs must be in the same language
The rules for each task are as specified in the linked questions.
Multiple tasks can be completed in the same orientation to help maximise score. For example, if s challenge has no expectation to handle the empty input, you could instead perform another task that takes no input.
Your code must perform tasks when oriented in at least three unique rotations.
You can assume that spaces will be automatically added when rotating your code, however if your code does necessitate space padding on the end of lines of each rotation, these should be included.

05AB1E, 5 14 15 18 rotations (5 6 7 8 unique, 61 213 1488 4367 bytes)
.ï i…( )7ÝJ»•αγʒδÓ₂©8¥ŽQxΣxêÿ•sÅвJIvN”</[(0._-=:"ÆŸ,*”0¶:º•DùÙÂ+;Èγтáì³ÓW©ÎÂ_`ƒ≠îj*ΓçÊ~ÞÒ¸β¦oåb/õ47/vÎΓ”›≠øØZµλÝº•20вè¶¡Nè4äyè.;ëĀiηû»ëтÝ3Å€"Fizz"}5Å€á”ÒÖ”J}¦»]q]À=F₂Aë}š.?ćvD¡SaA„iĀë∍sna„>+?Å8IàQô2$4Žнв₄iï.
ï                                                                                …
i                                                                                _
Å                                                                                |
f                                                                                _
ë                                                                                Ć
∞                                                                                Ƶ
€                                                                                м
,                                                                                ×
]                                                                                T
q                                                                                ä
]                                                                                »
.                                                                                q
                                                                                ”
.                                                                                !
…                                                                                ï
ë                                                                                ‚
p                                                                                ,
i                                                                                ™
ï                                                                                Ÿ
.ïi_i“Ûà€‰€ž€¢‡Í! :D“ćuìëdiU„ $„ |}…-~-`)X·>δ∍»}ëĀi1ú.γžOså}R`¦??н©?н®ì.•gÍĆdQ¸G•Â‡D?,ë“«Î‡Ä¦í¥Â“#€¦`«'kì)™•1¢₂P•3вè4ô»]q]»ì” ©¢ØŽ”)s”E1BA50 Ž¬”Ð”î€ot”ëFëgiÊ¹Š'iĀëå4B23iï.                                 \””

Try it online (integer input): ascii-art Do you want to code a snowman?
Try it online (string input): ascii-art It took me a lot of time to make this, pls like. (YouTube Comments #1)
Try it online (no input): string 1, 2, Fizz, 4, Buzz
Try it online with all rows reversed (integer input): ascii-art It's my Birthday :D
Try it online with all rows reversed (string input): string Covefify a string
Try it online with all rows reversed (no input): kolmogorov-complexity Hare Krishna Hare Krishna Krishna Krishna Hare Hare
Try it online with each row reversed (integer input): number You're on a 8 day streak!
Try it online with each row reversed (string input): string No A, just CAPS LOCK
Try it online with each row reversed (no input): kolmogorov-complexity Print a Tabula Recta!
Try it online with both the rows and each row itself reversed (integer input): number Am I a Rude Number?
Try it online with both the rows and each row itself reversed (string input): string Don't google "google"
Try it online with both the rows and each row itself reversed (no input): kolmogorov-complexity Sing Happy Birthday to your favourite programming language
Try it online rotated 90 degrees clockwise (integer input): number Fibonacci function or sequence
Try it online rotated 90 degrees clockwise (no input): number Count up forever
Try it online rotated 90 degrees clockwise and then each row reversed (integer input): number Is this number a prime?
Try it online rotated 90 degrees clockwise and then each row reversed (no input): quine Print the last, middle and first character of your code
Try it online rotated 90 degrees counterclockwise (no input): kolmogorov-complexity Build me a brick wall!
Try it online rotated 90 degrees counterclockwise and then each row reversed (no input): string "Hello, World!"
Explanation:

In general, I mostly rely on the builtin q. This will stop the program, making everything after it no-ops.
In addition, for the four main rotations, I split them up into integer/string/no input with:
.ïi         # If the (implicit) input is an integer:
            #  Do something with the integer-input
ëĀi         # Else-if the (implicit) input-string is NOT empty:
            # (using the Python-truthify builtin `Ā`)
            #  Do something else with the string-input
ë           # Else (there is no input):
            #  Do something else without input

For the two clockwise rotations it's similar, but only with integer or no input (since there aren't any other challenges available with input from the list in the challenge).
And for the two counterclockwise rotations it's just a kolmogorov-complexity output without input.
Some things I had to fix for the rotations include:

Adding an additional space between the .ï and i at the start of the first line, and a space on each subsequent line. Without this space, the middle character for subprogram of the Print the last, middle and first character of your code challenge would have a newline character as the center, which isn't possible without screwing up the layout. With that added space, the middle character in that rotation also becomes a space (the first and last characters are both .).
Adding \” at the end of the final line. This is to close this string and discard it for the programs with all rows and each row itself reversed, which will now contain a leading ””\ followed by a bunch of no-op spaces.
For most rotations I reuse the . for the .ï (is_integer check), but for one rotation it's .… instead. . opens up 2-byte builtins, but since .… doesn't exist, the . is a no-op instead in this case.

As for an explanation of each individual program:
ascii-art Do you want to code a snowman?: …( )7ÝJ»•αγʒδÓ₂©8¥ŽQxΣxêÿ•sÅвJIvN”</[(0._-=:"ÆŸ,*”0¶:º•DùÙÂ+;Èγтáì³ÓW©ÎÂ_`ƒ≠îj*ΓçÊ~ÞÒ¸β¦oåb/õ47/vÎΓ”›≠øØZµλÝº•20вè¶¡Nè4äyè.;
See this answer of mine, except that the actual newline is replaced with a 0, which we replace to a newline after creating the string with 0¶:.
ascii-art It took me a lot of time to make this, pls like. (YouTube Comments #1): ηû»
See the second program in this answer of mine (provided by @Grimmy).
string 1, 2, Fizz, 4, Buzz: тÝ3Å€"Fizz"}5Å€á”ÒÖ”J}¦»
See this answer of @Grimmy.
ascii-art It's my Birthday :D: _i“Ûà€‰€ž€¢‡Í! :D“ćuìëdiU„ $„ |}…-~-`)X·>δ∍»}
See this answer of @Grimmy, with additional trailing } to close the if-statement.
string Covefify a string: 1ú.γžOså}R`¦??н©?н®ì.•gÍĆdQ¸G•Â‡D?,
See this answer of @Grimmy.
kolmogorov-complexity Hare Krishna Hare Krishna Krishna Krishna Hare Hare: “«Î‡Ä¦í¥Â“#€¦`«'kì)™•1¢₂P•3вè4ô»
See this comment of mine on the answer of @Emigna.
“«Î‡Ä¦í¥Â“  # Push dictionary string "drama share irish dna"
 #          # Split it on spaces: ["drama","share","irish","dna"]
  €¦        # Remove the first character of each word:
            #  ["rama","hare","rish","na"]
    `       # Push them separated to the stack
     «      # Merge the last two together: "rishna"
      'kì  '# Prepend a "k": "krishna"
         )  # And wrap everything on the stack into a list again:
            #  ["rama","hare","krishna"]
          ™ # Titlecase each: ["Rama","Hare","Krishna"]
•1¢₂P•      # Push compressed integer 27073120
 3в         # Convert it to base-3 as list: [1,2,1,2,2,2,1,1,1,0,1,0,0,0,1,1]
   è        # Index each integer into the list of words
    4ô      # Split the list of words into parts of size 4
      »     # Join each inner list by spaces, and then each string by newlines
            # (after which the result is output implicitly as result)

See this 05AB1E tip of mine (sections How to use the dictionary?, How to compress large integers?, and How to compress integer lists?) to understand why “«Î‡Ä¦í¥Â“ is "drama share irish dna"; •1¢₂P• is 27073120; and •1¢₂P•3в is [1,2,1,2,2,2,1,1,1,0,1,0,0,0,1,1].
number You're on a 8 day streak!: ₄внŽ4$2ôQàI8Å?+>„ans∍
See this answer of mine.
string No A, just CAPS LOCK: „AaS¡Dvć?.š
See this this answer of @Emigna, although without õ? and with .š instead of š, since his answer is built in the legacy version of 05AB1E instead of the new one.
kolmogorov-complexity Print a Tabula Recta!: A₂F=À
See this answer of @Adnan, although with ₂F instead of Dv, since I personally prefer to keep my programs as straight-forward as possible despite codegolfing (where ₂ is the builtin for 26, and F loops that many times).
number Am I a Rude Number?: 32B4å
See this answer of mine.
string Don't google "google": 'Š¹ÊigëF
Although there is this pretty old answer of @Adnan which worked on one of the earliest versions of 05AB1E when he posted it back in 2016, it doesn't even work anymore in the latest legacy version on TIO from around mid-2017, let alone in the latest 05AB1E version. So instead I now use this (which is also 2 bytes shorter anyway):
'Š¹        '# Push the dictionary string "google"
   Êi       # If the (implicit) input-string is NOT equal to "google":
     g      #  Pop and push the length of the (implicit) input-string
            #  (which will be output implicitly as result)
    ë       # Else:
     F      #  Start a loop using the (implicit) input-string,
            #  which will result in an error if it isn't an integer

See this 05AB1E tip of mine (section How to use the dictionary?) to understand why 'Š¹ is "google".
kolmogorov-complexity Sing Happy Birthday to your favourite programming language: ”to€î”Ð”¬Ž 05AB1E”s)”ŽØ¢© ”ì»
See this 05AB1E answer of @Grimmy.
number Fibonacci function or sequence: Åf
Åf          # Given the (implicit) input-integer `n`, get the n'th Fibonacci number
            # (after which it is output implicitly as result)

number Count up forever: ∞€,
See this answer of @Sagittarius.
number Is this number a prime?: p
p           # Given the (implicit) input-integer, check if it's a prime number
            # (1 if truthy; 0 if falsey)
            # (after which it is output implicitly as result)

quine Print the last, middle and first character of your code: .…. .
As I already mentioned earlier, I added an additional no-op space to the program so the middle character in this orientation would be a space character, instead of a newline character. The first and last characters are ., so we'll have the following sub-program:
.           # No-op, since `.…` isn't an available 2-byte builtin
 …. .       # Push 3-char string ". ."
     q      # Stop the program, making everything after that no-ops
            # (after which the result is output implicitly)

kolmogorov-complexity Build me a brick wall!: .…_|_ĆƵм×Tä»
See this answer of @Adnan, although golfed by 2 bytes by replacing "_|__" with …_|_Ć (push 3-char string "_|_"; and then enclose, appending its own first character) and 175 with Ƶм (compressed integer).
string "Hello, World!": ”Ÿ™,‚ï!”
See this answer of @Adnan, except with trailing ” to close the string.
The ] you see before the q in each program is to close all open if-else statements and loops before doing this q.
I'm unable to fit anything more in it from the list in the challenge description. The ones left are three (kolmogorov-complexity/ascii-art) that require you to output something without input (which I have already used in all eight rotations) and four quine-related challenges, which are just impossible with this kind of layout in 05AB1E.
If there would have been more challenges taking integer/string inputs, those could have been added as well.


Find the Pisano Period The Fibonacci sequence is a well know sequence in which each entry is the sum of the previous two and the first two entries are 1.  If we take the modulo of each term by a constant the sequence will become periodic.  For example if we took decided to compute the sequence mod 7 we would get the following:

1 1 2 3 5 1 6 0 6 6 5 4 2 6 1 0 1 1 ...

This has a period of 16.  A related sequence, called the Pisano sequence, is defined such that a(n) is the period of the fibonacci sequence when calculated modulo n.

Task

You will should write a program or function that when given n will compute and output the period of the Fibonacci sequence mod n.  That is the nth term in the Pisano sequence.

You must only support integers on the range 0 < n < 2^30

This is a code-golf competition so you should aim to minimize the size of your source code as scored by bytes.

Test cases

1  -> 1
2  -> 3
3  -> 8
4  -> 6
5  -> 20
6  -> 24
7  -> 16
8  -> 12
9  -> 24
10 -> 60
11 -> 10
12 -> 24

GolfScript (28 25 24 23 chars)

~1.{(2$+}{.@+2$%}/+\-,)

Takes input in stdin, leaves it on stdout (or the stack, if you want to further process it...)

This correctly handles the corner cases (Demo).

As a point of interest to GolfScript programmers, I think this is the first program I've written with an unfold which actually came out shorter than the other approaches I tried.


Write a program to perform set operations. Your task is to write a program to perform set operations. The operations and arguments are taken from command line in the format program operation [argument]. There are four operations:

1: clears the set. no arguments. exit code 0.
2 integer: adds the integer into the set. exit code 0.
3 integer: removes the integer from the set. exit code 0.
4 integer: queries the set for integer. exit code 0 if integer exists or 1 otherwise.

The integer is a 64-bits integer. Shortest program wins. You can, of course, use a temporary file. However, watch out the space and time limit.

Example:

$ program 1 ; echo $?
0
$ program 2 10 ; echo $?
0
$ program 4 10 ; echo $?
0
$ program 3 10 ; echo $?
0
$ program 4 10 ; echo $?
1
$ program 2 10 ; echo $?
0
$ program 1 ; echo $?
0
$ program 4 10 ; echo $?
1

Bash -- 54 chars

case $1 in
1)rm *;w;;
2)>$2;;
3)rm $2;w;;
4)<$2;;
esac

Notes: Outputs to stdout/stderr in some scenarios. Empties working directory when clearing the set. Uses one file for each set element. The purpose of ;w is to exit with status 0.

This appears to comply with all the rules.


The rice and chess problem An Indian legend tells the story of the alleged inventor of the chess game, who impressed the emperor of India with his game so much that he would get rewarded with anything asked.

The man said he wanted to be paid in rice. He wanted a grain of rice for the first square of the chessboard, two for the second, four for the third, eight for the fourth, and so on, until the 64th square.

The emperor was amazed that the man asked for such a small reward, but as his mathematicians started counting, he ended up losing one of his provinces.

Task

Given the length of the side of a hypothetical chessboard (which is 8 on a default chessboard) and the multiplier between squares (which is 2 in the legend), calculate the number of grains of rice the emperor must pay to the man.

Notes

The side length will always be a positive integer. The multiplier could instead be any kind of rational number.
If your language of choice can't display very large numbers, it's okay as long as your program can correctly process smaller inputs.
Also if your language of choice rounds larger values (with exponential notations), it's okay if those values are approximately correct.

Testcases

Input (side length, multiplier) => Output
8, 2                            => 18446744073709551615
3, 6                            => 2015539
7, 1.5                          => 850161998.2854
5, -3                           => 211822152361
256, 1                          => 65536
2, 2                            => 15
2, -2                           => -5

Please note that the explicit formula

result = (multiplier ^ (side ^ 2) - 1) / (multiplier - 1)

Performs wrong on multiplier = 1, as

1 ^ (side ^ 2) - 1 = 0
1 - 1 = 0
0 / 0 != side ^ 2 (as it should be)

Scoring

This is code-golf. Shortest answer in bytes wins.

MATL, 6 bytes
2^:q^s

Try it online!
2^   % Take implicit input, say N, and square it: N^2
:q   % Generate array [0 1 ... N^2-1]
^    % Take implicit input, M, and compute [M^0 M^1 ... M^(N^2-1)]
s    % Sum of the array. Implicit display


Chaos is an ASCII ladder You know nothing The things I do for "Chaos is a ladder" is a memorable line from the television series Game of Thrones.
The purpose of this challenge is to build a ladder from chaos, in ASCII art.
The challenge
Input

Ladder width, W >= 3 (integer)
Step height, H >= 2 (integer)
Number of rungs, N >= 2 (integer).

Output
A ladder with horizontal rungs and vertical rails, all 1 character wide. Ladder width (W) includes the two rails, and step height (H) includes the corresponding rung.
All rungs, including the uppermost and the lowermost, will have a piece of vertical rail of length H-1 directly above and below. The example will make this clearer.
The ladder will be made of printable, non-whitespace ASCII characters, that is, the inclusive range from ! (code point 33) to ~ (code point 126).The actual characters will be chosen randomly. Given the inputs, each of the random choices of characters must have nonzero probability. Other than that, the probability distribution is arbitrary.
Leading or trailing whitespace, either horizontal or vertical, is allowed.
Example
Given W=5, H=3, N=2, one possible output is as follows.
x   :
g   h
q$UO{
t   T
6   <
bUZXP
8   T
5   g

Note that total height is H*(N+1)-1, as there are N rungs and N+1 vertical sections.
Aditional rules

Input means and format are flexible as usual. For example, you can input the three numbers in any order, or an array containing them.

Output may be through STDOUT or an argument returned by a function. In this case it may be a string with newlines, a 2D character array or an array of strings.

A program or a function can be provided.

Standard loopholes are forbidden.

Shortest code in bytes wins.

Test cases
For each W, H, N a possible output is shown.
W=5, H=3, N=2:

\   ~
:   K
ke:[E
5   u
0   _
8Fr.D
#   r
7   X

W=3, H=2, N=2:

$ X
Mb)
0 ]
(T}
j 9

W=12, H=4, N=5:

d          Y
P          `
5          3
p$t$Ow7~kcNX
D          x
`          O
*          H
LB|QX1'.[:[F
p          p
x          (
2          ^
ic%KL^z:KI"^
C          p
(          7
7          h
TSj^E!tI&TN8
|          [
<          >
=          Q
ffl`^,tBHk?~
O          +
p          e
n          j

W=20, H=5, N=3:

G                  %
o                  y
%                  3
-                  7
U'F?Vml&rVch7{).fLDF
o                  }
U                  I
h                  y
a                  g
;W.58bl'.iHm\8v?bIn&
,                  U
N                  S
4                  c
5                  r
F3(R|<BP}C'$=}xK$F]^
'                  h
h                  u
x                  $
6                  5


Polynomial -> Integrate Given a polynomial in one variable with rational coefficients, output an equivalent expression containing only 1, variables, and definite integrals. For example, -x2 can be expressed as ∫x∫111dtxdu.

E := 1 | var | ∫EEEdvar

Any reasonable input/output method is allowed.

Examples:

Your score will be the your code length multiplied by the number of ∫ symbols  used on the test cases. You should be able to score your program. Lowest score wins.

Test cases:

4/381*x^2+49/8*x^3-17/6
311/59*x^2-92/9*x^3-7/15*x
333/29*x^3+475/96*x^8

  Golfing is going to be difficult, because I can't golf just the code or just the output, and I therefore do not know if a change will help or hurt my score until I try it, which sucks in my opinion.

Don't let the score restrict your creation. You are welcomed to answer with mainly one part of the score well optimized, even if the other one badly left.

Python 2, 315 bytes * 5113 = 1610595 score
I'm still working on golfing the score. Golfing is going to be difficult, because I can't golf just the code or just the output, and I therefore do not know if a change will help or hurt my score until I try it, which sucks in my opinion.
Despite the annoyance of golfing this, I did enjoy the calculus.

t='t'
Z=lambda n:N(Z(-n))if n<0else[1,t,N(1),Z(n-1)]if n>1else[[1,t,1,1],1][n]
N=lambda a:[1,t,a,Z(0)]
x=lambda n:n>1and[x(n-1),t,Z(0),'x']or'x'
M=lambda a,b:[b,t,Z(0),a]
print reduce(lambda a,b:[1,t,N(a),b],[M((lambda a,b:M(Z(a),[x(b-1)if b>1else 1,'x',Z(0),1]))(*c),x(i)if i else 1)for i,c in enumerate(input())])

Try it online!
Run all test cases - to score, count all [ in the output.
The input polynomial is taken as a list of (numerator, denominator) coefficient pairs in order from lowest to highest power of x. (0, 1) (zero) is used for missing powers.
Output is given with each integral represented by a list [f,t,a,b] to represent ∫abf dt
Verification
Here is a slightly less golfed version that outputs valid Mathematica syntax for integration, which may be tested in an online notebook. Unfortunately, decently-sized programs will not complete in a free notebook.
Go here, scroll to bottom, "Create New Notebook", paste (Wolfram Language Input), and evaluate (Shift+Enter) (Note that using num-pad Enter doesn't work).
Explanation
Uses these equations:

Links

Tool that converts the output to Mathematica nested functions

Tool that converts the output to Mathematica, avoiding recursion

Run the Mathematica output on TIO

Equation images made with this tool.