Regex for Finding Non-Radioactive Elements Find the shortest regex that matches all non-radioactive elements and nothing else in the Periodic Table of Elements. This is the inverse of Regex for Finding Radioactive Elements

Radioactive Elements

'Technetium','Promethium','Polonium','Astatine','Radon','Francium','Radium','Actinium','Thorium','Protactinium','Uranium','Neptunium','Plutonium','Americium','Curium','Berkelium','Californium','Einsteinium','Fermium','Mendelevium','Nobelium','Lawrencium','Rutherfordium','Dubnium','Seaborgium','Bohrium','Hassium','Meitnerium','Darmstadtium','Roentgenium','Copernicium','Ununtrium','Flerovium','Ununpentium','Livermorium','Ununseptium','Ununoctium'

Non-radioactive Elements

'Hydrogen','Helium','Lithium','Beryllium','Boron','Carbon','Nitrogen','Oxygen','Fluorine','Neon','Sodium','Magnesium','Aluminium','Silicon','Phosphorus','Sulphur','Chlorine','Argon','Potassium','Calcium','Scandium','Titanium','Vanadium','Chromium','Manganese','Iron','Cobalt','Nickel','Copper','Zinc','Gallium','Germanium','Arsenic','Selenium','Bromine','Krypton','Rubidium','Strontium','Yttrium','Zirconium','Niobium','Molybdenum','Ruthenium','Rhodium','Palladium','Silver','Cadmium','Indium','Tin','Antimony','Tellurium','Iodine','Xenon','Caesium','Barium','Lanthanum','Cerium','Praseodymium','Neodymium','Samarium','Europium','Gadolinium','Terbium','Dysprosium','Holmium','Erbium','Thulium','Ytterbium','Lutetium','Hafnium','Tantalum','Tungsten','Rhenium','Osmium','Iridium','Platinum','Gold','Mercury','Thallium','Lead','Bismuth'

Scored by character count in the regex.
Use standard Perl regex (just no specialized functions).
Assume all lower case.
You only need to count the characters of the regex itself.

Note if you used a program to get you started and maybe post how well it did. I'll post my best attempt as an answer to get started/show an example.

Edit:
Apparently Bismuth is radioactive, but since I'm assuming the universe would die from heat death before it was ever much of a problem I'm not going to worry about it now.


Tips for Golfing in Standard ML Standard ML (or golfier: SML) is a general-purpose, modular, functional programming language with compile-time type checking and type inference. (from Wikipedia)
Though you almost certainly will never win a code golf challenge with SML, (ab-) using it for golfing can nevertheless be quite fun (<- keyword for function declaration). So without further ado ...
What tips do you have for golfing in Standard ML?
Please only post tips which are somewhat unique to SML. General golfing tips belong to Tips for golfing in all languages.

Use symbolic identifiers
From The Definition of Standard Ml (revised) [PDF], Section 2.4:

An identifier is either alphanumeric: any sequence of letters,
digits, primes (') and underbars (_) starting with a letter or
prime, or symbolic:  any non-empty sequence of the following symbols:
!  %  &  $  #  +  -  /  :  <  =  >  ?  @  \  ~  ‘  ^  |  *

In either case, however, reserved words are excluded. This means that for
example # and | are not identifiers, but ## and |=| are identifiers.

The important part (concerning golfing) is that you do not need white space between symbolic identifiers and alphanumeric identifiers or keywords.
Example

fun f a b c=if b then a else c

By replacing f by $ and b by !, we can save 6 bytes:
fun$a!c=if!then a else c

Note, however, that a symbolic identifier needs white space when next to other symbols. That's why we cannot replace a and c in the above example to get to the same byte count:
fun f$b!=if b then$else!    (* syntax error because != is parsed as one token *)


Sum integers in a string Input

A string.

Output

The sum of all integers in the line.

Constraints

1≤Length of line≤500

Sample test Case

Input

the 5is 108 seCONd4 a

Output

117

Explanation

Sum is: 5+108+4=117

05AB1E (legacy), 5 bytes
.œþOà

Try it online or verify a few more test cases. (Times out for the larger test cases due to the .œ builtin.)
05AB1E, 11 6 bytes
þмS¡þO

Try it online or verify a few more test cases.
Explanation:

.œ      # Get all partitions of the (implicit) input-string,
        # which are all possible ways of dividing the input-strings into substrings
  þ     # Only leave the items consisting of digits for each partition
        # (in the new version of 05AB1E, an explicit `€` is required)
   O    # Sum each inner list
    à   # Pop and push its maximum
        # (after which the result is output implicitly)

þм      # Only leave the non-digits of the (implicit) input-string
        #  i.e. "the 5is 108 seCONd4 a" → "the is  seCONd a"
  S     # Split it into a list of characters
        #  → ["t","h","e"," ","i","s"," "," ","s","e","C","O","N","d"," ","a"]
   ¡    # Split the (implicit) input-string by each of these characters
        #  → ["","","","","5","","","108","","","","","","","4","",""]
    þ   # Remove the empty strings by only leaving the digits
        #  → ["5","108","4"]
     O  # And sum these numbers (which is output implicitly)
        #  → 117


Create a Boolean Calculator Our boolean operators are AND, OR, XOR, NAND, NOR, XNOR and, in conjunction with one of those operators, NOT.
Our numbers are \$1\$ and \$0\$.
The challenge is to write a program or function that calculates the results of the input.
Input
A string, array or other input format of your choice; containing alternating numbers and operators, e.g. 1 NOR 1 or ["1","OR","0","AND","1"] or 0XOR0XNOR1.
As an exception, NOT must always come directly after another operator (e.g. 0 AND NOT 1).. You can't implement NOT by itself, and you won't ever get a chain of multiple NOTs (so 1 AND NOT NOT 0 is an invalid input).
The input must contain the strings for the operators (upper or lower-case is fine); no other representation can be used e.g. .+^¬||&& etc.
Output
Return or print a single number (\$1\$ or \$0\$), derived using the calculation below. Invalid input can lead to any output you choose, or none.
Calculation
We're ignoring any precedence rules here - just calculate them in the order they come in (i.e. left-to-right) - as if someone was typing it into a calculator and pressing Enter after each number. NOT is the only one that might cause some difficulties with that logic, as you need to figure out what it's NOT-ing before you can apply the other operator.
Truth Tables
INPUT   OUTPUT
A   B   AND NAND OR NOR XOR XNOR
0   0    0   1   0   1   0   1
0   1    0   1   1   0   1   0
1   0    0   1   1   0   1   0
1   1    1   0   1   0   0   1

IN OUT
A  NOT A
0    1
1    0

Examples

1 NOR 1 = 0
1 NOR NOT 0 = 0 (equivalent to \$1\$ NOR \$1\$)
1 NOR NOT 0 AND 1 = 0 (equivalent to \$0\$ (from above) AND \$1\$)
1 NOR NOT 0 AND 1 OR 1 = 1 (equivalent to \$0\$ (from above) OR \$1\$)
1 NOR NOT 0 AND 1 OR 1 XNOR 1 = 1 (equivalent to \$1\$ (from above) XNOR \$1\$)
1 NOR NOT 0 AND 1 OR 1 XNOR 1 NAND 0 = 1 (equivalent to \$1\$ (from above) NAND \$1\$)
1 NOR NOT 0 AND 1 OR 1 XNOR 1 NAND 0 XOR NOT 0 = 0 (equivalent to \$1\$ (from above) XNOR NOT \$0\$ = \$1\$ XNOR \$1\$ = \$0\$)

Scoring
This is code-golf, but with a twist.
Your score is the number of bytes in your code, divided by the number of operators your code implements. Smallest score wins.
For example, if you only implement AND, your score is the number of bytes of your code.
If you implement AND, OR, XOR, NAND, NOR, XNOR, NOT (the full list of operators); then you get to divide the number of bytes by 7.
You must implement at least one operator, and you cannot implement NOT by itself; as it must be preceded by another, different operator and so doesn't count as implemented otherwise.
Just because someone has a low score already, don't let that put you off trying to get the best score for your language! It would be interesting to compare across different numbers of implemented operators too - e.g. you might have a bad score for 2 operators, but you might be able to implement 7 really efficiently.

Python, 3 bytes ÷ 1 op = score 3

min

Try it online!
Implements AND, with inputs like ["1", "AND", "0", "AND", "0"]. Simply takes the smallest string value, which is "0" if present and "1" otherwise. Since "AND" is later alphabetically, it can be ignored.
Another solution is all, using inputs like [1, "AND", 0, "AND", 0] since only 0 is Falsey. Python 2 could also do min with such inputs, since it has numbers as smaller than strings, whereas Python 3 refuses to compare them.


Reinvent the For loop For loops are used extensively in many languages, but what would you do if no languages supported them?

Create a way to execute a basic for loop without using any repetition structures (for, foreach, while, do, etc).

The basic for loop that you need to replicate is set up like this

for(i=0;i<1000;i++)

You must be able to replicate this without using repetition structures.  It must also execute code in your language that would be in the body of the loop.  Any form of eval is allowed, though it may not execute the for loop on its own.

You can test your code by having it print i with a space 100 times, add this test case to the end of your answer to verify your code with others.

There are no restrictions on what exactly it has to be, all it needs to do is replicate the for loop.

Winner will be decided based on upvotes at the time that it is chosen.

C, 45 chars without goto, if, for, ...

Not the smallest solution, but I find this way of doing it quite interesting in C :)

Doesn't use goto, if, for, or any other kind of control structures.

The function by itself (45 chars):

m(){int (*a[])()={m,exit};i++;(*a[i>999])();}

A compilable, working program:

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

int i=0;
m(){int (*a[])()={m,exit};i++;printf("%i ",i);(*a[i>999])();}

int main()
{
  m();
}


Loves me, loves me not Loves me, Loves me not
This simple kids' game is old, but still popular. Since we are living in 21st century now, let's digitize it!
Specification
Program must take no input, unless you are using a language that can't generate random seed - in that case you are allowed to take the seed as an input. Your task is to write a program that will output randomly a total of 3 to 20 lines inclusive: "Loves me..." and "Loves me not..." in turns, as in the game (and one additional line; keep reading).
However, there are some restrictions. Each line should be followed by newline. The first line must be "Loves me...". The last line (either "Loves me" or "Loves me not") should end with exclamation mark or a single dot, respectively. After the last line, you need to output either a heart( <3 ) or a broken heart ( </3 ) in the new line, depending whether "Loves me!" or "Loves me not." was the last sentence.
Trailing whitespace are allowed.
Example Output
Output:

Loves me...
Loves me not...
Loves me...
Loves me not...
Loves me!
<3

Another output:

Loves me...
Loves me not...
Loves me...
Loves me not.
</3

This is the code-golf, so the shortest entry wins!
Also, my first challenge :) Good luck!


1-up your average quine A 1-up quine is a program which is very similar to a quine. The one major difference is that instead of printing itself once, when n copies of the program are concatenated, the result prints the original program n+1 times.

Example

If your program is Abc123:

Abc123  ->  Abc123Abc123
Abc123Abc123  ->  Abc123Abc123Abc123
Abc123Abc123Abc123  -> Abc123Abc123Abc123Abc123

Challenge

Your challenge is to create the shortest valid 1-up quine in any language. The usual quine rules apply, so you may not:

Submit the empty program.
Directly or indirectly read1 the source code.
Use quining built-ins.

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

1This does not include using a hard-coded string or code block as part of your program.

GolfScript, 12 bytes

{`'.~'+:n}.~

Try it online!

Explanation

This combines ideas from the standard GolfScript quine:

{'.~'}.~

And my recently discovered quine:

":n`":n`

The main idea is again to use n which is printed implicitly at the end of the program in order to get the additional copy of the quine. Since assigning the variable doesn't change anything when it's done again in subsequent copies, this will only add one copy. Here's a breakdown of the code:

{        # Standard quine framework. This pushes the block, duplicates it and runs the
         # second copy, such that it can process the first copy to create a quine.
  `      # Convert the block to its string representation.
  '.~'+  # Append the string '.~' to make a complete quine. This is simply left on the
         # stack to be printed at the end.
  :n     # Store the string in n such that one more copy is printed at the end.
}.~


Simulate a Cisco Ping Premise:

For those in networking, you've most likely sent a ping to or from some device to make sure everything's properly connected. Cisco, a popular company in networking[citation needed], has a command for it in their IOS that looks like this:

(Image source)

Your challenge is to graphically recreate a portion of this. The portions we are skipping are the first line (Type escape sequence to abort.) entirely, along with the IP address and round-trip times.

You will start by outputting the following:

Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:

You will then simulate the echo requests going out. Each request will start by waiting 2 seconds and then generating the response. A successful echo response  is represented by a !, a failed one by .. We won't actually be sending packets but to represent packet loss, your program must randomly choose between the two options with a non-zero chance for each. This line will start empty and each tick will add another character.

After the fifth echo, the percentage line will be outputted and the program should then terminate. The percentage line will be in the format of

Success rate is $p percent ($s/5)

where $p is in regex 0|20|40|60|80|100 and $s is the number of successful echos. The screen must be updated after each wait period by either redrawing the new state or appending to the existing echo line. This includes the Sending line.

Example run: (The tick count should not be displayed and is there to clarify what the output should look like at each time step)

#Tick 0
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:

#Tick 1
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
.

#Tick 2
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
.!

#Tick 3
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
.!.

#Tick 4
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
.!.!

#Tick 5
Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
.!.!.
Success rate is 40 percent (2/5)

Input:

No usable input provided.

Output:

Any reasonable format. An example final output looks like this:

Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:
...!!
Success rate is 40 percent (2/5)

Rules:

You must either append to the echo line or redraw the screen after each tick.
! and . do not have to be equally likely, just both possible.
Successive runs must be able to generate different results
Gifs or webms of your output would be cool. No bonus or anything for it though.
Standard Loopholes forbidden
This is code-golf

C (gcc), 172 bytes

So, I shaved off a whopping 6 bytes off of this thing with some quite ridiculous trickery. Compile with -DK=!sleep(2)-putchar(rand()%2?33:46)/46. Depends on the sleep() function being defined in the system standard libraries.
Does not loop or recurse.

p(n){puts("Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:");printf("\nSuccess rate is %i percent (%i/5)",n*20,n=K+K+K+K+K);}

Try it online!

Explanation

This solution depends on three critical implementation/runtime details. First, the sleep() must not be interrupted, via e.g. a signal. Second, the additions and subtractions being resolved in order from left-to-right. Third, the arguments to printf() must be resolved right-to-left.

With that out of the way, let's sort through this thing.

p(n){ // Unfortunately, I need a variable to store the RNG result.
    // This is straight-forward printing of a line.
    puts("Sending 5, 100-byte ICMP Echos, timeout is 2 seconds:");
    // So, resolving right-to-left, we have a) the K preprocessor macros,
    // b) the assigment of their sum to n, c) the percentage equivalent of
    // the fraction n/5 and d) a constant format string.
    // The summation of the K's is where the magic happens.
    printf("\nSuccess rate is %i percent (%i/5)",n*20,n=K+K+K+K+K);
}

The compiler argument

-DK=!sleep(2)-putchar(rand()%2?33:46)/46

So, starting from the left (i.e. like it should resolve), we have sleep().
sleep() returns the number of seconds left when it returns,
so we expect the user (and other processes) to be kind and to not interrupt our sleep. We take the logical complement, and because
in our case sleep() will always return 0, the result is 1. More on the
significance later.

Next, we enter putchar(). putchar() prints a single 1-byte character,
and returns the value of the byte. So, we get a random value inside,
compute modulo-2 for a nice 50-50 split (albeit with horrible entropy),
and then ternary-conditional it into our desired characters - ! (33)
and . (46). Then we divide the return value of putchar() with 46.

Now, that division will return 0 for ! and 1 for . - so we take 1 (from !sleep()) and subtract the result of the division from that. Presto!

Okay, there's a slight problem. When you write things to a buffer in C (i.e. stdout), it doesn't necessarily write to the receiving end immediately. In fact, when I was running this on my distro of choice, I discovered that it would only print the pings after the program terminated. However, given that all the other solutions in C are letting that slide, and that there probably exists at least one machine out there somewhere does that and fulfills all the other prerequisites (and one could always just "fix" that in the kernel...), I'm not going to mess with my score by fflush()ing stdout.


Detecting anagrams within a Parent String Given two strings, a parent string and a query string respectively, your task is to determine how many times the query string, or an anagram of the query string; appears in the parent string, in a case-sensitive search.

Examples of Behaviour

Input 1

AdnBndAndBdaBn
dAn

Output 1

4

Explanation
The substrings are highlighted in bold below:

AdnBndAndBdaBn

AdnBndAndBdaBn

AdnBndAndBdaBn

AdnBndAndBdaBn

Note the search MUST be case sensitive for all searches.

Input 2

AbrAcadAbRa
cAda

Output 2

2

This must work for standard ASCII only. This is code-golf, so shortest number of characters will get the tick of approval. Also please post a non-golfed version of your code along with the golfed version.

Pyth, 11 10 bytes

lfqSzST.:w

1 byte golf thanks to @Jakube.

Demonstration.

Takes the query string, followed by the parent string on a new line.

Ungolfed:

z = input()
len(filter(lambda T: sorted(z) == sorted(T), substrings(input())


How many consecutive descending numbers in my number? 2019 has come and probably everyone has noticed the peculiarity of this number: it's in fact composed by two sub-numbers (20 and 19) representing a sequence of consecutive descending numbers.

Challenge

Given a number x, return the length of the maximum sequence of consecutive, descending numbers that can be formed by taking sub-numbers of x.

Notes :

sub-numbers cannot contain leading zeros (e.g. 1009 cannot be split into 10,09)
consecutive and descending means that a number in the sequence must be equal to the previous number -1, or \$n_{i+1} = n_{i}-1\$ (e.g. 52 cannot be split into 5,2 because 5 and 2 are not consecutive, 2 ≠ 5 - 1)
the sequence must be obtained by using the full number, e.g. in 7321 you can't discard 7 and get the sequence 3,2,1
only one sequence can be obtained from the number, e.g. 3211098 cannot be split into two sequences 3,2,1 and 10,9,8

Input

An integer number (>= 0) : can be a number, or a string, or list of digits

Output

A single integer given the maximum number of decreasing sub-numbers (note that the lower-bound of this number is 1, i.e. a number is composed by itself in a descending sequence of length one)

Examples :

2019         --> 20,19           --> output : 2
201200199198 --> 201,200,199,198 --> output : 4
3246         --> 3246            --> output : 1
87654        --> 8,7,6,5,4       --> output : 5
123456       --> 123456          --> output : 1
1009998      --> 100,99,98       --> output : 3
100908       --> 100908          --> output : 1
1110987      --> 11,10,9,8,7     --> output : 5
210          --> 2,1,0           --> output : 3
1            --> 1               --> output : 1
0            --> 0               --> output : 1
312          --> 312             --> output : 1
191          --> 191             --> output : 1

General rules:

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

JavaScript (ES6), 56 bytes
A port of ArBo's Python answer is significantly shorter. However, it fails on some test cases because of too much recursion.

f=(n,a=0,c=0,s)=>a<0?f(n,a-~c):n==s?c:f(n,--a,c+1,[s]+a)

Try it online!

JavaScript (ES6), 66 bytes
Takes input as a string.

f=(s,n=x='',o=p=n,i=0)=>s[i++]?o==s?i:f(s,--n,o+n,i):f(s,p+s[x++])

Try it online!
Commented
f = (               // f = recursive function taking:
  s,                //   s = input number, as a string
  n =               //   n = counter
  x = '',           //   x = position of the next digit to be added to p
  o = p = n,        //   o = generated output; p = prefix
  i = 0             //   i = number of consecutive descending numbers
) =>                //
  s[i++] ?          // increment i; if s[i] was defined:
    o == s ?        //   if o is matching s:
      i             //     stop recursion and return i
    :               //   else:
      f(            //     do a recursive call with:
        s,          //       s unchanged
        --n,        //       n - 1
        o + n,      //       (n - 1) appended to o
        i           //       i unchanged (but it was incremented above)
      )             //     end of recursive call
  :                 // else:
    f(              //   this is a dead end; try again with one more digit in the prefix:
      s,            //     s unchanged
      p + s[x++]    //     increment x and append the next digit to p
    )               //   end of recursive call


Write a domino effect Using the fewest Unicode characters, write a function that accepts three parameters:

Total number of dominoes
nth affected domino
Topple direction of the affected domino (0 or L for left, 1 or R for right)

Once a domino is toppled, it must also topple the remaining dominoes in the same direction.

You should output the dominoes with | representing a standing domino and \ and / representing a domino toppled to the left and right respectively.

Examples

10, 5, 1 should return ||||//////
6, 3, 0 should return \\\|||

Ruby, 38 (46) characters

e=->n,k,r{k-=r;'\|'[r]*k+'|/'[r]*n-=k}

This function takes the direction as an integer (1 for right, 0 for left). A function that takes a string is 8 characters longer:

d=->n,k,r{n-=k;r<?r??\\*k+?|*n :?|*~-k+?/*-~n}

Usage examples:

puts e[10, 5, 1] # or d[10, 5, 'r']
||||//////
puts e[10, 5, 0] # or d[10, 5, 'l']
\\\\\|||||


One More Program and I'm Out! Given a positive integer nesting level n and string s of printable ascii characters( to ~, output a program which, when run in the same language, outputs a program which outputs a program . . . which outputs the string s.

A total of n programs should be generated, all of which should be run in the same language as your answer.

Note: you may output programs or functions -- anything you are allowed by default as a submission.

You may input s with escaped characters, how a program or function in your language would usually input a string.

Example

For example, given n=1 and s="recursion", a Python 2 program might output:

print "recursion"

Running this would output:

recursion

Given n=2 and s="PPCG", a Python 2 program might output:

print "print \"PPCG\" "

Running this outputs:

print "PPCG"

Running this outputs:

PPCG

Related (+title inspiration): One more LUL and I'm out

Also Related (in sandbox - now deleted, but can still be viewed with enough reputation): Source Code Recursion

Test Cases

Make sure that your code works for the following test cases (one per line):

n s
2 PPCG
4 Robert'); DROP TABLE Students;--
17 Deep
2 Spaces In Here
3 "Don't forget quotes!"
5 'Backt`cks might be a h`tch'
6 5%s
8 [Brackets]<Are>(Great){Usually}
3 !"#$%&'()*+,-./ 0123456789:;<=>?@ABCDEFGHIJKLMN
6 OPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
7 THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
3 the quick brown fox jumps over the lazy dog

Jelly, 2 bytes

Ṿ¡

Try it online!

Ṿ¡  Main link; left argument (text) is x, right argument (repetitions) is y
 ¡  Repeat y times:
Ṿ   Uneval x; produce code that outputs x

hehe builtins


Characteristic polynomial The characteristic polynomial of a square matrix \$A\$ is defined as the polynomial \$p_A(x) = \det(Ix-A)\$ where \$I\$ is the identity matrix and \$\det\$ the determinant. Note that this definition always gives us a monic polynomial such that the solution is unique.
Your task for this challenge is to compute the coefficients of the characteristic polynomial for an integer valued matrix, for this you may use built-ins but it is discouraged.
Rules

input is an \$N\times N\$ (\$N \ge 1\$) integer matrix in any convenient format
your program/function will output/return the coefficients in either increasing or decreasing order (please specify which)
the coefficients are normed such that the coefficient of \$x^N\$ is 1 (see test cases)
you don't need to handle invalid inputs

Testcases
Coefficients are given in decreasing order (ie. \$x^N, x^{N-1}, ..., x^2, x, 1\$):
[0] -> [1 0]
[1] -> [1 -1]
[1 1; 0 1] -> [1 -2 1]
[80 80; 57 71] -> [1 -151 1120]
[1 2 0; 2 -3 5; 0 1 1] -> [1 1 -14 12]
[4 2 1 3; 4 -3 9 0; -1 1 0 3; 20 -4 5 20] -> [1 -21 -83 559 -1987]
[0 5 0 12 -3 -6; 6 3 7 16 4 2; 4 0 5 1 13 -2; 12 10 12 -2 1 -6; 16 13 12 -4 7 10; 6 17 0 3 3 -1] -> [1 -12 -484 3249 -7065 -836601 -44200]
[1 0 0 1 0 0 0; 1 1 0 0 1 0 1; 1 1 0 1 1 0 0; 1 1 0 1 1 0 0; 1 1 0 1 1 1 1; 1 1 1 0 1 1 1; 0 1 0 0 0 0 1] -> [1 -6 10 -6 3 -2 0 0]

SageMath, 3 bytes

5 bytes saved thanks to @Mego

fcp

Try it online!

Takes a Matrix as input.

fcp stands for factorization of the characteristic polynomial,

which is shorter than the normal builtin charpoly.


Count the number of a number in the picture area Your goal is to write a full program or function that takes 5 positive integers   and a string with an image filename as input [X1,Y1], [X2,Y2], N, image.jpg in any reasonable format, where:

First couple [X1,Y1] are the top left X,Y coordinates (<=20) of the blue rectangle area in the example picture (16,11).
Second couple [X2,Y2] are the bottom right X,Y coordinates (<=20) of the blue rectangle area in the example picture (20,22).
Fifth number N such 0 <= N <= 9 is the number that has to be found.
Sixth parameter is a string with the filename of this JPG picture.

Output how many of N's are present in the indicated area (outlined in blue in the picture for this example):

Click here to obtain a bigger clean version of the same image.

In the picture there are 500 numbers from 0 to 9 (included) arranged in 20 columnns per 25 rows, in monospaced Courier New font.
Each different number has a different color (you can take advantage of this fact or ignore it and consider or convert the image in monocrome if that helps you).

Test cases:

[4,4],[13,5],1,image.jpg    > 4  (outlined in red)
[4,4],[13,5],4,image.jpg    > 2  (outlined in red)
[17,5],[17,5],2,image.jpg   > 1  (outlined in magenta)
[17,5],[17,5],9,image.jpg   > 0  (outlined in magenta)
[20,8],[20,9],3,image.jpg   > 1  (outlined in cyan)
[20,8],[20,9],2,image.jpg   > 0  (outlined in cyan)
[16,11],[20,22],0,image.jpg > 8  (outlined in blue)
[16,11],[20,22],3,image.jpg > 9  (outlined in blue)
[3,14],[11,20],7,image.jpg  > 6  (outlined in green)
[3,14],[11,20],5,image.jpg  > 6  (outlined in green)
[3,14],[11,20],8,image.jpg  > 8  (outlined in green)
[1,1],[20,25],0,image.jpg   > 47 (whole picture)
[1,1],[20,25],8,image.jpg   > 50 (whole picture)
[1,1],[20,25],1,image.jpg   > 55 (whole picture)

Rules:

This is code-golf so the shortest code wins.
You must take as input this JPG file.
You are not allowed to hardcode the matrix of numbers represented in the JPG, or the results.
Standard loopholes are forbidden.

Mathematica, 92 bytes

Count[Take[Characters@StringSplit@TextRecognize@Binarize[Import@#4,.9],#2,#],ToString@#3,2]&

Unnamed function taking the arguments in this format: [{X1,X2}, {Y1,Y2}, N, "image.jpg"]. (Indeed, the fourth argument can be either the local file name or the URL http://i67.tinypic.com/6qh5lj.jpg.)

Import@#4 imports the image file, Binarize[...,.9] darkens all of the numbers to black, and TextRecognize (the function clearly doing the heavy lifting here!) extracts a multi-line string from the resulting image, which is split into a nested list of characters with Characters@.

Take[...,#2,#] keeps only the characters corresponding to the outlined rectangle, and Count[...,ToString@#3,2] counts the number of occurrences of N in the result.


Beware of the matrix tornado! The matrix tornado is just like any other tornado: it consists of things rotating around a center. In this case, elements of the matrix instead of air.
Here is an example of a matrix tornado:

First we start by sectioning the matrix into square rings, each section consists of elements that are farther away from the border by the same distance. These sections will be rotated clockwise around the center. In real tornadoes, the severity increases towards the center, and so does the rotation step in a matrix tornado: the outermost section (the red one) is rotated by 1 step, the next (the yellow) one is rotated by 2, and so on. A rotation step is a 90° rotation around the center.
Task:
Your task, should you accept it, is to write a function or program that takes as input a square matrix, apply the tornado effect to it and then output the resulting matrix.
Input:
The input should be a square matrix of order n where n >= 1. No assumption is to be made about the elements of the matrix, they could be anything.
Output:
A square matrix of the same order which would be the result of applying the tronado effect to the input matrix.
Examples:
A matrix of order n = 1:
[['Hello']]               ===>    [['Hello']]

A matrix of order n = 2:
[[1 , 2],                 ===>    [[5 , 1],
 [5 , 0]]                          [0 , 2]]

A matrix of order n = 5:
[[A , B , C , D , E],             [[+ , 6 , 1 , F , A],
 [F , G , H , I , J],              [- , 9 , 8 , 7 , B],
 [1 , 2 , 3 , 4 , 5],     ===>     [/ , 4 , 3 , 2 , C],
 [6 , 7 , 8 , 9 , 0],              [* , I , H , G , D],
 [+ , - , / , * , %]]              [% , 0 , 5 , J , E]]

Python 3, 100 bytes

import numpy
def f(a):
 if len(a): a=numpy.rot90(a,axes=(1,0));a[1:-1,1:-1]=f(a[1:-1,1:-1]);return a

Try it online!


Can I burn the farmers too? Inspired by this and this which was inspired by the first question.

I've set my farmers' fields on fire, but unfortunately they saw me do it! If I don't deal with this situation they could report me and then I'd get arrested! So, that shouldn't be too hard. All I have to do is kill them with fire!

The field will be an m*n grid with odd m and n where both are one greater than a multiple of 4. The farmer starts out in the middle of the field. Each "tick", the farmer can move to an adjacent square (edge or corner) and any space on fire will ignite every grid adjacent to it in a 3x3 space (edge or corner again).

Note: fires and farmers can move diagonally.

The grid will be given as some 2D array of 3 unique values: Fire, .Wheat, and Human (Farmer). For example:

F...F
F...F
FFHFF
F...F
F...F

the farmer is doomed to DIE! >:-D

It would be easy if I could just light a fire right beside the farmer and set him on fire. However, he knows I am in the field with him and he has a gun. If he sees me, I'm dead. So, I can't light the fire within half of the distance between him and the edge, of him. Essentially, if you floordiv the width of the grid by 4, I must be within that many spaces from the edge, and same with the height.

I am immune to fire so I don't have to worry about getting myself out.

The question is:

Given a field with wheat, a farmer in the center, and potentially existing fires around the field, how many fires do I need to light to guarantee I can kill the farmer?

Test Cases

These test cases have input represented by a F . H grid and output as a single integer. You may take input in any other reasonable format and output a single integer.

FFFFF
F...F
F.H.F => 0, the farmer is doomed to die in 2 ticks anyway
F...F
FFFFF

FFFFF
F....
F....
F....
F.H.. -> 1 (just light a fire on the far right side of him)
F....
F....
F....
FFFFF

.....
.....
..H.. -> 4 (to ensure his demise, you would need to light 4 points around the perimeter (with rotational symmetry). Any 4 will do.
.....
.....

Rules

Standard Loopholes apply
You can take an array of 2 values if you would like, where you infer the farmer's position from the size (since the farmer will always be in the center)

Python 3, 672 bytes

e=enumerate;H='H';F='F'
def f(m):
	q=m[0];h=len(m);w=len(q);o=0;g=lambda m,c:{(k,l)for i,r in e(m)for j,v in e(r)for k in range(i-1,i+2)for l in range(j-1,j+2)if v==c and k>=0and k<h and l>=0and l<w};n=lambda m,c,d:[[c if(k,l)in g(m,c)-g(m,d)else m[k][l]for(l,v)in e(r)]for(k,r)in e(m)];s=lambda m:H in[q]+[m[h-1]]+[r[0]for r in m]+[r[w-1]for r in m];l=lambda m:all(H not in r for r in m)
	while 1:
		a=m
		while not(s(a)or l(a)):a=n(n(a,H,F),F,1)
		if l(a):return o
		else:o+=1;z(m,a,h,w)
def z(m,a,h,w):
	for i in(0,h-1):
		for j,v in e(a[i]):
			if v==H:m[i][j+(h-1)//2]=F;return
	for j in(0,w-1):
		for i,v in e(r[j] for r in a):
			if v==H:m[i+(w-1)//2][j]='F';return

Try it online!

It's very long (I've done my best to golf it), and the solution is not optimal. Here is the general idea:

First, let's see if the farmer burns in the original situation. The matrix a is filled with Fs when the fire grows and with Hs if the farmer can reach a position (a=n(n(a,H,F),F,1)).
If the farmer escapes (s(a)), look a the border of a. There must be at least a H. It takes (h-1)/2 ticks to reach the top or the bottom, and (w-1)/2 ticks to reach the left or right border. As soon as we find a H on the top, we put a fire at (h-1)/2 cases on its left. In (h-1)/2 ticks, an F will be there and it may also "burn" other Hs. The same applies for the left and right borders.

The solution is not optimal because:

there are some edge cases, in particular when a fire will burn two borders of the field.
considering top and bottom borders before right and left borders is not necessarily the best solution
going from left to right and top to bottom to find a H is not necessarily the best solution.


Codegolf Rainbow : Fun with Integer-Arrays Introduction:

 (Source: Wikipedia)
When we look at a rainbow it will always have the colors from top to bottom:
Red; orange; yellow; green; blue; indigo; violet

If we look at these individual rings, the red ring is of course bigger than the violet ring.
In addition, it's also possible to have two or even three rainbow at the same time.

All this above combined will be used in this challenge:

Challenge:

Given a list of integers of exactly size 7, where each value indicates the color-particles available to form rainbows (where the largest index indicates red and the smallest index indicated violet), output the amount of rainbows that can be formed.

A single integer-rainbow has to have at least 3x violet, 4x indigo, 5x blue, 6x green, 7x yellow, 8x orange, 9x red. A second rainbow on top of it will be even bigger than the red ring of the first rainbow (including one space between them), so it will need at least 11x violet, 12x indigo, 13x blue, 14x green, 15x yellow, 16x orange, 17x red in addition to what the first rainbow uses. The third rainbow will start at 19x violet again.

Example:

Input-list: [15,20,18,33,24,29,41]
Output: 2

Why? We have 15x violet, and we need at least 3+11=14 for two rainbows. We have 20 indigo and we need at least 4+12=16 for two rainbows. Etc. We have enough colors for two rainbows, but not enough to form three rainbows, so the output is 2.

Challenge rules:

The integers in the input-array are guaranteed to be non-negative (>= 0).
The input-list is guaranteed to be of size 7 exactly.
When no rainbows can be formed we output 0.
Input and output format is flexible. Can be a list or array of integers of decimals, can be taken from STDIN. Output can be a return from a function in any reasonable output-type, or printed directly to STDOUT.

Minimum amount of colors required for n amount of rainbows:

Amount of Rainbows    Minimum amount per color
0                     [0,0,0,0,0,0,0]
1                     [3,4,5,6,7,8,9]
2                     [14,16,18,20,22,24,26]
3                     [33,36,39,42,45,48,51]
4                     [60,64,68,72,76,80,84]
5                     [95,100,105,110,115,120,125]
etc...

General rules:

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

Test cases:

Input:  [15,20,18,33,24,29,41]
Output: 2

Input:  [3,4,5,6,7,8,9]
Output: 1

Input:  [9,8,7,6,5,4,3]
Output: 0

Input:  [100,100,100,100,100,100,100]
Output: 4

Input:  [53,58,90,42,111,57,66]
Output: 3

Input:  [0,0,0,0,0,0,0]
Output: 0

Input:  [95,100,105,110,115,120,125]
Output: 5

Input:  [39525,41278,39333,44444,39502,39599,39699]
Output: 98

Pyth, 14 bytes

thS.ef<b*+tkyy

Test suite!

How?

Algortihm

First off, let's derive the formula this answer is based off. Let's call the function that gives the necessary amount of colour particles \$C(n, i)\$, where \$n\$ is the number of layers and \$i\$ is the index of the colour, 0-based. First, we note that for the \$n^\text{th}\$ layer alone (where \$n\$ is 1-indexed, in this case), we need \$L(n, i)=i+3+8(n-1)\$ colour particles. Keeping this in mind, we sum the results of each \$L(k, i)\$ for each layer \$k\$:

$$C(n, i)=\color{red}{\underbrace{(i+3)}_{1^\text{st} \text{ layer}}} + \color{blue}{\underbrace{(i+3+8)}_{2^\text{nd} \text{ layer}}}+\cdots + \color{green}{\underbrace{[i+3+8(n-1)]}_{n^\text{th} \text{ layer}}}$$
$$C(n, i)=(i+3)n+8\left(0+1+\cdots +n-1\right)$$
$$C(n, i) = (i+3)n+8\cdot\frac{(n-1)n}{2}=(i+3)n+4n(n-1)$$
$$C(n, i)=n(i+3+4n-4)\implies \boxed{C(n,i)=n(4n+i-1)}$$

Therefore, we now know that the maximum number of possible layers, call it \$k\$, must satisfy the inequality \$C(k, i) \le I_i\$, where \$I_i\$ is the \$i^\text{th}\$ element of the input list.

Implementation

This implements the function \$C\$, and iterates (.e) over the input list, with \$k\$ being the index (0-based) and \$b\$ being the element. For each value, the program searches the first positive integer \$T\$ for which \$b<C(T, i)\$ (the logical negation of \$C(T, i)\le b\$, the condition we deduced earlier), then finds the minimum result and decrements it. This way, instead of searching for the highest integer that does satisfy a condition, we search for the lowest that does not and subtract one from it to make up for the offset of 1.


Heterograms, Palindromes, oh my! (First challenge, please let me know if there are any problems with it.)

A heterogram is a word where no letter of the alphabet occurs more than once, and a palindrome is a phrase that is the same backwards and forwards.

The challenge here is to write a piece of code that takes in a word (just letters) as input, and outputs whether or not it is a heterogram (truthy/falsy). The catch is that the program must be a palindrome -- reads the same backwards and forwards. Capitalization doesn't matter here, so for the heterogram to be valid it can't have both q and Q, for instance.  No comments are allowed, and you cannot place strings that contain your code (or a significant part of your code) to try to make the palindrome part easy :P

This is code-golf, so shortest code wins. Good luck!

EDIT: Parens, brackets or other symbols that have left and right forms must be reversed approriately for the palindrome part. So (helloolleh) is a palindrome, but (helloolleh( is not. Apparently this is called a convenient palindrome.

EDIT 2: You won't get any empty input, input with multiple words or input with characters other than letters. So don't worry about that :)

Pyth, 17 bytes
 Z.{rzZ.q.Zzr}.Z

Try it online here.
The leading space is necessary. I have counted it and the trailing space in the byte count.
Here's the breakdown:
     z            z is initialized to the input
    r Z           Z is initialized to 0, and r(string)0 converts the string to lowercase
  .{              .{ is pyth's builtin uniqueness test
       .q         .q terminates the program
         .Zzr}    This is just the program mirrored
              .Z  . requires a number to immediately follow it
                  If left blank the parser would throw an error
 Z                This is just mirrored from the end
                  The leading space suppresses the automatic printing of this 0
                  The trailing space mirrors the leading space


Tips for golfing in Processing Does anyone have any code-golf tips for golfing in Processing? It is a graphical extension of java, and is somewhat difficult to golf.

If no animation is required, you can skip the void draw() and put everything into void setup().
Initialising the size of the canvas is sometimes not necessary - it will be initialised to (100, 100) by default.
If you need to use height and width in your code, it is usually shorter to use their numeric values instead. For example, with a canvas of size (100, 100), using 99 to replace height and width can save you 7 bytes.


Bijection: tree-like lists - natural numbers We define a tree-like list, or trist for short, as the empty list or a list containing only previously constructed trists.

The natural numbers can either include 0 or not, according to your preference.

The task is to create a pair of functions or complete programs f and g (they don't have to be named like this or even named at all) that implement a bijection between trists and the natural numbers.  In other words:

f must be able to turn any trist into a natural number
g must be able to turn any natural number into a trist
f(g(n)) must equal n for any natural number n
g(f(l)) must be equivalent to l for any trist l

You can assume that all arguments and results fit in the usual numeric type for your language.
Alternatively, instead of the numeric type you could represent a natural number as a list of binary digits, either consistently little- or consistently big-endian.

The shortest solution per language wins. If your functions are recursive, you must name them. If your language requires a statement separator or a newline between the two functions/programs, you don't have to count it.

This is a sample algorithm in Python3 (you are free to implement the bijection in any way you like):

def f(x):
    r = 0
    for y in x:
        r = (2 * r + 1) * 2**f(y)
    return r

def g(n):
    r = []
    while n:
        m = 0
        while n % 2 == 0:
            n //= 2
            m += 1
        n //= 2
        r = [g(m)] + r
    return r

tests = [
    [],
    [[]],
    [[],[]],
    [[[]],[],[[[]],[]]],
    [[[[[]]]]],
]
for l in tests: print(g(f(l)) == l)

for n in range(20): print(f(g(n)) == n)

It uses the following representation:

\$
\begin{array}{|l}
f([~])=0\\
f([a_0,a_1,\ldots,a_{n-1}])=\overline{
1\underbrace{0\ldots0}_{f(a_0)\\\text{zeroes}}~
1\underbrace{0\ldots0}_{f(a_1)\\\text{zeroes}}~
\ldots~
1\underbrace{0\ldots0}_{f(a_{n-1})\\\text{zeroes}}}
{}_{(2)}
\end{array}
\$

Challenge inspired by @LeakyNun's question in chat.

Python 2, 118 114 109 105 103 97 94 bytes

f=lambda x:x>[]and f(x[:-1])*2+1<<f(x[-1])
g=lambda n:[g(len(w))for w in bin(n).split('1')[1:]]

Try it online!

Same encoding as the example...


Find distance between the closest 3D points Your task is to take \$n \ge 2\$ points in 3D space, represented as 3 floating point values, and output the Euclidean distance between the two closest points. For example
$$A = (0, 0, 0) \\ B = (1, 1, 1) \\ C = (4, 0, 2)$$
would output \$\sqrt3 = 1.7320508075688772...\$, the distance between \$A\$ and \$B\$.
The Euclidean distance, \$E\$, between any two points in 3D space \$X = (a_1, b_1, c_1)\$ and \$Y = (a_2, b_2, c_2)\$ is given by the formula
$$E = \sqrt{(a_2 - a_1)^2 + (b_2 - b_1)^2 + (c_2 - c_1)^2}$$
This is code-golf so the shortest code in bytes wins

R, 34 bytes

function(...)min(dist(rbind(...)))

Try it online!
This is a nice opportunity to use R's ... syntax to define a function that can accept a variable number of arguments; in this case, the x,y,z coordinates of each point.
The dist function calculates the pairwise distance between all rows of a matrix, using a chosen method - luckily, the default is 'euclidean' and so isn't specified in this case.
Of course, it could be even shorter if we allow the input to already be combined-together as a matrix, but this wouldn't be so neat...
R, 23 bytes

function(m)min(dist(m))

Try it online!


Are you in the biggest room? Introduction
You have recently accepted a job offer at a Pretty Good Software Company. You're pretty content with the size of your office, but do you have the biggest office? Its kinda hard to tell from just eyeballing your co-workers' offices when you stop by. The only way to figure this out is to examine the blueprints for the building...
Your Task
Write a program, script, or function that takes a floor plan for your building and indicates whether your office is the largest. The floor plan is easy to read because the building is an n by n square.
The input will consist of n+1 \n-delimited lines. The first line will have the number n on it. The next n lines will be the floorplan for the building. A simple example input:
6
......
.  . .
.X . .
.  . .
.  . .
......

The rules for the floorplan are as follows:

. (ASCII 46) Will be used to represent walls.   (Space [ASCII 32]) will be used to represent open space.
You are represented by an X (ASCII 88). You are in your office.
The floorplan will be n lines, each with n characters.
The building is totally surrounded by walls on all sides. This implies that the 2nd line of input (the first line of the floorplan) and the last line of input will be all .s. It also implies that the first and last characters of every floorplan line will be .s.
An office size is defined as the sum of adjacent spaces (contiguous by moving in 4 directions, N, S, E, W, without going through a wall).
For the purpose of office size, the X representing you counts as a   (open space)
4 <= n <= 80

You should output whether or not your office is strictly bigger than all the other offices. The output can be anything that unambiguously signifies True or False in your programming language of choice and adheres to standard conventions of zero, null, and empty signifying False. True implies your office is strictly the biggest.
Sample output for above input:
1

Because your office is 8 square feet, and the only other office is 4 square feet.
I/O Guidelines

The input may be read from stdin, and answer output to stdout.

Or

The input may be a single string argument to a function, and answer be the return value of that function.

FAQ

The entire building consists of walls and offices.
The building is only one floor
There is guaranteed to be an X in the input, but there are not guaranteed to be any spaces. You could have a 1x1 office and the rest of the building is walls (You have the biggest office! hooray!).

Other Example
10
..........
.   .  . .
.  .   . .
.  .   . .
. ..   . .
..       .
..........
.      X .
.        .
..........

Here there are 3 offices, your south office is rectangular, the northwest office is a triangle(ish) and the northeast office is strangely misshapen, yet bigger than yours. The output should be False.
This is a challenge to write the shortest code, happy code-golfing!

Ruby 2.0, 133 characters

A collaboration with @Ventero.  Always a good sign when it starts breaking the syntax highlighter!

This is a recursive flood-fill solution.  Reads from STDIN and outputs to STDOUT:

f=->*a{a.product([~n=$_.to_i,-1,1,n+1]){|p,d|a|=[p]if$_[p+=d]<?.}!=a ?f[*a]:a.size}
gets(p).scan(/ /){$*<<f[$`.size]}
p$*.max<f[~/X/]

See it running on Ideone.


10-pin bowling split spare Bowling

Bowling is a game where, essentially, each player gets 10 turns to:

Take 2 attempts at knocking down 10 pins arranged in a triangle.

between turns the pins are reset
from the 1st to the 2nd attempt the pins are left as-is

The arrangement of the pins resembles the following scheme, with the pins numbered 0-9:

6 7 8 9
 3 4 5
  1 2
   0

(Some rules and scoring mechanics omitted.)

Split spare

In bowling, a spare is when the player manages to knock down the pins that were left standing after a first attempt. A spare is said to be a split spare1 if the pins that were left standing are not adjacent.

E.g. if the pins are laid out as such:

. . 8 9
 . . .
  . 2
   .

Then a player who manages to knock down all these 3 pins would score a split spare, given that the pin 2 is not adjacent to the 8, 9 group.

(1 for the purposes of this challenge, a split spare is defined taking into account only the adjacency of the pins left standing, even though Wikipedia's link states that for a split spare to take place, the pin 0 must have been knocked down already)

Your task

Given the numbers of the pins left standing, output a Truthy value if such an arrangement would give a split spare and Falsy otherwise.

Input

The list of all pins left standing (at least 2), in any reasonable format. Pin numbering may be 0- or 1-indexed provided it follows the numbering direction shown above. Sensible input formats include:

a list of integers, like [2, 8, 9]
a string of integers, like "289"
separate arguments to a function
an integer whose bits correspond to the pints left standing and whose least significant bit corresponds to pin 0, e.g. 0b1100000100 for pins 2, 8 and 9.

You may assume input is sorted, if that helps you in any way.

Output

A single consistent value for Falsy test cases and anything else for Truthy test cases.

Test cases

Truthy

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

Falsy

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

Bonus imaginary internet points

Bonus imaginary internet points if your algorithm works for any triangle number of pins, instead of just 10.

So far, only Grimmy's 05AB1E answer qualifies for the bonus internet points!

Standard loopholes are forbidden by default.

This is code-golf so shortest solution wins! If you enjoy the challenge, consider upvoting it... And happy golfing!

05AB1E, 27 25 24 23 bytes

ÅTαε.āθDÆª}©æε®yKδαOß}à

Try it online!

Outputs 2 for falsy and a larger integer for truthy. Works for any triangle number of pins, thus qualifying for the bonus internet points.

A set of pins is split if and only if there is a partition of the set of pins in two subsets A and B such that no pin in A is adjacent to a pin in B.

Adjacency is determined using 3-element hexagonal coordinates.

First, we convert the input pins to their hex coordinate triplets:

   ε      }     # for each pin in the input:
ÅT              #  list of triangle numbers <= pin
  α             #  absolute difference of each one with pin
    .ā          #  enumerate: [a, b, c] => [[a, 1], [b, 2], [c, 3]]
      θ         #  get the last pair
       D        #  duplicate
        Æ       #  reduce the copy by subtraction
         ª      #  append that to the pair

Then, we iterate over partitions of this set of triplets in two subsets:

©               # save the set in the register
 æ              # powerset (list of subsets)
  ε       }     # for each subset y:
   ®            #  push the set from the register
    y           #  push y
     K          #  set difference (=> y's complement)

Then, we compute the 2D list of distances between each pin in the first subset and each pin in the second subset. Thanks to the elegance of 3-element hexagonal coordinates, this is surprisingly easy:

      δα        #  double vectorized absolute difference
        O       #  sum each triplet

Finally, we answer the question:

         ß      #  minimum distance for the current partition
          }     #  end the loop
           à    # maximum of the list of minimums


prOGraMMIng PuZZleS & cOde ____ Input
A non-empty encoded string consisting of printable ASCII characters (in the range 32-126), where some missing letters have been replaced with _.
Output
A decoded string of the same length with all letters in lowercase, including the missing ones.
How?
Edit: As mentioned by @Deusovi in the comments, this is a variant of Bacon's cipher.

Gather all letters in the original string and group them by 5. Additional letters that do not fit in a full group of 5 are ignored.
Convert each group into binary: lowercase = 0, uppercase = 1. This leads to a list of integers.
Use each value N in this list to replace each _ in the original string with the N-th letter of the alphabet (0-indexed), in order of appearance.

Example: prOGraMMIng PuZZleS & cOde ____
prOGr --> 00110 -->  6 -->  7th letter = 'g'
aMMIn --> 01110 --> 14 --> 15th letter = 'o'
gPuZZ --> 01011 --> 11 --> 12th letter = 'l'
leScO --> 00101 -->  5 -->  6th letter = 'f'

By replacing the missing letters and converting everything back to lowercase, the original string is unveiled:
programming puzzles & code golf

This is the expected output.
Clarifications and rules

The missing letters are guaranteed to appear at the end of the string. More formally: there will never be any letter after the first _ in the input string. However, there may be other printable ASCII characters such as spaces and punctuation marks.
The input is guaranteed not to contain any useless capital letter: all capital letters are bits set to 1 which are required to decode the missing letters. Everything else is in lowercase.
The input string is guaranteed to be valid. Especially:

It will always contain enough full groups of 5 letters to decode the underscores.
The binary-encoded integers are guaranteed to be in the range [0-25].

There may be no _ at all in the input string, in which case you just have to return the input.
This is code-golf, so the shortest answer in bytes wins!

Test cases
Input : hello!
Output: hello!

Input : helLO, worl_!
Output: hello, world!

Input : i aM yoUr faTh__.
Output: i am your father.

Input : prOGraMMIng PuZZleS & cOde ____
Output: programming puzzles & code golf

Input : Can YOu gUesS tHE ENd oF This ____?
Output: can you guess the end of this text?

Input : THe qUICk brown FOx JUMps oVEr the la__ ___.
Output: the quick brown fox jumps over the lazy dog.

Input : RoadS? wHERe we're goinG WE doN't need _____.
Output: roads? where we're going we don't need roads.

Input : thE greatESt Trick thE DeVIl EVer PUllEd wAs CONvInciNg tHe WorLD h_ ____'_ _____.
Output: the greatest trick the devil ever pulled was convincing the world he didn't exist.

Some extra test-cases:
Input : BInar_
Output: binary

Input : 12 MonKey_
Output: 12 monkeys

Input : hyPerbolIZ__
Output: hyperbolized

Input : {[One Last Test ca__]}
Output: {[one last test case]}

05AB1E, 18 bytes

Code:

áS.u5ôJC>.bv'_y.;l

Uses the 05AB1E encoding. Try it online!

Explanation:

á                       # Remove non-letters from the input string.
 S                      # Split the result into individual characters.
  .u                    # Check if is uppercase for each character.
    5ôJ                 # Split into binary numbers of length 5.
       C                # Convert from binary to decimal.
        >               # Add one.
         .b             # Map 1 → A, 2 → B, 3 → C, ..., 25 → Y, 26 → Z.
           v            # For each letter:
            '_y.;       #   Replace the first occurrence of '_' with the current letter.
                 l      #   Convert the string to lowercase.


This Challenge Makes Cents I know, the title cracks you up

Given an amount of money, output the fewest number of coins that make up that amount.

Examples

0.1
1 dime

0.01
1 penny

0.28
1 quarter 3 penny

0.56
2 quarter 1 nickel 1 penny

1.43
5 quarter 1 dime 1 nickel 3 penny

Spec

100 cents in a dollar.
The values of each type of coin is:

penny 1 cent
nickel 5 cents
dime 10 cents
quarter 25 cents

Built-ins which trivialize this task are not allowed.

I/O

Input is a decimal representing the dollar value of the total

No need to pluralize
Order: quarter -> penny
Output should be <#_of_coins> <coin type>
Separators: , or , (comma and a space) or

The only trailing whitespace allowed is a single trailing newline/space.

If there is zero of a coin type, that coin type should not be shown. E.g. 0.25 -> 1 quarter not 1 quarter 0 dime 0 nickel 0 penny


Display Scrolling Waves The challenge is to display and scroll a sine waveform in the least number of characters.

Restrictions:

Total height of wave must be at least seven units (characters, pixels, etc).
The generated wave must scroll in-place.

Additional Rules/Information:

The sine wave must be distinguishable from triangle and square waves.

"distinguishable" indicates sampling at least every π/8

Additional Judgement Criteria:

Appearance/Quality of the wave
Number of periods displayed

Winning entries will have the fewest characters of code and generate a sine wave with the most samples per period.

Mathematica : 49

Plot[Sin[x+a],{x,0,9},Axes->None]~Animate~{a,0,2Pi}

The flickering is a GIF-produced artifact. Runs smoothly on the screen.


Compute the number of ways how you can express a number as a sum For a given natural number n, compute the number of ways how one can express n as a sum of positive natural numbers. For example, for n = 1 there is just one way. For n = 4 we have 5 possible ways:

1 + 1 + 1 + 1
1 + 1 + 2
1 + 3
2 + 2
4

The ordering of terms in a sum doesn't matter, so 1 + 3 and 3 + 1 are considered the same. Your program should be effective enough to return the result for n = 1000 in order of minutes.

The winner will the solution with most up-votes in (at least) 2 weeks.

Haskell, 170 148

An efficient Haskell version using a generating function with Memoization. Solve instantaneously the problem for n = 1000. No precision issues even with large numbers:

time ./partitions 10000
36167251325636293988820471890953695495016030339315650422081868605887952568754066420592310556052906916435144
./partitions 10000  17.02s user 0.00s system 100% cpu 17.021 total

The code

generalizedPentagonal = map pentagonal $ [1..] >>= \i->[i,-i]
    where pentagonal n = (3*n^2-n)`quot`2

partitions = (map partitions' [0..] !!)
    where partitions' 0 = 1
          partitions' n = sum . alternate . map partitions . takeWhile (>=0) . map (n-) $ generalizedPentagonal
          alternate = zipWith (*) (concat . repeat $ [1,1,-1,-1])

Code-golf version

p=(map a[0..]!!)where a 0=1;a n=sum.zipWith(*)(concat.repeat$[1,1,-1,-1]).map p.takeWhile(>=0).map(n-).map(\n->(3*n^2-n)`quot`2)$[1..]>>= \i->[i,-i]

Efficiency improvements

Replace the memoization with an Array instead of a list:

import Data.Array
[...]
bnd = (0,10000)
partitions = (array bnd [(i, partitions' i) | i <- range bnd] !)
[...]

Time for partitions 10000 drop from 17s to 960ms

Results

Interpreted:

partitions 1000
24061467864032622473692149727991
(0.11 secs, 21833064 bytes)

Compiled:

time ./partitions 1000
24061467864032622473692149727991
./partitions 1000  0.08s user 0.00s system 99% cpu 0.084 total

Useful links

The generating function
Generalized pentagonal numbers


Two interwoven chains In this question I defined a "chain" function as a function that:

is a permutation, meaning that every value maps to and is mapped to by exactly one value.
and allows any value can be obtained from any other value by repeated applications of the function or its inverse.

There are a lot of functions that do this and some of them are pretty simple (see the answers on that question).  Now we are going to define a separate class of functions I am going to call "interwoven" functions.  An interwoven function is a function on a set A, that has two infinite partitions a0 and a1 such that the function is a chain function on both a0 and a1.

This means that no value in a0 can map to a value in a1 under the function or vice versa.

Task

Your task is to write a code that performs or defines an interwoven function on the positive integers.  Your function can be anything as long as it satisfies the criteria for being interwoven.  You should include a explanation as to why your function is interwoven in the answer.

This is a code-golf question so answers will be scored in bytes, with less bytes being better.


A well linked challenge An activity I sometimes do when I'm bored is to write a couple of characters in matching pairs.  I then draw lines (over the tops never below) to connect these characters.  For example I might write \$abcbac\$ and then I would draw the lines as:

Or I might write \$abbcac\$

Once I've drawn these lines I try to draw closed loops around chunks so that my loop doesn't intersect any of the lines I just drew.  For example, in the first one the only loop we can draw is around the entire thing, but in the second one we can draw a loop around just the \$b\$s (or everything else)

If we play around with this for a little while we will find that some strings can only be drawn so that closed loops contain all or none of the letters (like our first example).  We will call such strings well linked strings.

Note that some strings can be drawn in multiple ways.  For example \$bbbb\$ can be drawn in both of the following ways (and a third not included):

 or

If one of these ways can be drawn such that a closed loop can be made to contain some of the characters without intersecting any of the lines, then the string is not well linked. (so \$bbbb\$ is not well linked)

Task

Your task is to write a program to identify strings that are well linked.  Your input will consist of a string where every character appears an even number of times, and your output should be one of two distinct consistent values, one if the strings are well linked and the other otherwise.

In addition your program must be a well linked string meaning

Every character appears an even number of times in your program.
It should output the truthy value when passed itself.

Your program should be able to produce the correct output for any string consisting of characters from printable ASCII or your own program.  With each character appearing an even number of times.

Answers will be scored as their lengths in bytes with fewer bytes being a better score.

Hint

   A string is not well linked iff a contiguous non-empty strict substring exists such that each character appears an even number of times in that substring.

Test Cases

abcbac -> True
abbcac -> False
bbbb -> False
abacbc -> True
abcbabcb -> True
abcbca -> False

Regex (ECMAScript 2018 or .NET), 140 126 118 100 98 82 bytes
^(?!(^.*)(.+)(.*$)(?<!^\2|^\1(?=(|(<?(|(?!\8).)*(\8|\3$){1}){2})*$).*(.)+\3$)!?=*)
This is much slower than the 98 byte version, because the ^\1 is left of the lookahead and is thus evaluated after it. See below for a simple switcheroo that regains the speed. But due to this, the two TIOs below are limited to completing a smaller test case set than before, and the .NET one is too slow to check its own regex.
Try it online! (ECMAScript 2018)
Try it online! (.NET)
To drop 18 bytes (118 → 100), I shamelessly stole a really nice optimization from Neil's regex that avoids the need to put a lookahead inside the negative lookbehind (yielding an 80 byte unrestricted regex). Thank you, Neil!
That became obsolete when it dropped an incredible 16 more bytes (98 → 82) thanks to jaytea's ideas which led to a 69 byte unrestricted regex! It's much slower, but that's golf!
Note that the (|( no-ops for making the regex well-linked have the result of making the it evaluate very slowly under .NET. They do not have this effect in ECMAScript because zero-width optional matches are treated as non-matches.
ECMAScript prohibits quantifiers on assertions, so this makes golfing the restricted-source requirements harder. However, at this point it's so well-golfed that I don't think lifting that particular restriction would open up any further golfing possibilities.
Without the extra characters needed to make it pass the restrictions (101 69 bytes):
^(?!(.*)(.+)(.*$)(?<!^\2|^\1(?=((((?!\8).)*(\8|\3$)){2})*$).*(.)+\3))
It's slow, but this simple edit (for just 2 extra bytes) regains all the lost speed and more:
^(?!(.*)(.+)(.*$)(?<!^\2|(?=\1((((?!\8).)*(\8|\3$)){2})*$)^\1.*(.)+\3))
^
(?!
    (.*)               # cycle through all starting points of substrings;
                       # \1 = part to exclude from the start
    (.+)               # cycle through all ending points of non-empty substrings;
                       # \2 = the substring
    (.*$)              # \3 = part to exclude from the end
    (?<!               # Assert that every character in the substring appears a total
                       # even number of times.
        ^\2            # Assert that our substring is not the whole string. We don't
                       # need a $ anchor because we were already at the end before
                       # entering this lookbehind.
    |                  # Note that the following steps are evaluated right to left,
                       # so please read them from bottom to top.
        ^\1            # Do not look further left than the start of our substring.
        (?=
            # Assert that the number of times the character \8 appears in our
            # substring is odd.
            (
                (
                    ((?!\8).)*
                    (\8|\3$) # This is the best part. Until the very last iteration
                             # of the loop outside the {2} loop, this alternation
                             # can only match \8, and once it reaches the end of the
                             # substring, it can match \3$ only once. This guarantees
                             # that it will match \8 an odd number of times, in matched
                             # pairs until finding one more at the end of the substring,
                             # which is paired with the \3$ instead of another \8.
                ){2}
            )*$
        )
        .*(.)+         # \8 = cycle through all characters in this substring
        # Assert (within this context) that at least one character appears an odd
        # number of times within our substring. (Outside this negative lookbehind,
        # that is equivalent to asserting that no character appears an odd number
        # of times in our substring.)
        \3             # Skip to our substring (do not look further right than its end)
    )
)

I wrote it using molecular lookahead (103 69 bytes) before converting it to variable-length lookbehind:
^(?!.*(?*(.+)(.*$))(?!^\1$|(?*(.)+.*\2$)((((?!\3).)*(\3|\2$)){2})*$))
^
(?!
    .*(?*(.+)(.*$))       # cycle through all non-empty substrings;
                          # \1 = the current substring;
                          # \2 = the part to exclude from the end
    (?!                   # Assert that no character in the substring appears a
                          # total even number of times.
        ^\1$              # Assert that our substring is not the whole string
                          # (i.e. it's a strict substring)
    |
        (?*(.)+.*\2$)    # \3 = Cycle through all characters that appear in this
                          # substring.
        # Assert (within this context) that this character appears an odd number
        # of times within our substring.
        (
            (
                ((?!\3).)*
                (\3|\2$)
            ){2}
        )*$
    )
)

And to aid in making my regex itself well-linked, I've been using a variation of the above regex:
(?*(.+)(.*$))(?!^\1$|(?*(.)+.*\2$)((((?!\3).)*(\3|\2$)){2})*$)\1
When used with regex -xml,rs -o, this identifies a strict substring of the input that contains an even number of every character (if one exists). Sure, I could have written a non-regex program to do this for me, but where would be the fun in that?


Decimal “XOR” operator Many programming language provide operators for manipulating the binary (base-2) digits of integers.  Here is one way to generalize these operators to other bases:

Let x and y be single-digit numbers in base B.  Define the unary operator ~ and binary operators &, |, and ^ such that:

~x = (B - 1) - x
x & y = min(x, y)
x | y = max(x, y)
x ^ y = (x & ~y) | (y & ~x)

Note that if B=2, we get the familiar bitwise NOT, AND, OR, and XOR operators.

For B=10, we get the “decimal XOR” table:

^ │ 0 1 2 3 4 5 6 7 8 9
──┼────────────────────
0 │ 0 1 2 3 4 5 6 7 8 9
1 │ 1 1 2 3 4 5 6 7 8 8
2 │ 2 2 2 3 4 5 6 7 7 7
3 │ 3 3 3 3 4 5 6 6 6 6
4 │ 4 4 4 4 4 5 5 5 5 5
5 │ 5 5 5 5 5 4 4 4 4 4
6 │ 6 6 6 6 5 4 3 3 3 3
7 │ 7 7 7 6 5 4 3 2 2 2
8 │ 8 8 7 6 5 4 3 2 1 1
9 │ 9 8 7 6 5 4 3 2 1 0

For multi-digit numbers, apply the single-digit operator digit-by-digit.  For example, 12345 ^ 24680 = 24655, because:

1 ^ 2 = 2
2 ^ 4 = 4
3 ^ 6 = 6
4 ^ 8 = 5
5 ^ 0 = 5

If the operands are different lengths, then pad the shorter one with leading zeros.

The challenge

Write, in as few bytes as possible, a program or function that takes as input two integers (which may be assumed to be between 0 and 999 999 999, inclusive) and outputs the “decimal XOR” of the two numbers as defined above.

Test cases

12345, 24680 → 24655
12345, 6789 → 16654
2019, 5779 → 5770
0, 999999999 → 999999999
0, 0 → 0

Jelly, 14 bytes

DUz0«9_ṚƊṀƊ€UḌ

Try it online!

Grid of all single digit pairs

A monadic link taking a list of two integers as its argument and returning an integer.

Explanation

D               | Decimal digits
 U              | Reverse order of each set of digits
  z0            | Transpose with 0 as filler
          Ɗ€    | For each pair of digits, do the following as a monad:
    «   Ɗ       | - Minimum of the two digits and the following as a monad (vectorises):
     9_         |   - 9 minus the digits
       Ṛ        |   - Reverse the order
         Ṁ      | - Maximum
            U   | Reverse the order of the answer to restore the orignal order of digits
             Ḍ  | Convert back from decimal digits to integer

If a digit matrix is acceptable input/output:

Jelly, 12 bytes

Uz0«9_ṚƊṀƊ€U

Try it online!


Index sum and strip my matrix Index sum and strip my matrix

Given a matrix/2d array in your preferable language

Input:

The matrix will always have an odd length
The matrix will always be perfectly square
The matrix values can be any integer in your language (positive or negative)

Example:

1  2  3  4  5  6  7
2  3  4  5  6  7  8
3  4  50 6  7  8  9
4  5  6 100 8  9  10
5  6  7  8 -9  10 11
6  7  8  9  10 11 12
7  8 900 10 11 12 0

Definitions:

The "central number" is defined as the number that has the same amount of numbers to the left,right,up and down

In this case its middlemost 100

The "outer shell" is the collection of numbers which their x and y index is or 0 or the matrix size

1  2  3  4  5  6  7
2                 8
3                 9
4                 10
5                 11
6                 12
7  8 900 10 11 12 0

Your task:

Add to the central number the sum of each row and column after multiplying the values in each by their 1-based index

A single row for example

4  5  6  7  8

for each number

number * index + number * index.....

4*1 + 5*2 + 6*3 + 7*4 + 8*5 => 100

example:

 2 -3 -9  4  7  1  5  => 61
-2  0 -2 -7 -7 -7 -4  => -141
 6 -3 -2 -2 -3  2  1  => -10
 8 -8  4  1 -8  2  0  => -20
-5  6  7 -1  8  4  8  => 144
 1  5  7  8  7 -9 -5  => 10
 7  7 -2  2 -7 -8  0  => -60
                         |
78 65 60 45 -15 -89 10   => 154
                     |
                     => -16

For all rows and columns you combine these values..
Now you sum these too => 154-16 = 138
You add that number to the "central number" and remove the "outer shell" of the matrix

 0 -2 -7 -7 -7     => -88
-3 -2 -2 -3  2     => -15
-8  4 1+138 -8  2  => 395
 6  7 -1  8  4     => 69
 5  7  8  7 -9     => 26

19 69 442 30 -26

do this untill you end up with a single number

-2 -2 -3     => -15
 4  1060 -8  => 2100
 7 -1  8     => 29

27 2115 5

Add 2114+2147 to 1060
Remove the "outer shell" and get 5321
Now we have a single number left

this is the output!

test cases:

-6

-6

-7 -1  8
-4 -6  7
-3 -6  6

2

 6  7 -2  5  1
-2  6 -4 -2  3
-1 -4  0 -2 -7
 0  1  4 -4  8
-8 -6 -5  0  2

-365

 8  3  5  6  6 -7  5
 6  2  4 -2 -1  8  3
 2  1 -5  3  8  2 -3
 3 -1  0  7 -6  7 -5
 0 -8 -4 -9 -4  2 -8
 8 -9 -3  5  7  8  5
 8 -1  4  5  1 -4  8

17611

-9 -7  2  1  1 -2  3 -7 -3  6  7  1  0
-7 -8 -9 -2  7 -2  5  4  7 -7  8 -9  8
-4  4 -1  0  1  5 -3  7  1 -2 -9  4  8
 4  8  1 -1  0  7  4  6 -9  3 -9  3 -9
-6 -8 -4 -8 -9  2  1  1 -8  8  2  6 -4
-8 -5  1  1  2 -9  3  7  2  5 -6 -1  2
-8 -5 -7 -4 -9 -2  5  0  2 -4  2  0 -2
-3 -6 -3  2 -9  8  1 -5  5  0 -4 -1 -9
-9 -9 -8  0 -5 -7  1 -2  1 -4 -1  5  7
-6 -9  4 -2  8  7 -9 -5  3 -1  1  8  4
-6  6 -3 -4  3  5  6  8 -2  5 -1 -7 -9
-1  7 -9  4  6  7  6 -8  5  1  0 -3  0
-3 -2  5 -4  0  0  0 -1  7  4 -9 -4  2

-28473770

This is a codegolf challenge so the program with the lowest bytecount wins

MATL, 36 34 bytes
tnq?`t&+stn:*sytn2/)+ 7M(6Lt3$)tnq

Input is a 2D array with ; as row separator
Try it online! Or verify all test cases.
Explanation
tnq       % Take input. Duplicate, get number of elements, subtract 1
?         % If greater than 0
  `       %   Do...while
    t     %     Duplicate
    &+    %     Sum matrix with its transpose
    s     %     Sum each column. Gives a row vector
    tn:   %     Vector [1 2 ...] with the same size
    *     %     Multiply element-wise
    s     %     Sum of vector. This will be added to center entry of the matrix
    y     %     Duplicate matrix
    tn2/  %     Duplicate, get half its number of elements. Gives non-integer value
    )     %     Get center entry of the matrix, using linear index with implicit rounding
    +     %     Add center entry to sum of previous vector
    7M    %     Push index of center entry again
    (     %     Assgined new value to center of the matrix
    6Lt   %     Array [2 j1-1], twice. This will be used to remove shell
    3$)   %     Apply row and col indices to remove outer shell of the matrix
    tnq   %     Duplicate, number of elements, subtract 1. Falsy if matrix has 1 entry
          %   End do...while implicitly. The loop is exited when matrix has 1 entry
          % End if implicitly
          % Display stack implicitly


Wait... what was I going to say again? I often forget what I wanted to say when the teacher calls on me to speak. Can you make me a tool to solve this?

Requirements:

The program must loop as follows:

First, take in input
If the input is empty, print the last stored question.
Otherwise, store the input as a question.

Notes:

The input will never be empty if there are no questions stored.

Clarification: The program does not need to store multiple questions. I originally wanted it to store multiple, but I changed it after many people misunderstood the question.

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

Perl, 13 17 14 +1 = 15 bytes
/./?$;=$_:say$

+1 for the -n flag
(saved 4 bytes thanks to @Dada)
As long as the input is not equal to the carriage return, it stores the input in $;.  If it is equal to the carriage return, it prints what's already in $;.
This assumes that all input can be characterized as questions, even if grammatically, they are not such.


Shortest Mirror Quine Challenge Find the shortest mirror quine in a language of your choice.

A mirror quine is a quine whose source code is equal to the reverse of its own source code.

Note:

1) Length of source code should be atleast 2.

2) Quines not allowed are the one whose text can be echoed directly.

Example: Let L' be any language, then a quine with source code like ABBA or ABCBA is a mirror quine.


ASCII art is ready for take-off Task

Given a positive integer n, draw the corresponding rocket.

Examples

From n = 1 to 4 the rockets are below. For your program's output, the trailing newline after a rocket is optional.

  |
 / \
*---*
| o |
| o |
*---*
 /_\

   |
  / \
 /   \
*-----*
| o o |
| o o |
| o o |
| o o |
*-----*
 /___\

    |
   / \
  /   \
 /     \
*-------*
| o o o |
| o o o |
| o o o |
| o o o |
| o o o |
| o o o |
*-------*
 /_____\

     |
    / \
   /   \
  /     \
 /       \
*---------*
| o o o o |
| o o o o |
| o o o o |
| o o o o |
| o o o o |
| o o o o |
| o o o o |
| o o o o |
*---------*
 /_______\

You can check this reference implementation (ungolfed).

This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it... And happy golfing!

PowerShell, 131 117 bytes

param($n)' '*$n+" |"
$n..1|%{" "*$_+"/$(' '*++$i)\";$x="*-$('-'*++$i)*"}
$x
,("| $('o '*$n)|")*$i
$x
" /$('_'*--$i)\"

Try it online!

Line breaks added for clarity, but they could just as easily be ; (it's the same byte count either way).

We're basically brute-force building the rocket one line at a time. We start by taking input $n, then construct a string of $n spaces and the nose antenna. We then loop from $n down to 1, using a triangular number trick with $i to get the appropriate number of middle spaces for the nose cone. Including the construction of the joiner into the loop allows us to re-use ++$i to both create the joiner and increment for our triangular number, saved into $x for later use.

We then use array-multiplication with the comma operator to construct the body of the rocket, then $x onto the pipeline again for the bottom. Finally we output the engine part with the appropriate _ in between.

All of those strings are left on the pipeline, and default implicit output gives us newlines for free.

-14 bytes thanks to VisualMelon.


Write a hello world GUI program that closes itself after three seconds Please read the rules, and the bold areas as well.

Write a program in any language, so long as it has GUI support for a window system (cannot be text-consoles, etc., and must be a GUI/toolkit/window).

The program must say hello world in any manner (splash image, menu bar, status bar, title, video, message box, other widget stuff, etc.), so long as a GUI-compliant window appears and shows this text for three seconds. The person who can code this in the least amount of code used, counted in bytes, will take the cake.

Unix shell, 31 characters

xmessage -timeout 3 hello world

This program requires the xmessage(1) utility from X.Org. It uses the traditional black-and-white X Athena Widgets (Xaw).


Fastest square root of an arbitrary size We do seem to have a fastest square root challenge, but it's very restrictive. In this challenge, your program (or function) will be given an arbitrarily sized nonnegative integer, which is the square of an integer.
Input
You may take input in any normally allowed way, including (but not limited to) an arbitrary sized integer type, string in any base, or list of numbers representing digits.
Output
The allowed output methods are similar to the input ones, they just need to be in a way which can also represent a number of arbitrary size.
Requirements

Your program should theoretically work correctly given any number (which is the square of an integer), assuming the language is capable of this
All submissions should be in either:

A language with an online interpreter that can give (or be trivially modified to give) accurate times, and doesn't time out with your solution
A language with an interpreter/compiler available from the apt package manager, and is less than 1 GiB, in which case it will be run on my Chromebook's Linux VM

If it doesn't take under 20 minutes, I'll just give a good estimate based on the first test cases and time complexity
Built in square root functions are allowed (but boring :p)

Scoring
Your program's score will be the amount of time it takes to find the square root of:

All 4096 perfect squares up to (not including) \$2^{24}\$
A random (but same for all programs) 2048 perfect squares up to \$2^{48}\$
A random (but same for all programs) 1024 perfect squares up to \$2^{144}\$
A random (but same for all programs) 512 perfect squares up to \$2^{1440}\$
A random (but same for all programs) 256 perfect squares up to \$2^{5760}\$
A random (but same for all programs) 128 perfect squares up to \$2^{14400}\$
A random (but same for all programs) 64 perfect squares up to \$2^{86400}\$

UPDATE: The numbers have been made bigger. This is a total of 8128 numbers as inputs, specifically these. Remember that fitting the test cases specifically is a standard loophole. The only part that counts toward the time is the math. I/O and setup can be ignored.

C++, 140 µs
This is a trivial answer that uses GMP, but I’m submitting it anyway to drive home the point that the test cases are way too small.  Scores in the range of literally nanoseconds per input cannot meaningfully be compared.  We need larger test cases for this to be an interesting challenge.

#include <chrono>
#include <gmpxx.h>
#include <iostream>
#include <vector>

int main() {
  std::vector<mpz_class> numbers;
  mpz_class number;
  while (std::cin >> number)
    numbers.push_back(number);
  auto t0 = std::chrono::high_resolution_clock::now();
  for (auto &number : numbers)
    number = sqrt(number);
  auto t1 = std::chrono::high_resolution_clock::now();
  for (const auto &number : numbers)
    std::cout << number << '\n';
  std::cout
      << std::chrono::duration_cast<std::chrono::nanoseconds>(t1 - t0).count()
      << "ns\n";
}

Try it online!


Shortlex predecessor Please note the special scoring for this challenge.

Given a non-empty string made of a-z, output the string immediately before it in the shortlex order.

Shortlex order

We enumerate strings in shortlex order by first listing the strings of length 0, then those of length 1, then length 2, and so on, putting them in alphabetical order for each length. This gives an infinite list of all strings. Said a bit differently, this sorts strings by length, tiebroken alphabetically.

For strings a-z as used in the challenge, this list goes (abridged):

(empty string)
a
b
c
...
z
aa
ab
...
az
ba
bb
...
zy
zz
aaa
aab
...

Scoring

Answers will be compared in shortlex order, with earlier being better.

Like in code golf, fewest bytes wins, but there's a tiebreak for same-length answers in favor of coming first alphabetically. This means that you'll want to further "golf" your answer to use characters with lower code points where this doesn't hurt its length. Characters nearer to the start are more important.

For non-ASCII languages, answers are treated as a sequence of bytes. Use the byte order of the code page to compare characters, not their UTF encoding.

For your answer's header, you can just put the code's length and say when you've outgolfed a same-length answer in the same language. You could also put the code's position in shortlex order if that number is not too long.

Input and output

The input string will be between 1 and 10 characters long, and consist only of letters a-z. As per site defaults, you may do I/O with strings as lists of characters or code points. The letters should be lowercase (code points 97-122).

Test cases

The first output is the empty string.

a ->
c -> b
z -> y
aa -> z
az -> ay
ba -> az
aaa -> zz
zaa -> yzz
golf -> gole
bzaaaaaaaa -> byzzzzzzzz
zzzzzzzzzz -> zzzzzzzzzy

Related: Smaller Strings in Printable ASCII base, Counting in bijective base 62

Haskell, 64, 63, 56, 55 bytes

c is an infinite list of all strings composed of 97..122 in shortlex order.
\x y -> last$fst$span(/=x)y gives the predecessor of x in y

a b=last$fst$span(/=b)c
c=[]:[d++[e]|d<-c,e<-[97..122]]

Try it online!

1 byte saved by using code points: [97..122] vs. ['a'..'z']
9 bytes saved by ovs
1 bytes saved by Laikoni

Shortlex optimality

To get the lowest-ordered version of this code:

Each variable is chosen to be the smallest, front-to-back
The two lines are sorted (' ' < '=')


Golf English – using contractions I have not laughed as much from Stack Exchange content as I have from this. I think you all will enjoy this challenge, as it is inspired by what is over there.

You will write a function or program that is code-golf, i.e. it would have to be as short as you can make it.

Given a text, return (both by any means) the text where you will have contracted as many words as possible according this table.

You shall not pull information from the table, rather you must have all necessary information included in your code.

All default rules ought not to be broken as we will not have any unfair competition.

You need not consider text if it is not capitalized as in the table, so you must not convert you all WOULD not have or You all would not have to y'all'dn't've.

You may match just the good old apostrophe (U+0027) or any nice ones; whatever you want to.

Example input above ↑ and corresponding output below ↓

I'ven't laughed as much from StackExchange content as I've from this. I think y'all'll enjoy this challenge, as 'tis inspired by what's over there.

You'll write a function or program that's code-golf, i.e. it'd've to be as short as you can make it.

Given a text, return (both by any means) the text where you'll have contracted as many words as possible according this table.

You shan't pull information from the table, rather you must've all necessary information included in your code.

All default rules oughtn't to be broken as we'lln't've any unfair competition.

You needn't consider text if it'sn't capitalized as in the table, so you mustn't convert you all WOULD not have or You all would not have to y'all'dn't've.

You may match just the good ol’ apostrophe (U+0027) or any nice ones; whatever you wanna.


Hello, World! (Every other character) Write a program that prints "Hello, World!".
But also, if you take only the first, third, fifth, etc. characters of your program, the resulting program should still print "Hello, World!".

If your program is:

abc
def

It should output "Hello, World!", but so should

acdf

No solutions with fewer than 2 characters.

Python 3, 61 bytes

rant="partisn't"
print(("HHeelllloo,,  WWoorrlldd!!"""[::2]))

Try it online!

Abusing the fact that print is a function in Python 3 :)

The least partisan solution you'll find here on PPCG.

Becomes

rn=print
rn("Hello, World!"[:])


How good am I at CS:GO? Your task is given an input string of the full/short name of a CS:GO (Counter-Strike: Global Offensive, a computer game) rank return an integer from 1-18 representing the rank number. A higher number means you are a higher rank and so "better" at CS:GO.

Input

A string representing either the full name or short name of the CS:GO rank. Your code must be able to handle both cases.

Output

An integer representing the rank number of the given input. You can output in either 0-indexing or 1-indexing as 0-17 and 1-18 respectively.

Test cases:

The test cases use 1 - 18 as the output, just subtract one if you are using 0-indexing. Where SN means short name.

Full name                     SN   -> output

Silver I                      S1   -> 1
Silver II                     S2   -> 2
Silver III                    S3   -> 3
Silver IV                     S4   -> 4
Silver Elite                  SE   -> 5
Silver Elite Master           SEM  -> 6
Gold Nova I                   GN1  -> 7
Gold Nova II                  GN2  -> 8
Gold Nova III                 GN3  -> 9
Gold Nova Master              GNM  -> 10
Master Guardian I             MG1  -> 11
Master Guardian II            MG2  -> 12
Master Guardian Elite         MGE  -> 13
Distinguished Master Guardian DMG  -> 14
Legendary Eagle               LE   -> 15
Legendary Eagle Master        LEM  -> 16
Supreme Master First Class    SMFC -> 17
Global Elite                  GE   -> 18

JavaScript (ES6), 164 150 135 bytes
s=>'GE S1|S2|S3|S4|SE|SEMGN1GN2GN3GNMMG1MG2MGEDMGLE LEMSMFC'.search(s[r='replace'](/[a-z ]/g,'')[r]('IV',4)[r](/I+/,a=>a.length))/3||18

(Saved a bunch of bytes thanks to @Craig Ayre and @Steve Bennett.)
Explanation:
s[r='replace'](/[a-z ]/g,'')[r]('IV',4)[r](/I+/,a=>a.length) converts Full names to the SN equivalents.  It doesn't change SNs.
We then simply index into the array of SNs created by split.
Snippet:

f=
s=>'GE S1|S2|S3|S4|SE|SEMGN1GN2GN3GNMMG1MG2MGEDMGLE LEMSMFC'.search(s[r='replace'](/[a-z ]/g,'')[r]('IV',4)[r](/I+/,a=>a.length))/3||18

console.log(f('Silver I'));                      // S1   -> 1
console.log(f('Silver II'));                     // S2   -> 2
console.log(f('Silver III'));                    // S3   -> 3
console.log(f('Silver IV'));                     // S4   -> 4
console.log(f('Silver Elite'));                  // SE   -> 5
console.log(f('Silver Elite Master'));           // SEM  -> 6
console.log(f('Gold Nova I'));                   // GN1  -> 7
console.log(f('Gold Nova II'));                  // GN2  -> 8
console.log(f('Gold Nova III'));                 // GN3  -> 9
console.log(f('Gold Nova Master'));              // GNM  -> 10
console.log(f('Master Guardian I'));             // MG1  -> 11
console.log(f('Master Guardian II'));            // MG2  -> 12
console.log(f('Master Guardian Elite'));         // MGE  -> 13
console.log(f('Distinguished Master Guardian')); // DMG  -> 14
console.log(f('Legendary Eagle'));               // LE   -> 15
console.log(f('Legendary Eagle Master'));        // LEM  -> 16
console.log(f('Supreme Master First Class'));    // SMFC -> 17
console.log(f('Global Elite'));                  // GE   -> 18

console.log(f('S1'));
console.log(f('S2'));
console.log(f('S3'));
console.log(f('S4'));
console.log(f('SE'));
console.log(f('SEM'));
console.log(f('GN1'));
console.log(f('GN2'));
console.log(f('GN3'));
console.log(f('GNM'));
console.log(f('MG1'));
console.log(f('MG2'));
console.log(f('MGE'));
console.log(f('DMG'));
console.log(f('LE'));
console.log(f('LEM'));
console.log(f('SMFC'));
console.log(f('GE'));


Convert C header names to C++ header names In the C standard library, header names end with a .h suffix:

stdio.h

In C++, those header names are available in an alternative form, with a c prefix instead:

cstdio

Write a function that converts the first form into the second. You can do the conversion in-place, or leave the original string intact and return a new string. Whatever feelds natural in your language of choice.

The code must be compiled/interpreted without errors. Compiler warnings are acceptable.

Here is your baseline C solution. It has 70 characters and generates a warning about strlen:

void f(char*h){int i=strlen(h);h[--i]=0;while(--i)h[i]=h[i-1];*h='c';}

The shortest solution (measured in number of characters) wins.

Update: If your language of choice does not support functions, whole programs are also acceptable.

Update: As suggested by FUZxxl, here is a complete list of the header files in the C standard library:

assert.h
ctype.h
errno.h
float.h
limits.h
locale.h
math.h
setjmp.h
signal.h
stdarg.h
stddef.h
stdio.h
stdlib.h
string.h
time.h

Specifically, there are no header names with multiple dots in them.

80386 machine code, 13 bytes

Hexdump of the code:

b0 63 86 01 41 3c 2e 75 f9 c6 01 00 c3

Source code (can be compiled by Visual Studio):

__declspec(naked) void __fastcall conv(char s[])
{
    _asm {
        mov al, 'c';            // b0 63
    myloop:
        xchg al, [ecx];         // 86 01
        inc ecx;                // 41
        cmp al, '.';            // 3c 2e
        jne myloop;             // 75 f9
        mov byte ptr [ecx], 0;  // c6 01 00
        ret;                    // c3
    }
}

It converts the string in-place. The code is so simple, it doesn't need to save and restore registers (using only al and ecx, which the fastcall convention allows to clobber).


Fastest draw in the west! We're going rootin' tootin' cow-poke shootin!
This is a simple contest, first program to draw their pistol wins.
How it works:

I require 2 things from you, an executable, and a command to be run
from a bash terminal.
The executable needs to do one thing: wait
until it receives 'draw!' from STDIN, and then print 'bang!' as fast
as possible, and exit.
The executable can do anything else in the
meantime, even print to STDOUT, as long as it doesn't print 'bang!',
or feed itself from STDIN. It also can't use a standard loophole.
Printing 'bang!' early, or exiting without printing 'bang!' is not allowed (you'll be one dead son of a gun).
Bash, and other sh derivatives, including sh scripts are not allowed, we don't settle things on native land.

How I measure your boot size:

Using the golang runtime, I shall execute your command 1,000 times, the time it takes after feeding 'draw!' into STDIN to print 'bang!' will be your score, within +/- 2 nanoseconds. Your program will be given 500ms(+/-100ms of randomness) to stabilize, and load into memory. The program shall be run on ubuntu 20.04 server with only the necessary components to run your program installed.
There will be the following categories: Max time, Min time, Avg time, and Median time, all with lower times being the best.

At the end of the month, the fastest gun in the wild west will be chosen. Best of luck!

section .text

global _start

_start:
  xor r8, r8
  xor r9, r9
  xor r10, r10

_do_while:

_getchar:
  cmp r9, r10

  jne _getchar_done

_getchar_read_buffer:
  xor r9, r9

  xor eax, eax
  xor edi, edi
  mov rsi, in_buf
  mov rdx, inbuf_maxlen

  syscall

  mov r10, rax

_getchar_done:
  mov al, [in_buf + r9]
  inc r9

_do_while_cont:
  cmp al, [req + r8]

  jne _reset

_increment:
  inc r8

  cmp r8, 5

  jne _do_while

  mov rax, 1
  mov rdi, 1
  mov rsi, ans
  mov rdx, 5

  syscall

_end:
  mov rax, 60
  xor rdi, rdi

  syscall

_reset:
  xor r8, r8

  cmp al, 'd'

  jne _do_while

  inc r8

  jmp _do_while

section .rodata
  inbuf_maxlen equ 1000000

  req db "draw!"

ALIGN 8
  ans db "bang!"

section .bss
  in_buf resb inbuf_maxlen

A little hand-written assembly. Compile with:
nasm -felf64 foobar.s && ld foobar.o -o foobar

Edit: move in_bi into a register and use xor.
Edit: used the wrong jump, my code was wrong...
Edit: the previous code had a bug where it would read garbage if the read syscall did not return a full buffer. This version is more efficient (and correct)...
Edit: make sure to process ddraw! correctly. Thanks to Anders Kaseorg for the test case.
Edit: re-structure to move getchar out of a function and to jump less.
Edit: don't xor the high bits of the registers at the suggestion of Cody Gray
Edit: align (thanks to Joshua) and move into .rodata