Arbitrary Interval Ruler Make a program that takes a length and list of intervals and outputs a ruler of that length with longer ticks for each interval using the line drawing characters ┌ ┬ ┐ │ ╵

The first row of the output should begin with the tick for 0 with ┌ and end with a tick for the length with ┐, with a ┬ being used for every character in between. There will be a total of length + 1 line drawing characters in this first row.
A tick should be lengthened vertically by half-character increments using ╵ and │ based on the input intervals.
Intervals are listed from smallest to largest, relative to the interval before it. To elaborate:

The first interval tells how many base ticks (the first row - one character per tick) are in the second-smallest interval (the smallest interval being 1). For example, [3] will lengthen every third tick by a half-character.
The second and subsequent intervals are in terms of the next smallest interval. For example [3, 5] will lengthen every 15th base tick by a full character and [3, 5, 2] will lengthen every 30th base tick by a character and a half.
A sub-interval of 1 is valid and effectively means that the last interval lines are lengthened by a full character instead of a half-character.

The example test cases should help to clarify how this works.

Examples/Test Cases

3, []:

┌┬┬┐

9, [3]:

┌┬┬┬┬┬┬┬┬┐
╵  ╵  ╵  ╵

30, [5, 2]:

┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐
│    ╵    │    ╵    │    ╵    │

32, [4, 2, 2, 2]:

┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐
│   ╵   │   ╵   │   ╵   │   ╵   │
│               ╵               │

48, [5, 3, 2]

┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐
│    ╵    ╵    │    ╵    ╵    │    ╵    ╵    │
╵                             ╵

24, [7, 3]

┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐
│      ╵      ╵      │

17, [3, 2, 1]

┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐
│  ╵  │  ╵  │  ╵
╵     ╵     ╵

1, [23, 19, 13, 11, 7, 5, 3, 2, 1]

┌┐
│
│
│
│
╵

Other Rules/Notes

Input and output can use any convenient format
The ruler doesn't have to end on a major tick
The interval list may be empty
The zeroth tick is always within all intervals.
You may assume the ruler length and intervals will always be a positive integers less than 120
Trailing whitespace is fine, but leading whitespace is not.
Any fixed-single-wide space is allowed as a spacing character if you, for some reason, want to use something other than ASCII spaces.

Happy Golfing!

JavaScript (Node.js), 123 bytes

l=>g=([p,q,...t],h='┌'.padEnd(l,'┬')+`┐
`)=>p?h+g(t,h.replace(/\S/g,c=>'╵│ '[c>'╴'||++i%p?2:i/p%q<1|0],i=-1)):h

Try it online!

Use this function as f(20)([5, 2]).

Thanks Arnauld, saves 4 bytes.


Permutations such that no k+2 points fall on any polynomial of degree k Description

Let a permutation of the integers {1, 2, ..., n} be called minimally interpolable if no set of k+2 points (together with their indices) fall on a polynomial of degree k.
That is,

No two points fall on a horizontal line (0-degree polynomial)
No three points fall on a line (1-degree polynomial)
No four points fall on a parabola (2-degree polynomial)
Et cetera.

Challenge

Write a program that computes OEIS sequence A301802(n), the number of minimally interpolable permutations of {1, 2, ..., n} for n as a large as possible.

Scoring

I will time your code on my computer (2.3 GHz Intel Core i5, 8 GB RAM) with increasing inputs. Your score will be the greatest input that takes less than 1 minute to output the correct value.

Example

For example, the permutation [1, 2, 4, 3] is minimally interpolable because

the terms together with their indices
[(1, 1), (2, 2), (3, 4), (4, 3)]
have the property that
  (0) No two points have the same y-value.
  (1) No three points lie on a line.
  (2) No four points lie on a parabola.

In the illustration, you can see that the horizontal lines (red) have at most one point on them, the lines (blue) have at most two points on them, and the parabolas (green) have three points on them.

Data

Here are the minimally interpolable permutations for n=3, n=4, and n=5:

n = 3: [1,3,2],[2,1,3],[2,3,1],[3,1,2]
n = 4: [1,2,4,3],[1,3,2,4],[1,3,4,2],[1,4,2,3],[2,1,3,4],[2,1,4,3],[2,3,1,4],[2,4,1,3],[2,4,3,1],[3,1,2,4],[3,1,4,2],[3,2,4,1],[3,4,1,2],[3,4,2,1],[4,1,3,2],[4,2,1,3],[4,2,3,1],[4,3,1,2]
n = 5: [1,2,5,3,4],[1,3,2,5,4],[1,3,4,2,5],[1,4,2,3,5],[1,4,3,5,2],[1,4,5,2,3],[1,4,5,3,2],[1,5,3,2,4],[2,1,4,3,5],[2,3,1,4,5],[2,3,5,1,4],[2,3,5,4,1],[2,4,1,5,3],[2,4,3,1,5],[2,4,5,1,3],[2,5,1,3,4],[2,5,1,4,3],[2,5,3,4,1],[2,5,4,1,3],[3,1,4,5,2],[3,1,5,2,4],[3,1,5,4,2],[3,2,5,1,4],[3,2,5,4,1],[3,4,1,2,5],[3,4,1,5,2],[3,5,1,2,4],[3,5,1,4,2],[3,5,2,1,4],[4,1,2,5,3],[4,1,3,2,5],[4,1,5,2,3],[4,1,5,3,2],[4,2,1,5,3],[4,2,3,5,1],[4,2,5,1,3],[4,3,1,2,5],[4,3,1,5,2],[4,3,5,2,1],[4,5,2,3,1],[5,1,3,4,2],[5,2,1,3,4],[5,2,1,4,3],[5,2,3,1,4],[5,2,4,3,1],[5,3,2,4,1],[5,3,4,1,2],[5,4,1,3,2]

If my program is correct, the first few values of a(n), the number of minimally interpolable permutations of {1, 2, ..., n}:

a(1) = 1
a(2) = 2
a(3) = 4
a(4) = 18
a(5) = 48
a(6) = 216
a(7) = 584
a(8) = 2870

C#

using System;
using System.Diagnostics;
using BigInteger = System.Int32;

namespace Sandbox
{
    class PPCG160382
    {
        public static void Main(params string[] args)
        {
            if (args.Length != 0)
            {
                foreach (var arg in args) Console.WriteLine(CountValidPerms(int.Parse(arg)));
            }
            else
            {
                int[] smallValues = new int[] { 1, 1, 2, 4, 18, 48 };
                for (int n = 0; n < smallValues.Length; n++)
                {
                    var observed = CountValidPerms(n);
                    var expected = smallValues[n];
                    Console.WriteLine(observed == expected ? $"{n}: Ok" : $"{n}: expected {expected}, observed {observed}, error {observed - expected}");
                }
                for (int n = smallValues.Length; n < 13; n++)
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    Console.WriteLine($"{n}: {CountValidPerms(n)} in {sw.ElapsedMilliseconds}ms");
                }
            }
        }

        private static long CountValidPerms(int n)
        {
            // We work on the basis of exclusion by extrapolation.
            var unused = (1 << n) - 1;
            var excluded = new int[n];
            int[] perm = new int[n];

            // Symmetry exclusion: perm[0] < (n+1) / 2
            if (n > 1) excluded[0] = (1 << n) - (1 << ((n + 1) / 2));

            long count = 0;
            CountValidPerms(ref count, perm, 0, unused, excluded);
            return count;
        }

        private static void CountValidPerms(ref long count, int[] perm, int off, int unused, int[] excluded)
        {
            int n = perm.Length;
            if (off == n)
            {
                count += CountSymmetries(perm);
                return;
            }

            // Quick-aborts
            var completelyExcluded = excluded[off];
            for (int i = off + 1; i < n; i++)
            {
                if ((unused & ~excluded[i]) == 0) return;
                completelyExcluded &= excluded[i];
            }
            if ((unused & completelyExcluded) != 0) return;

            // Consider each unused non-excluded value as a candidate for perm[off]
            var candidates = unused & ~excluded[off];
            for (int val = 0; candidates > 0; val++, candidates >>= 1)
            {
                if ((candidates & 1) == 0) continue;

                perm[off] = val;

                var nextUnused = unused & ~(1 << val);

                var nextExcluded = (int[])excluded.Clone();
                // For each (non-trivial) subset of smaller indices, combine with off and extrapolate to off+1 ... excluded.Length-1
                if (off < n - 1 && off > 0)
                {
                    var points = new Point[off + 1];
                    var denoms = new BigInteger[off + 1];
                    points[0] = new Point { X = off, Y = perm[off] };
                    denoms[0] = 1;
                    ExtendExclusions(perm, off, 0, points, 1, denoms, nextExcluded);
                }

                // Symmetry exclusion: perm[0] < perm[-1] < n - 1 - perm[0]
                if (off == 0 && n > 1)
                {
                    nextExcluded[n - 1] |= (1 << n) - (2 << (n - 1 - val));
                    nextExcluded[n - 1] |= (2 << val) - 1;
                }

                CountValidPerms(ref count, perm, off + 1, nextUnused, nextExcluded);
            }
        }

        private static void ExtendExclusions(int[] perm, int off, int idx, Point[] points, int numPoints, BigInteger[] denoms, int[] excluded)
        {
            if (idx == off) return;

            // Subsets without
            ExtendExclusions(perm, off, idx + 1, points, numPoints, denoms, excluded);

            // Just add this to the subset
            points[numPoints] = new Point { X = idx, Y = perm[idx] };
            denoms = (BigInteger[])denoms.Clone();
            // Update invariant: denoms[s] = prod_{t != s} points[s].X - points[t].X
            denoms[numPoints] = 1;
            for (int s = 0; s < numPoints; s++)
            {
                denoms[s] *= points[s].X - points[numPoints].X;
                denoms[numPoints] *= points[numPoints].X - points[s].X;
            }
            numPoints++;

            for (int target = off + 1; target < excluded.Length; target++)
            {
                BigInteger prod = 1;
                for (int t = 0; t < numPoints; t++) prod *= target - points[t].X;

                Rational sum = new Rational(0, 1);
                for (int s = 0; s < numPoints; s++) sum += new Rational(prod / (target - points[s].X) * points[s].Y, denoms[s]);

                if (sum.Denom == 1 && sum.Num >= 0 && sum.Num < excluded.Length) excluded[target] |= 1 << (int)sum.Num;
            }

            // Subsets with
            ExtendExclusions(perm, off, idx + 1, points, numPoints, denoms, excluded);
        }

        private static int CountSymmetries(int[] perm)
        {
            if (perm.Length < 2) return 1;

            int cmp = 0;
            for (int i = 0, j = perm.Length - 1; i <= j; i++, j--)
            {
                cmp = perm.Length - 1 - perm[i] - perm[j];
                if (cmp != 0) break;
            }

            return cmp > 0 ? 4 : cmp == 0 ? 2 : 0;
        }

        public struct Point
        {
            public int X;
            public int Y;
        }

        public struct Rational
        {
            public Rational(BigInteger num, BigInteger denom)
            {
                if (denom == 0) throw new ArgumentOutOfRangeException(nameof(denom));

                if (denom < 0) { num = -num; denom = -denom; }

                var g = _Gcd(num, denom);
                Num = num / g;
                Denom = denom / g;
            }

            private static BigInteger _Gcd(BigInteger a, BigInteger b)
            {
                if (a < 0) a = -a;
                if (b < 0) b = -b;
                while (a != 0)
                {
                    var tmp = b % a;
                    b = a;
                    a = tmp;
                }
                return b;
            }

            public BigInteger Num;
            public BigInteger Denom;

            public static Rational operator +(Rational a, Rational b) => new Rational(a.Num * b.Denom + a.Denom * b.Num, a.Denom * b.Denom);
        }
    }
}

Takes values of n as command-line arguments, or if run without arguments times itself up to n=10. Compiling as "Release" in VS 2017 and running on an Intel Core i7-6700 I calculate n=9 in 1.2 seconds, and n=10 in 13.6 seconds. n=11 is just over 2 minutes.

FWIW:

n    a(n)
9    10408
10   45244
11   160248
12   762554


Digit sum of powers in bases You should write a program or function which outputs or returns the sum of the digits in base b representation of the first n natural power of a in ascending order.

Example for a = 2, b = 3  and n = 4

The base10 numbers are 2^0, 2^1, 2^2 and 2^3.
Their base3 representations are 1, 2, 11, 22.
The digit sums are 1, 2, 2, 4.
The sorted digit sums are 1, 2, 2, 4 which is the result.

Input

3 integers a > 1, b > 1  andn > 0

Output

A list of integers

Examples

Input => Output

2 5 10 => 1 2 4 4 4 4 4 4 8 8
3 2 20 => 1 2 2 3 4 5 6 6 6 8 9 10 11 11 13 14 14 14 15 17
5 6 1 => 1
6 6 11 => 1 1 1 1 1 1 1 1 1 1 1
6 8 20 => 1 6 6 8 8 8 13 13 15 20 22 22 22 27 29 34 34 34 36 41
8 2 10 => 1 1 1 1 1 1 1 1 1 1
15 17 18 => 1 15 17 31 31 33 49 49 63 65 81 95 95 95 95 113 127 129

This is code-golf so shortest code wins.

CJam, 13 bytes
q~,f#\fb::+$p

I think this can be improved, but lets get this started.
The input is in the following order : b a n
Example input:
3 2 4

Output:
[1 2 2 4]

Code expansion:
q~             "Read the input and parse it. Now we have on stack, b a and n"
  ,            "Get an array from 0 to n-1";
   f#          "Get all the powers of a present in the array, i.e. 0 to n-1";
     \         "Swap the array of a^i and bring the base on top";
      fb       "For each number in the array, convert it into its base representation array";
        ::+    "Calculate the sum of each of the sub arrays in the bigger array";
           $p  "Sort and print the sum of digits of base representation of n powers of a";

Try it online here


Print your system's logo This is a throwback challenge. You will choose an old computer system and an old language created for that system.

The challenge

Pick an old computer system that was made before the year 2000. In a programming language that was created to run on that system, print said system's logo.

Example systems, their languages, and their logos:

Atari ST - GFA BASIC - Atari logo
Apple ][ - Applesoft BASIC - Full logo or Apple only
IBM PC - IBM COMMAND.COM or BASIC-80 - IBM logo

The rules

You may not download the logo/icon from the internet or read it from the filesystem.
You must use graphics to print the logo - no ASCII art.
The icon's size must be at least 20 pixels by 20 pixels.
Your program will not take any input and will clear the screen, print the logo, and exit normally.
If the logo includes colors, your program must print the logo in the same colors, unless your system does not have a color display.
The computer must not shut down.
Your system must have a logo.
If the logo includes text (e.g. the Apple ][ in the Apple logo), you only need to print the image part (e.g. the actual colored Apple).

The winner

As with code-golf, the submission with the least bytes wins!

GFA BASIC on Atari ST, 27 bytes
This is a manually edited source code in .LST format. It contains unprintable characters: [SO] and [SI] stand for ASCII characters #14 and #15 respectively. Both lines ends with CR.
DEFTEXT,,,32
TEXT0,28,"[SO][SI]"

This will draw a 28x26 Atari logo, which is part of the Atari ST system font.


Minimum number of Jumps Given a sequence of numbers, find the minimum number of jumps to go from the starting position to the end and come back to the starting position again.

Each element of the sequence denotes the maximum number of moves that one can move from that position.

At any position, you can make a jump of at max k moves, where k is the value stored at that position. After reaching the end, you can use only those positions for jumping which have not been used previously for jumping.

The input will be given as a sequence of numbers separated by single-spaces.
Output should be a single number which is the minimum number of jumps used.
If its not possible to go to the end and come back to the starting position, then print -1

Input:

2 4 2 2 3 4 2 2

Output:

6 (3 to reach end and 3 to come back)

Input

1 0

Output

-1

Note

Assume all the numbers of the sequence are non-negative

EDIT 1

The line "Thus, it should be clear that one can always jump from the last position." might be confusing, so I removed it from the question. It will have no effect on the question.

Winning Criteria :

The winner will be the one with the shortest code.

Mathematica, 197 193 chars
Brute force.
Min[Length/@Select[Join[{1},#,{n},Reverse@#2]&@@@Tuples[Subsets@Range[3,n=Length[i=FromDigits/@StringSplit@InputString[]]]-1,2],{}⋃#==Sort@#∧And@@Thread[i[[#]]≥Abs[#-Rest@#~Append~1]]&]]/.∞->-1


What calculator is this datafile for? The challenge today is very simple. The task is to determine the TI calculator for which the submitted datafile was made.
The datafiles always start with a string **TI, the version (described below), and other data you can ignore.
Now, the versions you need to recognize are:
95* => TI-95
92P => TI-92+
92* => TI-92
89* => TI-89
86* => TI-86
85* => TI-85
84P => TI-84+
84* => TI-84
83* => TI-83
83P => TI-83+
82* => TI-82
81* => TI-81
74* => TI-74
73P => TI-73+

Examples
**TI95*   => TI-95
**TI83P   => TI-83+
**TI73P   => TI-73+
**TI85*   => TI-85
**TI83PGG => TI-83+
**TI86*asdf*9**TI92Pasd => TI-86

Rules
You can assume the input is always correct, is at least 7 characters long, and has been crafted for one of the TI calculators listed above.
This is code golf, so the shortest answer wins.
I/O rules and loopholes apply.

brainfuck, 39 38 35 bytes

Saved 3 bytes thanks to @Dorian.

,+++>,>,.,.<<.-->>,.,.,[-<->]<[<.<]

Try it online!

This abuses the fact that the characters *,+, and - are very close to each other in ASCII.

Ungolfed:

,+++>  create a minus from the first asterisk
,>      store the second asterisk for comparison later
,.      display T
,.      display I
<<.-->> display the minus from line 1 and turn it into a plus
,.      display first number
,.      display second number

,[-<->]<[  if the last char is not an asterisk from line 2
  <.<      display the plus from line 5
]

Original 38 byte solution:

>,+++>,>,.,.<<.-->>,.,.,<[->-<]>[<<.<]

Original 39 byte solution:

,+++>,>,.,.<<.-->>,.,.,<[->-<]>[<<.[-]]


Multi-lingual Challenge After all the fun we've had with polyglot challenges in the (recent) past, how about a challenge where the output can be in two languages?

Your answer needs to accept boolean input b and output the text "true" or "false". The same code needs to output, when run in another language, "waar" or "onwaar" or any other translation of trueand false.

Input

Input is a clearly distinguishable truthy/falsey. Admissible are the actual values T/F, a bit, int or (empty) string.
Input needs to be the same for all parts of your submission.

Output

Output may be returned by a function, written to STDOUT, placed in a popup-window, 3D-printed and mailed etc.
The output needs to represent the state of b. So a 'truthy' needs to output 'true', 'waar' ... and 'falsey' should lead to 'false', 'onwaar', etc.
Different languages may use different output methods.

Languages used

One of your outputs MUST be "true" and "false".
Different versions of programming languages count as different languages for this challenge.
Different dialects of a human language count as different languages for this challenge.
You may extend the polyglot to more than two programming languages. Every programming language needs to output a distinct human language.

The answer with the most languages incorporated will be declared the winner. When tied, bytecount is considered.

6 languages, 169 bytes

Expects 0\n or 1\n as input, and prints words in:

Python 2 (Dutch vals/waar),
Python 3 (French faux/vrai),
Ruby (English false/true),
CJam (Norwegian usant/sant),
Golfscript (Danish usand/sand),
Befunge-93 (Italian falso/vero).

"#{puts gets>?1;exit}"" "#"& 1v
""
print('vwfvaaarlauasrxi'[int(1/2*4+int(input()))::4])
""#";;;;ri"u">"sant"+o
""""
__END__
]0=~"u">"sand"""#@,,,,"vero"  _"oslaf",,,,,@


Radiation softened quine It's simple: Make a proper quine where if you remove any character, it's still a quine.

The difference between this and a radiation hardened quine is that if your program is AB, in a radiation hardened quine A would output AB, but here, A would output A.

Code golf, all standard rules, standard loopholes apply, no cheating.


Molar masses of compounds Task
Write a program that takes in a compound made solely of elements with an atomic number less than or equal to 92 (Uranium), and outputs the molar mass of the compound in grams/mole.
Rules and Restrictions

You may not use a function that directly calculates molar masses for you.
Your program must be able to run on an offline machine.
You MAY use a separate data file. Contents of this file must be provided.
Your score is the length of your program in bytes, plus the the length of your data file in bytes, should you choose to use one.
This is code-golf, therefore, lowest score wins.

Input
A string containing the compound. This string may be read through STDIN, passed as an argument, or set to a variable (please specify which). The following are all valid inputs:

CH2 (one Carbon, two Hydrogens)
(CH2)8 (8 Carbons, 16 Hydrogens)
U (1 Uranium)

Your program is not required to function for embedded parentheses (i.e. ((CH3)2N4)4), nor for any compound that contains an element with atomic number greater than 92. If your program does not function for either of the above two cases, it must output Invalid formula for such cases - no undefined behavior.
Output
You should output, to STDOUT or to a variable, the molar mass of the compound in grams/mole. A list of atomic masses of elements is available here (Wikipedia). Your answer should be accurate to the decimal place for compounds containing fewer than 100 atoms (rounded).
If the input is invalid, Invalid formula must be outputted.
Information on calculating the molar mass of a compound in grams/mole (Wikipedia).
Examples
Input                   Output
H2O                     18.015
O                       15.999 (16 acceptable)
C6H2(NO2)3CH3           227.132
FOOF                    69.995
C6H12Op3                Invalid formula
Np                      237 (or Invalid formula)
((C)3)4                 144.132 (or Invalid formula)
CodeGolf                Invalid formula

Bash, 978 708 675 673 650 636 632 631 598 594

211 bytes for the program and 382 bytes for the data.

Input is on STDIN, output is on STDOUT. WARNING: creates files called g and a, if they exist, they will be overwritten!

zcat y>g 2>a
s=(`sed 's/[A-Z][a-z]*/& /g;q'<g`)
p=1.008
v=`sed 's/[0-9]\+/*&/g;s/(/+(0/g'`
r=(`tail -1 g`)
for n in {0..91};{
p=`bc<<<$p+${r[n]}`
v=${v//${s[n]}/+$p}
}
o=`bc<<<0$v 2>a`
echo ${o:-Invalid formula}

Data file

This requires a file called y, which is the zopfli-compressed form of this data (no trailing newline). zopfli is a gzip-compatible compression algorithm and can be decompressed with standard gzip tools. It was run with 1024 iterations (this is probably too much). The last 8 bytes were then removed.

HHeLiBeBCNOFNeNaMgAlSiPSClKArCaScTiVCrMnFeNiCoCuZnGaGeAsSeBrKrRbSrYZrNbMoTcRuRhPdAgCdInSnSbITeXeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaWReOsIrPtAuHgTlPbBiPoAtRnFrRaAcPaThU
0 2.995 2.937 2.072 1.798 1.201 1.996 1.992 2.999 1.182 2.81 1.315 2.677 1.103 2.889 1.086 3.39 3.648 .850 .130 4.878 2.911 3.075 1.054 2.942 .907 2.848 .24 4.613 1.834 4.346 2.904 2.292 4.038 .944 3.894 1.670 2.152 1.286 2.318 1.682 3.054 2.04 3.07 1.836 3.514 1.448 4.543 2.407 3.892 3.050 5.144 .696 3.693 1.612 4.422 1.578 1.211 .792 3.334 .758 5.36 1.604 5.286 1.675 3.575 2.43 2.329 1.675 4.120 1.913 3.523 2.458 2.892 2.367 4.023 1.987 2.867 1.883 3.625 3.788 2.82 1.78 .02 1 12 1 3 1 4.036 1.002 5.991

The base64 of y is (use base64 -d to reproduce the original file):

H4sIAAAAAAACAwTB226DMAwA0G9LvEJQIbVi70LfHPBoJAiSaR729zsnBB2LVw/x0UWNMm1up4IE
+90ZCC1cvsCm2mkscEJ71l56dRept7ulTDY/Lebp5CW19MLVbbAOlSrlgfVH4fIyCihaXPGg49b6
lfPHXzhvxsecxxZ+Wb6TPq7B8O1a2HjH7Aue7p1qZ0ncgsKvz/8WxuRGoigGgfcfxYvA8r7kn9iA
ei6ohAt/+lzuihmD1PFnMrdIV0PeNfOczh3Ylrw8hnHaM6w1WC8V3X4hcYjOfbKlTyz0pewsP5nh
plOUK9mkPzkd4HLiCbktIGyQI5uaUvZzNBrwLhOf9hJij+Jo5WBf6mHLfh2OFqeaxOHbaGAZl5mL
h5UBI3Hlx99GX4llPumDjgw+NIee7uCaRbrZkzluIhJYi2E0ZU2gb5OnYBTSJQMRfv91irmCz4KK
B5Va5J7T7IGjHnR22PeAd+m3F3KW/voz4BMFPGNgxHE0Loq65M6+Pw==

The md5sum is d392b0f5516033f2ae0985745f299efd.

Explanation

The numbers in the file are increments of relative atomic mass (so the relative atomic mass of lithium is 1.008 + 0 + 2.995 + 2.937).

This script works by converting the chemical formula into an arithmetical expression with + and *, replacing each symbol with its relative atomic mass, then feeding the expression to bc. If the formula contains invalid symbols, bc will give a syntax error and output nothing to STDOUT; in that case, the output is Invalid formula.

If STDIN is empty, the output is 0. Nested brackets are supported.

zcat y>g 2>a # Unzip the file y and output result to the file g. Send standard error to file a (there will be an error because the last 8 bytes are missing)
s=(`sed 's/[A-Z][a-z]*/& /g;q'<g`)  # Read from g to sed; append a space after any capital letter optionally followed by a lowercase letter; exit at the end of the first line so the atomic masses are not processed in this way; parse result as space-separated array and save to variable $s
p=1.008 # In the upcoming loop, $p is the value obtained in the previous iteration
v=`sed 's/[0-9]\+/*&/g;s/(/+(0/g'` # Read from standard input to sed; prepend a * after any sequence of digits; replace ( with +(0; save to $v
r=(`tail -1 g`) # Get the last line of file g; parse as space-separated array; save to $r
for n in {0..91};{ # Loop once for each number from 0 to 91; set $n to the current number each iteration
p=`bc<<<$p+${r[n]}` # Concatenate $p, + and the next number from $r; send to bc and evaluate as arithmetic expression; save to $p (i.e. add the next increment from the file to $p)
v=${v//${s[n]}/+$p} # Replace every occurence of the current element symbol with + and $p (i.e. replace each symbol with a + and its relative atomic mass
} # end loop
o=`bc<<<0$v 2>a` # Prepend 0 to $v; send to bc and evaluate as arithmetic expression; redirect any errors on standard error to the file a; save result to $o
echo ${o:-Invalid formula} # If $o is empty (if there was a syntax error), output Invalid formula; otherwise output $o

Example

C6H2(NO2)3CH3  #input
C*6H*2+(0NO*2)*3CH*3  #after line 3
+12.011*6+*1.008*2+(0+14.007+15.999*2)*3+12.011+1.008*3  #after the loop in lines 4-6
0+12.011*6+*1.008*2+(0+14.007+15.999*2)*3+12.011+1.008*3  #given to bc in line 7
227.132 #output as evaluated by bc


place vials in your centrifuge This question originates in this reddit thread by reddit user taho_teg but it is expanded to a more general 'puzzle'.

You have a centrifuge with 24 holes for the vials uniformly distributed in a circle around the central axis. If you now have a number of vials and you want to start the centrifuge, you need to make sure that they are placed in a balanced manner. The only numbers of vials you cannot balance are 1 and 23. You can for example balance 4 obviously, but you can also balance 5 by making a 'triangle' with 3 vials and placing the other two on two opposite sites.

Goal

You have to write a program that accepts the number of holes (that are uniformly distributed in a circle around the rotating axis) of your centrifuge as input, and that outputs a list of numbers of vials that cannot be balanced in the centrifuge.

You have to do the calculation and cannot just hardcode the precomputed solutions.

Input and output have to be implemented in a way so that the program code does not have to be changed for calling the program for different inputs. It is also acceptable to write a function (or a similar construct in your language) that can be called via a console.

Be also aware that if you have 6 holes in your centrifuge, you can centrifuge 2 and 3 vials, but you cannot balance 5 since the 'triangle' and the opposite two will overlap at one point. Another example would be for n=15 you cannot balance 11 vials, you can balance 6 and 5 vials, but the combination of those solutions will overlap (this is of course not yet the criterion that it is impossible to do so).

Update

It seems some people did not understand the given example, so I made a graphic here. PLEASE write a short description of how your algorithm works as well as some example outputs for verification. Please include following examples:

n = 1, 6, 10, 24, 63, 100 = 10^2, 163 (prime), 40320 = 8!, 65536=2^2^2^2^2, 105953 (prime)

Note that 40320 and 65536 will produce huge lists, it will perhaps be a good idea to only indicate the length of those lists.

If you know some interesting numbers to add to that list please let me know!
The algorithm should work at least up to n = 1'000'000.

Example outputs:

These are some example outputs-but perhaps faulty because I just calculated them manually.

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

Hint

If you have a centrifuge with n holes, and you cannot balance e.g. 6 vials, you will also not be able to blance n-6 vials - it is basically the same task to balance m vials on an empty centrifuge or to balance a filled centrifuge by taking away m vials. So you if you have the number m in your list you will also have to include n-m.

Sage – 102 104/115

Why use number theory, when there is brute force?

v=lambda n:[j for j in range(n+1)if all(sum(e^(i*2*I*pi/n)for i in c)for c in Combinations(range(n),j))]

For a given number of vials, this goes over all ways to position the vials and calculates their center of mass by using complex arithmetics. If the center of mass is zero for none of these ways, the number is returned.

Unfortunately, this does not work in certain cases (10,14), because Sage fails to simplify some expressions to zero (which may be related to this bug). One could regard this as a flaw of the interpreter and not the program and still say that the algorithm and program are fine.

The following 113-character alternative relies on floats instead of symbols and does not suffer from these problems:

v=lambda n:[j for j in range(n+1)if all(abs(sum(exp(i*2j*pi/n)for i in c))>1e-9for c in Combinations(range(n),j))]

Test output of the 113-character version (for n in range(14): print n,v(n)):

0 []
1 [1]
2 [1]
3 [1, 2]
4 [1, 3]
5 [1, 2, 3, 4]
6 [1, 5]
7 [1, 2, 3, 4, 5, 6]
8 [1, 3, 5, 7]
9 [1, 2, 4, 5, 7, 8]
10 [1, 3, 7, 9]
11 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
12 [1, 11]
13 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
14 [1, 3, 5, 9, 11, 13]

I did not want to wait the runtime for higher n.

This originates from the following Python solution. Exact arithmetics and not having to import some modules is quite something.

Python – 173 154 156

from itertools import*
from cmath import*
v=lambda n:[j for j in range(n+1)if all(abs(sum(exp(i*2j*pi/n)for i in c))>1e-9for c in combinations(range(n),j))]

Test output of this variant (for n in range(24): print n,v(n)):

0 []
1 [1]
2 [1]
3 [1, 2]
4 [1, 3]
5 [1, 2, 3, 4]
6 [1, 5]
7 [1, 2, 3, 4, 5, 6]
8 [1, 3, 5, 7]
9 [1, 2, 4, 5, 7, 8]
10 [1, 3, 7, 9]
11 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
12 [1, 11]
13 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
14 [1, 3, 5, 9, 11, 13]
15 [1, 2, 4, 7, 8, 11, 13, 14]
16 [1, 3, 5, 7, 9, 11, 13, 15]
17 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
18 [1, 17]
19 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
20 [1, 3, 17, 19]
21 [1, 2, 4, 5, 8, 10, 11, 13, 16, 17, 19, 20]
22 [1, 3, 5, 7, 9, 13, 15, 17, 19, 21]
23 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
24 [1, 23]

I did not want to wait the runtime for higher n.


Shortest Google Sheets formula to detect if cell contains an image Step one
In a new google sheet insert an image into cell A1 with
Insert > Image > Image In Cell
Step two
Create a formula to return TRUE (if the cell contains an image) and FALSE (if the image is missing)
Rules
Only vanilla formulas are allowed. The shortest code in bytes wins.

26
The shortest I've found, which I believe currently works, is:
=TYPE(A1)>64>ISFORMULA(A1)


The Piggyback Sequence I made my own sequence recently (called the Piggyback sequence), and it works like this:
P(1), P(2) and P(3) = 1.
For all P(n) where n>3, the sequence works like this:
P(n) = P(n-3) + P(n-2)/P(n-1)

So, continuing the sequence:
P(4) = 1 + 1/1 = 2
P(5) = 1 + 1/2 = 3/2
= 1.5
P(6) = 1 + 2/(3/2) = 7/3
= 2.33333...
P(7) = 2 + (3/2)/(7/3) = 37/14 = 2.6428571428...
P(8) = 3/2 + (7/3)/(37/14) = 529/222
= 2.3828828828...
Your task is, when given n, calculate P(n) either as a floating point number or an (im)proper fraction.
This is code-golf, so shortest code in bytes wins.
If anyone can find the name of the sequence, please edit the post accordingly.
Current leaders: MATL and Jelly (both at 15 bytes).

Python 2, 40 39 bytes.

f=lambda x:x<4or.0+f(x-3)+f(x-2)/f(x-1)

Gives True instead of 1, if this isn't allowed we can have this for 42 bytes:

f=lambda x:.0+(x<4or f(x-3)+f(x-2)/f(x-1))

The way it works is pretty straightforward, the only trick is using .0+ to cast the result to a float.


The Lucas-nacci Numbers Background

Most everyone is familiar with the Fibonacci numbers F(n):

  0, 1, 1, 2, 3, 5, 8, 13, 21 ...

These are formed by the recursion function F(n) = F(n-1) + F(n-2) with F(0)=0 and F(1)=1. A000045

A closely related sequence is the Lucas numbers L(m):

  2, 1, 3, 4, 7, 11, 18, 29 ...

These are formed by the recursion function L(m) = L(m-1) + L(m-2) with L(0)=2 and L(1)=1. A000032

We can alternate between the two sequences based on even/odd indices, with the construction
A(x) = F(x) if x mod 2 = 0 and A(x) = L(x) otherwise. For example, A(4) is equal to F(4) since 4 mod 2 = 0. We'll call this sequence the Lucas-nacci Numbers, A(x):

  0, 1, 1, 4, 3, 11, 8, 29, 21, 76 ...

This can be formed by the recursion function A(x) = 3*A(x-2) - A(x-4) with A(0)=0, A(1)=1, A(2)=1, and A(3)=4. A005013

Challenge

Given input n, output the sequence of n+1 numbers up to and including A(n) as described above. Fewest bytes (or byte-equivalents, such as for LabVIEW, as determined individually on Meta) wins.

Input

A single non-negative integer n.

Output

A list of numbers that correspond to the subsequence of Lucas-nacci numbers from A(0) to A(n). The list must be in sequential order as described above.

Rules

Standard code-golf rules and loophole restrictions apply.
Standard input/output rules apply.
Input number can be in any suitable format: unary or decimal, read from STDIN, function or command-line argument, etc. - your choice.
Output can be printed to STDOUT or returned as a result of the function call. If printed, suitable delimiters to differentiate the numbers must be included (space-separated, comma-separated, etc.).
Additionally, if output to STDOUT, surrounding whitespace, trailing newline, etc. are all optional.
If the input is a non-integer or a negative integer, the program can do anything or nothing, as behavior is undefined.

Examples

Input -> Output
0 -> 0
5 -> 0, 1, 1, 4, 3, 11
18 -> 0, 1, 1, 4, 3, 11, 8, 29, 21, 76, 55, 199, 144, 521, 377, 1364, 987, 3571, 2584

Jelly, 12 bytes

;2U+¥Ð¡-,1ZḢ

Try it online!

Background

We can extend F and L to -1 by defining F(-1) = 1 and L(-1) = -1. This is consistent with the recursive function.

Our program starts with

-1  1
 0  2

In each step, to form the next pair, we reverse the last pair and add it to the penultimate pair. For example:

[0, 2] U+¥ [-1, 1] -> [2, 0] + [-1, 1] -> [1, 1]

If we continue this process for a few more steps, we get

-1  1
 0  2
 1  1
 1  3
 4  2
 3  7
11  5

The Lucas-nacci sequence is simply the left column.

How it works

;2U+¥Ð¡-,1ZḢ  Niladic link. No implicit input.
              Since the link doesn't start with a nilad, the argument 0 is used.

;2            Concatenate the argument with 2, yielding [0, 2].
       -,1    Yield [-1, 1]. This is [L(-1), F(-1)].
    ¥         Create a dyadic chain of the two atoms to the left:
  U             Reverse the left argument.
   +            Add the reversed left argument and the right one, element-wise.
     Ð¡       For reasons‡, read a number n from STDIN.
              Repeatedly call the dyadic link U+¥, updating the right argument with
              the value of the left one, and the left one with the return value.
              Collect all intermediate results.
          Z   Zip the list of results, grouping the first and seconds coordinates.
           Ḣ  Head; select the list of first coordinates.

‡ Ð¡ peeks at the two links to the left: 2 and U+¥. Since the leftmost one is a nilad, it cannot be the body of the loop. Therefore, U+¥ is used as body and a number is read from input. Since there are no command-line arguments, that number is read from STDIN.


Correct peoples grammar (yes, that title was intentional)

Your task is to correct common grammatical mistakes.

You must:

Capitalise the first letter of each sentence, ie the first non-whitespace letter after any of .!? and, additionally, capitalise the first letter of the input
Remove repeating punctuation, such as !!! -> !. Ellipses (...) are not special, and will collapse into ..
Remove repeating whitespace <space><space><space> -> <space>
Remove whitespace directly before any of .,;!? as in: Hello , World ! -> Hello, World!
If there is no space directly after any of .,;!?, add it.
Add a . at the end of the input if there is not any of .!? at the end.
Not use Mathematica's builtins

Examples:

This is a  sentence .Unfortunately, it's not very grammatically correct.can you fix it ???
This is a sentence. Unfortunately, it's not very grammatically correct. Can you fix it?

buffalo, buffalo;buffalo   buffalo? Buffalo.buffalo Buffalo buffalo
Buffalo, buffalo; buffalo buffalo? Buffalo. Buffalo Buffalo buffalo.

i'm not sure what to put for this test case...
I'm not sure what to put for this test case.

!this is a test. .Can ...you . . . 'ear me Ground-Control? ?! 'ere as in what you do with you're [sic] ears !
! This is a test. Can. You. 'ear me Ground-Control?! 'ere as in what you do with you're [sic] ears!

Retina, 80 74 73 71 74 64 65 62 78 72 bytes

 *([.,;!? ])(\1| )*
$1
T`l`L`[.!?].|^.
([.,;!?])(\w|')
$1 $2
[^.!?]$
$&.

Try it online!

This is my first Retina answer.

-12 bytes thanks to @BusinessCat!

-3 bytes thanks to @Neil.


Sum the rows of the concatenated triangle Consider the following triangle.

1
23
456
7891
01112
131415
1617181
92021222
324252627
2829303132
33343536373
839404142434
4454647484950
51525354555657
585960616263646
5666768697071727
37475767778798081

As you probably noticed, the first row is of length 1, and each row thereafter is 1 digit longer than to the previous one and that it contains the digits of the positive integers concatenated.
You will be given an integer N. Your task is to find the sum of the digits that lie on Nth row of the above triangle.
Rules

You can choose either 0 or 1 indexing. Please specify that in your answer.

Default Loopholes apply.

You can take input and provide output by any standard mean, and in any reasonable format.

This is OEIS A066548, and this sequence is the triangle itself (except that we do not remove leading zeros).

This is code-golf, so the shortest code in bytes (in every language) wins. Have fun golfing!

Test Cases
Input  |  Output

0  |  1
1  |  5
2  |  15
3  |  25
4  |  5
5  |  15
6  |  25
7  |  20
8  |  33
9  |  33
10 |  43
11 |  46
12 |  64

Note that the above are 0-indexed. If you are looking for 1-indexed test cases, increment the input by 1.
On a quite unrelated note, I recently changed my profile picture and that inspired me to write this challenge.

Husk, 7 bytes
1-indexed
Σ!CNṁdN

Try it online!
Explanation
    ṁ     Map then concatenate
     d    Integer digits
      N   Over the natural numbers
  CN      Cut into lists of lengths corresponding to the natural numbers
 !        Index it
Σ         Sum


Random Capitalization The Task

Your task is to create a program or a function that, given an input, outputs the input text with random letters capitalized, while keeping already capitalized letters capitalized.

Every combination of capitalizations of the lowercase letters should be possible. For example, if the input was abc, there should be a non-zero probability of outputting any of the following combinations: abc, Abc, aBc, abC, ABc, AbC, aBC or ABC.

Input

Your input is a string, containing any number of printable ASCII characters, for example Hello World. The outputs for that input include HeLLo WoRlD, HElLO WOrld, etc.

Scoring

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

TI-Basic (83 series), 137 bytes

For(I,1,length(Ans
Ans+sub(sub(Ans,I,1)+"ABCDEFGHIJKLMNOPQRSTUVWXYZ",1+int(2rand)inString("abcdefghijklmnopqrstuvwxyz",sub(Ans,I,1)),1
End
sub(Ans,I,I-1

Takes input in Ans, as illustrated in the screenshot below:

(If the screenshot looks scrambled, as it sometimes does for me, try opening it in a new tab?)

TI-Basic (at least the TI-83 version... maybe I should branch out into TI-89 golfing) is a terrible language to try to golf this challenge in, since:

It provides absolutely no support for any arithmetic with characters, knowing the uppercase version of a lowercase character, or even knowing the alphabet.
Every single lowercase character takes 2 bytes to store. (In fact, I had to use an assembly script just to be able to type the lowercase letters.)

The result is that 78 bytes of this program (more than half) are just storing the alphabet, twice.

Anyway, the idea is that we loop through the string, with a chance of turning lowercase characters into uppercase ones as we go, and adding the result onto the end of the string so that both the input and the output are stored in Ans. When we leave the For( loop, I is one more than the length of the original string, so taking the I-1 characters starting at I gives the output.


An "Iniative" game mechanic This challenge is inspired by turn based videogames like "Heroes of Might and Magic"

Implement this game mechanic:

There is some units(Imps, Swordsmans etc...) in our game
Every unit have an integer "initiative"
Your program must decide which unit's turn now - based on unit's initiative
The more initiative means more frequent turns(for example unit with 10 iniative will move 5 times more often than 2 iniative unit)
Unit with highest initiative moves first
Input: Array of pairs of [unit_name: string, unit_initiative: integer]
Output: Unit names in moving sequence separated by line break (\n)
Make 50 turns total

Test case:

Units:
[["Imp", 500], ["Mammoth", 50], ["Swordsman", 250], ["Elf", 350]]

turn sequence(50 turns) output:

Imp
Elf
Imp
Swordsman
Elf
Imp
Imp
Swordsman
Elf
Imp
Elf
Imp
Swordsman
Imp
Elf
Imp
Swordsman
Elf
Imp
Elf
Imp
Swordsman
Mammoth
Imp
Elf
Imp
Swordsman
Elf
Imp
Imp
Swordsman
Elf
Imp
Elf
Imp
Swordsman
Imp
Elf
Imp
Swordsman
Elf
Imp
Elf
Imp
Swordsman
Mammoth
Imp
Elf
Imp
Swordsman

Other rules:

Use your favorite language
Write shortest code possible
Attach a link to an online iterpreter
Please follow standard code golf rules

Jelly, 20 15 bytes

P:ṭ×¥Ɱ"Ɗ,€"ẎṢṪ€

Try it online!

A dyadic link taking a list of initiative scores as its left argument and a list of characters as its right and returning a list of the characters in movement order.

Jelly, 14 bytes

İṭ×¥Ɱ"$,€"ẎṢṪ€

Try it online!

This version is one bytes shorter but I expect may sometimes get the order wrong because of inaccuracies in floating point calculations.


Remove duplicate words from a sentence In this challenge, you will remove duplicate words from each sentence.

Examples

Hello Hello, World!
Hello, World!

Code Code! Golf Code
Code! Golf Code

Hello  hello   World
Hello   World

Programming Golf Programming!
Programming Golf!

Specification

Input will be a string of ASCII characters.
A sentence is defined as anything until the end of the string, a linefeed (\n), or punctuation (.!?).
A word is defined as a sequence of A-Za-z.
Words are case insensitive (Hello == heLlO).

Only the first occurrence of a word in a sentence is kept.
If a word is removed, the spaces before the removed word should be removed. (e.g. A   A B -> A B).

As always standard loopholes are disallowed.

This is code-golf so shortest code in bytes wins!

JavaScript (ES6), 98

Note while I found it myself, it's annoyingly similar to @Neil's, just with the additional logic to split the whole input string in sentences.

s=>s.replace(/[^\n.!?]+/g,s=>s.replace(/ *([a-z]+)/ig,(r,w)=>k[w=w.toUpperCase()]?'':k[w]=r,k=[]))

Test

f=s=>s.replace(/[^\n.!?]+/g,s=>s.replace(/ *([a-z]+)/ig,(r,w)=>k[w=w.toUpperCase()]?'':k[w]=r,k=[]))

console.log=x=>O.textContent+=x+'\n'

;[['Hello Hello, World!','Hello, World!']
,['Code Code! Golf Code','Code! Golf Code']
,['Hello  hello   World','Hello   World']
,['Programming Golf Programming!','Programming Golf!']]
.forEach(t=>{
  var i=t[0],k=t[1],r=f(i)
  console.log((r==k?'OK ':'KO ')+i+' -> '+r)
})


Figure out the maximum amount of candy a child can collect The city of Poughkeepsie celebrates Halloween every year. Geographically, the city is a rectangle that is 30 miles long and 45 miles wide. On a map, it looks like a grid, with its east-west roads horizontally dividing the city into 1-mile-long rectangles and its north-south roads vertically dividing the city likewise. There is one house at each road intersection.

The city's residents tend to be more generous with their candy as one moves toward the center of the rectangle. The resident at the lower-left corner of the city - whom we'll call Bob - gives out 10 candies per child. If a child starts at Bob's house and proceeds eastward, each resident they come across will give them 5 more candies than the last one (In other words, Bob's nearest eastern neighbor will give 15 candies. If a child walks another mile to the next eastern neighbor, they get another 20 candies.) After they reach the horizontal center street, that number decreases by 5. If that same child instead proceeds northward of Bob's house - which is located at (0,0) - each resident they meet will give them 10 more candies than the previous resident. After they reach the relevant center street, each resident they meet will give 10 less.

The number of candies given out by residents who do not live on the edges of the city is the sum of the number of candies given out by the two neighbors who live on the nearest borders of the city. So, a resident who lives at (44,29) will give out the number of candies given by the resident at (45,29) + the number of candies given by the resident at (30,44).

Important note: The only way to access each house is by walking along roads or adjacent paths. One is not allowed to, for example, bee-line from Bob's house to (1,1) - s/he must first either walk along the y-axis for 1 mile, turn right and walk for another mile; or walk along the x-axis for 1 mile, turn left and walk for another mile. Also, once a child has received candy from a house, they will receive no more candy from that same house.

Objective:
Your program is to figure out how much candy a child can receive if s/he starts at Bob's house and is to walk no more than a given distance "d".

Scoring
Programs will be scored based on the size (in bytes) of the source code.

Jelly, 58 bytes

Ø+0r;U$ṗµØ1W;⁸+\Q%“.þ‘)ẎẠ$Ƈµ20Ḋ×©5Ḋ+þ14Ḋ×⁵¤⁺;"Wɼ;ŒBm0⁸œị§Ṁ

Try it online!

Very slow (brute force), TIO can handle up to 8. Test cases in \$[0,8]\$: Try it online!


Golf the repeated totient function You will take two positive integers n and x as input, and output Euler's totient function (number of positive integers less than x co-prime to x) applied n times.
Testcases
n x   result
1 10  4
2 10  2
3 10  1
1 100 40
2 100 16
3 100 8
4 100 4
5 100 2
6 100 1

05AB1E, 2 bytes
Code:
FÕ

Explanation:
F   # Do the following n times:
 Õ  #   ..Calculate the totient

Uses the CP-1252 encoding. Try it online!.


Insert typos into text I wrote some text, but it looks too professional. I want to make it look like I was really tired when I wrote it. I need you to insert some typos.

Your challenge is to take an arbitrary single line of text, and add typos. This means that for each character, there will be a 10% chance for it to be typofied.

The definition of "typofied" is that you must choose (randomly) one of the following:

Duplicate the character.
Delete the character.
Shift the character one keyboard space. The "keyboard" is defined as:

qwertyuiop
asdfghjkl
 zxcvbnm

For the character shift, you must go one space up, down, left, or right. This must be chosen randomly. The shift option only applies to alphabetic characters. Case must be preserved. Be careful with edge-cases, like m!

The definition of "random" is that the result must not be predictable (by looking at previous results). For example, you can't typofy every tenth character. Furthermore, the randomness must have an even distribution. For example, you can't do 30% duplicate, 30% delete, and 40% shift; it has to be a 1/3 chance for each (1/2 for each if it's a nonalphabetic character).

Example input:

This is some correct text. It is too correct. Please un-correctify it.

Example output:

This iissome xorreect tex..  It is too coteect. Please jn-corretify it.

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

C, 358 bytes
(There are only three lines of code, but I've broken up line 3 for legibility)
#define x putchar
#define y random()
c,n;main(){char*s[26]={"QS","HNV","FVX","EFSX","DRW","CDGR","FHTV","BGJY","KOU","HKNU",
"IJLM","KO","KN","BJM","ILP","OO","AW","EFT","ADWZ","GRY","IJY","BCG","ESQ","CDZ","HTU",
"SX"};while((c=getchar())>0){if(y%10>0&&x(c))continue;if(isalpha(c)&&y%3<1){n=(c&31)-1;
x(s[n][y%strlen(s[n])]|(c&32));continue;}if (y&1)x(x(c));}}

The array of strings at the beginning lists the possible adjacent keys for each letter of the alphabet. I had to double up the "O" (adjacent to "P") to avoid calculating random()%1 when selecting a shifted character.
Test run:
$ echo "This is some correct text. It is too correct. Please un-correctify it." |./a.out
This is some  cofrect teext. It is too correct.. Plleaase un-correctify it..

Update:
Here's an expanded and commented version of the same source code:
#include <stdio.h>
#include <string.h>
/* ^^ These should be included, but the code compiles without them */

int c,n;

void main() {

  /* Adjacent keys for each letter of the alphabet (A, B, C, ..., Z): */
  char *s[26] = { "QS","HNV","FVX","EFSX","DRW","CDGR","FHTV","BGJY","KOU","HKNU",
                  "IJLM","KO","KN","BJM","ILP","OO","AW","EFT","ADWZ","GRY","IJY",
                  "BCG","ESQ","CDZ","HTU","SX" };

  /* Fetch input until null character or EOF reached */
  while ((c=getchar())>0) {

    /* For 90% of the time, just echo the character unchanged */
    if (random()%10>0 && putchar(c)) continue;

    /* If it's a letter of the alphabet, shift with 33% probability */
    if (isalpha(c) && random()%3<1) {
      /* Calculate offset to adjacent keys data */
      n=(c&31)-1;
      /* Choose a random adjacent key, and change to lower case if needed */
      putchar(s[n][random()%strlen(s[n])]|(c&32));
      continue;
    }

    /* If we reach this point, either we didn't fetch an alphabet character, or   */
    /* we did but chose not to shift it. Either way, we now need to either repeat */
    /* the character or delete it, with 50% probability for each. */

    /* This repeats the character by printing the return value from putchar() */
    if (random()&1) putchar(putchar(c));

    /* To delete the character, we don't have to do anything. */
  }
}


School moving out (Day 1) Challenge Taken with permission from my University Code Challenge Contest

For some years now, the number of students in my school has been growing steadily. First the number of students was increased by classroom, but then it was necessary to convert some spaces for some groups to give classes there, such as the gym stands or, this last course, up to the broom room.

Last year the academic authorities got the budget to build a new building and started the works. At last they have finished and the new building can be used already, so we can move (the old building will be rehabilitated and will be used for another function), but it has caught us halfway through the course. The director wants to know if the move will be possible without splitting or joining groups, or that some students have to change groups.

Challenge

Given the amount of students of the current groups and the new classrooms (capacity), output a truthy value if it is possible to assign a different classroom, with sufficient capacity, to each of the current groups, or a falsey value otherwise.

Test Cases

Input: groups of students => [10, 20, 30], classrooms capacity => [31, 12, 20]
Output: True

Input: groups of students => [10, 20, 30], classrooms capacity => [100, 200]
Output: False

Input: groups of students => [20, 10, 30], classrooms capacity => [20, 20, 50, 40]
Output: True

Input: groups => [30, 10, 30, 5, 100, 99], classrooms => [40, 20, 50, 40, 99, 99]
Output: False

Input: groups => [], classrooms => [10, 10, 10]
Output: True

Input: groups => [10, 10, 10], classrooms => []
Output: False

Input: groups => [], classrooms => []
Output: True

Input: groups => [10, 1], classrooms => [100]
Output: False

Input: groups => [10], classrooms => [100, 100]
Output: True

Input: groups => [1,2,3], classrooms => [1,1,2,3]
Output: True

Notes

You can take the input in any reasonable format
You can output any Truthy/Falsey value (1/0, True/False, etc...)
code-golf

Brachylog, 4 bytes

It's always nice to see a challenge and know brachylog is gonna beat everyone.
Takes current classes as input and new classrooms as output; It will output true if it finds a way to fit the students, false otherwise

p≤ᵐ⊆

Explanation

The code has 3 parts of which the order actually doesn't matter

≤ᵐ --> projects each value to a value bigger/equal then input
⊆  --> input is a ordered subsequence of output
p  --> permutes the list so it becomes a unordered subsequence

Try it online!


Who has a comma for a middle name? Your challenge is to take a name (string) as input, like

Albert Einstein

and output:

Einstein, Albert

Pseudocode:

set in to input
set arr to in split by " "
set last to the last element of arr
remove the last element of arr
set out to arr joined with " "
prepend ", " to out
prepend last to out
output out

More test cases:

John Fitzgerald Kennedy => Kennedy, John Fitzgerald
Abraham Lincoln => Lincoln, Abraham

Rules

The input will always match the regex ^([A-Z][a-z]+ )+([A-Z][a-z]+)$.
You don't need to handle weird names, even if the output is technically incorrect it is fine here.
Trailing whitespace / newline is OK.
Any questions? Comment below!

05AB1E, 7 bytes
Code:
',ì#Áðý

Uses the 05AB1E encoding. Try it online!
Explanation:
',ì         # Prepend the input to ","
   #        # Split on spaces
    Á       # Rotate every element one position to the right (wrapping)
     ðý     # Join the array by spaces


Match strings whose length is a fourth power Within the scope of this question, let us consider only strings which consist of the character x repeated arbitrary number of times.
For example:
<empty>
x
xx
xxxxxxxxxxxxxxxx

(Well, actually it doesn't have to be x - any character is fine as long as the whole string only has 1 type of character)
Write a regex in any regex flavor of your choice to match all strings whose length is n4 for some non-negative integer n (n >= 0). For example, strings of length 0, 1, 16, 81, etc. are valid; the rest are invalid.
Due to the technical limitation, values of n bigger than 128 is hard to test against. However, your regex should logically work correctly regardless.
Note that you are not allowed to execute arbitrary code in your regex (to Perl users). Any other syntax (look-around, back-reference, etc.) is allowed.
Please also include a short explanation about your approach to the problem.
(Please don't paste auto generated regex syntax explanation, since they are useless)
This is code-golf. For each regex flavor, the regex compatible with that flavor having the shortest length in bytes wins in that category. The shortest of all of the answers wins overall.

Note that this challenge was originally posted as a puzzle, not code-golf. But the actual answers basically treated it as code-golf anyway, just without actually specifying their sizes in bytes. That has now been fixed, to give the challenge objective winning criteria and make it on-topic for CGCC.

Perl / Java / PCRE / .NET, 39 bytes
Another Solution
This is, in my opinion, one of the most interesting problems on the site. I need to thank deadcode for bumping it back up to the top.

^((^|xx)(^|\3\4\4)(^|\4x{12})(^x|\1))*$

39 bytes, without any conditionals or assertions... sort of. The alternations, as they're being used (^|), are a type of conditional in a way, to select between "first iteration," and "not first iteration."
This regex can be seen to work here: http://regex101.com/r/qA5pK3/1
PCRE interprets the regex correctly, and it has also been tested in Perl up to n = 128, including n4-1, and n4+1.

Definitions
The general technique is the same as in the other solutions already posted: define a self-referencing expression which on each subsequent iteration matches a length equal to the next term of the forward difference function, Df, with an unlimited quantifier (*). A formal definition of the forward difference function:
\$D_f(n)=f(n+1)-f(n)\$
Additionally, higher order difference functions may also be defined:
\$D_f^2(n)=D_f(n+1)-D_f(n)\$
Or, more generally:
\$D_f^k(n)=D_f^{k-1}(n+1)-D_f^{k-1}(n)=\sum\limits_{i=0}^k{(-1)^i}{k\choose i}f(n+k-i)\$
The forward difference function has a lot of interesting properties; it is to sequences what the derivative is to continuous functions. For example, Df of an nth order polynomial will always be an n-1th order polynomial, and for any i, if Dfi = Dfi+1, then the function f is exponential, in much the same way that the derivative of ex is equal to itself. The simplest discrete function for which f = Df is 2n.

f(n) = n2
Before we examine the above solution, let's start with something a bit easier: a regex which matches strings whose lengths are a perfect square. Examining the forward difference function:
\$D_f=[1,3,5,7,9,\dots]=2n+1\$
Meaning, the first iteration should match a string of length 1, the second a string of length 3, the third a string of length 5, etc., and in general, each iteration should match a string two longer than the previous. The corresponding regex follows almost directly from this statement:
^(^x|\1xx)*$

It can be seen that the first iteration will match only one x, and each subsequent iteration will match a string two longer than the previous, exactly as specified. This also implies an amazingly short perfect square test in perl:
(1x$_)=~/^(^1|11\1)*$/

This regex can be further generalized to match any n-gonal length:
Triangular numbers:
^(^x|\1x{1})*$
Square numbers:
^(^x|\1x{2})*$
Pentagonal numbers:
^(^x|\1x{3})*$
Hexagonal numbers:
^(^x|\1x{4})*$
etc.

f(n) = n3
Moving on to n3, once again examining the forward difference function:
\$D_f=[1,7,19,37,61,\dots]=3n^2+3n+1\$
It might not be immediately apparent how to implement this, so we examine the second difference function as well:
\$D_f^2=[6,12,18,24,30,\dots]=6n+6\$
So, the forwards difference function does not increase by a constant, but rather a linear value. It's nice that the initial ('-1th') value of Df2 is zero, which saves an initialization on the second iteration. The resulting regex is the following:
^((^|\2x{6})(^x|\1))*$

The first iteration will match 1, as before, the second will match a string 6 longer (7), the third will match a string 12 longer (19), etc.

f(n) = n4
The forward difference function for n4:
\$D_f=[1,15,65,175,369,\dots]=4n^3-6n^2+4n-1\$
The second forward difference function:
\$D_f^2=[14,50,110,194,302,\dots]=12n^2-24n+14\$
The third forward difference function:
\$D_f^3=[36,60,84,108,132,\dots]=24n+36\$
Now that's ugly. The initial values for Df2 and Df3 are both non-zero, 2 and 12 respectively, which will need to be accounted for. You've probably figured out by now that the regex will follow this pattern:
^((^|\2\3{b})(^|\3x{a})(^x|\1))*$

Because the Df3 must match a length of 12 on the second iteration, a is necessarily 12. But because it increases by 24 each term, the next deeper nesting must use its previous value twice, implying b = 2. The final thing to do is initialize the Df2. Because Df2 influences Df directly, which is ultimately what we want to match, its value can be initialized by inserting the appropriate atom directly into the regex, in this case (^|xx). The final regex then becomes:
^((^|xx)(^|\3\4{2})(^|\4x{12})(^x|\1))*$

Higher Orders
A fifth order polynomial can be matched in with the following regex:
^((^|\2\3{c})(^|\3\4{b})(^|\4x{a})(^x|\1))*$
f(n) = n5 is a fairly easy excercise, as the initial values for both the second and fourth forward difference functions are zero:
^((^|\2\3)(^|\3\4{4})(^|\4x{30})(^x|\1))*$

For six order polynomials:
^((^|\2\3{d})(^|\3\4{c})(^|\4\5{b})(^|\5x{a})(^x|\1))*$
For seventh order polynomials:
^((^|\2\3{e})(^|\3\4{d})(^|\4\5{c})(^|\5\6{b})(^|\6x{a})(^x|\1))*$
etc.
Note that not all polynomials can be matched in exactly this way, if any of the necessary coefficients are non-integer. For example, n6 requires that a = 60, b = 8, and c = 3/2. This can be worked around, in this instance:
^((^|xx)(^|\3\6\7{2})(^|\4\5)(^|\5\6{2})(^|\6\7{6})(^|\7x{60})(^x|\1))*$

Here I've changed b to 6, and c to 2, which have the same product as the above stated values. It's important that the product doesn't change, as a·b·c·… controls the constant difference function, which for a sixth order polynomial is Df6. There are two initialization atoms present: one to initialize Df to 2, as with n4, and the other to initialize the fifth difference function to 360, while at the same time adding in the missing two from b.


Is this a three-digit number ending in one? Given a nonnegative integer, return whether it is a three digit number ending in one, in any consistent integer base. In other words, the number needs to be represented in base-N, N being an integer greater than zero.
Rules

This is code-golf, so shortest answer wins.
Since unary behaves weirdly, the behavior with input 310 is undefined.
Standard loopholes are prohibited.

Examples
True:
5
73
101
1073
17
22
36
55
99

False:
8
18
23
27
98
90
88
72
68

A handful of large numbers:
46656 true
46657 true
46658 true
46659 true
46660 true
46661 false
46662 false
46663 true
46664 false
46665 true
46666 true
46667 false
46668 false
46669 false
46670 true
46671 true

JavaScript (ES7), 43 40 39 bytes

f=(n,b)=>n<b*b?0:n%b==1&n<b**3|f(n,-~b)

Test cases

f=(n,b)=>n<b*b?0:n%b==1&n<b**3|f(n,-~b)

console.log('[Truthy]')
console.log(f(5))
console.log(f(73))
console.log(f(101))
console.log(f(1073))
console.log(f(17))
console.log(f(22))
console.log(f(36))
console.log(f(55))
console.log(f(99))
console.log(f(46656))
console.log(f(46657))
console.log(f(46658))
console.log(f(46659))
console.log(f(46660))
console.log(f(46663))
console.log(f(46665))
console.log(f(46666))
console.log(f(46670))
console.log(f(46671))

console.log('[Falsy]')
console.log(f(8))
console.log(f(18))
console.log(f(23))
console.log(f(27))
console.log(f(98))
console.log(f(90))
console.log(f(88))
console.log(f(72))
console.log(f(68))
console.log(f(46661))
console.log(f(46662))
console.log(f(46664))
console.log(f(46667))
console.log(f(46668))
console.log(f(46669))

Commented

f = (n,           // given n = input
        b) =>     // and using b = base, initially undefined
  n < b * b ?     // if n is less than b²:
    0             //   n has less than 3 digits in base b or above -> failure
  :               // else:
    n % b == 1 &  //   return a truthy value if n is congruent to 1 modulo b
    n < b**3 |    //   and n is less than b³ (i.e. has less than 4 digits in base b)
    f(n, -~b)     //   or the above conditions are true for some greater value of b


Avoid repeating letters between five simple programs You're challenge is to write 5 different full programs for the 5 following tasks:

Print Hello, World!

Given an input with STDIN, output the factorial, you can assume that the input is an integer >= 0

Given an integer N, calculate the sum of the primes <= N

Given an input with STDIN, output the letters used in the input. For example: the input is Hello world, you need to output helowrd. Note that the output is in lowercase. You can assume that the input is always alphabetic with whitespaces, the whitespaces are ignored.

Output the following diamond exactly like this:
  *
 ***
*****

*****
 ***
  *

All these challenges are probably very easy, but there is a catch. Every letter you use cannot be used again in the other programs. This is not prohibited, but will give you a penalty of +8 bytes. For example, if this is your program for the first task:
print("Hello, World!");

Then you cannot use the following letters (in uppercase or lowercase form): p, r, i, n, t, h, e, l, o, w, d in the other programs. If you do have to use them, you can 'buy' each letter for 8 bytes. So if you want to use the letter l again in another program, you get a penalty of 8 bytes. After you have paid the penalty, you can use each letter as much as you want in this program. Other characters don't matter. Also, all 5 programs should be in the same language.
This is a code-challenge, least amount of bytes wins!

CJam, 73 bytes

"Obkkh+'Phukc&"7f^
q~m!
ri){'j3+_3++~},:+
lS-el_&
4{_' *4@-Y*('**+}%_1>W%\+N*

Each line is a full program. Try them online: 1 | 2 | 3 | 4 | 5

Letter map

 bc  f h  k   op    u       18
            m   q            4
        ij       r          17
    e      l      s          7
             n        w y   27

If you want (and each of your programs fits in a line), you can use this CJam program to create a letter map for your own submission.


Programming a Pristine World Let's define a pristine program as a program that does not have any errors itself but will error if you modify it by removing any contiguous substring of \$N\$ characters, where \$1 \le N < \text{program length}\$.
For example, the three character Python 2 program
`8`

is a pristine program (thanks, Sp) because all the programs resulting from removing substrings of length 1 cause errors (syntax errors in fact, but any type of error will do):
8`
``
`8

and also all the programs resulting from removing substrings of length 2 cause errors:
`
`

If, for example, `8 had been a non-erroring program then `8` would not be pristine because all the results of substring removal must error.
Your task in this challenge is to write the shortest pristine program possible that takes no input but outputs any one of the following five words:
world
earth
globe
planet
sphere

Which word you choose is entirely up to you. The sole word plus an optional trailing newline should be printed to stdout (or your language's closest alternative). The shortest program in bytes wins.
Notes:

A standalone program is required, not a function.
The words are case sensitive; outputting World or EARTH is not allowed.
Compiler warnings do not count as errors.
The erroring subprograms can take input or give output or do anything else as long as they always eventually error.

Here's a stack snippet that will list what programs need to error given a potentially pristine program:

Program:
<textarea id='i' rows='16' cols='80'>`8`</textarea>
<button onclick='go()' type='button'>Go</button>

Programs that should error: (--- separated)
<textarea id='o' rows='16' cols='80'></textarea>

Rail, 24 bytes

$'main'    #
 -[world]o/

I think this works. And it's both short and readable (as far as Rail goes).

If the removed substring includes any part of $'main' we get Internal Error: Crash: No 'main' function found.
If the removed substring includes the #, there is no way for the program to exit cleanly, so it will always terminate with Crash: No valid move. I believe that it's not possible to delete a substring such that the track forms a valid (infinite) loop.
If the removed substring is in front of the #, it will be disconnected from the end of the track, so the train will crash (with the same error as above).
If the removed substring is after the #, it will also disconnect the # from the end of the track (and potentially even the beginning of the track from the entry point $). So again the same error.

As for the actual program: every Rail program needs to have a $'main' (or a longer variant, but we're golfing here) as an entry point into the function and the train starts on the $ going South-East. Everything on that first line can be part of the track though, so removing the 'main' the track is:

$          #
 -[world]o/

The - and / are simply pieces of rail which we need to let the train take those 45° turns.

[world] pushes the string world and o prints it. # marks the end of the track - the only way to safely terminate a Rail program.

Interestingly, this solution is only possible because Rail allows the tracks to go through the main line - if that wasn't possible # would be after the first newline and the code could always be shortened to

$'main'
 #

which is a valid program that doesn't do anything. (Non-space characters between ' and # wouldn't affect that.)

Also quite interesting: if I had just golfed the task printing world it wouldn't have been much shorter or simpler:

$'main'
 -[world]o#


Tips for golfing in MarioLANG I recently saw this language in a challenge and it's awesome. Does anyone have some tips for code-golfing in it?

Your tips should be at least somewhat specific to MarioLANG.

Please post one tip per answer.

Use the fall at the end for instructions

This is a pretty simple tip but many MarioLANG programs end something like this, ending with Mario falling down:

.....
=====

and this can be written instead as this:

....
===.

saving two bytes.

If your program has an elevator near an end like this you can often improve even further. This:

]!......
=#======

 <
="

goes to this:

]!.
=#.
  .
  .
 <.
=".

You do have to be careful with the last one though, since the added spaces to get to the final instructions can in many situations be more costly than just writing it largely on one line.


Products of Consecutive Primes As of time of submission to the sandbox, I had 17017 reputation, which you will all be able to factorise as 7×11×13×17, a product of 4 consecutive primes.

Please write a function or program to output all the products of two or more consecutive primes up to an input integer n. For example, given n=143 you should output 6, 15, 30, 35, 77, 105, 143 (or equivalent output format).

Normal restrictions on I/O and loopholes apply.

This is code-golf, so the shortest program wins.

Jelly, 14 10 bytes

(no doubt there is golfing to do here! - yep...)
-4 bytes thanks to @Dennis - replace check for greater than n by using a range

ÆRẆP€ḟÆRfR

Note - this is both extremely inefficient and the results are unsorted.

Test it at TryItOnline

How?

ÆRẆP€ḟÆRfR - main link takes an argument, n
ÆR    ÆR   - primes up to n
  Ẇ        - all sublists
   P€      - product for each
     ḟ     - filter out the primes (since the sublists include those of lnegth 1)
        fR - filter out any not in range [1,N]
             (yep, it's calculating all products of primes up to n - gross)


Eight Queens Obsfucation You've probably heard of the classic Eight Queens Puzzle. For those of you who haven't it goes something like this:

  Position 8 queens on an 8×8 chessboard so that no two queens threaten
  each other (no two queens appear on the same row, column or diagonal
  as each other).

Here is one answer that is very close:

X - - - - - - -
- - - - X - - -
- X - - - - - -
- - - - - X - -
- - X - - - - -
- - - - - - X -
- - - X - - - -
- - - - - - - X

As you can see, two queens appear on the long diagonal between the top left corner and the bottom right corner.
Your task is to solve the Eight Queens Puzzle (using any programming language) in a unique or obfuscated manner. The first answer to 15 up-votes wins (the number may be subject to change depending on the popularity of this question).
Your output must be like the example above (empty squares represented by -, queens represented by X and a space between each X or -). Good luck!!

Mathematica
The following implementation challenges the player to find one or more solutions to the eight queens problem. (It was too easy to simply have the program output the answers.)
Clicking on any of the squares in the chessboard toggles between "queen" and .
When show attacks is checked, any attacks between queens are highlighted.
The following picture queenImg.

In the board below, no queen attacks another:

Placing a fourth queen on a conflicting square results in two reciprocal attacks.

The following is one of the solutions.

DynamicModule[{qns = ConstantArray[0, {8, 8}]},
Manipulate[
ClickPane[
Dynamic[ArrayPlot[
 Array[Boole[(Mod[#1, 2] == 0 \[And]
       Mod[#2, 2] == 0) \[Or] (Mod[#1, 2] == 1 \[And]
       Mod[#2, 2] == 1)] &, {w, w}],
 ColorRules -> {1 -> White, 0 -> LightBrown}, Mesh -> True,
 Epilog -> {Red, Thickness[.005],
   If[attacks,
    Line[Cases[
       Tally@Flatten[z[##] & /@ (Reverse /@ Position[qns, 1]),
         1], {a_, n_} /; n > 1][[All, 1]]], {}],
   Table[Inset[queenImg, p, Automatic, 10/w], {p,
     Position[qns, 1] - .5}]}]], (qns = flip[qns, Ceiling@#]) &],
{{attacks, True, "show attacks"}, {True, False}},
Initialization -> (w = 8;
z[{r_, c_}] := {row[r], col[c], diag1[r, c], diag2[r, c]};
row[r_] := {{0, r - .5}, {8, r - .5}};
col[c_] := {{c - .5, 0}, {c - .5, 8}};
diag1[r_, c_] := {{0, r - c}, {8 - (r - c), 8}};
diag2[r_, c_] := {{0, c + r - 1}, {c + r - 1, 0}};
flip[a_, pos_] := MapAt[(# - 1)^2 &, a, pos])]]


Find the perfect square! Your task is to turn a square root like this:
√12

into a form like this:
2√3

For our purpose, we only need to output the left number here:
2

Test cases
4  -> 2
9  -> 3
12 -> 2
13 -> 1
108-> 6

Specifications

You may assume for the input that \$n>0\$. \$n\$ has to be as large as possible.
If the number is already a perfect square, do this:

√4 = 2√1 -> 2

If the number doesn't contain perfect squares, do this:

√13 = 1√13 -> 1

05AB1E, 9 6 5 bytes
LnIÖO

Try it online or verify all test cases.
Previous 9 6 bytes approach:
LR.ΔnÖ

-3 bytes thanks to @ovs.
Try it online or verify all test cases.
Explanation:

L       # Push a list in the range [1, (implicit) input]
 n      # Take the square of each value in the list
  IÖ    # Check which squares are divisible by the input (1 if truthy; 0 if falsey)
    O   # And sum those checks
        # (after which this sum is output implicitly as result)

L       # Push a list in the range [1, (implicit) input]
 R      # Reverse it to [input, 1]
  .Δ    # Find the first value in this list which is truthy for:
    n   #  Square the current value
     Ö  #  Check if the (implicit) input is evenly divisible by this square
        # (after which the found value is output implicitly as result)


Draw me the (weird) unit circle! Introduction
You may know and love your normal unit circle. But mathematicans are crazy and thus they have abstracted the concept to any point that satisfies x*x+y*y=1. Because Cryptographers1 are also weird, they love finite fields and sometimes finite rings (it is not like they have much choice though), so let's combine this!
The Challenge
Input
A positive integer larger than one in your favorite encoding. Let's call this number n.
Output
You will output the "picture" (which consists of n times n characters) of the unit circle modulo the input integer as ASCII-Art using "X" (upper-case latin X) and " " (a space). Trailing spaces and newlines are allowed.
More Details
You have to span a coordinate system from bottom-left to top-right. Whenever a point fulfills the circle equation, place an X at the position, otherwise place a space.
The condition for a point to be considered part of the circle border is:
mod(x*x+y*y,n)==1.
Here a quick illustration of the coordinate-system:
(0,4)(1,4)(2,4)(3,4)(4,4)
(0,3)(1,3)(2,3)(3,3)(4,3)
(0,2)(1,2)(2,2)(3,2)(4,2)
(0,1)(1,1)(2,1)(3,1)(4,1)
(0,0)(1,0)(2,0)(3,0)(4,0)

If it helps you, you may also invert the direction of any of the axes, but the examples assume this orientation.
Who wins?
This is code-golf so the shortest code in byte wins! Only the default I/O methods are allowed and all standard loopholes are banned.
Examples
Input: 2
X
 X

Input: 3
X
X
 XX

Input: 5
X

X
 X  X

Input: 7
X
  X  X

  X  X
X
 X    X

Input: 11
X

     XX

   X    X
   X    X

     XX

X
 X        X

Input: 42
X
         X                       X

            X                 X
       X                           X
      X                             X
                     X
  X             X         X             X

     X             X   X             X
X
               X           X
              X             X
         X                       X

            X                 X
                     X
        X           X X           X
                     X
            X                 X

         X                       X
              X             X
               X           X
X
     X             X   X             X

  X             X         X             X
                     X
      X                             X
       X                           X
            X                 X

         X                       X
X
 X           X               X           X

1 I suggest you take a look at my profile if you're wondering here.

Bash + GNU Utilities, 59

x={0..$[$1-1]}d*
eval echo $x$x+$1%1-0r^56*32+P|dc|fold -$1

Input n given as a command-line parameter.  The y-axis is inverted.
Try it online.


Remove each integer from a string and multiply them all! Goal:

Get every integer from the string (not a number, but integer)
Multiply them
Output the result

Input:

5 kilograms of food eaten, 10 liters of water drank, 20 plates dirty, 40 mugs dirty, and only 3 people acted!

Output:

120000

How:

Result was 5 * 10 * 20 * 40 * 3

What do we count as an integer:

General:

If integer has a symbol BEFORE of AFTER the int, only take the number without symbols. -335 or 335+ are 335 anyways.
If integer has a symbol like this: 35:3, don't take it. 35 : 3 is available though, and considered as 2 integers.

Detailed:
35/3 aren't two integers, skip this
35.3 is not an integer, skip this
35:3, 35*3, 3e3, etc. aren't ints, skip them as well
353 is an integer
35 3 are two integers

is an integer

353?, 353!, etc. are integers
-353 is an integer, but you only claim 353 and skip "-".
+353 is the same case as upper

Requirements:
Select any language you want
The program should contain as little bytes as possible
You should tell us the language (if it's, like, exotic, link it like this)
Please, upload the code to Try It Online services like this
Count the bytes using special services like this
It would be fine if you'd explain your code!

Scoring:

Less bytes program wins! The end is 20th of June, you guys have a week

Red, 109 bytes

func[s][p: 1 d: charset"0123456789"parse s[any[to d copy t[any d ahead[" "|"!"|"?"]](p: p * to p t)| skip]]p]

Try it online!


Implement Minecraft's Rails Background Information
Inspired by this answer on Arqade SE
Minecraft has rails which allow you to move minecarts around on them for transporting players, entities, and items. There are many types of rails, but today we're only interested in regular rails, which are also the only type that can curve.
When you place down a normal rail that has two adjacent rails, it will connect them. If they are not on opposite sides of the rail, the rail will curve to a 90 degree angle. However, if there are more than two adjacent rails, it can't connect all of them. In that case, it will always favor going south-east (this is called the south-east or Z-X rule) (for this challenge, north is up, east is right, south is down, west is left). If there is a T-junction, the rail will always connect to the "vertical" branch of the T, and then it will prioritize south over north if the main branch is east-west, and east over west if the main branch is north-south. If there is a four-way junction, the rail will connect south and east.
I/O
For this challenge, you will need eight distinct characters: empty space, vertical rail, horizontal rail, up-left curved rail, up-right curved rail, down-left curved rail, down-right curved rail, and placeholder. You may select any characters; I choose to use box-drawing characters in my examples. You may count these eight characters as one byte in your code (this is just to allow people to use box-drawing characters instead of just like " |-WXYZ#" or something not as nice-looking).
You will be given input in a convenient format for a layout of existing rails. This will be a grid, so you may take it as a matrix of characters, a list of strings, newline-separated strings, etc. Anything reasonable. To simplify a bit, your input will only contain straight rails, placeholders, and blanks.
Your output should be a grid of the same size, but in each placeholder you are to place a rail according to the rules given. To make this challenge a bit simpler, every placeholder will always have at least two adjacent rails that are already facing the appropriate direction, so you should not change any cells except the placeholders. Note that it is possible for the rails to be on opposite sides of the placeholder, in which case you may need to place down a straight rail.
Detailed Example
This contains every possible configuration:
.═.═.═.
║ ═ ║ ║
.║  ║ ║
║   ║ ║
.═══.═.
║   ║ ║
.═══.═.

The output for this would be:
╔═══╔═╗
║ ═ ║ ║
║║  ║ ║
║   ║ ║
╔═══╔═╗
║   ║ ║
╚═══╚═╝

Note that it's valid to have rails facing the wrong direction next to placeholders. You are guaranteed that at least two adjacent rails are facing the right way though. Technically, in Minecraft, this might cause the side rails to turn to face the new rail and then curve, but in this specific challenge, we'll just assume that existing straight rails will not turn, and you just need to connect up exactly two of the adjacent, correctly-oriented rails in accordance to the S-E rule.
   .══.══.             ╔═════╗
   ║     ║             ║     ║
.══.══.  .          ╔══╔══╗  ║
║  ║  ║  ║    ->    ║  ║  ║  ║
.══.══.  .          ╚══╔══╝  ║
   ║     ║             ║     ║
   .══.══.             ╚═════╝

You're running out of space on your minecart to write your code, so your code must be as short as possible! This is code-golf, so the shortest answer in bytes wins (remember that you may count your eight I/O characters as one byte).

Python 3, 394 378 370 328 bytes

def p(s,i,R,C,H='═',V='║'):
 v=i%C and s[i-1]==H
 v|=(i//C and s[i-C]==V)<<3
 v|=(i%C-C+1and s[i+1]==H)<<2
 return' ═║╗══╔╔║╝║╗╚╚╔╔'[v|(i//C-R+1and s[i+C]==V)<<1]
def f(s,i=0):
 t=s.split('\n');R,C,s=len(t),len(t[0]),''.join(t)
 for c in s:print([c,p(s,i,R,C)][c=='.'],end='\n'[:-~i%C==0]);i+=1

Try it online!
A very naive method. Receives as input a string and iterates over its characters. If a character is a point (a placeholder), replace it with the character returned by p.
The function p builds a "4-bits integer" v, where:

if its 1st bit is set, the placeholder has a valid connection with the west;
if its 2nd bit is set, the placeholder has a valid connection with the south;
if its 3rd bit is set, the placeholder has a valid connection with the east; and
if its 4th bit is set, the placeholder has a valid connection with the north.

A invalid connection occurs with a direction when

the rail is on a border of that direction (the first placeholder in the example given by the OP has an invalid connection with the north and the west since it's in the border, so its 4-bit integer is 1010).

the rail of that direction is misaligned with the placeholder (the fifth placeholder in the example given by the OP has an invalid connection with the east since the east rail is misaligned, so its 4-bit integer is 1011).

After this 4-bit integer is built, it returns the corresponding box-drawing character using this integer as index of a string.


Produce an XOR table Introduction
XOR is a digital logic gate that implements an exclusive or. Most of the times, this is shown as ^. The four possible outcomes in binary:
0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0

This can also be seen as addition modulo 2 in binary. In decimal, we need to convert the decimal to binary, 35 = 100011 and 25 = 11001.To compute the XOR value, we place them on top of each other:
100011
 11001 ^
--------
111010  = 58 in decimal

The task: When given an integer value N greater than 1, output an XOR table with the size N + 1. For example, N = 5:
 0 1 2 3 4 5
 1 0 3 2 5 4
 2 3 0 1 6 7
 3 2 1 0 7 6
 4 5 6 7 0 1
 5 4 7 6 1 0

You can see that there is one space in front of each number, because the highest amount in the table has length 1. However, if we take N = 9, we get the following grid:
  0  1  2  3  4  5  6  7  8  9
  1  0  3  2  5  4  7  6  9  8
  2  3  0  1  6  7  4  5 10 11
  3  2  1  0  7  6  5  4 11 10
  4  5  6  7  0  1  2  3 12 13
  5  4  7  6  1  0  3  2 13 12
  6  7  4  5  2  3  0  1 14 15
  7  6  5  4  3  2  1  0 15 14
  8  9 10 11 12 13 14 15  0  1
  9  8 11 10 13 12 15 14  1  0

The highest value has length 2, so the value is right-aligned to length 3 (highest length + 1).
Rules:

Leading whitespace is not mandatory, only if used (or not) consistently
You must output a table in the form shown above.
The padding between columns should be as small as possible
This is code-golf, so the submission with the least amount of bytes wins!

MATL, 10 bytes

0i2$:tXgZ~

The compiler (and in particular this program) now seems to work in Octave, although it still needs some refinement. You can provisionally use this GitHub commit.

Edit (Mar 30 '16): Try it online!

Example

>> matl 0i2$:tXgZ~
> 9
0  1  2  3  4  5  6  7  8  9
1  0  3  2  5  4  7  6  9  8
2  3  0  1  6  7  4  5 10 11
3  2  1  0  7  6  5  4 11 10
4  5  6  7  0  1  2  3 12 13
5  4  7  6  1  0  3  2 13 12
6  7  4  5  2  3  0  1 14 15
7  6  5  4  3  2  1  0 15 14
8  9 10 11 12 13 14 15  0  1
9  8 11 10 13 12 15 14  1  0

Explanation

0i2$:       % vector 0, 1, 2, ... up to input number
t           % duplicate
Xg          % nd-grid
Z~          % bitxor


Working Week Completion I work a standard nine to five. Monday through Friday. I take a half hour for lunch from 12:30 to 13:00.

Write me a program which, when run, calculates the percentage of the working week that I have completed at the current moment.

Rules

Only count time actually spent working. I am punctual and do not work
over lunch.
No input. You may obtain information like current time/date however is convenient.
The working week is considered complete from end-of-day Friday to midnight between Sunday and Monday.
Timezone is the local timezone.
Output should be a decimal number, eg 66.25498, percentage symbol optional.
The program should be reasonably future-proof. It should be able to cope with leap years.
Output resolution should be a second or better. I like to watch the kettle boil.
Code golf. Shortest code wins.

Python 3, 132

from datetime import*
t=datetime.now().timetuple()
m=max(0,t[3]*2+t[4]/30-18)
print(20*min(5,(t[6]+min(15,m-min(8,max(7,m))+7)/15)))

The resolution is one minute, or 2/45 of a percent. That's more than enough IMO.


Golf you an anagram for great good! The Task
In this challenge, your task is to write some code which outputs one of its anagrams chosen randomly with uniform distribution but it should never output itself.

Elaboration
Given no input, your program should output any one of the anagrams of its source code. Your program should never output its own source as it is, i.e. it should never be a quine.

Input
Your program must not take any input. However, if your language requires input as a necessity, you may assume that it will be given lowercase a. You must not use the input in any way, though.

Output
Your program can output in any way except writing it to a variable. Writing to file, console, screen, etc. is allowed. Function return is allowed as well.

Additional Rules

Your program's source code must have at least 3 chars (not 3 bytes).

Your program's source code must have at least 3 possible anagrams (excluding itself). For example, aab does not count as a valid submission as aab only has two anagrams other than aab (baa and aba).

Your program must not produce any error.

Your program should output its anagrams exactly.

Standard Loopholes and Standard quine rules apply.

Example
Suppose your program's source code is abc. It should randomly output any one of the following (with uniform distribution):

acb
bca
bac
cba
cab

And, it should never output abc.

Winning Criterion
This is code-golf, so the shortest code in bytes wins! In case of a tie, the solution which was posted earlier wins!

Jelly, 15 bytes

“v0¡µṾ;ḢŒ!QḊX”v

Just to get things started; this is almost certainly beatable. This is basically just a combination of a universal quine constructor and a "pick a random permutation other than the input" function; the latter may be improvable, the former almost certainly is.

Explanation

Universal quine constructor

“v0¡µṾ;Ḣ”v
“       ”v   Evaluate the following, given {itself} as argument:
 v0¡µ          No-op (which starts with "v")
     Ṿ         Escape string
      ;Ḣ       Append first character of {the argument}

This can be seen to be a quine if run by itself. It's also a proper quine by most definitions I know of; it doesn't read its own source (rather, it contains a literal that's "eval"ed, and is given a copy of itself as an argument), it can carry a payload (as seen here!), and the v outside the string literal is encoded by the v inside.

Pick a random anagram

Œ!QḊX
Œ!     All permutations
  Q    Discard duplicates
   Ḋ   Discard the first (i.e. the string itself)
    X  Choose random element

This is really inefficient on a string this long, so I haven't been able to test the program as a whole, but I've tested it on shorter strings and it appears to function correctly.


Decrypt xor-encryption Your task is to take an encrypted string as input, and output the string decrypted, to reveal its hidden message.

The strings, both the input and output, will contain characters from this list of 64 ASCII-characters (note the leading space):

 !"#$%&'()*+,-./0123456789:;=?@[\]^_abcdefghijklmnopqrstuvwxyz|~

These characters are assigned numbers, in the order they are listed above:

  ! " # $ % &   ...
0 1 2 3 4 5 6   ...

So, space is number 0, ! is number 1 and ~ is number 63. These numbers can be represented in 6-bit binary code:

 :  0:  000000
!:  1:  000001
":  2:  000010
#:  3:  000011
.. ...  ......
z: 61:  111101
|: 62:  111110
~: 63:  111111

The encryption is very simple:

I'll use eC for encrypted characters, and C for characters of the original string. C(n) is the n'th character of the original string, while eC(n) is the n'th character of the encrypted string.

You'll use the 6-bit binary representation of the characters. The first character will be eC(0) = not(C(0)). From there, all characters will be eC(n) = xor(C(n),C(n-1)).

Example:

Let's assume the input string is code.

c is the 38th character (zero indexed), or 100110 in binary. The encrypted version has all bits flipped, so 011001 -> 25 -> '9' (again, zero indexed).
o is the 50th character, or 110010 in binary. xor(100110, 110010) = 010100 = 20 = '4'.
d is the 39th character, or 100111 in binary. xor(100111, 110010) = 010101 = 21 = '5'.
e is the 40th character, or 101000 in binary. xor(101000, 100111) = 001111 = 15 = '/'.

So, if the original string is code, the encrypted string will become 945/.

Test cases:

945/
code

,&'8[14 =?;gp+% 2'@s&&c45/eg8?&
programming puzzles & code golf

;a$5$%0r?2@12dw6# lb-eg&519nt%ot=9$@es@96+?;ga" 4*)&ta56dp[?o#t%oh/"(&?#ee![,+,/+fe4"
a $150 reward will be given to those sending account and pin# to hackers@steal_id.com

~!#!'!#!/!#!'!#![!#!'!#!/!#!'!#!~!#!'!#!/!#!'!#![!#!'!#!/!#!'!#!
 !"#$%&'()*+,-./0123456789:;=?@[\]^_abcdefghijklmnopqrstuvwxyz|~

Jelly, 27 26 bytes

ØJḟ“<>`{}”ḟØAɓi@€_33^\96_ị

Try it online!

Alternate version, 22 bytes (non-competing)

Jelly finally caught up with other golfing langs and got a printable ASCII atom, so this works now.

ØṖḟ“<>`{}”ḟØAɓi@€’^\Nị

Try it online!

How it works

ØJḟ“<>`{}”ḟØAɓi@€_33^\96_ị  Main link. Argument: s (string)

ØJ                          Yield Jelly's code page, i.e., 32 non-ASCII characters,
                            followed by all printable ASCII characters, followed by
                            129 non-ASCII characters.
  ḟ“<>`{}”                  Filterfalse; remove the characters "<>`{}".
          ḟØA               Filterfalse; remove all uppercase ASCII letters.
                            Let's call the resulting alphabet a.
             ɓ              Begin a new, dyadic chain.
                            Left argument: s. Right argument: a
              i@€           Find the (1-based) index of all characters of s in a.
                 _33        Subtract 33, so ' ' maps to 0, '~' maps to 63.
                    ^\      Compute the cumulative bitwise XOR.
                            We didn't take the bitwise NOT of the first index,
                            which can be rectified by subtracting all results from
                            63. However, we must also add 33 to account for the
                            fact that the index of ' ' in a is 33.
                      96_   Subtract the results from 96.
                         ị  Index into a.


The number of tilings of a grid Setup:
A block is any rectangular array of squares, specified by its dimensions \$(w,h)\$. A grid is any finite ordered list of blocks. For example, \$\lambda = ((3,2),(3,1),(1,2))\$ defines a grid.
Let \$\lambda\$ and \$\mu\$ be two grids with equal area.
A tiling of \$\lambda\$ by \$\mu\$ is any rearrangement of the squares of \$\mu\$ into the shape of \$\lambda\$ satisfying two properties:

horizontally adjacent squares of \$\mu\$ remain horizontally adjacent in \$\lambda\$, and
vertically adjacent squares of \$\lambda\$ come from vertically adjacent squares of \$\mu\$.

In other words, while rearranging one is allowed to make horizontal cuts to the blocks of \$\mu\$ but not vertical cuts, and one is allowed to place blocks into \$\lambda\$ side-by-side, but not on top of one another.
Two tilings of \$\lambda\$ by \$\mu\$ are considered equivalent if they can be rearranged into one another by any combination of either permuting squares within a column or reordering the columns of a block.
Problem: Write a function \$T(\mu,\lambda)\$ which computes the number of inequivalent tilings of a grid \$\lambda\$ by another grid \$\mu\$ of equal area.
Specifications: You may use any data type you would like to specify a grid.
Examples:

The grid \$\lambda=((1,2),(1,2),(1,1),(2,1))\$ admits a tiling by \$\mu=((1,3),(1,2),(2,1))\$ given by

There is exactly one other inequivalent tiling given by

(Since the two differently colored columns of height \$2\$ are not part of the same block, they cannot be permuted.)

The three displayed tilings of \$\lambda=((3,1))\$ by \$\mu=((1,2),(1,1))\$ are equivalent:

Let \$\lambda\$ be an arbitrary grid of area \$n\$ and let \$\lambda[(w,h)]\$ denote the number of blocks of \$\lambda\$ of dimension \$w \times h\$. Then \$T(\lambda,\lambda) = \prod_{w,h\geq 1} \lambda[(w,h)]!\$ and \$T(\lambda,((n,1))) = 1\$.

The matrix of values of \$T(\mu,\lambda)\$ for all pairs of grids of area \$3\$ (row is \$\mu\$, column is \$\lambda\$):

((1,3))
((1,2),(1,1))
((1,1),(1,1),(1,1))
((2,1),(1,1))
((3,1))

((1,3))
1
1
1
1
1

((1,2),(1,1))
0
1
3
2
1

((1,1),(1,1),(1,1))
0
0
6
3
1

((2,1),(1,1))
0
0
0
1
1

((3,1))
0
0
0
0
1

Haskell, 255…247 242 bytes

-2 bytes thanks to xnor, for suggesting a better partitioning function q.
-8 bytes thanks to ovs, for suggesting [a!!i|i:_<-u] and removing an unnecessary map.

(a#b)c d=sum[1|g<-nub$(permutations(zipWith replicate b[0..]>>=id)>>=q)>>=mapM(q.sort),l g==l c,and[l x==h&&all(==x!!0)x&&sum[a!!i|i:_<-u]==w|(u,w,h)<-zip3 g c d,x<-u]]
q=foldr(\h t->map([h]:)t++[(h:y):z|y:z<-t])[[]]
l=length
import Data.List

Try it online!
A grid \$\mu\$ is represented as a pair \$(W_\mu,H_\mu)\$ where \$W_\mu\$, \$H_\mu\$ are lists containing, respectively, the widths and the heights of the blocks in \$\mu\$.
The relevant function is (#), which takes as input four lists: a\$=W_\mu\$, b\$=H_\mu\$, c\$=W_\lambda\$, d\$=H_\lambda\$. It returns the integer \$T(\mu,\lambda)\$.