Longest equal subsequences Definitions

A subsequence may not be contiguous, e.g. [1, 1, 1] is a subsequence of [1, 2, 1, 2, 1].
An equal subsequence is a subsequence in which every element is equal.
The longest equal subsequence may not be unique, e.g. [1, 1] and [2, 2] are both longest equal subsequences of [2, 1, 1, 2].

Input

A non-empty list of positive integers in one of the format below:

as the native implementation of an array of positive integers in your language
as a string of newline-separated integers in decimal
as a string of newline-separated integers in unary
any other reasonable formats

Output

All of the longest equal subsequences in any order in one of the formats below:

as a 2D nested array in your language (if the input is an array)
as a flattened array with the equal elements being contiguous
any other reasonable format

Scoring

Although we are looking for something long, the code used should be as short as possible in terms of number of bytes, since this is code-golf

Testcases

Inputs:

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

Outputs:

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

Note that for the outputs above, any order is valid.

A flattened array is also valid, as long as the equal elements are contiguous.

Jelly, 5 bytes

ĠLÐṀị

Try it online!

How it works

ĠLÐṀị  Main link. Argument: A (array)

Ġ      Group; partition the indices of A by their corresponding values.
 LÐṀ   Select all index arrays with maximal length.
    ị  Unindex; retrieve the items of A at the specified indices.


(KevinC's) Triangular DeciDigits Sequence Input:

A positive integer n which is 1 <= n <= 25000.

Output:

In this sequence we start with the decimal number 1/n.
Then we take the sum of digits up until the n'th digit after the comma (1-indexed); followed by the sum of digits up until the (n-1)'th, then (n-2)'th, etc. Continue until n is 1.
The output is the sum of all these combined.

For example:

n = 7
1/7 = 0.1428571428...
7th digit-sum = 1+4+2+8+5+7+1 = 28
6th digit-sum = 1+4+2+8+5+7 = 27
5th digit-sum = 1+4+2+8+5 = 20
4th digit-sum = 1+4+2+8 = 15
3rd digit-sum = 1+4+2 = 7
2nd digit-sum = 1+4 = 5
1st digit     = 1
Output = 28+27+20+15+7+5+1 = 103

Challenge rules:

If the decimal of 1/n doesn't have n digits after the comma, the missing ones will be counted as 0 (i.e. 1/2 = 0.50 => (5+0) + (5) = 10).
You take the digits without rounding (i.e. the digits of 1/6 are 166666 and not 166667)

General rules:

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.
Also, please add an explanation if necessary.

First 1 - 50 in the sequence:

0, 10, 18, 23, 10, 96, 103, 52, 45, 10, 270, 253, 402, 403, 630, 183, 660, 765, 819, 95, 975, 1034, 1221, 1500, 96, 1479, 1197, 1658, 1953, 1305, 1674, 321, 816, 2490, 2704, 4235, 2022, 3242, 2295, 268, 2944, 3787, 3874, 4097, 1980, 4380, 4968, 3424, 4854, 98

Last 24990 - 25000 in the sequence:

1405098782, 1417995426, 1364392256, 1404501980, 1408005544, 1377273489, 1395684561, 1405849947, 1406216741, 1142066735, 99984

Mathematica, 42 bytes

#&@@RealDigits[1/#,10,#,-1].(#-Range@#+1)&

or

#&@@RealDigits[1/#,10,#,-1].Range[#,1,-1]&

or

Tr@Accumulate@#&@@RealDigits[1/#,10,#,-1]&

Explanation

Take the example from the challenge spec. We want to compute:

  1+4+2+8+5+7+1
+ 1+4+2+8+5+7
+ 1+4+2+8+5
+ 1+4+2+8
+ 1+4+2
+ 1+4
+ 1

Rearranging, this is:

  1*7 + 4*6 + 2*5 + 8*4 + 5*3 + 7*2 + 1*1
= (1, 4, 2, 8, 5, 7, 1) . (7, 6, 5, 4, 3, 2, 1)

where . is the scalar product of two vectors.

That's pretty much all the solution does.

#&@@RealDigits[1/#,10,#,-1]

This gets us the first N decimal digits of 1/N (the #&@@ extracts the first element of the RealDigits result because that also returns the offset of the first digit which we don't care about).

Then we get the list from N down to 1 either using (#-Range@#+1) or Range[#,1,-1], both of which are shorter than Reverse@Range@#, and take the scalar product.

The alternative solution instead uses Accumulate to compute a list of all prefix sums and then adds up those prefix sums with Tr.

Since this is really fast even for large inputs, here is a scatter plot of the sequence up to N = 100,000 (doing all of them and plotting them took a while though):

Click for larger version.

The blue line is the naive upper bound of 9 N (N+1) / 2 (if all the decimal digits were 9) and the orange line is exactly half of that. Unsurprisingly this is right inside the main branch of the plot since, statistically, we'd expect the average digit to be 4.5.

The thin line of plot points which you can see below the main branch are fractions which end in ...3333..., as they all lie very close to 3 N (N+1) / 2.


Old MacDonald function Create a function in your chosen language that prints out the following:

Old MacDonald had a farm, E-I-E-I-O,
And on that farm he had a cow, E-I-E-I-O,
With a moo moo here and a moo moo there,
Here a moo, there a moo, everywhere a moo moo,
Old MacDonald had a farm, E-I-E-I-O!

Where cow and moo are strings in the function parameters, and as such, can be changed to pig and oink or sheep and baa, for example.

It should take into account capital letters, hyphens, punctuation, spaces and line breaks.

Aim to type the fewest amount of Unicode characters in your code.

Javascript ES6 - 204

  Aim to type the fewest amount of Unicode characters in your code.

Not the shorter but probably the most obfuscated.

f=(a,b)=>{for(c=[b,a].concat('!,-ADEHIMOWacdefhilmnortvwy \n'.split(o='')),i=62;i;o+=c[e>>10]+c[e/32&31]+c[e&31])e='ⱞᄤ⒇瓤抣瘭㾭癍㚏᫶⦮函࿋Π疽䌐獲樘ྰ㞠戝晐}疽䌐࿈䌐眲Π疽㛏戝癐Π疽伲࿌⒋ფᲉѽ疽䦯䨝抽瘭䦹容㾷碶ᅣᲉᄤྦྷ㜕㞱㗽㾲妴㣗畍⺏'.charCodeAt(--i);alert(o)}

If your browser do not support ES6 :

function f(a,b){for(c=[b,a].concat('!,-ADEHIMOWacdefhilmnortvwy \n'.split(o='')),i=62;i;o+=c[e>>10]+c[e/32&31]+c[e&31])e='ⱞᄤ⒇瓤抣瘭㾭癍㚏᫶⦮函࿋Π疽䌐獲樘ྰ㞠戝晐}疽䌐࿈䌐眲Π疽㛏戝癐Π疽伲࿌⒋ფᲉѽ疽䦯䨝抽瘭䦹容㾷碶ᅣᲉᄤྦྷ㜕㞱㗽㾲妴㣗畍⺏'.charCodeAt(--i);alert(o)}

Copy/Paste that code into your browser console and try f('cow','moo'), f('pig','oink'), f('sheep','baa')

How it works ?

c is an array of 29 letters plus the animal and its sound (let call this our alphabet).
So, all the 31 characters fit in 5 bits (2^5 = 32).
A Unicode character is 16 bits long, so it can encode 3 characters of our alphabet with a padding bit.
The full text with the new lines is 186 characters of our alphabet, it can be encoded with 62 Unicode characters.

For example, Old is encoded like this :

alphabet value         O      l      d
alphabet index         11     20     15
unicode           0  01011  10100  01111  ===> \u2e8f (⺏)

If you have troubles to read some Unicode chars, install Code2000 font


Draw a hollow square of # with given width I got this challenge from Codingame and am curious about better solutions than mine:

Given a width via standard input draw a hollow square of '#' in given width and length.

Example:

5 results in

#####
#   #
#   #
#   #
#####

I used python to solve this so i am particulary interested in other python code. But please feel free to post your solution in any language you want.

Charcoal, 6 bytes

Code:

ＮβＢββ#

Explanation:

Ｎβ        # Get input from the command line and store into β
   Ｂ      # Draw a hollow box with...
     β     #  Width β
      β    #  Height β
       #   #  Filled with the character '#'
           # Implicitly output the box

Try it online!


Make a better score than my students! For the last day of the semester, I decided to have some fun with my students and I showed them Code Golf... poor guys, they're addicted now.
The goal was to compete against the other students to solve those problems with what would be very usual rules for you. They had to use C# (because it's the language they are learning right now) so please do the same.
The length of each method must be the shortest including the method signature!
Tasks
Write functions that do the following:

Input: string, int.
Output: string.
Description: the output string repeats the input string as many times as the input int.
Example: a("Hi", 5) returns "HiHiHiHiHi".
Input: int.
Output: int.
Description: the output is the quantity of prime numbers lower or equal to the input.
Example: b(10) returns 4. b(100) returns 25.
Input: object[].
Output: object[].
Description: returns the input without the null values.
Example: c(new object[] { "Hello", 42, null, new Program(), null, null, false }) returns an array containing [Hello, 42, Program instance, false].
Input: int.
Output: int.
Description: the output is the sum of all the integers from 1 to int input.
Example: d(4) returns 10 (because 1 + 2 + 3 + 4 = 10).
Input: char.
Output: char.
Description: the output is the input char with the other case. non-letters don't need to be checked.
Example: e('a') returns 'A'. e('A') returns 'a'. e('-') may have unexpected results.
Input: string, int.
Output: bool.
Description: true if and only if the length of the input string is a multiple of the input int.
Example: f("Programmer", 5) returns true. f("Programming", 5) returns false.
Input: string.
Output: boolean.
Description: true if and only if the input string is a palindrome.
Example: g("level") returns true. g('label') returns false.

Their solutions
I took the best of each task that they presented to me.

64
135
105
30
71
45
83

Total: 533
(I will write their complete answers when the challenge is over).
Your rules

Use C# to be evaluated equally to my students.
Write each task on a separate line with the method signature (string a(string s,int i)), it is part of the answer.
Write your best score for each task so we know what score matches what task.
Write the sum of all task scores in the title of your answer.
The shortest overall score wins, but honorary mention may be awarded to the lowest score of a given task.

Note: It is not impossible that many of you have the same answer, my students did without cheating. Please consider that someont who has the same answer as you may simply have taken the same path and did not steal your idea.

FAQ:

Why should people here use C#? It's not the best language for code golfing !
I know, but I would like to have some examples from pros like you to show them what a real golfer would do in their shoes.

Score: 387

string a(string s,int n){return string.Join(s,new string[n+1]);} (64)
int b(int n){bool p=true;for(int i=2;i<n;i++)if(n%i<1)p=false;return n<2?0:b(n-1)+(p?1:0);} (91)
object[]c(object[]l){return l.Where(x=>x!=null).ToArray();} (59)
int d(int n){return(n+1)*n/2;} (30)
char e(char c){return(char)(c<97?c+32:c-32);} (45)
bool f(string s,int n){return s.Length%n<1;} (44)
bool g(string s){return s.SequenceEqual(s.Reverse());} (54)

Total: 387


Output: Calendar Month (without native calendar generating functions) Upon receiving month and year in YYYYMM format, generate output of the corresponding calendar month for that year.

For example the input 201312 should generate the following output:

Mo Tu We Th Fr Sa Su
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

Only trick is, NO native calendar generating functions... so Linux clones, no "cal" function... Muahahahahah!

PS: The calendar must start out with Monday as the left-most day, this is to ensure that the output is like the "cal" function, but does not output like "cal", which has Sunday as its left-most day...

Smallest code size wins.

Ruby, 170 168 characters
g=gets.to_i
require'date'
d=Date.new g/100,g%100
puts'Mo Tu We Th Fr Sa Su'
l=['']*(d.jd%7)+[*1..(d>>1).jd-d.jd]
56.times{|i|$><<"#{l[i].to_s.rjust 2} #{?\n if i%7>5}"}

Bugfix: didn't require the neccessary library (+16)
used julian date modulo 7 instead of current week day directly (-3)
used /100 and %100 to parse date instead of regex (-13). Taken from LegoStormtroopr's answer.
removed the parentheses around the argument to rjust and Date.new(-2)


Write a java code to detect the JVM version The objective is to write java code that detects the JVM version relying in compatibility changes, side effects, bugs and/or undefined behavior that works in a way in one version and another way in another version. Further, the code should be at least a bit readable, without sacrificing whitespaces and legible variable names.

To ensure that objective, the exact formal rules are:

The code must be written in java and should output the JRE version in which it is running.
The code must not use any JDK or JRE API provided specifically for detecting the java version or which gives the JDK or JRE version for free.
The code must not use reflection.
The code is only required to work in Hotspot Java SE 5, 6 and 7, but may work in other JVMs.
The code must not use any third-party libraries in the classpath.
The code must not start any other process, java or not.
The code must not use environment variables.
The code must not search the file system looking for pre-existing files or folders.
The code must be contained in a single file and be called via public static void main(String[] args) or public static void main(String... args).
The code must not use any non-public API present in the JRE.
The code must not generate any NoClassDefFoundError, NoSuchMethodError, ClassNotFoundException or NoSuchMethodException during its execution.
The code should run in a system disconnected from the internet or from any local network.
You should provide an explanation of why it behaves in one way in a version and another way in another version.

Scoring

The method used for measuring the best solution is max(n/s), where n is the number of different java versions detected without violating any of these rules (at least versions 5, 6 and 7) and s is the number of lexical tokens in the solution.

I'm not sure what my score is, because it depends on what precisely you consider to be a lexical token, but I'm trying to abuse that counting system as much as possible with a long string...

It also depends on whether you count this as identifying 7 different versions or 16... (It could trivially be extended up to 190).

class V extends ClassLoader
{
    public static void main(String[]args)
    {
        for(byte b=60;;)
            try {
                byte[]buf="\u00ca\u00fe\u00ba\u00be\u0000\u0000\u00002\u0000\u0005\u0007\u0000\u0003\u0007\u0000\u0004\u0001\u0000\u0001A\u0001\u0000\u0010java/lang/Object\u0006\u0000\u0000\u0001\u0000\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000".getBytes("ISO-8859-1");
                buf[7]=b--;
                new V().defineClass(buf,0,53);
                System.out.println(b-43);
                break;
            }
            catch(Throwable t){}
    }
}

It works by attempting to define an interface in a custom classloader with descending major version numbers of the class format. The first one which doesn't throw a java.lang.UnsupportedClassVersionError corresponds to the VM's version.


Reverse the Polarity The aim of this challenge is to write a program that satisfies the following conditions:

The program is not palindromic, or essentially palindromic (meaning that it is possible to remove characters to make it a palindrome without changing the effects of the program).
The program is not an involution (meaning that it does not produce its original input when run on its output)
The reversed-polarity program is the inverse of the normal program; so when the reversed program is run on the output of the normal program, it returns the original input.

What does reversed-polarity mean? Well, it differs between languages.

For most non-esolangs, this means reversing the order of sub-operations in a single operation, reversing the order of arguments, and reversing the contents of hard-coded lists/arrays/tuples/dictionaries/stacks/queues/etc, as well as reversing the order of code-blocks and stand-alone lines (but not lines within blocks)

Examples:

Haskell:
x`mod`y -> y`mod`x;zipWith ((*3).(+)) [1,2,3] [4,5,6] -> zipWith ((+).(*3)) [6,5,4] [3,2,1]

Python: 2**3 -> 3**2; for x,y in [(1,2),(3,4),(5,6)] -> for y,x in [(6,5),(4,3),(2,1)]

For languages that have 1-character functions (like Pyth, APL), simply reverse the string of instructions
For 1-dimensional esolangs like BF, reverse the instructions or swap the polarity; polarity swaps are [] -> {}, + -> -, - -> +, > -> <, < -> >, . -> , and , -> . (but not both)
For 2-dimensional esolangs like Befunge, you may either perform a reflection across the x- or y- axes or a diagonal, rotate 180 degrees, or do a combination of a reflection and a rotation

Commutative operations are allowed, but palindromic ones are not: 2*x is fine, but x+x is bad. The definition of a polarity-reversal is pretty loose, but use your judgment as to what makes sense; the object isn't to find the most clever loophole, but to find the most clever solution.

This is a popularity contest, so a very clever loophole may be popular, but try to keep within the spirit of this challenge. The winner will be announced once there are at least 10 solutions with at least 1 upvote, and there is at least one solution with more upvotes than there are submissions with at least 1 upvote; or in 1 month, whichever comes first. This is my first challenge, so try to be fair and give me constructive feedback, but also let me know if this is an unreasonable challenge or it is in any way miscategorized or ambiguous. If you have questions about a language that don't fit into any of the pigeonholes I have set out here, comment, and I will bend to the will of the community if there is a strong outcry for a particular clarification or rule-change.

UPDATE

It has been exactly 1 month since this contest was started (I just happened to check on it by chance, not knowing that I was actually on time). As this is a popularity contest, the winner (by a landslide) is
Pietu1998-Befunge. Even though the bottom components (the text reverser and the backwards-alphabet) are both involutions, the encoder/decoder are not, so there is no problem there. Bonus points (in my mind) for managing to write "BEFUNGE" down the middle. I personally liked the novelty of Zgarb's Theseus solution, because the language looks cool (if restricted). Thanks to everyone for participating, and while the winner has been chosen, I am leaving this contest completely open, and welcome future submissions.

Befunge

Whoa, that was a job, even with the editor I made for this challenge. Here's what I got, a nice 11x12 block:

v$,g6<6g,$v
v,$ _^_ $,v
1W>v\B\v>L1
~T+:1E1:-O~
+F00-F-02L+
>:|6gUg6|:>
{a@>^N^>@z`
>1+|@G$| +>
:^9< E<  ^1
~>7^@_,#:>:
 xD>65 ^=P~
v,-\+**<  v

It does a couple of things, sadly only for lowercase letters.

What it does

When run normally, it performs a Caesar cipher on the input.

abcxyz      -> bcdyza
exampletext -> fybnqmfufyu

When flipped horizontally, it reverses said cipher. This is the requirement for the challenge, but it doesn't end here.

bcdyza      -> abcxyz
fybnqmfufyu -> exampletext

When flipped vertically, it ciphers input with a reverse alphabet. This can be considered the opposite approach to the Caesar cipher.

abcxyz      -> zyxcba
exampletext -> vcznkovgvcg

Finally, when rotated 180 degrees, it reverses input. I have a feeling it has to be a reverse of something (hint: the input).

abcxyz      -> zyxcba
exampletext -> txetelpmaxe

How it works

The block basically consists of four semi-overlapping algorithms.

Caesar cipher encoder

v$,g6<
v,$ _^
1 >v\
~ +:1
+ 00-
>:|6g
{a@>^

Caesar cipher decoder (flipped horizontally)

v$,g6<
v,$ _^
1 >v\
~ -:1
+ 20-
>:|6g
`z@>^

Reverse alphabet cipher (flipped vertically)

v,-\+**<
   >65 ^
~>7^
:^9<
>1+|@
   >^

Text reverser (rotated 180 degrees)

v  <
~
:>:#,_@
1^  <
>+ |$
   >^


Name the poker hand - 7 cards edition The Challenge:
In this question: Name the poker hand you had to take a five card poker hand and identify it. This question is similar, with two twists:
First, the output will be in all lower case. This allows for more golfing, as you don't have to worry about the capitalization of flush and straight
high card
one pair
two pair
three of a kind
straight
flush
full house
four of a kind
straight flush
royal flush

Secondly, with the popularity of Texas Hold'em and 7 card stud, we here at code golf should be able to score a seven card poker hand am I right? When scoring a seven card hand, use the five best cards for your hand and ignore the two you don't need.
Reference:
List of poker hands: http://en.wikipedia.org/wiki/List_of_poker_hands
Input (lifted directly from the previous thread)
7 cards from either stdin or commandline arguments.
A card is a two letter string on the form RS, where R is rank and S is suit.
The ranks are 2 - 9 (number cards), T (ten), J (Jack), Q (Queen), K (King), A (Ace).
The suits are S, D, H, C for spades, diamonds, hearts and clubs respectively.
Example of cards
5H - five of hearts
TS - ten of spades
AD - ace of diamonds

Example of input => desired output
3H 5D JS 3C 7C AH QS => one pair
JH 4C 2C 9S 4H JD 2H => two pair
7H 3S 7S 7D AC QH 7C => four of a kind
8C 3H 8S 8H 3S 2C 5D => full house
AS KC KD KH QH TS JC => straight

Notice in the second example there are actually three pairs, but you can only use five cards, so it's two pair. In the fifth example, there are both a three of a kind and a straight possible, but a straight is better, so output straight.
Scoring
This is code-golf, so shortest code wins!
Errata

You may not use external resources.
Ace is both high and low for straights.

Haskell 618 603 598 525 512 504 480 464

Cards taken as a line of input. I think I've golfed this to death, but will easily be beaten by ruby etc using the same trick: if you generate all permutations, you get the forward sorts you want to look for straights, plus the reverse sorts you want for testing N of a kind.

import Data.List
m=map
z=take 5
q=m(\x->head[n|(f,n)<-zip"A23456789TJQK"[1..],f==x!!0])
l=m length
v=" of a kind"
w="flush"
y="straight"
c f s p r|f&&r="9royal "++w|f&&s='8':y++" "++w|f='5':w|s||r='4':y|True=case p of 4:_->"7four"++v;3:2:_->"6full house";3:_->"3three"++v;2:2:_->"2two pair";2:_->"1one pair";_->"0high card"
d x=c([5]==l(group$m(!!1)x))(q x==z[head(q x)..])(l$group$q x)$q x==1:[10..13]
k h=tail$maximum$m(d.z)$permutations$words h
main=interact k

Edited to inline "pair" and use number prefixes after seeing @FDinoff's entry, also composed map functions to shave one more char.


Coding hex board game Introduction
Hex is a strategy board game played on a hexagonal grid, theoretically of any size and several possible shapes, but traditionally as an 11×11 rhombus. Other popular dimensions are 13×13 and 19×19 as a result of the game's relationship to the older game of Go. According to the book A Beautiful Mind, John Nash (one of the game's inventors) advocated 14×14 as the optimal size.

Game Rules
Each player has an allocated color, conventionally Red and Blue or White and Black. Players take turns placing a stone of their color on a single cell within the overall playing board. The goal for each player is to form a connected path of their own stones linking the opposing sides of the board marked by their colors, before their opponent connects his or her sides in a similar fashion. The first player to complete his or her connection wins the game. The four corner hexagons each belong to both adjacent sides.
Coding Rules

You may use any program or language. Do not use any third party libraries or modules (full or in part) that implements the same game. The rest are fine.
Players are computer and user.
You may choose the size of the grid.
You may use either CLI or GUI for output (see points).
Your code should not exceed 5120 bytes.

Points

+(5120 - bytes) / 100 golfing points
+50 points for making GUI
+50 for two player mode
+75 for best-move-prediction#
+50 for undo-move

# Tell the user, if they wish, their next best move.
Super bot challenge

+150 points if your bot is undefeatable. Add this points ONLY IF you are absolutely certain of your bot's 100% winning capability. If any user defeats your bot and reports it all your points will be taken away (zero points). The person reporting this must either post a screenshot or input sequences based on the implementation of game. They will be awarded +150 points, if they have posted an answer.

HTML5 and JavaScript, 12.72 + 50 + 50 + 50 = 162.72 points

Hi, this is my very first code golf, but I think, the following code works quite well (it's a full HTML page, 3848 bytes).

<meta charset="utf-8"><title>Hex</title><canvas style="position:absolute;top:0px;left:20px" width="850" height="600" id="o"></canvas>
<input type="button" onClick="I()" value="New game">

Multiplayer: <input id="mp" type="checkbox" onClick="Mp()">
<input type="button" onClick="U()" value="Undo">

Expanded

    <meta charset="utf-8">
    <title>Hex</title>

    <canvas style="position:absolute; top:0px; left:20px" width="850" height="600" id="output">Canvas not supported...</canvas>

<input type="button" onClick="init()" value="New game">

Multiplayer: <input id="mp" type="checkbox" onClick="chgMP()">
<input type="button" onClick="undo()" value="Undo">

Explanation

The code uses the HTML5's canvas-tag to display the game (14x14 board). You can undo the last step and play against another player (enable Multiplayer) or the computer, but its AI is still very weak (it just uses a random position to place the next field). The entire graphical design is based on your screenshot.


Noel Constant's idiotically simple investment system Noel Constant did it without genius and without spies.

  His system was so idiotically simple that some people can't understand it, no
  matter how often is is explained. The people who can't understand it are people
  who have to believe, for their own peace of mind, that tremendous wealth can be
  produced only by thremendous cleverness.

  This was Noel Constant's system:

  He took the Gideon Bible that was in his room, and he started with the first
  sentence in Genesis.

  The first sentence in Genesis, as some people may know, is: "In the beginning
  God created the heaven and the earth." Noel Constant wrote the sentence in
  capital letters, put periods between the letters, divided the letters into
  pairs, rendering the sentence as follows: "I.N., T.H., E.B., E.G., I.N. N.I.,
  N.G., G.O., D.C., R.E., A.T., E.D., T.H., E.H., E.A., V.E., N.A., N.D., T.H.,
  E.E., A.R., T.H."

  And then he looked for corporations with those initials, and bought shares in
  them. His rule at the beginning was that he would own shares in only one
  corporation at a time, would invest his whole nest-egg in it, and would sell the
  instant the value of his shares had doubled.

–Kurt Vonnegut, Sirens of Titan

The investor Noel Constant is getting tired of using his system manually. He
needs the power of computers to pick the companies to invest in.

Noel Constant is willing to learn how to execute a command line script or a
function in the language of your choice. He will provide a single string of
input. He won't bother removing any whitespace, punctuation, or change case for the input string. He doesn't like that kind of work.

In return he expects to see a list of companies he can invest in, produced
according to his idiotically simple system. He wants to see each company on its
own line with the initials in brackets. If there isn't a company with the
initials needed he wants to see three dots (...).

International Nitrate (IN)
Throwbridge Helicopter (TH)
Electra Bakeries (EB)
Eternity Granite (EG)
... (IN)

His company, Magnum Opus, provided a list of company names and their initials
for you: https://gist.github.com/britishtea/2f57710a114cfd79616d.

As you may have guessed, Noel Constant doesn't like reading, so he'll want the
shortest program or function possible.

EDIT

To clarify, the input to the function or program is string (with punctuation and whitespace, case unaltered). An example of such a string is "In the beginning
God created the heaven and the earth." The list of company names and initials is not an input source, it should be read some other way (from disk for example).

The output is a list in the above format. I forgot to mention in the original challenge that the order the company names appear in shouldn't be altered, i.e. if you read the initials in the output from top to bottom it renders the original input (stripped of punctuation and whitespace).

This is no longer a requirement, but if your function or program satisfies this condition, there is a 0.9 bonus (# characters * 0.9) in it for you.

Unix tools, 111 * 0.9

(Not counting downloading and parsing the Bible)

$ curl -s https://www.gutenberg.org/cache/epub/10/pg10.txt|grep '^[0-9]:'|cut -d' ' -f2-|sed 's/[^a-z]//gi'|tr -d \\n|fold -w2|xargs -n1 sh -c 'grep -i ^$0 symbols.txt'|sed -r 's/(..) (.*)/\2 \(\1\)/'
Zylog Systems Ltd (IN)
Zynga Inc - Cl A (TH)
Zwahlen & Mayr Sa-br (EB)
Surpapelcorp Sa (EG)
Zylog Systems Ltd (IN)
Nisource Inc. (NI)
Novagold Resources Inc. (NG)
Zealand Pharma A/s (DC)
Everest Re Group, Ltd. (RE)
Atlantic Power Corporation (AT)
^C

I am not a professional investor but I think that the more times a company is mentioned in the Bible the more successful it will be, so I would invest in these:

  10027 th - Zynga Inc - Cl A
   9026 he - Hawaiian Electric Industries, Inc.
   4748 nd - *
   3681 an - Autonation, Inc.
   3150 ha - Hawaiian Holdings, Inc.
   3109 er - *
   2925 re - Everest Re Group, Ltd.
   2829 in - Zylog Systems Ltd
   2665 nt - *
   2519 es - *

(Future founders, consider creating a company with stock symbols I marked with *, they are not yet taken)


Shortest code to print ':)' random times You have to create a code which prints

:)

a random number of times from 1 to 255 inclusive. Your output may not contain any whitespace.

Your score :
The count in bytes

EDIT : Also show 3 outputs of your code


The most pointless shell command you can concoct, based upon a often used shell command Let's waste some time coming up with stupid ideas which are close cousins of good ideas.

Your useless command doesn't have to fit any minimum or maximum length.
Do, however, try to turn it into a one-liner if you can.
No particular requirement for what shells and utilities are used, within reason.
He who wins, wins.
More rules will be added if they are added.

Mine is the inverse of "print the kernel arguments you booted with on Linux":

cat /proc/cmdline
# turns into...
fgrep -x -f <(awk -F\= 'BEGIN { RS = " "} ; {print $1"="}' </proc/cmdline)\
-v <(curl 'https://www.kernel.org/doc/Documentation/kernel-parameters.txt'
2>/dev/null | awk '/\t+[a-z._]+=/ {print $1}' | tee test2) | tr '\n' ' ' &&
echo


Can the dog reach the neighbour's house? A dog is leashed to a pole and the owner wants to know if it can venture to the neighbour's building. You're given a map, which contains the pole (represented by x), the owner's buildings (represented by 1) and the neighbour's building (represented by 2). Empty areas are padded with dots and every line has the same length. EDIT: I forgot to mention, neighbour is always to the right from the dog. Every tile represents an area of one square meter. You're also given the length of the dog's leash (as meters). The pole is at the center of the tile. For input you must use the STDIN (and respectively STDOUT for output), if it's available in your language. Otherwise create a function, which takes the input as parameters and returns the answer. An example input to the STDIN would look like this.

6
............
...11..222..
...11..222..
...11.......
.x.11.......
............

Additional newline is guaranteed after the input. The program should output Yes if the dog can reach the neighbour's building and otherwise No.

Assumptions

There can be several buildings belonging to the owner.
There can only be one neighbour's building.
The dog can't venture outside the map or through the buildings.
The dog can't be trapped inside a building.
The length of the leash is always an integer
Distances are calculated in Euclidean metric.

This is a codegolf, shortest code wins.

Test cases

Input:

6
............
...11..222..
...11..222..
...11.......
.x.11.......
............

Output: No

Input:

7
............
...11..222..
...11..222..
...11.......
.x.11.......
............

Output: Yes

Input:

7
........
...11...
..111.22
..111.22
.x111.22
..111.22
..111...

Output: No

Input:

8
........
...11...
..111.22
..111.22
.x111.22
..111.22
..111...

Output: Yes

PHP 781 chars
I know this can be smaller but I am sorry that I am confused. If I take your first two examples (answers no and yes), if diagonal moves are not allowed, answers should be no and no, surely. If diagonal moves are allowed, answers should be yes and yes. Have I misunderstood?
I also took beside to be the criteria of 'reached' as the dog can then wee on the building - however changing that to on top of can easily be done changing the pass counter which currently equals leash length.
Anyway, this allows for diagonal movement, non diagonal would be smaller than this.
<?php
$a.='7
............
...11..222..
...11..222..
...11.......
.x.11.......
...........';$b='No';$c=array();$d=array();function check_2($e,$f){if(($c[$e+1][$f-1]=='2')OR($c[$e+1][$f]=='2')OR($c[$e+1][$f+1]=='2')OR($c[$e][$f-1]=='2')OR($c[$e][$f]=='2')OR($c[$e][$f+1]=='2')OR($c[$e-1][$f-1]=='2')OR($c[$e-1][$f]=='2')OR($c[$e-1][$f+1]=='2')){return TRUE;;}else{return FALSE;}}str_replace("\n\r","\n",$a);$g=explode("\n",$a);$h=$g[0];unset($g[0]);$i=count($g);$j=0;foreach($g as $k){$l=str_split($k);$m=count($l)+1;unset($l[$m]);$c[$j]=$l;++$j;}$d=$c;for($n=0;$n<=$h;++$n){for($e=0;$e<$i;++$e){for($f=0;$f<$m;++$f){if($c[$e][$f]=='2'){$b='Yes';}if($c[$e][$f]=='x'){for($o=-1;$o<2;++$o){for($p=-1;$p<2;++$p){if($c[$e+$o][$f+$p]=='.'){$d[$e+$o][$f+$p]='x';}}}}}}$c=$d;}echo $b;?>

I am pretty sure I can make this smaller but with the confusion not sure which way to go.
Anyway this is my first flood fill so I am sure it can be done more efficiently. Most of the work was getting the input into a variable and a multi dimensional array.
The input it contained in the first variable $a. You can see it here on codepad.
I hope you like it. As a relative newbie and since this is the only answer I suppose I am officially winning here at the moment. Although I cannot imagine this will last long if someone else enters :-)


Convert Brainfuck to a Non-Golfing Language Input:
Any Brainfuck program. This includes brainfuck programs with comments such as +++COMMENT[>+++<-]..
Output:
A program in one of the below languages that produces the same output as the Brainfuck program on all inputs. It should produce the same output exactly as the interepreter on this website There are no code-golf or performance restrictions on the output program; the outputted program doesn't need to be optimized in any way. In other words, the quality of the outputted program does not affect score, only the translation program. To clarify: you may write your answer in any language that is normally valid for answers on PCG. The restriction on output languages is only for the outputted program.
The outputted program only receives the same input that would be received by the Brainfuck program. The outputted program does not receive the Brainfuck program as input.
Valid Output Languages

C#
C++
C
Java 8
Javascript ES6 (it is both okay to receive all of stdin in a single prompt, or multiple prompts per character)
Perl
Python 2.7
Python 3.4.2
Ruby

Fine Print
You may write a program or function which takes the Brainfuck program as a String argument or on STDIN or closest alternative, and which returns the output as a String or printing it to STDOUT (or closest alternative). You may optionally include a single trailing newline in the output.
Additionally, standard loopholes which are no longer funny are banned. You may not use external libraries or external data files, the code must be self contained.
This is code-golf, shortest program wins.

K, 143 129 113 bytes

1!"}int a[99];int*p=a;main(){",,/{("p++;";"p--;";"*p++;";"*p--;";"*p=getchar();if(*p<0)*p=0;";"putchar(*p);";"while(*p){";"}";"")"><+-,.[]"?x}'

This is an extremely straightforward approach which generates C source code by emitting a preamble, a C snippet for each BF command and then a postscript. Non-BF characters are translated into empty strings in the concatenated output.

The translation into C is as follows:

preamble: int a[99];int*p=a;main(){
>: p++;
<: p--;
+: *p++;
-: *p--;
,: *p=getchar();if(*p<0)*p=0;
.: putchar(*p);
[: while(*p){
]: }
postscript: }

I suspect that there is room for improvement here by using more mangled abuses of C or compressing the C fragments.

The K part of the program by itself would look like the following, where c is the C translations of each BF instruction and p is the preamble/postscript:

1!p,,/{c"><+-,.[]"?x}'

Using the venerable BF string reverser program >,[>,]<[.<] as my test case I generate code which looks like the following after a bit of whitespace for readability:

int a[99];
int*p=a;

main(){
    p++;
    *p=getchar();if(*p<0)*p=0;
    while(*p){
        p++;
        *p=getchar();if(*p<0)*p=0;
    }
    p--;
    while(*p){
        putchar(*p);
        p--;
    }
}

edit:

A few tweaks. Firstly, more compliant tape declaration as suggested by alexander-brett. The int part can be left off:

int a[99]; -> a[1<<15]; (-1 byte)

Also, it seems that EOF behavior in BF can return 0, -1 or cause no change as a result of ,. EOF=-1 seems to be what other solutions are going with, so for the sake of uniformity I will do the same:

*p=getchar();if(*p<0)*p=0; -> *p=getchar(); (-13 bytes)

Note that this means my string reverser program will choke if you simply cat it a file ending in EOF(!), but as above it seems to be fair.

The new complete 129 byte solution:

1!"}a[1<<15];int*p=a;main(){",,/{("p++;";"p--;";"*p++;";"*p--;";"*p=getchar();";"putchar(*p);";"while(*p){";"}";"")"><+-,.[]"?x}'

edit 2, much, much later:

I randomly stumbled upon this old answer and, being older and wiser, realized there are several ways to make this shorter:

exploit the fact that it's completely syntactically valid C to include semicolons after every fragment instead of just those who need them, and thus remove them from the lookup table entries.
use the k5/k6 or oK dialects, which have overloads for \ and / which split a string apart on a character or join a list of strings with a character, respectively, to use a more compact representation of the lookup table and accomplish the above.
take advantage of the fact that find (dyadic ?) in the above dialects naturally conforms to a listy right argument, and thus does not need an explicit lambda + each

The one downside is that in these dialects there is no "rotate" primitive, so we have to add the "}" suffix in a less elegant manner. The overall structure of our solution:

1!     p, ,/{c"><+-,.[]"?x}'   / old
,[;"}"]p,";"/c"><+-,.[]"?      / new

The complete (and now totally points-free!) solution:

,[;"}"]"a[1<<15];int*p=a;main(){",";"/("|"\"p++|p--|*p++|*p--|*p=getchar()|putchar(*p)|while(*p){|}|")"><+-,.[]"?

Which shaves us down to 113 bytes.


Is it a good 2048 board? This is my first question here, so any suggestions in the comments would be appreciated! Thanks ;)
Introduction
One very common strategy for the 2048 game is never ever swiping down. This positions all the big numbers at the top, and the lower ones in the bottom. So, if you apply this strategy correctly, your board will always match the following pattern:
The pattern to check for / Your task
Your submission should be either a full program or a function which returns a truthy value if the board can be described like this:
Going down each column of the board, the first number should be the highest of the column, the second number should be less than or equal to the first number, etc. A good 2048-board is defined as a board where the highest numbers are all on the top.
This is code-golf, so the shortest Code per language (in bytes) wins.
I/O
The input can be taken in any appropriate way, for example an array of 4 arrays, each containing 4 numbers, or an array of 16 numbers. In total, it will be always 16 numbers, representing the 4x4 board
The output should be a truthy value of the input is a "good 2048-board", and a falsy value otherwise.
Examples
Truthy:
|-------------------|
| 16 |    | 64 |  8 |
|-------------------|
|  8 |    | 32 |  8 |
|-------------------|
|  4 |    | 32 |  2 |
|-------------------|
|  2 |    |    |    |
|-------------------|

|-------------------|
| 16 | 128| 64 | 32 |
|-------------------|
|  8 | 128| 32 |  8 |
|-------------------|
|  4 | 16 |  8 |  2 |
|-------------------|
|  4 |    |    |    |
|-------------------|

Falsy:
|-------------------|
| 16 |    | 64 |  8 |
|-------------------|
|  8 |    | 32 | 16 |
|-------------------|
| 32 |    | 128|  2 |
|-------------------|
|  2 |    |    |    |
|-------------------|

|-------------------|
| 16 | 128| 64 | 32 |
|-------------------|
|  8 |  32|    |  8 |
|-------------------|
|  4 | 16 |  8 |  2 |
|-------------------|
|  4 |    |    |    |
|-------------------|

Note
Look at the 2nd falsy test case: When there is an empty value (or a 0) somewhere and even when it's followed by a value which is higher than the last non-zero number, this should be falsy, because the next value after the zero would be higher than the 0 itself, which makes it invalid.
Good luck!

Haskell, 21 bytes

all$scanr1 max>>=(==)

Try it online!

Takes a list of columns, with empty spaces as 0.


Generating versions of an array with elements changed in ruby I'm new to code golf challenges. My problem came up in Advent of Code 2020 Day 8
The input is an array of arrays. In part two of the problem one needs to run several trials to produce a result by changing an element in the input array. My current code is this (comments added to explain what's going on):
p input.each_with_index { |val, i|
  next if val[0] != :acc # not all elements need to be experimented with
  changed = input.dup # clone input to make a change
  # change the first element of the value at input position i (but keep the rest)
  changed[i] = val.dup.tap { |v| v[0] = v[0] == :nop ? :jmp : :nop }
  result = try_with(changed) # run the experiment
  break result if result[1] == :terminate # success condition
end

So, that's quite a lot of code for something relatively simple. Can I make it shorter? Can I have a simple generator that produces different versions of the same array?
My complete code for day 8 is here
Edit:
As suggested in the comments, I'll try to put the problem my snippet is solving as a code golf challenge (note that this is just my snippet):
In ruby you have input: an array of instructions. Each element of input is another array of two elements, where the first is a symbol (the instruction name) which is one three: :acc, :jmp, or :nop, and the second is an integer (the instruction argument).
You also have a function try_with which works with such an array, executes the instructions and returns [n, :terminate] if the program terminates or [n, :loop] if the program is an endless loop. n is the value of the accumulator after the execution.
The original input is a loop. If you change one of the instructions in the input array from :nop to :jmp or from :jmp to :nop, and keep the argument, it will result in a terminating program. What is the value of the accumulator after you find and execute the terminating program?
The original AOC2008D8 problem
You have a file with valid assembly. Each line is a three character instruction and a (possibly negative) integer argument separated by a single space. Example
nop +0
acc +1
jmp +4
acc +3
jmp -3
acc -99
acc +1
jmp -4
acc +6

Instructions are acc add arg to accumulator and increment ip, jmp add arg to ip, nop ignore arg and just increment ip.
Then... what I said above about the snippet-only problem
Changing the next-to-last line in the example from jmp to nop results in a termination with acc value: 8

Ruby, 102 99 98 95 bytes

(k=input.map &:dup)[$.-=1][0]=%i[nop jmp acc][k[$.][0]<=>:jmp]until(r=try_with k||$:)[1]>:t;p r

Try it online!
I assume that input and try_with are mandatory names for the Advent of Code challenge. If not, the code can obviously be even shorter. Here, I also assume that the try_with method will accept invalid input, that is, an array whose elements are not of the form [:instruction, integer]. See below for a slightly longer version in case try_with strictly requires valid input.
See commented code below for a complete list of ideas used. Apart from generic code-golf tips such as 'use short variable names', or common Ruby tips such as 'omit parentheses in method calls', here are some specific tips for the problem posed:

Instead of each_with_index, use a counter variable together with an anonymous lambda and redo together with until (or while) in modifier form. For the counter, a good choice in this case is the predefined global variable $., which is initialised to 0. Processing the input array in reverse (by decrementing $. in place) is the best approach. Incrementing $. in place doesn't work (because input[0] would be skipped); incrementing $. at the end of the loop would cost bytes.
Only call dup at the lowest level, that is, on the elements of input, not on input itself.
Lexicographical comparisons work with symbols, so >:t is better than == :terminate, for example.
It turns out to be slightly shorter to use the spaceship operator <=> instead of a ternary conditional to choose between instructions. In the code, k[$.][0]<=>:jmp returns -1 if the current instruction is :acc, 0 if it is :jmp, and 1 if it is :nop. Use these values to index into an array of the three symbols, ordered such that the correct replacement is chosen.

(k=                # use parentheses to define variables inline
   input.map &:dup # only duplicate the lowest-level arrays, and do all at once
)[$.-=1][0]        # use $. as a counter and decrement in place
=%i[nop jmp acc][k[$.][0]<=>:jmp] # use the spaceship operator to choose between instructions
until              # loop with until
(r=try_with k      # omit parentheses in the call to try_with
||$:)[1]           # on the first iteration (only), k is nil so pass the predefined array $: to try_with as dummy input
>:t;               # test for >:t instead of ==:terminate
p r                # print the result

Ruby, 98 bytes

p->{(k=input.map &:dup)[$.-=1][0]=%i[nop jmp acc][k[$.][0]<=>:jmp];(r=try_with k)[1]>:t||redo;r}[]

Try it online!
Use this version if try_with rejects $: as valid input. Here, we iterate using an anonymous lambda and redo.


Quadrants passed through by a line Task

Given a representation of a line, output the number of quadrants that that line passes through.

Valid Representations of a Line

You can represent a line as

Three signed integers A, B, and C which share no common factor and where A and B are not both zero, representing the line Ax + By = C,
Four signed integers X1, Y1, X2, and Y2, representing the line passing through the points (X1, Y1) and (X2, Y2), or
A data type that describes a line, if your language has one (it must support vertical lines).

You may not take input in any format that does not allow for a vertical line (e.g. slope-intercept form). If you choose to take integers as input, you can assume that they lie in the inclusive range [-127, 128].

Specifications

The output will always be 0, 2, or 3 (a line can never pass through all four quadrants, nor can it pass through only a single one).
A line on an axis is considered not to pass through any quadrants. A line through the origin is considered to only pass through 2 quadrants.
You do not have to return which quadrants are being passed through (though the test cases include them for clarity).
This is code-golf, so the shortest valid answer (measured in bytes) wins.

Test Cases

You will have to convert these to a suitable format before using them.

1x + 1y = 1   ->  3  (quadrants I, II, and IV)
-2x + 3y = 1  ->  3  (quadrants I, II, and III)
2x + -3y = 0  ->  2  (quadrants III and I)
1x + 1y = 0   ->  2  (quadrants II and IV)
3x + 0y = 6   ->  2  (quadrants I and IV)
-3x + 0y = 5  ->  2  (quadrants II and III)
0x + -8y = 4  ->  2  (quadrants III and IV)
0x + 1y = 0   ->  0  (lies on the x-axis)
1x + 0y = 0   ->  0  (lies on the y-axis)

Python 3, 24 bytes

lambda a:3<<a.count(0)&3

Try it online!


Palindrome Compression Challenge
Write a program that compresses and decompresses ASCII text losslessly. It should be specialized to work well with palindromes, including case-insensitive and punctuation-insensitive palindromes. The best compression with the smallest source wins.
Scoring
total_bytes_saved / sqrt(program_size) - Highest score wins
total_bytes_saved is how many bytes smaller the compressed strings are than the originals, total across the test cases below. program_size is the size in bytes of the source code of both the compression and decompression programs. Code shared between the two need only be counted once.
For instance, if there are 10 test cases and a 100 byte program saved 5 bytes on 7 test cases, 10 each on 2 of them, but the last test case was 2 bytes longer, the solution would score 5.3. ((7 * 5 + 10 * 2 - 2) / sqrt(100) = 5.3)
Test Cases

tacocat
toohottohoot
todderasesareddot
amanaplanacanalpanama
wasitacaroracatisaw?
Bob
IManAmRegalAGermanAmI
DogeeseseeGod
A Santa at NASA
Go hang a salami! I'm a lasagna hog.

Rules

Standard loopholes apply.
The compression must work on all printable ASCII (bytes 32-126, inclusive) text strings, not just palindromes. It doesn't actually have to save space for any inputs, however.
Output can be any sequence of bytes or characters, regardless of its implementation or internal representation (strings, lists, and arrays are all fair game, for instance). If encoding to UTF-8, count bytes, not characters. Wide strings (e.g. UTF-16 or UTF-32) are not allowed unless the only codepoints possibly used are between 0 and 255.
Compression/Decompression builtins are not allowed.

For the sake of our own enjoyment, post the compressed strings with your source code.
UPDATE 1: Scoring changed from total_bytes_saved / program_size to total_bytes_saved / sqrt(program_size) in order to give more weight to better compression and less weight to aggressive golfing. Adjust your scores accordingly.
UPDATE 2: fixed wasitacaroraratisaw? to be wasitacaroracatisaw?

JavaScript (ES6), 3.143 (81 bytes saved, 664 byte program)

R='replace',S=String.fromCharCode,T=c=>c.charCodeAt(),U='toUpperCase',V='0000000',W=(a,b,c=2)=>a.toString(c).slice(b),X=x=>'0b'+x,Y=a=>[...a].reverse().join``,Z=/[^]/g
C=s=>S(...((Y(q=s[U]()[R](/[^A-Z]/g,m=''))==q?(q=q.slice(0,p=-~q.length/2),p%1&&10):11)+q[R](Z,x=>W(T(x),2))+111+s[R](Z,c=>/[a-z]/.test(c)?W("00",m,m=1):m+(/[A-Z]/.test(c,m='')?"01":W(c<'!'?2:T(c)+384)))+V).match(/(?!0+$).{8}/g).map(X))
D=s=>{s=s[R](Z,c=>W(256+T(c),1))+V;M=r=>(s=s[R](p=s.match(`^${r}|`)[0],''),p);for([,a]=M`1.|0`,t=u=i='';!M`111`;)t+=W(X(M`.{5}`)-~8,0,36);for(t+=W(Y(t),a?a/0:1);p;)u+=M`0(?=00)|00?1`?(c=t[i++])?+p[1]?c[U]():c:'':M`10`?' ':M`11`&&S(X(M`.{7}`));return u+W(t,i)}

Now that I'm fairly satisfied with this program (and the scoring system), I'll write a bit of an explanation.

The basic idea is to compress the input into a string of bits, then compress each set of 8 bits into a byte. For the purposes of explanation, I'll just manipulate the bit string.

The bit string can be separated into several sections:

input  -> Taco Cat.
output -> 0101000000100011011111110100001100100011101011100000000

0      | 10100 00001 00011 01111 111 | 01 00001 10 01 0001 110101110
header | letter data                 | styling data

The header is a very simple mapping:

0  -> odd-length palindrome
10 -> even-length palindrome
11 -> non-palindrome

Letter data is also fairly simple. First, all non-letters are extracted from the string, and all letters are converted to uppercase. If the resulting string is a palindrome, the reversed half is stripped. Then this mapping is applied:

A -> 00001
B -> 00010
C -> 00011
D -> 00100
...
Z -> 11010

This section is terminated with 111. After that comes the styling data, which stores upper/lower-case data and non-letters. This works like so:

01 -> next letter as uppercase
0...01 (n 0s) -> next (n-1) letters as lowercase
10 -> space
11xxxxxxx -> character with code point 0bxxxxxxx

So going through the example shown above, we have

header: 0 -> palindrome
letter data: 10100 00001 00011 01111 111 -> taco
styling data:
  01        -> T
  00001     -> aco
  10        -> <space>
  01        -> C
  0001      -> at
  110101110 -> .

When the end of the bit string is reached, all remaining characters from the letter data are appended to the result. This saves us from having to do one last 000...001 and allows us to truncate these bits from the string.

Going through the test cases:

tacocat -> 3 bytes (-4)
    24 bits: 010100000010001101111111
toohottohoot -> 5 bytes (-7)
    35 bits: 10101000111101111010000111110100111
todderasesareddot -> 7 bytes (-10)
    49 bits: 0101000111100100001000010110010000011001100101111
amanaplanacanalpanama -> 8 bytes (-13)
    59 bits: 00000101101000010111000001100000110000001011100000100011111
wasitacaroracatisaw? -> 11 bytes (-9)
    84 bits: 010111000011001101001101000000100011000011001001111111000000000000000000001110111111
Bob -> 2 bytes (-1)
    16 bits: 0000100111111101
IManAmRegalAGermanAmI -> 13 bytes (-8)
    98 bits: 00100101101000010111000001011011001000101001110000101100111010100010100101000001010100000010100101
DogeeseseeGod -> 7 bytes (-6)
    54 bits: 000100011110011100101001011001100101111010000000000101
A Santa at NASA -> 8 bytes (-7)
    63 bits: 100000110011000010111010100000011110110010000011000011001010101
Go hang a salami! I'm a lasagna hog. -> 20 bytes (-16)
   154 bits: 1000111011110100000001011100011100001100110000101100000010110101001111010011000000110001100000000111010000110011101001110011000110000000001100000111010111


Write a program which replaces with spaces the braces in cases where braces in places cause stasis You are a project manager. One day, one of your programmers went insane (not your fault) and took all the expressions in the codebase and added random brackets to them, before quitting on the spot, ranting about your incompetence (also not your fault). This would be an easy fix, however, for some reason you aren't using revision control (totally not your fault). And for some reason, none of the other programmers want to go through every expression to fix up the mismatched brackets (by the way, that is not your fault). Programmers these days, you think to yourself. You will have to do it yourself. The horror! Such tasks were supposed to be beneath you...

The input will be a single line, which will contain a number of left brackets (( [ {) and right brackets () ] }). It also may, but not always, contain comments (/* */) and string literals (" " or ' ') and various numbers, letters, or symbols.

There will be at least one bracket (outside of a comment or string literal) that does not have a corrosponding opposite (outside of a comment or string literal). For example, an errant } without a { prior. Another example: a ( which does not have a ) afterwards. Your program will replace with a space the minimum number of brackets required to make the brackets match up.

Examples:

(4 + (2 + 3))] ==> (4 + (2 + 3))  (the square bracket at the end)
][][[]] ==>  [][[]] (the square bracket at the start)
("Hel(o!")) ==> ("Hel(o!")  (the parenthesis at the end)
( /* )]*/ ==>   /* )]*/  (the parenthesis at the start)
{()] ==>  ()  (the curly bracket and the square bracket)

Input can be taken from whichever way is most convenient (STDIN, command line argument, reading from a file, etc.)
If there is more than one way to resolve the mismatch with the same number of removals, either is acceptable.
There will be only mismatches in brackets. String literals and comments will always be correctly formed.
The title comes from this SO thread
There will never be any quotes in comments, quotes in quotes, comments in comments, or comments in quotes.

This is code golf, so minimum number of bytes wins. Ask questions in comments if the specification is not clear.

Ruby, 223 characters

This one turned out a bit long.

u,b,i=[],[[],[],[]],-1
s=gets.gsub(/(\/\*|"|').*?(\*\/|"|')|~/){|m|u+=[m];?~}
s.chars{|c|i+=1
(t='{[('.index(c))?b[t].push(i):((t='}])'.index(c))&&(b[t].pop||s[i]=' '))}
b.flatten.map{|l|s[l]=' '}
puts s.gsub(/~/){u.shift}

What it does is take out the strings and comments first, so they don't get counted (and puts them back in later).

Then, it goes through the string character by character. When it finds an opening brace, it stores its position. When it finds a closing brace, it pops from its respective open brace storage array.

If pop returns nil (i.e. there weren't enough opening braces), it removes the closing brace. After this entire thing is done, it removes the remaining extra opening braces (i.e. there weren't enough closing braces).

At the end of the program, it puts all the strings and comments back and outputs them.

Ungolfed:

in_str = gets

# grab strings and comments before doing the replacements
i, unparsed = 0, []
in_str.gsub!(/(\/\*|"|').*?(\*\/|"|')|\d/){|match| unparsed.push match; i += 1 }

# replaces with spaces the braces in cases where braces in places cause stasis
brace_locations = [[], [], []]
in_str.each_char.with_index do |chr, idx|
    if brace_type = '{[('.index(chr)
        brace_locations[brace_type].push idx
    elsif brace_type = '}])'.index(chr)
        if brace_locations[brace_type].length == 0
            in_str[idx] = ' '
        else
            brace_locations[brace_type].pop
        end
    end
end
brace_locations.flatten.each{|brace_location| in_str[brace_location] = ' ' }

# put the strings and comments back and print
in_str.gsub!(/\d+/){|num| unparsed[num.to_i - 1] }
puts in_str


Visualize the Euclidean algorithm again Task

Given two positive integers:

Draw the rectangle with dimensions specified by the two integers.
Repeat Step 3 until there is no more space.
Draw and fill the largest square touching three sides of the (remaining) rectangle.
Output the resulting rectangle.

Example

For example, our input is 6 and 10.

We draw the hollow rectangle of size 6 x 10:

xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx

After repeatedly filling squares, this is what we would obtain:

aaaaaabbbb
aaaaaabbbb
aaaaaabbbb
aaaaaabbbb
aaaaaaccdd
aaaaaaccdd

There are 4 squares here (a, b, c, d), each with side length 6, 4, 2, 2 respectively.

Rules and freedom

You must use a different letter for each square.
You can choose which letters to support, as long as the letters supported are all printable characters and there are at least 10 characters supported.
In each iteration of Step 3 above, you have two choices (except in the last iteration, where you only have one choice). Both choices are valid.
The number of squares required will not exceed the number of letters you support.
You can fill in the squares with the letters you support in any order.

Testcases

Input: 6, 10

Output:

aaaaaabbbb
aaaaaabbbb
aaaaaabbbb
aaaaaabbbb
aaaaaaccdd
aaaaaaccdd

or

aaaaaaccdd
aaaaaaccdd
aaaaaabbbb
aaaaaabbbb
aaaaaabbbb
aaaaaabbbb

or

bbbbaaaaaa
bbbbaaaaaa
bbbbaaaaaa
bbbbaaaaaa
ccddaaaaaa
ccddaaaaaa

or

ccddaaaaaa
ccddaaaaaa
bbbbaaaaaa
bbbbaaaaaa
bbbbaaaaaa
bbbbaaaaaa

or

ddddddaaaa
ddddddaaaa
ddddddaaaa
ddddddaaaa
ddddddbbcc
ddddddbbcc

Input: 1,1

Output:

a

Input: 1,10

Output:

abcdefghij

Input: 10,1

Output:

a
b
c
d
e
f
g
h
i
j

Note that there are more possibilities than I can include for the testcases above.

Scoring

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

Standard loopholes apply.

Charcoal, 30 bytes

ＮδＮγＦβ¿×γδ«ＵＯγδι¿‹γδＡ⁻δγδＡ⁻γδγ

Try it online! Explanation:

Ｎδ      Input d
Ｎγ      Input g
Ｆβ      For i In ['a' ... 'z']
 ¿×γδ«   If g * d
  ＵＯγδι   Oblong g, d, i
  ¿‹γδ    If g < d
   Ａ⁻δγδ   d = d - g
   Ａ⁻γδγ   Else g = g - d

Annoyingly Charcoal's Oblong command won't take 0 for a dimension, which costs me 4 bytes. The other approach would be to loop while g * d, but then I couldn't work out how to iterate over b (which is predefined to the lowercase letters).


The PPCG Handicap System As we all know, meta is overflowing with complaints about scoring code-golf between languages (yes, each word is a separate link, and these may be just the tip of the iceberg).
With so much jealousy towards those who actually bothered to look up the Pyth documentation, I thought it would be nice to have a little bit more of a constructive challenge, befitting of a website that specializes in code challenges.

The challenge is rather straightforward. As input, we have the language name and byte count. You can take those as function inputs, stdin or your languages default input method.
As output, we have a corrected byte count, i.e., your score with the handicap applied. Respectively, the output should be the function output, stdout or your languages default output method. Output will be rounded to integers, because we love tiebreakers.
Using the most ugly, hacked together query (link - feel free to clean it up), I have managed to create a dataset (zip with .xslx, .ods and .csv) that contains a snapshot of all answers to code-golf questions. You can use this file (and assume it to be available to your program, e.g., it's in the same folder) or convert this file to another conventional format (.xls, .mat, .sav etc - but it may only contain the original data!). The name should remain QueryResults.ext with  ext the extension of choice.

Now for the specifics. For each language, there is a Boilerplate \$B\$ and Verbosity \$V\$ parameters. Together, they can be used to create a linear model of the language. Let \$n\$ be the actual number of bytes, and \$c\$ be the corrected score. Using a simple model \$n=Vc+B\$, we get for the corrected score:
$$c = \frac{n-B}V$$
Simple enough, right? Now, for determining \$V\$ and \$B\$. As you might expect, we're going to do some linear regression, or more precise, a least squares weighted linear regression. I'm not going to explain the details on that - if you're not sure how to do that, Wikipedia is your friend, or if you're lucky, your language's documentation.
The data will be as follows. Each data point will be the byte count \$n\$ and the question's average bytecount \$c\$. To account for votes, the points will be weighted, by their number of votes plus one (to account for 0 votes), let's call that \$v\$. Answers with negative votes should be discarded. In simple terms, an answer with 1 vote should count the same as two answers with 0 votes.
This data is then fitted into the aforementioned model \$n=Vc+B\$ using weighted linear regression.

For example, given the data for a given language
$$
\begin{array} \\
n_1=20, & c_1=8.2,  & v_1=1 \\
n_2=25, & c_2=10.3, & v_2=2 \\
n_3=15, & c_3=5.7,  & v_3=5
\end{array}$$
Now, we compose the relevant matrices and vectors \$A\$, \$y\$ and \$W\$, with our parameters in the vector
$$
A = \left[\begin{matrix}
1 & c_1 \\
1 & c_2 \\
1 & c_3 \\
\end{matrix}\right]
y = \left[\begin{matrix}
n_1 \\
n_2 \\
n_3 \\
\end{matrix}\right]
W = \left[\begin{matrix}
1 & 0 & 0 \\
0 & 2 & 0 \\
0 & 0 & 5 \\
\end{matrix}\right]
x = \left[\begin{matrix}
B \\
V \\
\end{matrix}\right]
$$
we solve the matrix equation (with \${}^T\$ denoting the matrix transpose)
$$A^TWAx=A^TWy$$
for \$x\$ (and consequently, we get our \$B\$ and \$V\$ parameter).

Your score will be the output of your program, when given your own language name and bytecount. So yes, this time even Java and C++ users can win!
WARNING: The query generates a dataset with a lot of invalid rows due to people using 'cool' header formatting and people tagging their code-challenge questions as code-golf. The download I provided has most of the outliers removed. Do NOT use the CSV provided with the query.
Happy coding!

Mathematica, 244.719 (245 bytes)
f[l_,n_]:=x/.Solve[d=Rest@Import@"QueryResults.csv";LinearModelFit[#.#2/Tr@#&@@{#~Max~-1&/@#4+1,#3}&@@Thread@#&/@{#,#~Cases~{_,l,__}}&/@d~GroupBy~Last/@#[[;;,1,5]],x,x,Weights->Tr/@#[[;;,;;,4]]]&[d~Cases~{_,l,_,v_/;v>=0,_}~GatherBy~Last]@x==n,x]

Test case
f["mathematica", n]   (* { .820033 (n + 53.4263) } *)
f["mathematica", 245] (* { 244.719 } *)

What about other languages?
f["c++", n]           (* { .821181 (n - 79.5437) } *)
f["java", n]          (* { .717579 (n - 56.0858) } *)
f["cjam", n]          (* { 2.21357 (n + 2.73772) } *)
f["pyth", n]          (* { 4.52194 (n - 8.82806) } *)

Alternative model: \$\log(c)=\log\left(\frac{n-B}V\right)\$
One notable feature of code golf (and probably other coding problems) is that the distribution of the lengths of programs tends to be exponential distribution (in contrast to uniform distribution). Hence model \$\log(n)=\log(Vc+B)\$ is much more likely to balance the influences between points with large \$c\$ and small \$c\$.
As we can see in the graphs below, the distribution of points are suitable for fitting in logarithmic scale.

Results of the new model
Language       V       B

Python       1.365   -19.4
Javascript   1.002     1.6
Ruby         0.724     1.7
Perl         1.177   -32.7
C            1.105     1.5
Haskell      1.454   -24.5
Mathematica  1.319   -39.7
PHP          1.799   -62.0
Java         1.642     4.4
C#           1.407     4.5

CJam         0.608   -12.5
Pyth         0.519   -11.4
Golfscript   0.766   -18.0
J            0.863   -21.4
APL          0.744   -17.7
K            0.933   -23.3
Retina       1.322   -37.9
MATL         0.762   -13.3
Jelly        0.965   -23.8

We have found two exceptional language - Ruby with \$V=0.72\$` and Retina with \$V=1.322\$, and a criterion of being a popular golfing language - having a large negative boilerplate.


Maclaurin series of Black Box Function Given a Black Box function ff that takes a single floating-point parameter, write a function M to generate the Maclaurin series for that function, according to the following specifications:

take a parameter n, and generate all terms from x^0 to x^n where 0 <= n <= 10
coefficients for each term should be given to at least 5 decimal places for non-integral values; underflows can simply be ignored or replaced with 0 and left out if you wish, or you can use scientific notation and more decimal places
assume ff is a continuous function and everywhere/infinitely differentiable for x > -1, and returns values for input x in the range: -10^9 <= ff(x) <= 10^9
programming languages with functions as first-class data types can take ff as a parameter; all other languages assume a function called ff has already been defined.
output should be formatted like # + #x + #x^2 + #x^5 - #x^8 - #x^9 ..., i.e., terms having 0 coefficient should be left out, and negative coefficients should be written - #x^i instead of + -#x^i; if the output terms are all zero, you can output either 0 or null output
output can be generated either to stdout or as a return value of type string from the function

Examples (passing ff as a first parameter):

> M(x => sin(x), 8)
x - 0.16667x^3 + 0.00833x^5 - 0.00020x^7
> M(x => e^x, 4)
1 + x + 0.5x^2 + 0.16667x^3 + 0.04167x^4
> M(x => sqrt(1+x), 4)
1 + 0.5x - 0.125x^2 + 0.0625x^3 - 0.03906x^4
> M(x => sin(x), 0)
0 (or blank is also accepted)

Python, 188 chars

D=lambda f:lambda x:100*(f(x+.005)-f(x-.005))
def M(f,n):
 s="";d=1
 for i in xrange(n+1):
  c=f(0)/d;f=D(f);d*=i+1
  if c:s+='%+.5f'%c+['','x','x^%d'%i][(i>0)+(i>1)]
 print s[s[:1]=='+':]

This code takes lots of liberties with accuracy and numerical stability, but it generates something close to the right answer for the given examples.

Running it:

import math
M(lambda x:math.sin(x),8)
M(lambda x:math.exp(x),4)
M(lambda x:math.sqrt(x+1),4)
M(lambda x:math.sin(x),0)

gives:

1.00000x-0.16666x^3+0.00833x^5-0.00020x^7
1.00000+1.00000x+0.50000x^2+0.16667x^3+0.04167x^4
1.00000+0.50000x-0.12500x^2+0.06251x^3-0.03907x^4
<a blank line>


root of root of root of root This idea came to me when I saw my little brother playing with my calculator :D
The task
Taking a integer as an input, print that many graphical square roots under each other, like this:
n = 1

  ___
\/ 1

n = 3
    _______
   / _____
  / / ___
\/\/\/ 3

n = 5

      ___________
     / _________
    / / _______
   / / / _____
  / / / / ___
\/\/\/\/\/ 5

n = 10

           ______________________
          / ____________________
         / / __________________
        / / / ________________
       / / / / ______________
      / / / / / ____________
     / / / / / / __________
    / / / / / / / ________
   / / / / / / / / ______
  / / / / / / / / / ____
\/\/\/\/\/\/\/\/\/\/ 10

Each root consists of 4 parts, which I'm going to very scientifically name:
(s is the root size on the stack of roots, n is the input number, x is the number of digits)

The "tail", which is a single \
The "wall", which consists of / * s
The "roof", which consists of  _ * 2 * s + x
And the number n under the smallest root, placed in the centre (leaving one empty space under the last _ in the smallest root)

Input
You must take input of the number n, no hardcoding the n
Output
The ascii roots your program made
This is a code-golf challenge, so lowest byte count for each language wins!

Python 2, 104 94 89 81 79 bytes

s=n=input()
while s:print' '*s,'/ '*(n-s)+'_'*(2*s+len(`n`));s-=1
print'\/'*n,n

Try it online!
Edit 1: Forgot I switched to python 2 lol
Edit 2: Thanks @ElPedro for the idea of switching to while loop!
Edit 3: Thanks @SurculoseSputum for saving 8 bytes!
Edit 4: Thanks @xnor for saving 2 bytes!


Tile the plane with this modified circle Take a unit circle centered on the origin. In any two neighboring quadrants, mirror the curve of the circle across the lines connecting the circle's x and y intercepts.

With the resulting shape, you can tile the plane:

I made this image with the awesome 2D physics sandbox Algodoo!

Write a program that outputs an image similar to this one in some common lossless image file format. You may save the image as a file with the name of your choice or you may simply display it. No input should be taken.

Rules:

The entire image must be tessellated with the modified-circle tiles using any two visually distinct RGB colors: one for the vertically pointing tiles, one for the horizontally pointing tiles.
The radius of the circle tiles should be at least 32 pixels. (The radius in the image above is about 110 pixels.)
The image should be at least 4 tiles wide and 4 tiles tall. This, combined with the rule above, means that images can have a minimum size of 256×256 pixels. (The image above is 4 tiles by 4 tiles.)
The tessellation may be translated by any amount. For example, the top left corner of the image does not need to be the vertex where tiles meet. (The tessellation should not be rotated, however.)
You may use external graphics libraries that have commands for drawing circles and outputting images and the like.
The curves really should approximate circles, as can done with the midpoint circle algorithm, which most graphics libraries will do for you.
Anti-aliasing around the edges of the tiles is allowed but not required.

The shortest submission in bytes wins.

POV-Ray, 199 163
Old version
camera{location -9*z}light_source{-9*z}#declare L=union{#for(X,-9,9,2)#for(Y,-9,9,2)cylinder{X*x+x+Y*y,<.001*pow(-1,(X+Y)/2),0,.1>+X*x+x+Y*y,1}#end#end}object{L pigment{color x}}object{L rotate z*90}

Same output, but golfed down further by using default light/camera, so I dont even need to specify them
#declare L=union{#for(X,-9,9,2)#for(Y,-9,9,2)cylinder{<X+1,Y,9>,<.001*pow(-1,(X+Y)/2),0,.1>+<X+1,Y,9>,1}#end#end}object{L pigment{color rgb x}rotate z*90}object{L}

I am using as many default parameters for camera and lightsource as possible, thats why it is a little dark. Lets ungolf it first
camera{location 9*z look_at 0}
light_source{9*z color 1}
#declare L=union{
    #for(X,-9,9,2)
        #for(Y,-9,9,2)
            cylinder{<1+X,Y,0>,                                 //central axis, start
                     <1+X,Y,0> + <.001*pow(-1,(X+Y)/2), 0, .1>, //central axis, end
                      1}                                        //radius
        #end
    #end
}
object{L pigment{color x}} // x is the <1,0,0> vector, here interpreted as RGB
object{L rotate<0,0,90>}

It is obvious what is happening once we increase the offset of the cylinder axis and change the perspective


Jelly, 6 bytes

½Ċ|1c3

Try it online! or verify all test cases.

Background

For all positive integers k, we have 1² + 3² + ⋯ + (2k - 1)² = k(2k - 1)(2k +1) ÷ 3.

Since there are m C r = m! ÷ ((m-r)!r!) r-combinations of a set of m elements, the above can be calculated as (2k + 1) C 3 = (2k + 1)2k(2k - 1) ÷ 6 = k(2k - 1)(2k + 1) ÷ 3.

To apply the formula, we must find the highest 2k + 1 such that (2k - 1)² < n. Ignoring the parity for a moment, we can compute the highest m such that (m - 1)² < n as m = ceil(srqt(n)). To conditionally increment m if it is even, simply compute m | 1 (bitwise OR with 1).

How it works

½Ċ|1c3  Main link. Argument: n

½       Compute the square root of n.
 Ċ      Round it up to the nearest integer.
  |1    Bitwise OR with 1 to get an odd number.
    c3  Compute (2k + 1) C 3 (combinations).


Division of not so little numbers Write a program or function that takes in positive integers a, b and c, and prints or returns a/b to c decimal places, using the operations +-*/% [add, subtract, multiply, divide, modulate] on the positive integers: you can use all that your language allows, but not on floating point numbers. The range of a,b,c would be the range allowed for unsigned integers in your language.
The number result will be truncated to the last digit to print (so no round).

This means that if your language does not have an integer type (only float), you can participate by using these float numbers as positive integers only.
The clue of this exercise it would be to write the function that find the
digits in a float point division, using only the operation +-*/%  on
[unsigned] integers.

Examples

print(1,2,1) would print 0.5
print(1,2,2) would print 0.50
print(13,7,27) would print 1.857142857142857142857142857
print(2,3,1) would print 0.6
print(4,5,7) would print 0.8000000
print(4,5,1) would print 0.8
print(9999,23,1) would print 434.7
print(12345613,2321,89) would print if your Language has 32 bit unsigned 5319.09220163722533390779836277466609220163722533390779836277466609220163722533390779836277466

The shortest code in bytes wins. I'm sorry if this appear not clear... I don't know languages too, not remember words well...
It is better to have one link to Ideone.com or some other place for easily try the answer especially for to test some input different from proposed.

Haskell, 87 bytes

(a#b)c|s<-show$div(a*10^c)b,l<-length s-c,(h,t)<-splitAt l s=['0'|l<1]++h++['.'|c>0]++t

Usage example: (13#7)27 -> "1.857142857142857142857142857".

23 bytes to handle the c==0 case and using a leading zero instead of things like .5.

How it works: multiply a with 10^c, divide by b, turn into a string, split where the . must be inserted, join both parts with a . in-between and fix the edge cases.


Implement the Enigma Machine The Enigma machine is a fairly complex cipher machine used by the Germans and others to encrypt their messages.  It is your job to implement this machine*.
Step 1, Rotation
Our enigma machine has 3 slots for rotors, and 5 available rotors for each of these slots. Each rotor has 26 different possible positions (from A to Z).  Each rotor has a predefined notch position:
Rotor  Notch
------------
1      Q
2      E
3      V
4      J
5      Z

On keypress the following steps occur:

The rotor in Slot 1 rotates
If the rotor in Slot 1 moves past its notch, then it rotates the rotor in Slot 2.
If the rotor in Slot 2 is in its notch (but didn't just move there), both rotor 2 and 3 rotate once.

If we are using rotors 1,3,5 and they are in positions P,U,H then the sequence of positions is: P,U,H > Q,U,H > R,V,H > S,W,I
Step 2, Substitution
Each of the rotors performs a simple character substitution.  The following is a chart of each of the rotors in the A position:
  ABCDEFGHIJKLMNOPQRSTUVWXYZ
  --------------------------
1 EKMFLGDQVZNTOWYHXUSPAIBRCJ
2 AJDKSIRUXBLHWTMCQGZNPYFVOE
3 BDFHJLCPRTXVZNYEIWGAKMUSQO
4 ESOVPZJAYQUIRHXLNFTGKDCMWB
5 VZBRGITYUPSDNHLXAWMJQOFECK
R YRUHQSLDPXNGOKMIEBFZCWVJAT

Rotor 1 in position T is PAIBRCJEKMFLGDQVZNTOWYHXUS, which would substitute the letter C for I.
After the three rotors perform their substitution, the reflector is hit (listed as R above).  It performs its own substitution, and then reflects the signal back through the rotors.  The rotors then perform a reverse substitution in reverse order.
Reverse substitution means that instead of Rotor 1 substituting A with E, it substitutes E with A
Slots are filled with rotors 1,2,3 all in position A.  The letter Q follows the path Q>X>V>M through the rotors.  M reflects to O, which then follows the reverse path of O>Z>S>S.  Therefore, A is substituted with S.
Input/Output
You are passed:

A list of 3 rotors (as integers)
A list of 3 starting rotor positions (as letters)
A string that needs to be encrypted.

You can assume that your input will be well formed, and all characters will be uppercase letters, no spaces.
You must return the encrypted string.
You can optionally accept the rotors, notches, and reflectors as input.  For those that don't can take off 95 bytes from their score, as 95 = ceil(log2(26 letters ^(26*6 rotors +5 notches))/8 bytes)
Test cases
Rotor Position Input              Output
4,1,5 H,P,G    AAAAAAAAA          PXSHJMMHR
1,2,3 A,A,A    PROGRAMMINGPUZZLES RTFKHDOCCDAHRJJDFC
1,2,3 A,A,A    RTFKHDOVZSXTRMVPFC PROGRAMRXGVGUVFCES
2,5,3 U,L,I    GIBDZNJLGXZ        UNCRAUPSCTK

My implementation can be found on Github.  I've tested it, but I may have bugs in my implementation (which would mean that my test cases are likely wrong).
*I've tried to make this as accurate as possible, but due to the variations between machines, I may have some details wrong.  However, your task is to implement what I've described, even if I'm inaccurate.  I'm not including the plugboard for simplicity

Jelly, 42 38 37 bytes
="⁵Ḣ€Ṗ1;ṙ@"µɼ⁶ṭØAiịɗƒµ®Ṛi@ịØAɗƒ
ḷ⁹©Ç€

Try it online!
Verify each test case
This is extremely liberal with the input format. It takes input in the following way:

The three rotors (the strings, not the numbers) as the first command line argument, each rotated so that the starting points are the first characters
The message as the second command line argument
The 3 specific notches as the third command line argument
The reflector as the fourth command line argument

In the above TIO link, the Footer converts a triple of numbers (the rotors) into the rotor strings, then rotates them to the correct order, so that you don't have to do it yourself.
However, for 45 bytes we can have a program which takes input in the following way:

The message, on STDIN
The three rotors (as the strings) as the first command line argument
The 3 specific notches as the second command line argument
The reflector as the third command line argument
The three starting points for the rotors as the fourth command line argument

Again, the Footer converts the rotors from integers to the corresponding strings.
Finally, if we want to go all the way and just accept 3 inputs (the rotors, as integers, the starting positions and the message (thus have -95 to our score), we get a score of 44

How it works
As they all use the same underlying algorithm, I'll just explain the 38 byte version in full, and I'll cover how the other two versions adapt the inputs to match the shortest version. For this explanation: M is the message, R are the three rotor strings, N are the notches, F is the reflector and C is the value in the register (initially 0).
ḷ⁹©Ç€ - Main link. Takes M on the left and R on the right
 ⁹    - Yield R
  ©   - And copy it into the register. C = R
ḷ     - Discard R and yield M
    € - Over each character in M:
   Ç  -   Call the helper link
        Implicitly output the final result

="⁵Ḣ€Ṗ1;ṙ@"µɼ⁶ṭØAiịɗƒµ®Ṛi@ịØAɗƒ - Helper link. Takes a character X on the left

="⁵Ḣ€Ṗ1;ṙ@"µɼ                   - Rotate the rotors
            ɼ                   - Yield C, run the following on it, save the result to C:
           µ                    -   Initially, C = R, the list of rotors
  ⁵                             -   Yield the notches, N
 "                              -   Pair each notch with each rotor, then:
=                               -     Vectorised equality
   Ḣ€                           -   Take the head of each
                                      This yields a triple of bits [a, b, c]
                                      which indicate which rotor hits its notch
     Ṗ                          -   Remove c as rotor 3 has no affect
      1;                        -   Prepend 1 as rotor 1 always moves; [1, a, b]
          "                     -   Pair 1 with rotor 1, a with rotor 2 and b with rotor 3,
                                        then for each pair:
        ṙ@                      -     Rotate the rotor if the bit is 1

             ⁶ṭØAiịɗƒ           - Send the character through the rotors
             ⁶                  - Yield the reflector F
              ṭ                 - Tack it to the end of the rotors, call this C'
                   ɗ            - Group the previous 3 links into a dyad f(U, L):
                                   where U is a character and L a list of characters
               ØA               -   "ABC...XYZ"
                 i              -   Index of U in the alphabet
                  ị             -   Index into L
                    ƒ           - Starting with X, reduce C' by the dyad f(U, L)
                                  As C is a triple of lists of characters, this returns
                                  A = f(f(f(f(X, C[1]), C[2]), C[3]), F), a single character

                     µ®Ṛi@ịØAɗƒ - Send A back through the rotors
                     µ          - Begin a new link with A as the argument
                             ɗ  - Group the previous 3 links into a dyad g(U, L)
                        i@      -   Index of U in L, i
                          ịØA   -   i'th letter of the alphabet
                      ®         - Yield C
                       Ṛ        - Reverse C
                              ƒ - Starting with A, reduce rev(C) by the dyad g(U, L)
                                      This yields g(g(g(A, C[3]), C[2]), C[1]),
                                      which is our intended result

How the other 2 work
The 45 byte version
Taking a look at the code, we notice that the only thing that's changed is that the last line is now
ṙ"©⁶O_65¤ṛɠÇ€

The difference between this version and the 37 byte version is how the rotors are taken as input:

The three rotors (the strings, not the numbers) as the first command line argument, each rotated so that the starting points are the first characters

The three rotors (as the strings) as the first command line argument

The new bits here just rotate the rotors for us and take M from STDIN:
ṙ"©⁶O_65¤ṛɠÇ€ - Main link. Takes R on the left
        ¤     - Create a nilad:
   ⁶          -   The 3 starting points of the rotors
    O         -   Converted to char points
     _65      -   Minus 65
 "            - Zip with each rotor:
ṙ             -   Rotate the rotor that many steps
  ©           - Save this to the register
          ɠ   - Read M from STDIN
         ṛ    - Discard the rotors and yield M
           Ç€ - Call the helper link on each character of M

The 139 byte version
Let's take a look at the full code:
="³ị“QEVJZ”¤Ḣ€Ṗ1;ṙ@"µɼ“¡ƝḋœṚṗḶw⁸Aß`’œ?ØA¤ṭØAiịɗƒµ®Ṛi@ịØAɗƒ
ị“F.⁻wṣḊ£tọḅɱ“¥AṡḌỴịk⁼UH9“Ñɱ½#Ẋʋẹ¹⁼UṢ“KzBpñÇḅẊẎḳḣ“¡j5ɼ}ṡỴb\£BṆ’œ?ØAṙ"©⁴O_65¤ṛɠÇ€

Try it online!
This is very similar to our 45 byte version. In fact, here's what's different in the first lines, with everything that is unchanged, replaced with .
..³ị“QEVJZ”¤..........“¡ƝḋœṚṗḶw⁸Aß`’œ?ØA¤.................

Furthermore, you'll note that the end of the first line is ṙ"©⁴O_65¤ṛɠÇ€, which is the first line of the 45 byte version, meaning that there are really only three changes. In this case, those changes are because of the changes to the input system. Here's the first 2:

⁴ \$\to\$ ³ị“QEVJZ”¤. Rather than take the notches as input, we use the rotor list (³) to ịndex into the string of notches “QEVJZ”. The ¤ is simply a precedence marker, telling the program to treat this as a constant

⁵ \$\to\$ “¡ƝḋœṚṗḶw⁸Aß`’œ?ØA¤. Again, this is changing an input into program data, the reflector in this case. ¤ Once again acts as a precedence marker. However, we have 3 new commands here:

œ? is a dyad which takes 2 arguments - on the left, an integer x, and on the right a string, s - and returns the x'th permutation of s
ØA we've already encountered, and is the uppercase alphabet. In this context, it acts as the right argument to œ?
“¡ƝḋœṚṗḶw⁸Aß`’ is the compressed integer \$383316524290458478707255597\$, which is the left argument to œ?

Together, this returns the \$383316524290458478707255597\$th permutation of the uppercase alphabet, or the string "YRUHQSLDPXNGOKMIEBFZCWVJAT"

The final change is the entire start of the last line:
ị“F.⁻wṣḊ£tọḅɱ“¥AṡḌỴịk⁼UH9“Ñɱ½#Ẋʋẹ¹⁼UṢ“KzBpñÇḅẊẎḳḣ“¡j5ɼ}ṡỴb\£BṆ’œ?ØA

Here, we have a list of massive compressed numbers:
“F.⁻wṣḊ£tọḅɱ“¥AṡḌỴịk⁼UH9“Ñɱ½#Ẋʋẹ¹⁼UṢ“KzBpñÇḅẊẎḳḣ“¡j5ɼ}ṡỴb\£BṆ’

Each “ marks the beginning of a new compressed number, and the entire list is
[67892310845892591685803413, 5023890671354916271018308, 16834429128340685633834184, 72949485053238139997554738, 340670280577577536609579431]

We then take the three integers which correspond to the three rotor inputs with ị, and then use œ?ØA to generate the alphabet permutations we want for each rotor. Finally, these permutations are fed into the rest of the program, already covered above.


Nearest hamming cycle period in MD5 This riddle was inspired by that thread. Consider that you are super-hacker and try to break MD5 hashing algorithm by looking for a hash collisions for a given hash string which your friend gave to you. But this is a non-trivial task and you have a migraine disorder so you try to break the problem into smaller parts. First thing which you try is to look for a hamming distance patterns in a repeated execution of MD5() feeding it's last output to an input. For example, if your friend gave to you a hash bb2afeb932cc5aafff4a3e7e31d6d3fb, then you will notice a such pattern :

e3b86f8d25e5a71a88eabef0d7ed9840=md5(bb2afeb932cc5aafff4a3e7e31d6d3fb), hamming 95
45fcdb59517b39f18d1622a84be0a301=md5(e3b86f8d25e5a71a88eabef0d7ed9840), hamming 91
0b3f2eac737b916f3b78f240e7fc97ec=md5(45fcdb59517b39f18d1622a84be0a301), hamming 77
fe56b1802722cc30b936186aacce1e01=md5(0b3f2eac737b916f3b78f240e7fc97ec), hamming 95

So after 4 iterations you arrived at hamming distance 95 between an output and a first input, which is the same 95 number which you have started from. So nearest hamming cycle period of MD5(bb2afeb932cc5aafff4a3e7e31d6d3fb) is 4. You have found a hamming collision !

Your task is to write a program which takes an arbitrary MD5 hash from the standard input, and outputs it's nearest hamming cycle period on standard output. For example:

Input:  45fcdb59517b39f18d1622a84be0a301, Output: 3
Input:  1017efa1722ba21873d79c3a215da44a, Output: 7
Input:  edc990163ff765287a4dd93ee48a1107, Output: 90
Input:  c2ca818722219e3cc5ec6197ef967f5d, Output: 293

Shortest code wins.

Notes:

If your language doesn't have an md5() built-in, feel free to implement that yourself and then write in the solution total byte count  and byte count without md5() sub-program implementation, the later will be considered as an answer.
Hamming distance is defined as number of differing bits between two strings. If strings converted to binary (by character ASCII code) has different lengths - smaller one is padded from the left with 0. Example:

Word1: nice Binary1: 01101110011010010110001101100101
Word2: car  Binary2: 00000000011000110110000101110010
Hamming distance (differing bits): 12

In this task you should calculate hamming distance between a FIRST input in a cycle and current output. So according to a given hamming cycle example above you should calculate

hamming(bb2afeb932cc5aafff4a3e7e31d6d3fb,e3b86f8d25e5a71a88eabef0d7ed9840)
hamming(bb2afeb932cc5aafff4a3e7e31d6d3fb,45fcdb59517b39f18d1622a84be0a301)
hamming(bb2afeb932cc5aafff4a3e7e31d6d3fb,0b3f2eac737b916f3b78f240e7fc97ec)
hamming(bb2afeb932cc5aafff4a3e7e31d6d3fb,fe56b1802722cc30b936186aacce1e01)

Jelly, 37 bytes

Ç,³OBU+0x8¤_/FAS,Ç
Ç;0ịÇƊ$⁺-ịn1ị$Ʋ¿LH

Try it online!

Try it online! - using full implementation of MD5

I'll comment it when I have time. Jelly doesn't have an MD5 built-in, so the header for the first TIO implements MD5 for a fixed length (32 bytes) input. I've also now extended this to a general purpose MD5 routine (second TIO link). For the purposes of the challenge, there is a monadic link just above the challenge code that takes a 32 character string and returns the MD5 hash. The remaining code (as displayed above here) calculates the hamming distance between the original input and sequential hashes until it matches the first one.


Output a Magical 8 Trapezium Your task is to output a Magical 8 Trapezium:

        1 × 8 + 1 = 9
       12 × 8 + 2 = 98
      123 × 8 + 3 = 987
     1234 × 8 + 4 = 9876
    12345 × 8 + 5 = 98765
   123456 × 8 + 6 = 987654
  1234567 × 8 + 7 = 9876543
 12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321

Output in your chosen language in the fewest bytes possible.
Note the number of spaces at the start of each line to maintain the trapezium shape.
Trailing spaces are allowed.
You can use × or the letter x - whichever you prefer.

Python 2, 59 bytes

a=i=1
exec"print'%9d x 8 +'%a,i,'=',a*8+i;i+=1;a=a*10+i;"*9

The numbers a and i the equation a * 8 + i are generated arithmetically. Each line, i is incremented, and a has the next digit appended via a=a*10+i. For example, if a=12345, i=5, then i becomes 6, so the new a is 12345*10 + 6 which is 123456.
Storing these as numbers rather than strings lets us compute the RHS as given by the equation a*8+i, which is shorter than string reversing.


Column-wise summation of overlapping slices Task

Given a list of integers L and another integer s, the goal is to compute the column-wise sums of all s-length (potentially overlapping) slices of L, while pertaining their positions relative to L (see below).

Definitions

The s-length (overlapping) slices of the list L are all the contiguous subsequences (without wrapping) of L that are of length s.

In order to pertain the positions of the slices s relative to L, you can imagine building a "ladder", where each slice si has an offset of i positions from the beginning.

Specs

s is an integer higher than 1 and strictly smaller than the length of L.
L will always contain at least 3 elements.
You can compete in any programming language and can take input and provide output through any standard method, while taking note that these loopholes are forbidden by default. This is code-golf, so the shortest submission (in bytes) for every language wins.

Examples and Test Cases

Here is a worked example:

[1, 2, 3, 4, 5, 6, 7, 8, 9], 3

[1, 2, 3]
   [2, 3, 4]
      [3, 4, 5]
         [4, 5, 6]
            [5, 6, 7]
               [6, 7, 8]
                  [7, 8, 9]
-------------------------------- (+)  | column-wise summation
[1, 4, 9, 12, 15, 18, 21, 16, 9]

And some more test cases:

[1, 3, 12, 100, 23], 4         -> [1, 6, 24, 200, 23]
[3, -6, -9, 19, 2, 0], 2       -> [3, -12, -18, 38, 4, 0]
[5, 6, 7, 8, 2, -4, 7], 3      -> [5, 12, 21, 24, 6, -8, 7]
[1, 2, 3, 4, 5, 6, 7, 8, 9], 3 -> [1, 4, 9, 12, 15, 18, 21, 16, 9]
[1, 1, 1, 1, 1, 1, 1], 6       -> [1, 2, 2, 2, 2, 2, 1]
[1, 2, 3, 4, 5, 6, 7, 8, 9], 6 -> [1, 4, 9, 16, 20, 24, 21, 16, 9]

J, 11, 9 8 bytes

-1 byte thanks to miles!

[:+//.]\

How it works?

The left argument is s, the right one - L

]\ - splits L into sublists with length s

/. - extracts the oblique diagonals (anti-diagonals)

+/ - adds them up

[: - makes a fork from the above verbs

Here's an example J session for the first test case:

   a =. 1 2 3 4 5 6 7 8 9

   ] 3 ]\ a
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9

   ] </. 3 ]\ a
┌─┬───┬─────┬─────┬─────┬─────┬─────┬───┬─┐
│1│2 2│3 3 3│4 4 4│5 5 5│6 6 6│7 7 7│8 8│9│
└─┴───┴─────┴─────┴─────┴─────┴─────┴───┴─┘

   ] +//. 3 ]\ a
1 4 9 12 15 18 21 16 9

Try it online!


Spelling Bee Acceptable This is similar to this question.
However, I have a different goal in mind:
Reduce the wordlist to words that could appear.
The easy part is to delete hyphens and similar.

The hard part, however: Remove words containing more than seven letters.

So, the problem:
Given a set of words containing only lowercase (or uppercase) ASCII letters, remove the words containing eight or more different letters.

Any input and output format is acceptable.

Standard loophole rules apply.

Shortest byte count wins.

Clever solutions are better, and faster is better as well.

My solution (implementing a quite clever O(n) algorithm, noncompetitive ref implementation):

#include <stdio.h>
#include <stdint.h>

int main(void) {
  char str[1024];
  while(scanf("%s\n", str) == 1) {
    uint32_t st = 0;
    int s = 0;
    for(char *p = str; *p && s <= 7; p++) {
      s += ~st >> (*p - 'a') & 1;
      st |= 1 << (*p - 'a');
    }
    if(s <= 7)
      printf("%s\n", str);
  }
}

APL (Dyalog Unicode), 11 bytes

{⍵/⍨8>≢∪⍵}¨

Takes input as a list of strings.

Explanation:

{⍵/⍨8>≢∪⍵}¨
{       ⍵}¨ for each word
       ∪    take unique letters
    8>≢     length less than 8 as a boolean (0 or 1)
 ⍵/⍨        repeat word that many times

Try it online!


ROT13 and upside-down text (flip text) When I saw this title in the Hot Network Questions I thought it was going to be a PPCG challenge. I was a little disappointed when it was on Mathematica.

So now it is on PPCG:

Challenge

Given an input string, output the ROT13, flipped value. The input will contain characters from the following alphabet: [abcdefghijklmnopqrstuvwxyz <flipped alphabet>]1

The flipped alphabet can be anything visually similar to the flipped lowercase Latin alphabet so long as it can be accepted as input.

The space character should remain unchanged.

As an example, your flipped alphabet might be zʎxʍʌnʇsɹbdouɯlʞɾᴉɥƃɟǝpɔqɐ

Example

Input:    caesar woz ere
Rot13:    pnrfne jbm rer
Output:   ɹǝɹ ɯqɾ ǝuɟɹud

Input:    ɹǝɹ ɯqɾ ǝuɟɹud
Rot13:    pnrfne jbm rer
Output:   caesar woz ere

Scoring

Simple code-golf, the lowest number of bytes wins.

I think this is different enough to the proposed duplicate for a few reasons:

The answerer has the choice of which characters to use as output (within limits)
The process should be reversible. i.e. flipped text should be acceptable as input and return "normal" text.
There is the opportunity for graphical solutions in this question.

Python 3, 120 bytes

many bytes saved thanks to @JonathanAllan

lambda s,a='abcdefghijklmnopqrstuvwxyz VOďƄɹ5ʇη^MXʎ2ɐʠ>Pəɟ6ɥ!ɾʞ|W ':''.join(a[(a.find(c)+27)%54]for c in s)

Try it online!


Create a simple 2048 game clone 2048 is an incredibly fun and addictive game in which the goal is to create a tile with 2048 on it.

Here's a short description of the game:

Pressing an arrow key will slide all the blocks in the stage in that direction. For example, if x represents a block, and you pressed the up arrow in this case:

...x
.x..
..x.
xx..

Then the board would become

xxxx
.x..
....
....

Furthermore, the blocks are numbered, starting at 2. If two of the same numbered blocks are moved together, they will merge into the next number. For example, pressing "up" on this board:

.2..
..22
.2..
....

Would create this:

.422
....
....
....

And then after pressing "right," it would become ..44, and therefore pressing right again would create an "8" block, and so on.

Each turn, a new "2" block is created on a random open square. (It's actually not always a "2," but for simplicity let's keep it at that.) If there are no possible moves left (i.e., the board is full and you can't merge anything), the game is lost, and if a 2048 block is created, you win!

Your challenge is to recreate this game, golfed!

For edge-cases, such as pressing "right" on this board:

....
.222
....
....

you must merge the tiles closest to the edge of the arrow key pressed. For example, this would become ..24, because the second and third "2"s are the closest to the right edge.
If the player presses an invalid move (such as "up" on a board like 2.2. / .... / .... / ....), you must ignore the move.
Moves can be accepted in any way, such as clicking, arrow keys, ULRD, etc.
The tiles must all be the same shape—a "1024" tile should be the same size as a "2" tile.
The tiles must be separated in some way. For example, |1024|   2|1024|1024| is a valid example of a row (assuming that the tiles are squares), while 1024   210241024 is not.
You must output "you win" if the player creates a 2048 tile, or "you lose" if there are no valid moves left.
This is code-golf, so the shortest code in bytes will win!


Finding "sub-palindromes" 2: subsequences. The same task as Finding "sub-palindromes" but instead of finding substrings you must find subsequences that are not substrings.

eg1:

input: "12131331"
output:
"11", "33", "111", "121", "131", "313", "333", "1111", "1331", "11311", "13331"
or
"11", "33", "111", "333", "1111", "11311", "13331"

eg2:

input: "3333"
output:
"33", "333"
or
(null)

Input is a string of printable ascii characters.
Output is a list of unique strings.
If a subsequence also appears as a substring it may be omitted.
Shortest code wins.

Haskell (119)
import Data.List
main=interact f
f a=show.nub.filter(\x->(not$isInfixOf a x)&&x==reverse x&&length x>1)$subsequences a

Isn't too difficult with a builtin subsequences and nub... :)