0xDEADBEEF is not tasty, but still 0xFEEDBEEF Inspired by "You had me at hello"
Introduction
For those who don't know, hexadecimal is a base system like decimal. Contrary to decimal however, it uses 16 (hence the name) digits instead of 10.
Here are the first few numbers while counting up in hexadecimal to maybe give you a feel of things, although you should probably google it for more info.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 1C, 1D, 1E, 1F, 20...
From now on I'll refer to hexadecimal as hex.

Challenge
Take a possibly infinite stream of bytes, and convert it to hex. This should be done as you read since you might get an infinite stream and keep on reading forever.
The twist, is that if a sequence of converted numbers equals the exact hex number DEADBEEF (3735928559 in decimal), you must output FEEDBEEF (4276993775 in decimal) instead.
If no DEADBEEF is found, print the string as it was
Inter-character matches work too, so 2D EA DB EE F0 works and should be converted to 2F EE DB EE F

Example
This might seem a bit vague, so here are 2 step-by-step examples.
Example 1
Input: Hello, World (bytes represented as string)

Step 1: Convert the input to ASCII: 072 101 108 108 111 044 032 087 111 114 108 100
Step 2: Convert the ASCII to hex: 48 65 6C 6C 6F 2C 20 57 6F 72 6C 64
Step 3: Print out everything until DEADBEEF is found. It wasn't found, so just print Hello, World again.

Example 2
Input: Hello,Þ¾ï,,

Step 1: Convert to ASCII: 72 101 108 108 111 44 222 173 190 239 44 44
Step 2: Convert to hex: 48 65 6C 6C 6F 2C DE AD BE EF 2C 2C
Step 3: Is there DEADBEEF? Yep. so take everything up to it. 48 65 6C 6C 6F 2C
Step 4: Append FEEDBEEF to it. 48 65 6C 6C 6F 2C FE ED BE EF
Step 5: Convert back to a string and print it. Output is Hello,þí¾ï

Scoring
Try to make a program that does the above in the fewest bytes of source code as possible.

Remember!
Make sure your program works for finite and infinite streams. The stream can be STDIN, file, function argument (if you can pass streams as arguments), or your language's closest alternative. Output is to STDOUT or function returning (if you can return streams).
More test cases (contain invisible characters)
eeþí¾Þ¾ïe (6565feedbedeadbeef65) -> eeþí¾þí¾ïe
Þ¾ï (deadbeef)-> þí¾ï
Þ=êÛîôV -> Þ?îÛîôV

Python 3, 121 bytes

I=open(0).read
p=print
x=i=I(1)
while i:p(end=x[:-4]);x=x[-4:];x!='Þ¾ï'or+p(end='þí¾ï');i=I(1);x+=i
p(end=x[:5])

Try it online!


Chris Pine's "Deaf Grandma" I'm a mentor at RubyLearning and one of the exercises we give to our students is the "Deaf Grandma" exercise from Chris Pine's book "Learn to Program". Here's the description:

  Write a Deaf Grandma program. Whatever you say to grandma (whatever
  you type in), she should respond with:
  "Huh?! Speak up, sonny!", unless you
  shout it (type in all capitals). If
  you shout, she can hear you (or at
  least she thinks so) and yells back:
  "No, not since 1938!"

  To make your program really believable, have grandma shout a
  different year each time; maybe any
  year at random between 1930 and 1950.
  (This part is optional, and would be
  much easier if you read the section on
  Ruby's random number generator at the
  end of the methods chapter.) You can't
  stop talking to grandma until you
  shout "BYE".

After several course iterations I tried to see how small I can get this and now have it down to 112 characters:

puts (s||='').upcase==s ? "NO, NOT SINCE #{1930+rand(21)}!":"HUH?! SPEAK UP, SONNY!" until(s=gets.chomp)=="BYE"

I'm curious to see in how few characters this can be achieved in the language of your choice, because I think Ruby is already doing really well here.

Edit: The Perl solution posted below led to

ruby -nle 'puts($_=="BYE"?exit: $_.upcase!? "HUH?! SEPAK UP, SONNY!":"NO, NOT SINCE #{1930+rand(21)}!")'

which is 92 characters for the expression + 2 more for the n and l options.

Perl, 85 91

Run with perl -nE '<code goes there>' (n counted in program size):

$==1930+rand 21;say/^BYE$/?last:uc eq$_?"
NO, NOT SINCE $=!":"HUH?! SPEAK UP, SONNY!"

That trailing exclamation mark is very expensive...

Edits suggested by IK:

Using a regexp instead of a string match spares the -l global option as well as two program characters: -3.
Using an actual variable to save a value and use it later for interpolation (Genius! Who'd have thought of using a variable for that?): 0.
Making that variable $=, constrained to be an integer: -4.

(and it still doesn't add up and I'm too sleepy to find out why.  Oh well, the final count is right at least)


Teach me how to add! Everyone knows how to add numbers by hand, right?––Well, I hope so, but for anyone who needs a quick reminder:

To add 17282 and 1342, you proceed as follows:

place the larger (value wise, not number of digits) number above the smaller number and match up the digits

17282
 1342

draw the plus sign (+) to the left of the equation on the second row. The plus sign must be flush with the left side.

 17282
+ 1342

draw a line of dashes (-) with one dash in each column of the digits of the first line

 17282
+ 1342
 -----

evaluate the expression and write the digits above each column if you need to 'carry' them

   1
 17282
+ 1342
 -----
 18624

Your output is what you get after applying step #4. You may have trailing whitespace, but there may not be any leading zeroes.

You must write a program or a function that prints or returns the output.

The input can be taken as either two separate inputs or an array with two items; the type of the inputs can be either string or integer.

This is code golf so shortest code in bytes wins!

Edit:

The largest number you could expect to receive as output/the sum is the largest integer that your system will display without exponents (thanks to Adám).

More examples:

Input:
1596, 8404
Output:
1111
 8404
+1596
 ----
10000

Input:
1776, 76
Output:
  11
 1776
+  76
 ----
 1852

Input:
123, 456
Output:
 456
+123
 ---
 579

Dyalog APL, 90 bytes

{⌽↑(⊂⌽s),⍨↓⌽(' + ',⍨' 1'⊃⍨l<⍴s),'-'⍪⍨w⍪⍨' 1'[10|(⍎¨(-l←⍴⍉w)↑s←⍕+/⍵)-(+/0 10⊤⍎)¨⊂[0]w←⍕⍪⍵]}

Takes list of two numbers as argument. Needs ⎕IO←0 which is default on many systems.

      f←{⌽↑(⊂⌽s),⍨↓⌽(' + ',⍨' 1'⊃⍨l<⍴s),'-'⍪⍨w⍪⍨' 1'[10|(⍎¨(-l←≢⍉w)↑s←⍕+/⍵)-(+/0 10⊤⍎)¨⊂[0]w←⍕⍪⍵]}
      f¨(17282 1342)(1596 8404)(1776 76)(123 456)
┌──────┬─────┬─────┬────┐
│   1  │1111 │  11 │    │
│ 17282│ 1596│ 1776│ 123│
│+ 1342│+8404│+  76│+456│
│ -----│ ----│ ----│ ---│
│ 18624│10000│ 1852│ 579│
└──────┴─────┴─────┴────┘

TryAPL online! Note that ⎕IO has been set and ⍎ has been emulated with e as ⍎ is banned from TryAPL for security reasons.

Ungolfed and explained

  { An anonymous function

    w ← ⍕ ⍪⍵ w gets the textified vertical arrangement of the argument
    (the numbers to be added)

    l ← ≢ ⍉w s gets the count of rows in the transposed w (i.e. the
    number of columns in w)

    s ← ⍕ +/⍵ s gets the textified sum of the argument

    ' 1'[... index into the string " 1", so zeros give spaces, and ones
    give character 1s.

      ⊂[0] w enclose down, gets list of pairs of corresponding digits in
      the numbers

      (+/ 0 10 ⊤ ⍎)¨ for each pair; make into digit(s), then sum

      (⍎¨ (-l) ↑ s)- chop left-most digit of grand total to the width of
      the longest input, then make each character into separate number and
      subtract the column sums (if the sum does not add up to the total, the
      discrepancies are due to carrys, so this gives us each column's carry)

      10| division remainder when divided by 10

    ] [end of indexing]

    w⍪⍨ stack the input numbers below

    '-'⍪⍨ stack a minus below each column

    (' + ',⍨' 1'⊃⍨l<⍴s), prepend a space to the 2nd line, a
    plus to the 3nd, a space to the 4rd, and a one
    or space to the 1st – depending on if the sum is wider than
    the widest input (meaning we need a carry high over the plus )

    ⌽ mirror right-left (so left-justification will be to the right)

    ↓ make table into list of lines (so that differing line lengths are
    allowed

    (⊂⌽s),⍨ append the sum

    ↑ combine list of lines into table (padding the right with spaces as
    needed)

    ⌽ mirror back to normal

  } [end of function]`


Be respectful in the restroom Of course, the SE network is very knowledgeable about how to be respectful in the restroom, but for those of you who need a recap, being respectful means flushing the toilet, etc. Most importantly, though, it means using the stall as far away from others as possible.

The challenge

Given a blueprint of a set of stalls with indications of which ones are in use as a string, you must return or print from a function or program where the most respectful place to do your business is.

The input

 0 1 2 3 4 5    <- The stall number which is not actually visible in the input.
| | |-| |-|-|   <- the stalls

The stalls are numbered in ascending order from left to right. There will always be at least one empty stall. There can be up to 50 stalls in an input. You can also take the input as an array or string of 0s and 1s or booleans if you prefer to do so.

Stalls in use have - in them (in between the pipes).

The output

The most respectful stall to go to is the one that is on average farthest away from the ones in use. The distance between two stalls is the absolute value of the difference of the numbers above them.

Just to be clear: you are finding the average distance from all of the stalls—not just the neighboring ones.

You must output the lowest number of the most respectful stall to go to that is empty.

Examples

Input:
|-| |-| OR 101
Output:
1

Input:
| | |-| |-|-| OR 001011
Output:
0

Input:
|-| |-| | | | |-|-| OR 101000011
Output:
1

Input:
|-| | | | | |-|-| | | | | OR 100000110000
Output:
11

Input:
|-|-|-|-| | | | | | |-| OR 11110000001
Output:
9

Input:
|-| | OR 10
Output:
1

Input:
|-| | |-| OR 1001
Output:
1

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

You can use 0 or 1 based indexing in your answer — whichever you prefer; if you use 1 based indexing, then you must say so explicitly in your answer.

Jelly, 10 9 bytes

JạþTS×¬MḢ

Uses 1-based indexing. Try it online! or verify all test cases.

How it works

JạþTS×¬MḢ  Main link. Argument: A (array of Booleans)

J          Yield all indices of A.
   T       Yield all truthy indices of A.
 ạþ        Compute the table of absolute differences.
    S      Compute the sums of all columns.
           For each index, this yields the sum of all distances to occupied stalls.
     ×¬    Multiply each sum by the logical NOT of the corresponding Boolean in A.
           This zeroes sums that correspond to occupied stalls.
       M   Maximal; yield an array of all indices of maximal sums.
        Ḣ  Head; extract the first index.


Shortening str.replace() In Python it is often necessary to use str.replace(a,b), however .replace is rather long and feels unnecessary. So is there a shorter alternative to str.replace.

Alternatively is there a similar trick to how you can use r=range for golfing for str.replace?

Example code for golfing

m=input()
f="hello"
print m.replace('t','Ushd')
print m.replace('h','gyhj')
print f.replace('o','%£&')

r=str.replace;print r('abc','b','c')

The magic is real.

Shortening str.replace()


Write a Vim command that reads as English text Once you grok vi, your muscle memory learns tricks like ggVGx to delete all the text in a file. Trouble is, ggVGx is not an English word, so it makes a terrible mnemonic.
This challenge is about constructing a single Vi[m] command that can be reasonably read as an English word, phrase or sentence. One point per letter.
Modifier keys such as meta/alt, control, and shift should be written as they are in VimScript, e.g. <C-c> so we can read them, but will be pronounced as two consecutive letters: cc, for a score of 2.
Vim commands that start with : are only count toward your scrore if they build a word out of non-words.  So :%s/aword/anotherword/gi would only add 3 to your score, for sgi (and only then if sgi is part of an actual English word or phrase, such as hasgills. Similarly :help would add zero to your score.
No user-defined mappings. Your answer should work on a fresh install of Vim with no .vimrc or other gizmos.
Finally, the command has to do something other than throw an error.
Example Entry:
cap  (3)
cap, change a paragraph

Score 60

:s/foo/bar/incerepellingliceingreeceIgrillripeninggreenpepperinniceice

  since repelling lice in Greece I grill ripening green pepper in nice ice

You can repeat flags arbitrarily in the :s command so this can get as long as you care to come up with a sentence/phrase/word using only the letters c,e,g,i,I,n,p,l,r and starting with an s.


Tips for golfing in Perl? What general tips do you have for golfing in Perl? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Perl (e.g. "remove comments" is not an answer). Please post one tip per answer.

TMTOWTDI

That's the most important Perl golfing tip you need to know. Whenever you're looking at some too-long sequence of characters you absolutely have to have in order to accomplish your task, ask yourself if there isn't some other way to get the same effect using a different feature. There usually is. Here are just a handful:

~~ enforces a scalar context and is 4 chars shorter than scalar.
y///c is one char shorter than length when getting the length of $_.
Need to iterate over the chars in $_? Replace split// with /./gs. (Or use /./g if you also want to skip newlines.) This works with other variables: replace split//,$x with $x=~/./gs.
Every Perl builtin returns something. print returns 1, for example, to indicate successful I/O. If you need to initialize $_ to a true value, for example, $_=print$foo allows you to kill two birds with one stone.
Almost every statement in Perl can be written as an expression, allowing it to be to used in a wider variety of contexts. Multiple statements can be become multiple expressions chained together with commas. Tests can be done with short-circuiting operators ?: && ||, and also with and and or, which do the same thing but with precedence lower than all other operators (including assignment). Loops can be done via map or grep. Even keywords like next, last and return can be used in an expression context, even though they don't return! Keeping these kinds of transformations in mind give you opportunities to replace code blocks with expressions that can be stuffed into a wider variety of contexts.


The Double Slit Experiment A lazy physicist has the job to perform the double slit experiment. However, they are lazy and can't be bothered to set up all the equipment themselves and so are going to simulate the effects. They can't program though so are going to need some help. As they are lazy your program should be as short as possible.

Given an odd positive integer n (n >= 1 and n % 2 == 1), perform the simulation.

How it works

You will start off with an empty canvas and each frame a single particle of light will go through the slits and land on the canvas. The particle will land at a maxima with a chance of:

n = 1:

+-----+
|     |
| 1/2 |
|     |
+-----+

n = 3:

+-----+ +-----+ +-----+
|     | |     | |     |
| 1/4 | | 1/2 | | 1/4 |
|     | |     | |     |
+-----+ +-----+ +-----+

n = 5:

+-----+ +-----+ +-----+ +-----+ +-----+
|     | |     | |     | |     | |     |
| 1/8 | | 1/4 | | 1/2 | | 1/4 | | 1/8 |
|     | |     | |     | |     | |     |
+-----+ +-----+ +-----+ +-----+ +-----+

etc.

For example for n=5 we check the middle box, there's a 50% chance of falling in it. If it falls end of frame, if not move to the next two, there's a 25% chance of falling in those. If it falls end of frame, if not move to the next two, there's a 12.5% chance of falling in those. If it doesn't fall it doesn't matter, it's still the end of the frame.

There has been some confusion over how to calculate the chances, most of this is due to people thinking of them as probabilities that should add up to 1. Remove that idea from your mind and it should clear it up a bit for you.

At most one particle will lad per frame, this means a particle may not land at all on that frame.
A particle can be represented by any printable character.
The particle will land anywhere in the box with a random chance.
The width of the boxes should be 2n-1 the size of the canvas. So for n=5 they should be 1/9th of the canvas's width.
The height of the boxes should be the height of the canvas.
The particle should not land outside of the boxes at all.
If a particle has already landed at a spot that is chosen that doesn't matter it can land there again.
The above ascii boxes are for clarity, they should not be drawn.
You may choose your own canvas size as long as it is reasonable. For example, it mustn't just be a few pixels high. It also should be able to fit all of the boxes on it.
If your code sleeps between frames you do not need to add that into your byte count.

There should be gaps between each of the maxima, a minima. This should be the same width as a box but no particles will land there. See the following diagram:

+---+---+---+---+---+
|   |   |   |   |   |
|max|min|max|min|max|
|   |   |   |   |   |
+---+---+---+---+---+

The program should run until it is stopped manually.

Rules

A pseudo random number generator (pRNG) is fine.
Standard loopholes are forbidden.
Input may be taken by any reasonable format.
You should output to STDOUT.
This is code-golf so the shortest answer wins.

Example

The following GIF is an example run for n = 5. I only knocked it up quickly so the chances may be off slightly.

BASH, 396 - 11 = 385 bytes

E='echo -en';$E "\e[2J\e[99A";while :;do sleep 0.01;for i in `seq $((($1+1)/2)) -1 1`;do p=$(((($1+1)/2 - $i)));[ $p -lt 0 ]&&p=$((-$p));p=$((2**(p+1)));if [ $RANDOM -lt $((32768/$p)) ];then [ $(($RANDOM%2)) -eq 1 ]&&i=$((($1+1)-i));sector=$(((i*2-1)-1));C=`tput cols`;R=`tput lines`;SS=$((C/($1*2-1)));SX=$((SS*sector));X=$((SX+(RANDOM%SS)));Y=$((RANDOM%R));$E "\e[$Y;${X}H*";break;fi;done;done

Unfortunately I cannot demonstrate this on TryItOnline because of the endless loop & ANSI escape sequences that move cursor, but you can still copy-paste it into your terminal!

Unminified version:

E='echo -en'
$E "\e[2J\e[99A"

while :
do
    sleep 0.01
    for i in `seq $((($1+1)/2)) -1 1`
    do
        p=$(((($1+1)/2 - $i)))
        [ $p -lt 0 ] && p=$((-$p));
        p=$((2**(p+1)))
        if [ $RANDOM -lt $((32768/$p)) ]
        then
            [ $(($RANDOM%2)) -eq 1 ] && i=$((($1+1)-i));
            sector=$(((i*2-1)-1))
            C=`tput cols`
            R=`tput lines`
            SS=$((C/($1*2-1)))
            SX=$((SS*sector))
            X=$((SX+(RANDOM%SS)))
            Y=$((RANDOM%R))
            $E "\e[$Y;${X}H*"
            break
        fi
    done
done


Possible periods of input Background:
Take this input as an example:
1 1 2 1 1 2 1 3 1 3

If you look only at the first few digits, between 1 1 2 and 1 1 2 1 1 2 1, this input appears to consist of the pattern 1 1 2 repeating indefinitely. This would make its period 3, as there are 3 numbers in the pattern.
Given only the first number, the period appears to be 1, as only the number 1 is in the input. Given the first two numbers, it still appears to be the number 1 repeating, so the period does not change.
Task:
Given an array of numbers (or strings, or similar), determine the period of each prefix of the array, and return the unique ones. For example, the above input would have periods of:
1 1 3 3 3 3 3 8 8 10

Thus, the output would be:
1 3 8 10

I/O:
Input should be an array of any set of a large number of different values. For example, numbers, strings, natural numbers, or pairs of integers. Booleans wouldn't be allowed, but chars/bytes would.
Output can be any reasonable representation of the numbers, such as an array/list, or a string with the numbers joined by newlines.
Test cases:
1                     ->  1
1 2 1 1 2 1           ->  1 2 3
1 1 2 1 1 2 1         ->  1 3
1 2 1 2 1 2 1 2 4     ->  1 2 9
1 2 3 4 1 2 3 1 2 1   ->  1 2 3 4 7 9
4 4 4 4 4 4 4 4 4 4   ->  1

R, 88 82 81 bytes

unique(Map(function(i)Find(function(j)all(a[1:i]==a[1:j]),1:i),seq(a=a<-scan())))

Try it online!
Thanks to Giuseppe for fixing a mistake and -6 bytes.


Upside-Down Pyramid Addition...REVERSED! Upside-Down Pyramid Addition is the process of taking a list of numbers and consecutively adding them together until you reach one number.

When given the numbers 2, 1, 1 the following process occurs:

 2   1   1
   3   2
     5

This ends in the number 5.

YOUR TASK

Given the right side of an Upside-Down Pyramid (Ascending), write a program or function that will return the original list.

New Extra Challenge: Try doing this in less than O(n^2)

EXAMPLE

f([5, 2, 1]) => [2, 1, 1]
f([84,42,21,10,2]) => [4,7,3,8,2]

NOTE: The Upside-Down Pyramid will never be empty and will always consist of positive integers ONLY.

JavaScript (ES6),  62 58 49  46 bytes
Saved 3 bytes thanks to @Oliver
Returns the list as a comma-separated string.

f=a=>+a||f(a.map(n=>a-(a=n),a=a.shift()))+[,a]

Try it online!
Commented
f = a =>              // f = recursive function taking the input list a[]
  +a                  // if a[] consists of a single positive integer:
                      //   stop recursion and return this integer
  ||                  // else:
    f(                //   do a recursive call to f:
      a.map(n =>      //     for each value n in a[]:
        a - (a = n),  //       yield the difference between the previous value and n
                      //       and update a to n
        a = a.shift() //       start by removing the first element and saving it in a
                      //       (because of the recursion, it's important here to reuse
                      //       a variable which is defined in the scope of f)
      )               //     end of map()
    )                 //   end of recursive call
    + [, a]           //   append the last entry from a[]


n-th term of the rise & reset sequence (Challenge taken from a multiplayer game (clash of code) at codingame.com)

The challenge

Find the n-th term of the following sequence: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4... or, to make it more obvious, {1}, {1,2}, {1,2,3}, {1,2,3,4}...

The sequence is made up from concatenated ranges from 1 to x, starting from 1, all the way up to infinity.

Rules / IO

Input and output can be in any format, as long as it's distinguishable. Input can be taken from any appropriate source: STDIN, file, etc...

The input can be 0- or 1-indexed, and the selected indexing must be mentioned in the post.

You will have to handle at least up to a result of 255 inclusive (meaning the 0-indexed maximum input is 32640). Anything over that has to be handled, if your language supports it.

This is code-golf so the shortest byte count wins!

Test cases (0-based indexing)

0 -> 1
1 -> 1
5 -> 3
10 -> 1
59 -> 5
100 -> 10
1001 -> 12

Haskell, 27 26 bytes

([z|k<-[1..],z<-[1..k]]!!)

Try it online!

Thanks @DanD. for -1 byte!

This is an anonymous function, creating the infinite sequence an just returning the n-th element thereof: [[1..k]| k<-[1..]] produces an infinite list of list: [[1],[1,2],[1,2,3],[1,2,3,4],...]. To concatenate these we can write [z|k<-[1..],z<-[1..k]] which results in [1,1,2,1,2,3,1,2,3,4,...] and finally (...!!) accepts the input n (pointless notation) and returns the n-th term (0-based).


Is this a truncated triangular number? Related OEIS sequence: A008867

Truncated triangular number

A common property of triangular numbers is that they can be arranged in a triangle. For instance, take 21 and arrange into a triangle of os:

     o
    o o
   o o o
  o o o o
 o o o o o
o o o o o o

Let's define a "truncation:" cutting triangles of the same size from each corner. One way to truncate 21 is as follows:

     .
    . .
   o o o
  o o o o
 . o o o .
. . o o . .

(The triangles of . are cut from the original).

There are 12 os remaining, so 12 is a truncated triangle number.

Task

Your job is to write a program or a function (or equivalent) that takes an integer and returns (or use any of the standard output methods) whether a number is a truncated triangle number.

Rules

No standard loopholes.
The input is a non-negative integer.
A cut cannot have a side length exceeding the half of that of the original triangle (i.e. cuts cannot overlap)
A cut can have side length zero.

Test cases

Truthy:

0
1
3
6
7
10
12
15
18
19

Falsy:

2
4
5
8
9
11
13
14
16
17
20

Test cases for all integers up to 50: TIO Link

This is code-golf, so submissions with shortest byte counts in each language win!

Haskell, 46 45 bytes

f n|t<-scanl(+)0[1..n]=or[x-3*y==n|x<-t,y<-t]

Try it online!


Professor Schwartzman's Acme Canine Decoder 2000 Introduction
We -- especially the geeks among us, who tend to be fans -- all remember this old Far Side cartoon:

Clearly, Professor Schwartzman could have brushed up on his programming skills just a wee bit more before he put his invention to use. But can you replicate it yourself... using as few bytes as possible?
Input Specs
You must create a script that translates dog sounds into appropriately intonated "Hey"s. This is pure code golf; the lowest number of bytes wins.
Your input will consist of some combination of the following tokens:

Bark, Baark, Baaark, Baaaark, ... (that is, B*rk  with at least 1 a replacing the asterisk)
Woof, Wooof, Woooof, ... (W*f with at least 2 os replacing the asterisk)
Grr, Grrr, Grrrr, ..., (G followed by at least 2 rs)
Any number of . (period), ! (exclamation mark) and/or ? (question mark) characters, which may occur anywhere in the input

Note, again, that the Woof-based and Grr-based tokens always require at least two os and rs respectively; Wof and Gr are not valid tokens.
There is no limit on how long a token can be (e.g., how many repeated as there can be in a Bark token); however, your decoder only needs to work correctly for input tokens with up to 10 total as, os, or rs to pass this challenge.
Output Specs
Faithful to Schwartzman's design, your canine decoder program must process it into output text as follows:

Bark, Woof, and Grr become Hey;
Baark, Wooof, and Grrr become Heyy;
Baaark, Woooof, and Grrrr become Heyyy; etc.
For all Bark-based tokens, the number of ys in the output Hey-based token must be equal to the number of as;
For all Woof-based tokens, the number of ys in the output Hey-based token must be one less than the number of os;
For all Grr-based tokens, the number of ys in the output Hey-based token must be one less than the number of rs;
All punctuation (., !, and ?) is left unchanged.

Remember to drop one y from the output for Woofs and Grrs only! The input Baaaaaaaark?, with 8 as, will become Heyyyyyyyy?, with a matching set of 8 ys. However, Woooooooof? becomes only Heyyyyyyy?, with 7 ys.
Again, if you can get your program to work for input tokens of unlimited size, that's great, but for purposes of this challenge, your program will only be checked to ensure that it works properly for input tokens that have no more than 10 repeated letters.
All Bark-, Woof-, and Grr-based tokens in your input are assumed to begin with capital letters. Therefore, there is no need to handle turning Bark grrr into Hey heyy or anything similar.
Example Inputs and Outputs

Input: Bark. Bark! Bark!!
Output: Hey. Hey! Hey!!

Input: Baaaaaark? (six as)
Output: Heyyyyyy? (six ys)

Input: Grrrrrrrr... (eight rs)
Output: Heyyyyyyy... (seven ys)

Input: ?...!
Output: ?...!

Input: Wooof Woof? Grrrr. Baaaark Grr!
Output: Heyy Hey? Heyyy. Heyyyy Hey!

Retina, 24 18 17 16 bytes

1 byte saved based on an idea in MT0's answer.

\wf?k?
y
\byy
He

Try it online!

Explanation

\wf?k?
y

This simply turns all letters into y, but if they are followed by an f or k we immediately replace that as well. By removing f and k we "normalise" the lengths of the words so that they now all have two more ys than they need.

\byy
He

This turns the first two y of every word into He, completing the transformation.


Print all the ways to aquire specific number using only specific numbers Let's say we have some arbitrary number:

For example 25. We also have some "tokens" (poker chips, money, something similar) with different values.

Values of tokens are
2; 3; 4; 5.

"Tokens" are limitless

You need to achieve number 25 using exactly n tokens (for example, 8) and to output all possible ways of doing so.

Fragment of example expected output (25 with 8 tokens):

3 '5' tokens, 5 '2' tokens
2 '5' tokens, 1 '4' token, 1 '3' token, 4 '2' tokens
....
1 '4' token, 7 '3' tokens

You may output in any reasonable, non-ambiguous format. For instance, 3 '5' tokens, 5 '2' tokens can be represented as a single list [5,0,0,3] or as a list of tuples [[3,5],[5,2]]. And if there's no solution, you can provide empty output (or state no solution found or something among the lines)

Standard code golf rules apply, so winner is decided by shortest byte count (though you have to also provide "commented" version of your code, especially for languages such as Brainfuck, Jelly, Piet and so on)

Edit:
 I intended this challenge as challenge with fixed tokens, but I like universal answers more then "niche" ones even if it's not specified in challenge itself initially. As long as making tokens "third input parameter" still provides correct answer for tokens provided it's accepted for this challenge. If you are willing to rewrite your code - go on, save those precious bytes/chars.

Jelly, 10 bytes

ŒṗfƑƇL=¥Ƈ⁵

Try it online!

A full program that takes the total, token values and number of arguments as its arguments. Returns a list of lists of token values.

Explanation

Œṗ          | Integer partition (of first argument)
    Ƈ       | Keep only those which:
   Ƒ        | - are invariant when:
  f         |   - filtered to only include the (implicit) second argument.
       ¥Ƈ   | Keep only those for which:
     L      | - the length
      =  ⁵  |   - is equal to the third argument


Shuffle a deck without local variables The object of this puzzle is to take a deck of 52 cards and shuffle it so that each card is in a random position.
Given:

An array, deck, of 52 distinct integers representing the cards. When you start, deck contains exactly one of each card in some unknown order.
A function, int rand(min, max), that returns a random integer between ints min and max, inclusive. You can assume that this function is truly random.
A function, void swap(x, y) that swaps two cards in the deck. If you call swap(x, y), the cards at positions x and y will switch places.

When:

The program calls shuffle() (or shuffle(deck) or deck.shuffle() or however your implementation likes to run),

Then:

deck should contain exactly one of each card in perfectly random order.

The Catch:
You can't declare any variables. Call swap and rand as much as you like, but you can't declare any variables of your own. This includes for loop counters--even implicit ones like in a foreach.
Clarifications:

You can change minor details to suit your chosen language. For example, you can write swap to switch two integers by reference. Changes should be to make this work with your language, not to make the puzzle easier.
deck can be a global variable, or you can take it in as a parameter.
You can do anything you want to the contents of deck, but you can't change its length.
Your cards can be numbered 0-51, 1-52, or anything you like.
You can write this in any language, but no cheating with your language's built-in shuffle function.
Yes, you could write the same line 52 times. No one will be impressed.
Execution time doesn't matter, but true randomness does.
This isn't really code golf, but feel free to minimize/obfuscate your code.

Edit: Boilerplate code and visualizer
If you used .NET or JavaScript, here's some test code you may find useful:
JavaScript:

Quick-and-dirty JavaScript visualizer, with CoffeeScript source: https://gist.github.com/JustinMorgan/3989752bdfd579291cca
Runnable version (just paste in your shuffle() function): http://jsfiddle.net/4zxjmy42/

C#:

ASP.NET visualizer with C# codebehind: https://gist.github.com/JustinMorgan/4b630446a43f28eb5559
Stub with just the swap and rand utility methods: https://gist.github.com/JustinMorgan/3bb4e6b058d70cc07d41

This code sorts and shuffles the deck several thousand times and performs some basic sanity testing: For each shuffle, it verifies that there are exactly 52 cards in the deck with no repeats. Then the visualizer plots the frequency of each card ending up at each place in the deck, displaying a grayscale heat map.
The visualizer's output should look like snow with no apparent pattern. Obviously it can't prove true randomness, but it's a quick and easy way to spot-check. I recommend using it or something like it, because certain mistakes in the shuffling algorithm lead to very recognizable patterns in the output. Here's an example of the output from two implementations, one with a common flaw:

The flawed version does partially shuffle the deck, so might look fine if you examined the array by hand. The visualizer makes it easier to notice a pattern.

Haskell

Here is a point-free implementation.  No variables, formal parameters, or explicit recursion.  I used lambdabot's @pl ("pointless") refactoring feature quite a bit.

import Data.List
import Control.Applicative
import Control.Monad
import System.Random

shuffle :: [a] -> IO [a]
shuffle = liftM2 (<$>) ((fst .) . foldl' (uncurry ((. flip splitAt) . (.) .
          (`ap` snd) . (. fst) . flip flip tail . (ap .) . flip flip head .
          ((.) .) . (. (++)) . flip . (((.) . (,)) .) . flip (:))) . (,) [])
          (sequence . map (randomRIO . (,) 0 . subtract 1) . reverse .
          enumFromTo 1 . length)

main = print =<< shuffle [1..52]

Here's my test procedure to make sure the numbers were uniformly distributed:

main = print . foldl' (zipWith (+)) (replicate 52 0)
       =<< replicateM 1000 (shuffle [1..52])

Here is the original algorithm:

shuffle :: [a] -> IO [a]
shuffle xs = shuffleWith xs <$>
             sequence [randomRIO (0, i - 1) | i <- reverse [1..length xs]]

shuffleWith :: [a] -> [Int] -> [a]
shuffleWith xs ns = fst $ foldl' f ([], xs) ns where
    f (a,b) n = (x:a, xs++ys) where
        (xs, x:ys) = splitAt n b


Cannonball Conundrum Your task is to, with an input number p, find the smallest positive cannonball number of order p that is NOT 1.

Definition

A cannonball number (of order p) is a number which is both:

An p-gonal number (See this page).
and an p-gonal pyramid number.

The nth p-gonal pyramid number is the sum of the 1st to nth p-gonal numbers.

(e.g. 4th square pyramid number = 1 + 4 + 9 + 16 = 30)

The picture below represents the 4th square pyramid number, as a square pyramid.

For more info, visit this link.

The cannonball number of order 3, for example, is 10, because it is:

The fourth triangle number (1 + 2 + 3 + 4 = 10)
and the third triangular pyramid number. (1 + 3 + 6 = 10)

Formulas

NOTE: If you can find (or make) more useful formulae than my ones here, please post it here (or message me on the question chat thing).

If you're interested, the formula for the nth p-gonal number is:

And the nth p-gonal pyramid number is:

Specs

p is guaranteed to be larger than 2.
The program must check values for a solution for p up to (and including) 2^16. Your program may do anything if no solutions are found for p.
Only positive indices for n.

Test cases

3 outputs 10 (4th triangle number, 3rd triangle pyramid number)
4 outputs 4900 (70th square number, 24th square pyramid number)

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

Note: If you do post a solution, please include a description of how the code works.

Should I start a bounty for a solution which is better and doesn't use my formulae?

Python 3, 129 127 bytes
def f(p):
 x=2
 while 1:
  for i in range(x*x):
   if i//x*((p-2)*i//x+4-p)/2==i%x*(i%x+1)*((p-2)*i%x+5-p)/6==x:return x
  x+=1

A function that takes input via argument and returns the output.
This is an extremely naïve brute force, and takes a very long time for even moderately large p; the execution time will be ridiculous for anything approaching the given maximum for p of 2^16, but there is no reason why the program would not work, given sufficient time.
There are probably far shorter and faster ways of doing this, but I thought it would be good to post something to get this started off.
How it works
The return value x is initialised to 2, and then the program simply loops over all the p-gonal and p-gonal pyramidal numbers up to order x. If the current p-gonal and p-gonal pyramidal numbers, calculated using the formulas, are equal to each other and to x, then x must be the relevant cannonball number and this is returned. Else, x is incremented, and the program tries again for the new value of x.
In terms of golfing, a Cartesian product is used to collapse the two for-loops for the p-gonal and p-gonal pyramidal numbers into a single loop, and the formulas were factorised further to save a few bytes.


Help me sub-divide a time signature This challenge is based on a video in which Andrew Huang discusses unusual time signatures...

https://www.youtube.com/watch?v=JQk-1IXRfew

In it, he advises that you can understand time signatures by dividing them into 3's and 2's. So you count to a small number a few times, instead of counting to a large number.

Here's the pattern he builds which repeats after 19 steps:

5 groups of 3
2 groups of 2

This is how it looks:

#..#..#..#..#..#.#.

Actually, as you'd play each beat alternatively, the accented beats move from left to right, because there's an odd number of steps. So now this pattern is:

R..L..R..L..R..L.L.
L..R..L..R..L..R.R.

If we reduce this to an algorithm, it can be described like this.

Step 1: where are the accents

From your number of steps, start by taking groups of 3 from the start until there's 4 or fewer steps remaining.

E.g. for a pattern 8 steps long.

8 steps - take three, 5 steps remaining

#..

5 steps - take 3, 2 steps remaining

#..#..

Once we're down to 4 steps or fewer, there's 3 possibilities.

4 steps - 2 groups of 2
3 steps - 1 group of 3
2 steps - 1 group of 2

So from our above example:

#..#..#.

Step 2: Which hand are the accents on

Let's assume that each individual step will be played on alternate hands, starting with the right.

So for 8 steps, the (underlying) pattern will go

rlrlrlrl

The pattern we output will only tell use which hand the accents are on. With the above example:

R..L..R.

That's fine, it's repeatable.

but

If it's an odd number, you've got the same hand for both the first and last steps, and you can't keep alternating when you repeat the pattern. Instead, the second pattern will be on the other hand. Here's the pattern on an 11 step pattern.

R..L..R..L.
L..R..L..R.

To clarify, if the pattern length is odd, we need to see the repeated, alternated pattern. If the length is even, we only need to see it once.

Hopefully that's clear enough:

The Rules

It's code golf, go for the shortest code.
Your code will accept one pattern, a positive integer higher than 1.
It will output some text describing a pattern diagram, as described above.
Any language you like.
Please include a link to an online interpreter.

Test cases

2

R.

3

R..
L..

4

R.R.

7

R..L.L.
L..R.R.

9

R..L..R..
L..R..L..

10

R..L..R.R.

19

R..L..R..L..R..L.L.
L..R..L..R..L..R.R.

22

R..L..R..L..R..L..R.R.

Retina 0.8.2, 66 bytes

.+
$*
1
RL
^(.+)RL\1$
$1R¶L$1
^(.+)\1$
$1
(.)(..?)(?!.\b)
$1$.2$*.

Try it online! Link includes test cases. Explanation:

.+
$*

Convert the input to unary.

1
RL

Alternate between hands.

^(.+)RL\1$
$1R¶L$1

If there are an odd number of beats then divide the output in the middle.

^(.+)\1$
$1

But if there are an even number of beats then just use one copy.

(.)(..?)(?!.\b)
$1$.2$*.

Try to match groups of three beats, but without leaving a lone beat at the end, and replace the offbeats with .s.


x86_64 machine language on Linux, 6 bytes

0:       f3 48 0f bd c7          lzcnt  %rdi,%rax
5:       c3                      ret

Requires Haswell or K10 or higher processor with lzcnt instruction.

Try it online!


It's almost Christmas! Because of this, families from all over the world are building Christmas trees.

But this normal tree can get boring after a while, so let's make an ASCII tree!

Leafs are represented by # and must be arranged as shown in the example output. We have 5 balls (O) and 5 candy canes (J), which we place randomly around the tree. We also have a candle on top.

Input: none

Output:

         ^
         |
        ###
       ##O##
      #######
       #####
      ####J##
     #########
    ####O######
   #############
      ###J###
     #########
    ####O###J##
   #######O#####
  ###J########O##
 ###########J#####
        ###
        ###

Rules (if it's not in the rules, assume you can)

Balls and candy canes must be randomly placed on the tree and must have at least one leaf between them, not counting diagonals.
Each leaf must have a non-zero chance of getting a ball or a candy cane.
There may be leading or trailing spaces on each line, as long as the tree has the proper shape.
This is code-golf, so shortest code in characters wins.

CS-Script - 306 bytes

var c=new string(' ',342).ToCharArray();var r=new Random();int e=18,i,j,w;for(;i<e;i++){c[i*e+e]='\n';w=i<5?i:i<10?i-2:i<16?i-6:2;for(j=1;j++<w*2;)c[i*e+8-w+j]='#';}for(i=0;i<10;){j=37+r.Next(288);if(c[j]=='#'&c[j+1]<42&c[j-1]<42&c[j+e]<42&c[j-e]<42)c[j]=i++<5?'J':'O';}c[8]='^';c[27]='|';Console.Write(c);

Once more with formatting and comments:

// create 'char bitmap' filled with spaces
var c=new string(' ',342).ToCharArray();
// Random for placing ornaments
var r=new Random();
int e=18,i,j,w;
// once for each row
for(;i<e;i++)
{
    // add new lines
    c[i*e+e]='\n';
    // determine width of tree for this row
    w=i<5?i:i<10?i-2:i<16?i-6:2;
    for(j=1;j++<w*2;)
        // add leaves
        c[i*e+8-w+j]='#';
}
for(i=0;i<10;)
{
    // select random location
    j=37+r.Next(288);
    if( // check we have a leaf
        c[j]=='#' &
        // check surrounding to be leaf/space/new-line
        c[j+1]<42 & c[j-1]<42 & c[j+e]<42 & c[j-e]<42)
        // add ornament if location is valid
        c[j]=i++<5?'J':'O';
}
// light candle
c[8]='^';
c[27]='|';
// print
Console.Write(c);

It's basically C#, but using CS-Script allows me to skip all the boiler-plate.

Try it here!

Notes:

This currently outputs another line of white spaces below the tree to make sure the that 'checking for existing ornaments below' does not throw an IndexOutOfBoundsException. Other solutions would be:

Checking if it is the last line before checking below (adds a few more character)
Not adding ornaments to the 'stem' of the tree (Same byte count, but seems to me to be against rules)

I'll leave it to the OP if this should be changed.

Lastly, this is my first golf, so any feedback is appreciated. ;)


Bubble the brackets! There are a few questions on this site about balancing brackets, and checking whether brackets are balanced. I propose it's now time to use those balanced brackets for something!
In mathematics and programming, brackets are like bubbles, isolating everything inside form everything outside so that whatever's inside can do its thing in peace and whatever's outside only sees one object. However, a string of brackets is one-dimensional, while bubbles usually are at least two dimensional. That means that bubbles are free to move around one another as long as they never touch each other or cross between the inside and the outside of any other bubbles.
Challenge
The input is a string of matched brackets of a single type, either round (), square [], curly {} or angle <>. It's up to you what kind you want your program to accept, and a program that only accepts a single kind of brackets is accepted. (Imaginary bonus if your program can handle any of them, massive imaginary bonus points if it can handle all of them in the same input.) The input cannot contain anything between the brackets, although trailing whitespaces are allowed.
The output is all possible reorganisations (in arbitrary order, and including the original input) of those brackets that yields the same configuration of bubbles, with no two identical strings. That means that with an input of ()(), the output is also just ()(), even though it's technically two bubbles that could swap places. For the massive imaginary bonus, an input of {}[]() will of course lead to an output of 6 different elements / strings / lines.
Two configurations of bubbles are "the same" if you can make one into the other by moving bubbles around, without letting any bubble cross from inside another bubble to outside it, or from outside to inside. If you liken nested parentheses to trees (each matched pair is one node, and every matched pair within is a subnode, and each matched pair within there is a subnode of those again, and so on) where the subnodes of any given node are ordered, then a single configuration of bubbles is a tree where the nodes are unordered.
Any reasonable output format will do, like returning a list of strings or a list of list of single characters or a single string with some kind of whitespace, or printing to stdoutor stderr with some form of visible whitespace character (most commonly newline or space) between each reorganisation.
Trailing spaces for each reorganisation and trailing and preceeding newlines / empty list elements before and after the actual output is allowed. You should use the same kind of brackets in your output as you accept in your input. Apart from the brackets, newlines and spaces as specified here, and whatever separator you use, nothing should be printed (including invisible / zero-width characters).
The score is the number of bytes in the code; lowest count for each language wins. You may note whether you get an imaginary bonus, either regular or massive, but it doesn't affect your score. Actual bonuses are too hard to balance right.
Input-output examples
Example 1:
Input:
()(())

Output:
()(())
(())()

Example 2:
Input:
(()())()()

Output:
(()())()()
()(()())()
()()(()())

Example 3:
Input:
(()(()))()

Output:
((())())()
()((())())
(()(()))()
()(()(()))

CJam, 18 bytes

{~{_{{B}%e!}&}:B~}

Try it online!

-2 thanks to Business Cat.

Receives input as a string containing only []. Returns a list of permutations (empty lists are the same as empty strings in CJam, so instead of [] you'll be getting "").


Create the shortest BitShift Introduction

BitShift is an esolang, created by me, to output strings. Sounds boring, is boring. However, the only instructions available to BitShift are 0 and 1. Therefore it can be challenging to golf in it. To make matters even more interesting, the language only supports 4 bitshifting instructions, a clear, a print and an input instruction.

How it works

BitShift is written by alternating 0 and 1 characters. Once the interpreter finds 2 of the same characters in a row, it will perform an instruction based on the amount of non-alternating characters preceding it.

010010110001010 will perform the operations 3 4 2 1 5
010 0101 10 0 01010 here, the non-alternating characters are seperated by a spacebar for readability.

The interpreter can be found here

Operations

All operations are performed on one single value. BitShift does not know of a stack.
BitShift programs initially start with a value of 0. This value can range from 0-255 and overflows at -1 and 256

1   Shift the value 1 bit to the left (0000 0001 > 0000 0010)
2   Shift the value 1 bit to the right (0000 0010 > 0000 0001)
3   XOR the value with 1 (0000 0000 > 0000 0001)
4   XOR the value with 128 (0000 0000 > 1000 0000)
5   Set the value to 0
6   Convert the value to a character and print it
7   Read a character from user input and set the value to it

Challenge

Your task is to create a program which can convert an input string to the shortest possible BitShift program which will output that string when run.

Rules

You are not allowed to use the 7 operation
Your program takes only one input argument, which is the string to convert
Your program will output the translated BitShift program to STDOUT
You can use any kind of built-in function in your preffered language
You can use any kind of language, as long as it's created before this date

Scoring

This is a metagolf.

The person who can create the shortest BitShift program will win this challenge. In case of a tie, the lowest byte count will win.

The input string (ISO 8859-1) you should base your answer on is:
This is a string, meant to test the effectiveness of your program. Here are some special characters to make matters interesting: Æ Ø ß. How meta! :D

The special characters used are &#198; &#216; &#223;

Please post the output of your program in your answer, so that it can be tested for validation.

The following is an example solution. Obviously, this is a terrible solution.

Javascript, 594 bytes, 4275 characters

var flag = true;
var input = prompt();
var output = ""
for (n in input) {
    var c = input.charCodeAt(n).toString(2);
    while (c.length < 8) {
        c = "0" + c;
    }
    for (var i = 0; i < 8; i++) {
        if (c[i] == "1") {
            output += flag ? "010" : "101";
        }
        if (i < 7) output += flag ? "0" : "1";
    }
    for (var z = 0; z < 6; z++) {
        output += flag ? "0" : "1";
        flag = !flag;
    }
    flag = !flag;
    for (var z = 0; z < 5; z++) {
        output += flag ? "0": "1";
        flag = !flag;
    }
    flag = !flag;
}
console.log(output);

Mathematica, 343 bytes, 2573 characters
B=BitXor;t[a_]:={Mod[2a,256],⌊a/2⌋,a~B~1,a~B~128,0};w[a_,b_]:=Position[t@a,b][[1,1]];f=FindShortestPath[Graph[0~Range~255,e=Join@@Table[a#&/@({}⋃t@a),{a,m=c=0,255}],EdgeWeight(w@@#&/@e)],All,All];o="";u[a_,b_]:=(Do[o=o<>ToString[m=1-m],{If[a==b,6,a~w~f[a,b][[2]]]}];m=1-m);While[c~u~y;c!=y,c=f[c,y][[2]]]~Do~{y,ToCharacterCode@i};o

This is my first code competition. This program should generate the shortest possible program for any string. It effectively calculates a lookup table given the current state of the accumulator and the goal byte to find the shortest sequence of the five operations to get from any one to another, carrying the accumulator over characters and taking advantage of the size difference between instructions. Uses Mathematica 8's Graph infrastructure for calculating shortest paths (alternatives being to roll one's own or just embed the 256 x 256 table of instructions).
Ungolfed version (the first i = "..." line is also present, but not counted in the golfed version since it is the input):
i = "This is a string, meant to test the effectiveness of your program. Here are some special characters to make matters interesting: Æ Ø ß. How meta! :D";
B = BitXor;
t[a_] := {Mod[2 a, 256], Quotient[a, 2], B[a, 1], B[a, 128], 0}
w[a_, b_] := Position[t[a], b][[1, 1]]
g = Graph[Range[0, 255],
  e = Join @@ Table[DirectedEdge[a, #] & /@ Union@t@a, {a, 0, 255}],
  EdgeWeight -> (w @@ # & /@ e)];
f = FindShortestPath[g, All, All]; c = m = 0; o = "";
u[a_, b_] := (Do[
   o = o <> ToString[m = 1 - m], {If[a == b, 6, w[a, f[a, b][[2]]]]}];
   m = 1 - m);
Do[While[u[c, y]; c != y, c = f[c, y][[2]]], {y, ToCharacterCode[i]}];
o

Output:
10111101111011110101000010110010101101101010000010110010110010010101101111110101001011001011001001010111110100110100110110101001000000101011101001101101010000000101011011101110111110111011010100110010000101011001101110111010100100001000001001010110011011101110101000010001000011011010100110100110010101111111001101010010001000010001000010010101101110111101101010011001000010010101100110010001000100010101110111101010000001101010010110010110010110010101100100010000110110101000000000110010101101001101001101001101010001000001011001001010110100110110101001100100001010111111001010110100110100110100110101000011010100100000101100100101011011111010100110100110100110110101001101110101001010110010001001010111011111101110110101000100001000010101111001001010110100110010001010111101111011010100010001000010110010101111011111001001010110100110110101001010110111111010100100010000100010001000100101011111011101111001010110010000001010110111011101110111110110101001101001101001101010010001000010010101100110111011101010000001010111010011010011010100110111010100110100110100110110101000001000100001101101010000010001010110111111101101010011010011010011011010100110111110011010100000000110010101100101100101011010011011010100101100101011110010010101101111101010001011001001010110100110010001010111100100101011011111010100100010001000001000100101011001011001011001001010110010001001010110111011110110101001000001010110111011101111101110110101001101110101001101111100100101011101111110111011010100001000001001010111011111110110101001101001101001101010000000110010101100100001011001001010111101111101010000010110010010101101001100100010101101111111011010100110111011010100010000100001010111011111010011011010100101100101011011010100100000010101101001101001101001101010011011101111001001010111111111001101010010001000010001000010010101101111101101010011001101111011101101010000010000100101011011111010100100010000100010000100101011011111011010100101100110010000101011010100010000010110010010101101001101010010010101101111110101001011001011001001010110011011101110101000100001010111011111010011011010100101100101011110010010101101001101101010011001000010101111001001010110011011101110101000010001000011011010100001000101011111110010101100100010001011010100110111111010100010110011010011010010101111110011010100100001000100010001000100101101010001100100101011111111001101010011010011010100110111011101111010011011010100101100101011111111100110101001000100001000100001001010110111011110110101001011001100100001010111111010011011010100001100101011011010100100010001000010001010111110111101010


Tips for golfing in Cheddar Cheddar is a high-level, functional + object-oriented programming language created by our user Downgoat designed to make programming easier, faster, and more intuitive.

What general tips do you have for golfing in Cheddar? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Cheddar (e.g. "Remove unnecessary whitespace." is not an answer).

Use Functionized Properties

If you ever use just a property in a function:

A->A.long.property(n).foo.bar

You can use functionized properties to save some bytes:

@.long.property(n).foo.bar

You can reference the variable in the functionized property with $0.


Is this Pascal's Matrix? In Pascal's triangle each number is the sum of the two numbers directly above it, treating empty spots as zero:

By rotating the triangle, we can cut out square matrices of varying sizes and rotations which I will call Pascal's matrices. Note that those matrices always need to contain the top \$1\$. Here are some examples:

1  1  1  1
1  2  3  4
1  3  6 10
1  4 10 20

6  3  1
3  2  1
1  1  1

1  5 15 35 70
1  4 10 20 35
1  3  6 10 15
1  2  3  4  5
1  1  1  1  1

1

1  1
2  1

The Task

Given a square matrix containing positive numbers in any reasonable format, decide if it is a Pascal's matrix.

Decide means to either return truthy or falsy values depending on whether the input is a Pascal's matrix, or to fix two constant values and return one for the true inputs and the other for false inputs.

This is code-golf, so try to use as few bytes as possible in the language of your choice. The shortest code in each language wins, thus I will not accept an answer.

Test cases

True

[[1, 1, 1, 1], [1, 2, 3, 4], [1, 3, 6, 10], [1, 4, 10, 20]]
[[6, 3, 1], [3, 2, 1], [1, 1, 1]]
[[1, 5, 15, 35, 70], [1, 4, 10, 20, 35], [1, 3, 6, 10, 15], [1, 2, 3, 4, 5], [1, 1, 1, 1, 1]]
[[1]]
[[1, 1], [2, 1]]

False

[[2]]
[[1, 2], [2, 1]]
[[1, 1], [3, 1]]
[[1, 1, 1, 1], [1, 2, 3, 4], [1, 4, 6, 10], [1, 4, 10, 20]]
[[6, 3, 1], [1, 1, 1], [3, 2, 1]]
[[2, 2, 2, 2], [2, 4, 6, 8], [2, 6, 12, 20], [2, 8, 20, 40]]
[[40, 20, 8, 2], [20, 12, 6, 2], [8, 6, 4, 2], [2, 2, 2, 2]]
[[1, 5, 15, 34, 70], [1, 4, 10, 20, 34], [1, 3, 6, 10, 15], [1, 2, 3, 4, 5], [1, 1, 1, 1, 1]]

Brachylog, 28 24 23 bytes

This feels quite long but here it is anyway

-4 bytes thanks to DLosc by compressing the optional flips
-1 bytes thanks to DLosc again by doing the partial sums in 1 go

{|↔}\↰₁{k{a₀ᶠ+ᵐ}ᵐ⊆?h=₁}

Explanation

{|↔}\↰₁{k{a₀ᶠ+ᵐ}ᵐ⊆?h=₁}       # Tests if this is a pascal matrix:
{|↔}\↰₁                       #     By trying to get a rows of 1's on top
{|↔}                          #       Through optionally mirroring vertically
     \                        #       Transposing
      ↰₁                      #       Through optionally mirroring vertically

       {k{a₀ᶠ+ᵐ}ᵐ⊆?h=₁}       #     and checking the following
                  ?h=₁        #        first row is a rows of 1's
        k{     }ᵐ             #        and for each row except the last
          a₀ᶠ+ᵐ               #          calculate the partial sum by
          a₀ᶠ                 #             take all prefixes of the input
             +ᵐ               #             and sum each
               ⊆?             #        => as a list is a subsequence of the rotated input

Try it online!


Sort numbers by binary 1's count Goal

Write a function or program sort an array of integers in descending order by the number of 1's present in their binary representation.  No secondary sort condition is necessary.

Example sorted list

(using 16-bit integers)

  Dec                Bin        1's
16375   0011111111110111        13
15342   0011101111101110        11
32425   0111111010101001        10
11746   0010110111100010         8
28436   0000110111110100         8
19944   0100110111101000         8
28943   0000011100011111         8
 3944   0000011111101000         7
15752   0011110110001000         7
  825   0000000011111001         6
21826   0101010101000010         6

Input

An array of 32-bit integers.

Output

An array of the same integers sorted as described.

Scoring

This is code golf for the least number of bytes to be selected in one week's time.


Multiple program Quinecatenate! Your task is to give three different languages A, B, C, and write two different programs P and Q such that:

P is a quine in language A, but not a quine in B nor C;

Q is a quine in language B, but not a quine in A nor C; and

Q concatenated after P (without any new characters added in between) is a quine in language C, but not in B nor A.

This is codegolf, where your score is the length of the final, concatenated quine. Again, adhere to the rules of proper quines  -- no reading your source code, no empty programs etc.

Fission + CJam + GolfScript, 38 36 bytes

Fission, 6 bytes

'!+OR"

This is one of Martin Büttner's Fission quines. Try it online!

CJam, 30 bytes

' {"''"@*" "+YX#<
\"0$~"N}0$~

The last byte is a linefeed. Try it online!

GolfScript, 36 bytes

'!+OR"' {"''"@*" "+YX#<
\"0$~"N}0$~

The last byte is a linefeed. Try it online!

Verification

$ wc -c P Q
 6 P
30 Q
36 total
$ cat P Q > P+Q
$
$ Fission P 2>&- | diff -qs - P
Files - and P are identical
$ cjam P 2>&- | diff -qs - P
Files - and P differ
$ golfscript P 2>&- | diff -qs - P
Files - and P differ
$
$ cjam Q 2>&- | diff -qs - Q
Files - and Q are identical
$ golfscript Q 2>&- | diff -qs - Q
Files - and Q differ
$ Fission Q 2>&- | diff -qs - Q
Files - and Q differ
$
$ golfscript P+Q 2>&- | diff -qs - P+Q
Files - and P+Q are identical
$ Fission P+Q 2>&- | diff -qs - P+Q
Files - and P+Q differ
$ cjam P+Q 2>&- | diff -qs - P+Q
Files - and P+Q differ

How it works

Fission

R spawns an atom that moves right, wrapping around at the edge.
" toggles printing mode. Everything up to the next " is printed.
'! sets the atom's to the code point of '!'.
+ increments the atom's mass, setting it to the code point of ".
O prints the character whose code point is the atom's mass and destroys the atom.

CJam

'       e# Push a space character.
{       e# Push the following code block:
  "''"  e# Push that string.
  @*    e# Separate its characters by spaces.
  " "+  e# Append one more space.
  YX#   e# Raise 2 to the first power. Pushes 2.
  <     e# Discard all but the first two characters of the string, i.e., "' ".
  \     e# Swap the string "' " with the code block in execution.
  "0$~" e# Push that string.
  N     e# Push a linefeed.
}       e#
0$~     e# Push a copy of the code block and execute it.

GolfScript

'!+OR"' # Push that string.
{       # Push the following code block:
  "''"  # Push that string.
  @*    # Join its characters, separating them by the first string.
  " "+  # Append a space.
  YX    # Undefined token. Does nothing.
  #<    # Comment.
  \     # Swap the string with the code block in execution.
  "0$~" # Push that string.
  N     # Undefined token. Does nothing.
}       #
0$~     # Push a copy of the code block and execute it.


Numbers Increase While Letters Decrease Inspired by this Stack Overflow question: Sorting a list: numbers in ascending, letters in descending. Your task is to solve the following problem and, as this is code-golf, you should do so in as few as bytes as possible.

You should take a list of objects as input containing letters (any reasonable form: string, char, etc) and numbers. You should then sort the numbers into ascending order and the letters into descending order. However, you should keep letters in letter positions and numbers in number positions. For example, if the list is:

[L, D, L, L, D, L]

The output list should be in the form of:

[L, D, L, L, D, L]

Workthrough

Input: ['a', 2, 'b', 1, 'c', 3]

Sort the numbers into ascending order: [1, 2, 3]
Sort the letters into descending order: ['c', 'b', 'a']
Join them back but keep the order the same: ['c', 1', 'b', 2, 'a', 3]

Rules

The list will only contain letters and digits.
The list may be empty.
The list may only contain letters or only digits.
If your language does not support mixed type arrays you may use digit characters instead of numbers. Note that if your language does support this you must use mixed types.
Letters will only be [a-z] or [A-Z], you may choose which one.
Letters are sorted as a being lowest, z being highest i.e. a = 1, z = 26.
Standard loopholes are forbidden.
I/O may be by any standard means including as a string.

Test cases

[5, 'a', 'x', 3, 6, 'b'] -> [3, 'x', 'b', 5, 6, 'a']

[ 3, 2, 1] -> [ 1, 2, 3 ]

[ 'a', 'b', 'c' ] -> [ 'c', 'b', 'a' ]

[] -> []

[ 2, 3, 2, 1 ] -> [1, 2, 2, 3]

As this is code-golf the shortest answer in bytes wins!

Python 2, 53 52 51 bytes
-2 bytes thanks to g.rocket
-1 byte thanks to Jonathan Frech
-1 byte thanks to RootTwo

def F(x):n=sorted(x);print[n.pop(-(e>x))for e in x]

Try it online!
The sorted list will have the numbers first and then the chars like [3, 5, 6, 'a', 'b', 'x'], then use e>x to filter what is number and what is char, in python any number is less than a list (input) and a list is less than a string.


Could you please stop shuffling the deck and play already? Challenge:
Input: A list of distinct positive integers within the range \$[1, \text{list-size}]\$.
Output: An integer: the amount of times the list is riffle-shuffled. For a list, this means the list is split in two halves, and these halves are interleaved (i.e. riffle-shuffling the list [1,2,3,4,5,6,7,8,9,10] once would result in [1,6,2,7,3,8,4,9,5,10], so for this challenge the input [1,6,2,7,3,8,4,9,5,10] would result in 1).
Challenge rules:

You can assume the list will only contain positive integers in the range \$[1, \text{list-size}]\$ (or \$[0, \text{list-size}-1]\$ if you choose to have 0-indexed input-lists).
You can assume all input-lists will either be a valid riffle-shuffled list, or a sorted list which isn't shuffled (in which case the output is 0).
You can assume the input-list will contain at least three values.

Step-by-step example:
Input: [1,3,5,7,9,2,4,6,8]
Unshuffling it once becomes: [1,5,9,4,8,3,7,2,6], because every even 0-indexed item comes first [1, ,5, ,9, ,4, ,8], and then all odd 0-indexed items after that [ ,3, ,7, ,2, ,6, ].
The list isn't ordered yet, so we continue:
Unshuffling the list again becomes: [1,9,8,7,6,5,4,3,2]
Again becomes: [1,8,6,4,2,9,7,5,3]
Then: [1,6,2,7,3,8,4,9,5]
And finally: [1,2,3,4,5,6,7,8,9], which is an ordered list, so we're done unshuffling.
We unshuffled the original [1,3,5,7,9,2,4,6,8] five times to get to [1,2,3,4,5,6,7,8,9], so the output is 5 in this case.
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.

Test cases:
Input                                                   Output

[1,2,3]                                                 0
[1,2,3,4,5]                                             0
[1,3,2]                                                 1
[1,6,2,7,3,8,4,9,5,10]                                  1
[1,3,5,7,2,4,6]                                         2
[1,8,6,4,2,9,7,5,3,10]                                  2
[1,9,8,7,6,5,4,3,2,10]                                  3
[1,5,9,4,8,3,7,2,6,10]                                  4
[1,3,5,7,9,2,4,6,8]                                     5
[1,6,11,5,10,4,9,3,8,2,7]                               6
[1,10,19,9,18,8,17,7,16,6,15,5,14,4,13,3,12,2,11,20]    10
[1,3,5,7,9,11,13,15,17,19,2,4,6,8,10,12,14,16,18,20]    17
[1,141,32,172,63,203,94,234,125,16,156,47,187,78,218,109,249,140,31,171,62,202,93,233,124,15,155,46,186,77,217,108,248,139,30,170,61,201,92,232,123,14,154,45,185,76,216,107,247,138,29,169,60,200,91,231,122,13,153,44,184,75,215,106,246,137,28,168,59,199,90,230,121,12,152,43,183,74,214,105,245,136,27,167,58,198,89,229,120,11,151,42,182,73,213,104,244,135,26,166,57,197,88,228,119,10,150,41,181,72,212,103,243,134,25,165,56,196,87,227,118,9,149,40,180,71,211,102,242,133,24,164,55,195,86,226,117,8,148,39,179,70,210,101,241,132,23,163,54,194,85,225,116,7,147,38,178,69,209,100,240,131,22,162,53,193,84,224,115,6,146,37,177,68,208,99,239,130,21,161,52,192,83,223,114,5,145,36,176,67,207,98,238,129,20,160,51,191,82,222,113,4,144,35,175,66,206,97,237,128,19,159,50,190,81,221,112,3,143,34,174,65,205,96,236,127,18,158,49,189,80,220,111,2,142,33,173,64,204,95,235,126,17,157,48,188,79,219,110,250]
                                                        45

JavaScript (ES6), 44 bytes
Shorter version suggested by @nwellnhof
Expects a deck with 1-indexed cards as input.

f=(a,x=1)=>a[x]-2&&1+f(a,x*2%(a.length-1|1))

Try it online!
Given a deck \$[c_0,\ldots,c_{L-1}]\$ of length \$L\$, we define:
$$x_n=\begin{cases}
2^n\bmod L&\text{if }L\text{ is odd}\\
2^n\bmod (L-1)&\text{if }L\text{ is even}\\
\end{cases}$$
And we look for \$n\$ such that \$c_{x_n}=2\$.

JavaScript (ES6),  57 52  50 bytes
Expects a deck with 0-indexed cards as input.

f=(a,x=1,k=a.length-1|1)=>a[1]-x%k&&1+f(a,x*-~k/2)

Try it online!
How?
Since JS is lacking native support for extracting array slices with a custom stepping, simulating the entire riffle-shuffle would probably be rather costly (but to be honest, I didn't even try). However, the solution can also be found by just looking at the 2nd card and the total number of cards in the deck.
Given a deck of length \$L\$, this code looks for \$n\$ such that:
$$c_2\equiv\left(\frac{k+1}{2}\right)^n\pmod k$$
where \$c_2\$ is the second card and \$k\$ is defined as:
$$k=\begin{cases}
L&\text{if }L\text{ is odd}\\
L-1&\text{if }L\text{ is even}\\
\end{cases}$$


Counting in bijective base 62 The task is to generate all the strings from 'a' to '999' including upper case characters like so:

'a', 'b', 'c' ... 'y', 'z', 'A', 'B', 'C' ... 'Y', 'Z', '0', '1', 2' ...
'8', '9', 'aa', 'ab', 'ac' ... 'az', 'aA', 'aB' ... 'aZ', 'a0' ... 'a9', 'ba'

and so on (filling in the gaps), optionally starting with the empty string.

Input:

The amount of consecutive characters the program has to print up to.

Output:

An array containing each string OR one string per line

Clarifications:

The order doesn't matter, you can print uppercase or lowercase letters first if you want.
The output can return any type of enumerable, doesn't have to be an array specifically, although I doubt printing all the combinations won't be the easiest way to go.
An input of 3 would print all the string from 'a' (or '') to '999'‚ an input of 5 up to '99999' and so on.

Jelly, 7 bytes

ØWṖṗR;/

This is a monadic link that accepts an integer as input and returns an array of strings.

Try it online!

How it works

ØWṖṗR;/  Main link. Argument: n

ØW       Yield 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'.
  Ṗ      Remove the last element (underscore).
    R    Range; yield [1, ..., n].
   ṗ     Cartesian product. For each k in the range, this yields the arrays of all
         strings of alphanumeric characters.
     ;/  Concatenate the arrays of strings of each length.


The 1+ Metagolf Challenge I'm letting this one out of the sandbox. Hopefully it is well-written and make sense, feel free to improve.
So in order to make 1+ more popular (and ease the creation of golfed 1+ text-printing programs) here comes the metagolf challenge:
The 1+ Language
1+ is a fun deque-based esolang where 1 is the only literal, and other numbers are constructed with operators
It is also "monotonic", that is, it only has the + and * operators, and not - or /
The deque is often referred to as a "stack", and one end of the deques is often referred to as the "top"
Here are the commands:

1 pushes 1
+ and * pop 2 numbers, and push their sum and product respectively
" duplicates the top number
/ and \ rotate the stack upwards and downwards respectively. That is, / moves the top number to the bottom and \ does the exact reverse
^ swaps the top two numbers
< is the only comparison operator (although it probably won't do much in Kolmogorov-complexity challenges)
. and , input an integer and a Unicode character respectively, and push it onto the stack. You are not allowed to take input here
: and ; output an integer and a Unicode character respectively. In the original interpreter, the : command outputs with a trailing newline, but here we allow both with a trailing newline and without a trailing newline
# is a goto-command that pops the top value n, and sends program flow to immediately after the nth # in the current line of execution (where numbering starts from 0)
Functions are defined with (name|code) and are called with (name). The name can be empty and the point where they are defined causes their execution too. They are separate lines of execution, so the numbering of #'s in them starts from 0

Original interpreter
Slightly modified interpreter to remove integer output trailing newline
Challenge
Your challenge is to write a program that inputs some text and outputs a 1+ program that outputs the text. The program can be in any language (lesser-known ones preferably), but it must output valid programs for any text.
Do not golf the test cases manually, otherwise I'll change them.
Winning criteria
Your score for a particular test case is your output length divided by the input length. The total score is the sum of the scores of all test cases. The lower, the better.
The test cases are:

"Hello, World!"
We're no strangers to code golf, you know the rules, and so do I
A keyboard so real you can almost TASTE it
Pascal's Tree-angle


Make 1s using a bunch of 1s Your task is to form an expression equaling \$ 11111111111 \text{ (11 ones)} \$ using only the following characters: 1+(). Keep in mind that the result is in base 10, and not some other base like binary. Of course, these expressions should follow the order of operations. Furthermore, the only operations which should be performed are addition, multiplication, and exponentation.

Some examples of valid expressions include

$$ 1 + 1 + 1 = 3 $$
$$ (1 + 1)(1 + 1) = 4 $$
$$ (1 + 1)^{1 + 1 + 1} = 8 $$
$$ 1 + (1 + 1(1 + 1)^{1 + 1^{1 + 1}}) = 6 $$

Some examples of invalid expressions include

$$ 11 + 11 \quad | \quad \text{concatenation of ones}$$
$$ 1 + ((1) \quad | \quad \text{unbalanced parentheses} $$
$$ \displaystyle\binom{1}{1 + 1} \quad | \quad \text{disallowed operation} $$

Scoring

After forming an expression which equals \$ 11111111111 \$, your score will be calculated by the sum of the \$ \text{no. of 1} \$, the \$ \text{no. of +} \$, and the \$ \text{no. of} \$ pairs of parentheses. For example, \$ (1 + 1)(1 + 1)^{1 + (1)} \$ has a score of \$ 12 \$, because it has \$ 6 \$ \$ 1 \$s, \$ 3 \$ pluses, and \$ 3 \$ pairs of parentheses.

The submission with the lowest score wins!

score = 82 71 69 (34 ‘1’s + 23 ‘+’s + 12 parenthesis pairs)

$$\begin{multline*}
11111111111 = 1 + (1 + 1) \cdot {}
\\
(1 + 1 + 1 + (1 + 1)^{(1 + 1)^{1 + 1 + 1}}(1 + ((1 + 1)(1 + 1 + 1))^{1 + 1 + 1})) \cdot {}
\\
(1 + (1 + (1 + 1 + 1)^{1 + 1})^{1 + (1 + 1)^{1 + 1}})
\end{multline*}$$

Try it online!

Search program in Rust

This finds optimal solutions for up to about 8 digit numbers.  Don’t try it on anything larger—it will eat all your memory.

I constructed the above solution by manually writing \$11111111111 = 1 + 111110 \cdot 100001\$ and searching for optimal solutions to \$111110\$ and \$100001\$.

use std::env;

#[derive(Clone, Debug)]
enum Op {
    One,
    Add(u32, u32),
    Mul(u32, u32),
    Pow(u32, u32),
}

fn show(ops: &[Option<Op>], z: u32, prec: u32) {
    match ops[z as usize].as_ref().unwrap() {
        Op::One => print!("1"),
        Op::Add(x, y) => {
            if prec > 0 {
                print!("(");
            }
            show(ops, *x, 0);
            print!(" + ");
            show(ops, *y, 0);
            if prec > 0 {
                print!(")");
            }
        }
        Op::Mul(x, y) => {
            if prec > 1 {
                print!("(");
            }
            show(ops, *x, 1);
            show(ops, *y, 1);
            if prec > 1 {
                print!(")");
            }
        }
        Op::Pow(x, y) => {
            if prec > 2 {
                print!("(");
            }
            show(ops, *x, 3);
            print!("^{{");
            show(ops, *y, 0);
            print!("}}");
            if prec > 2 {
                print!(")");
            }
        }
    }
}

fn main() {
    for target in env::args().skip(1).map(|arg| arg.parse().unwrap()) {
        let mut ops: Vec<Option<Op>> = vec![None; target as usize + 1];
        let mut vs: Vec<Vec<u32>> = vec![];
        while !ops[target as usize].is_some() {
            let mut v: Vec<u32> = vec![];
            let mut visit = |x, op| {
                if let Some(x) = x {
                    if x <= target {
                        if ops[x as usize].is_none() {
                            ops[x as usize] = Some(op);
                            v.push(x);
                        }
                    }
                }
            };
            let level = vs.len();
            let score = level / 2;
            match level % 2 {
                0 => {
                    if score == 1 {
                        visit(Some(1), Op::One);
                    }
                    for i in 1..score.saturating_sub(1) {
                        let j = score - 1 - i;
                        for u in &vs[i * 2..i * 2 + 2] {
                            for v in &vs[j * 2..j * 2 + 2] {
                                for &x in u {
                                    for &y in v {
                                        visit(x.checked_pow(y), Op::Pow(x, y));
                                    }
                                }
                            }
                        }
                    }
                    for i in 1..score {
                        let j = score - i;
                        for u in &vs[i * 2 - 1..i * 2 + 1] {
                            for v in &vs[j * 2 - 2..j * 2 + 1] {
                                for &x in u {
                                    for &y in v {
                                        visit(x.checked_mul(y), Op::Mul(x, y));
                                    }
                                }
                            }
                        }
                    }
                }
                1 => {
                    for i in 1..score.saturating_sub(1) {
                        let j = score - 1 - i;
                        for u in &vs[i * 2..i * 2 + 2] {
                            for v in &vs[j * 2..j * 2 + 2] {
                                for &x in u {
                                    for &y in v {
                                        visit(x.checked_add(y), Op::Add(x, y));
                                    }
                                }
                            }
                        }
                    }
                }
                _ => unreachable!(),
            }
            vs.push(v);
        }
        print!("{} = ", target);
        show(&ops, target, 0);
        println!();
    }
}

Try it online!


Multiplicative Persistence #2 We had a challenge on Multiplicative Persistence here.
As a recap, to get a multiplicative persistence of a number, do these steps:

Multiply all the digits of a number (in base \$10\$)
Repeat Step 1 until you have a single digit left.
Then count the number of iterations.

More here on Numberphile:

Numberphile "What's special about 277777788888899?"
Numberphile "Multiplicative Persistence (extra footage)"

See the previous challenge.
Rules
The last challenge was all about seeing the intermediate results, but here:

The input should be a positive integer \$n\$.
The output should be the integer with the greatest multiplicative persistence among numbers from \$0\$ to \$n-1\$, choosing the smallest option in case of a tie.
This is code-golf, so the shortest code wins.

Example
[inp]: 10
[out]: 0

[inp]: 100
[out]: 77

[inp]: 50
[out]: 39

[inp]: 31
[out]: 25

Note: Numbers somewhat randomly chosen.
Good Luck!

Husk, 10 bytes
►ȯLU¡oΠd↔ŀ

Try it online!
Explanation
►ȯLU¡oΠd↔ŀ
        ↔ŀ reverse the range 0..n-1
►ȯ         max-by, returning the last maximal element for the following:
    ¡o      create an infinite list using:
      Πd     product of digits.
   U        longest unique prefix
  L         take its length


La La Land... no wait, Moo Moo Moonlight This challenge is a tribute to the winner of Best Picture at the Oscars 2017, La La Land Moonlight!

Write a function/program that takes a string containing only letters [A-Za-z], the four symbols that are common in every day sentences  .,'? and spaces, and outputs the string in the style of La La Land.

To be more specific, take the letters up to, and including, the first vowel group, and print/output it twice adding a space each time, then print/output the whole string. y is a vowel in this challenge. Punctuation and capitalization should be kept.

You may assume that all strings contain at least one vowel, and that all strings start with a letter.

Test cases:

Land
La La Land

Moonlight
Moo Moo Moonlight

quEueIng
quEueI quEueI quEueIng

This isn't a single word.
Thi Thi This isn't a single word.

It's fun to play golf
I I It's fun to play golf

Ooo
Ooo Ooo Ooo

I'm okay
I I I'm okay

Hmm, no. There will be at least one vowel, but it can be anywhere.
Hmm, no Hmm, no Hmm, no. There will be at least one vowel, but it can be anywhere.

Why is y a vowel?
Why Why Why is y a vowel?

This is code-golf so the shortest code in each language wins. Explanations are encouraged, also in mainstream languages.

Sed 30 bytes

s/[^aeiouy]*[aeiouy]\+/& & &/i


Shortest representation of an Underload number Flavour text

The stack-based esolang Underload has some interesting ties to functional programming. One of them is its treatment of the numerical datatype—like the lambda calculus, you represent the natural number N by a function which perform an action N times.

To make things simple, we will only consider only the following subset of Underload commands:

: - This command duplicates the top item on the stack.
* - This command concatenates the top two items on the stack into a single item.

We define an Underload numeral N as a string of : and * which, when executed, consume the top item on the stack, and produce N copies of that item concatenated together. Some examples:

There are no Underload numerals 0, -1, 1/2, π.
The empty string  is the Underload numeral 1, because it leaves the stack untouched.
:* is the Underload numeral 2, because it duplicates the top item, and then concatenates those two copies together into a single item: (A):* = (A)(A)* = (AA).
::** is the Underload numeral 3: (A)::** = (A)(A):** = (A)(AA)* =
(AAA).
:::*** is the Underload numeral 4.
:*:* is also the Underload numeral 4: (A):*:* = (AA):* = (AA)(AA)* = (AAAA).

In general, you will find that, if M and N are the Underload numerals M and N, then :N* is the numeral N+1, and MN is the numeral M×N.

The challenge

Your task is to write the shortest program (taking input on STDIN) or function (taking input via argument) which produces the shortest representation of the Underload numeral for its input as a string. That is to say, if the input is a positive natural number N > 1, you must produce an Underload numeral N whose length in characters is less than or equal to that of every other Underload numeral N.

Sample inputs and outputs: ("Input - OUTPUT.")

1 - .
2 - :*.
5 - ::*:** (2×2+1).
7 - ::*::*** (2×3+1) or :::**:** (3×2+1).
33 - ::*:*:*:*:** (2×2×2×2×2+1).
49 - ::*:*:*:*::*** (16×3+1, length 14) but not ::*::***::*::*** (7×7, length 16).

If the input is not a positive natural number, you are free to return an error, produce undefined behaviour, or even fail to terminate. An explanation of your submission's method of finding the answer is appreciated.

Standard loophole restrictions apply: no extra input, no web requests, output/return value must be exactly the answer and not an infinite random stream of : and *, etc.

Python 2.7 - 87 84 92

u=lambda n:n>1and min([u(i)+u(n/i)for i in range(2,n)if n%i<1]+[':'+u(n-1)+'*'],key=len)or''

Explanation:
This is a pretty straightforward solution. It recursively tests all possible representations of n as either the product of two numbers or as :(n-1)*, and then finds the minimum length solution. range(2,n) is necessary so that the recursion has bounded depth, and n<2 gives the base case.

Notes:
i and n/i are the two factors of n. The ... and ... or ... replacement for ... if ... else ... doesn't work because '' evaluates to false. min of strings gives one of the shortest strings. Python 2.7 saves 1 character by using / instead of //.

Edit: Moved the base case to the back of the expression, allowing me to use ... and ... or ... and shave a couple spaces.

Test cases:

u(1)
''
u(5)
'::*:**'
u(49)
'::*:*:*:*::***'


Calculate digits of Pi This is a somewhat different task. Calculate 1024 hexadecimal digits of π, beginning at the 1024th hexadecimal place.

Formally: Your program should complete in less then 1 minute and produce the following output:

  25d479d8f6e8def7e3fe501ab6794c3b976ce0bd04c006bac1a94fb6409f60c45e5c9ec2196a246368fb6faf3e6c53b51339b2eb3b52ec6f6dfc511f9b30952ccc814544af5ebd09bee3d004de334afd660f2807192e4bb3c0cba85745c8740fd20b5f39b9d3fbdb5579c0bd1a60320ad6a100c6402c7279679f25fefb1fa3cc8ea5e9f8db3222f83c7516dffd616b152f501ec8ad0552ab323db5fafd23876053317b483e00df829e5c57bbca6f8ca01a87562edf1769dbd542a8f6287effc3ac6732c68c4f5573695b27b0bbca58c8e1ffa35db8f011a010fa3d98fd2183b84afcb56c2dd1d35b9a53e479b6f84565d28e49bc4bfb9790e1ddf2daa4cb7e3362fb1341cee4c6e8ef20cada36774c01d07e9efe2bf11fb495dbda4dae909198eaad8e716b93d5a0d08ed1d0afc725e08e3c5b2f8e7594b78ff6e2fbf2122b648888b812900df01c4fad5ea0688fc31cd1cff191b3a8c1ad2f2f2218be0e1777ea752dfe8b021fa1e5a0cc0fb56f74e818acf3d6ce89e299b4a84fe0fd13e0b77cc43b81d2ada8d9165fa2668095770593cc7314211a1477e6ad206577b5fa86c75442f5fb9d35cfebcdaf0c7b3e89a0d6411bd3ae1e7e4900250e2d2071b35e226800bb57b8e0af2464369bf009b91e5563911d59dfa6aa78c14389d95a537f207d5ba202e5b9c5832603766295cfa911c819684e734a41b3472dca7b14a94a

The program with the shortest length wins. You have to calculate all the digits at runtime. You do not have to implement the algorithm that computes π; if your language already provides that functionality, you can use it.

Shell Utilities: 48

curl -sL ow.ly/5u3hc|grep -Eom 1 '[a-f0-9]{1024}'

All output is "calculated" at runtime. (thanks to OP posting the solution)
Runs in under a minute. (may be dependent on your internet connection speed)


The Math is Right, But the Answer is Wrong - Robbers Challenge
The cops created code challenges which result in certain wildly incorrect answers despite correct math. Choose an uncracked, not safe formula from the cop thread.
Your task is to find an incorrect answer and describe its underlying cause. The challenge author has the responsibility to confirm whether the explanation is valid, but the incorrect answer does not have to be the same one the challenge creator had in mind.
Scoring, Rules, and Notes

Score 1 point for each successfully cracked answer.
If the error is caused by a particular usage of an external library (or specific version of it), it is sufficient to simply state that there is a known bug with a particular usage of the library used by the cop challenge. Link to a relevant bug report or article.

This is to avoid having to pour through potentially millions of lines of source code in libraries (which may be closed source anyway) to find the exact cause of the error.

Example
Cop Challenge

Formula: The Pythagorean Theorem, \$ a^2 + b^2 = c^2 \$
Inputs: 2 nonnegative real numbers
Off by more than either input number
Affects most inputs
WSL (Ubuntu 18.04) on Windows 10, Python 3.6.9

def badpythag(a, b):
    a2 = (a / 1e200) ** 2
    b2 = (b / 1e200) ** 2
    return math.sqrt(a2 + b2) * 1e200

Cracked Answer
This will fail on many inputs (e.g. 3, 4 => 0, but should be 5) due to floating point underflow and return  0. The answer is correct with very large inputs e.g. 3e150 and 4e150, however.


Imaginary Parts of Non-Trivial Riemann Zeroes Introduction

According to the Riemann Hypothesis, all zeroes of the Riemann zeta function are either negative even integers (called trivial zeroes) or complex numbers of the form 1/2 ± i*t for some real t value (called non-trivial zeroes). For this challenge, we will be considering only the non-trivial zeroes whose imaginary part is positive, and we will be assuming the Riemann Hypothesis is true. These non-trivial zeroes can be ordered by the magnitude of their imaginary parts. The first few are approximately 0.5 + 14.1347251i, 0.5 + 21.0220396i, 0.5 + 25.0108576i, 0.5 + 30.4248761i, 0.5 + 32.9350616i.

The Challenge

Given an integer N, output the imaginary part of the Nth non-trivial zero of the Riemann zeta function, rounded to the nearest integer (rounded half-up, so 13.5 would round to 14).

Rules

The input and output will be within the representable range of integers for your language.
As previously stated, for the purposes of this challenge, the Riemann Hypothesis is assumed to be true.
You may choose whether the input is zero-indexed or one-indexed.

Test Cases

The following test cases are one-indexed.

1       14
2       21
3       25
4       30
5       33
6       38
7       41
8       43
9       48
10      50
50      143
100     237

OEIS Entry

This is OEIS sequence A002410.

Mathematica, 23 bytes

⌊Im@ZetaZero@#+.5⌋&

Unfortunately, Round rounds .5 to the nearest even number, so we have to implement rounding by adding .5 and flooring.


Find the \$\left(n^2\right)^\text{th }n\$-gonal number Given a non-negative integer, \$n\$, yield the \$(n^2)^\text{th } n\$-gonal number.

Further Detail:

The \$x\$-gonal numbers, or polygonal numbers, are also known as the two-dimensional figurate numbers.

Many people will be familiar with the triangular numbers, these are the \$3\$-gonal numbers:

$$F(3,n)=\sum_{i=1}^{n}(i)=\frac{n(n+1)}{2}$$

The triangular numbers are OEIS A000217:

0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, ...

Probably even more will be familiar with the square numbers, these are the \$4\$-gonal numbers:

$$F(4,n)=\sum_{i=1}^{n}(2i-1)=n^{2}$$

The square numbers are OEIS A000290:

0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, ...

In general the \$k^\text{th }x\$-gonal number is the number of pebbles required to iteratively build up an \$x\$-sided polygon by adding pebbles to \$x-2\$ of the sides, here are a few formulae:

\begin{align}
F(x,k)&=\sum_{i=1}^{k}\left(1+\sum_{j=2}^{i}(x-2)\right) \\
&=\frac{k^2(x-2)-k(x-4)}{2} \\
&=\frac{k(k-1)}{2}(x-2)+k\\
&=(x-3)\sum_{i=1}^{k-1}(i)+\sum_{i=1}^{k}(i)\\
&=(x-2)(k-1)+1+F(x,k-1)
\end{align}

I'm sure there are plenty more.
Note that the last one is recursive but that \$F(x,0)=0\$.

The challenge

...is to golf code for \$G(n)=F(n,n^2)\$ for non-negative \$n\$.
i.e. Given a non-negative integer, \$n\$, yield the \$(n^2)^\text{th } n\$-gonal number.
This is not (currently) in the OEIS:

0, 1, 4, 45, 256, 925, 2556, 5929, 12160, 22761, 39700, 65461, 103104, 156325, 229516, 327825, 457216, 624529, 837540, 1105021, ...

Notes

You may yield a list of these numbers up to and including the required one if preferred.
For example, given an input of 5 you may yield either:

the integer 925, or
the list [0, 1, 4, 45, 256, 925]
...but not [0, 1, 4, 45, 256] or [1, 4, 45, 256, 925]

Results may also be results of floating point calculation and may deviate as such, so long as infinite precision floating point arithmetic would yield correct results.

Win by creating the shortest code in bytes in a language. The overall winner will be the shortest across all languages, but please don't let golfing languages dissuade you from entering in your favourite language - the primary goals are to challenge yourself and have fun!

Wolfram Language (Mathematica), 19 bytes

#(4-#-2#^2+#^3)#/2&

Try it online!

Just a golfy version of the second formula.

With PolygonalNumber built-in, 23 bytes

PolygonalNumber[#,#^2]&

Try it online!

As expected, the Mathematica built-in is longer than the golfed version.


Determine dice value from side view Write program or function which will take left and right value of dice as integers (1-6) and return value on top.

Dice layout:

    +---+
    | 1 |
+---+---+---+---+
| 2 | 3 | 5 | 4 |
+---+---+---+---+
    | 6 |
    +---+

  ,^.
<´ 5 `>  <-- Top value
|`._,´|
.6 | 4,  <-- Side values
 `.|,´

So inputting 6 4 will return 5.

Order is important:

2 3 -> 1
3 2 -> 6

Program doesn't have to work with invalid input values.

To discourage obvious approach (using table with all combinations), using any builtin text encoding or de/compression routines or base encoding or anything else similar to reduce size is not allowed. Note that using table is still allowed and rolling your own decompression is allowed too, as long as it's not done using some ready library function.

For reference purposes, here's a table of all combinations (i.e. all possible inputs and outputs):

23, 35, 42, 54 -> 1
14, 31, 46, 63 -> 2
12, 26, 51, 65 -> 3
15, 21, 56, 62 -> 4
13, 36, 41, 64 -> 5
24, 32, 45, 53 -> 6

Shortest code wins, and standard loopholes apply.

There's a nice polynomial expression modulo 7 for the third side given two sides a and b.

$${3(a^3b - ab^3) \mod 7}$$

or factored

$${3ab(a^2-b^2) \mod 7}$$

The modulo 7 maps to a remainder in {0,1,2,3,4,5,6}.

I explain why it works in this Math SE answer, though I do think there probably is a cleaner argument I'm missing. The only other two-term polynomial that works is

$${(3a^5b^5 - a^3b) \mod 7}$$

which I originally found by transforming my bit-bashing into arithmetic operations, then did a brute-force search over polynomials of this form to find the nicer one.

Please feel free to add ports of this into your favorite language; this is a CW post.

J, 9 by Synthetica

7|3***+*-

See my post

Dyalog APL, 9 by ngn (typo fixed by Adám)

7|3×××+×-

Blatantly stolen from above J answer.

TI-Basic, 14 by Timtech

7fPart((A³B-AB³)/21

Pyth, 16 by FryAmTheEggman

M%*3-*H^G3*^H3G7

Defines a function g of two values.

Golfscript, 18 by Peter Taylor (old polynomial)

~1$*.5?3*@.*@*- 7%

CJam, 18 by Martin Büttner (ported from Peter's GolfScript) (old polynomial)

l~1$*_5#3*@_*@*m7%

Mathematica, 20 by Martin Büttner

Mod[+##(#-#2)3##,7]&

Yes, that's a unary plus, and no, there's no shorter way that doesn't use a unary plus.

dc, 21 by Toby Speight

sb7+d3^lb*rlb3^*-3*7%

I have to add 7 to a to ensure the difference is always positive (dc has a signed % operator).

Julia, 24 23 by Martin Büttner

f(a,b)=3a*b*(a^2-b^2)%7

CoffeeScript, 28 26 by rink.attendant.6

x=(a,b)->3*a*b*(a*a-b*b)%7

JavaScript (ES6), 28 26 by rink.attendant.6

x=(a,b)=>3*a*b*(a*a-b*b)%7

Essentially the same as CoffeeScript.

Python 28, by xnor

lambda a,b:3*a*b*(a*a-b*b)%7

Bash, 31

Nothing special:

echo $[3*($1**3*$2-$1*$2**3)%7]

or alternatively:

echo $[3*$1*$2*($1*$1-$2*$2)%7]

Another (longer but perhaps interesting) approach.

Nim, 36 by Sillesta

proc(x,y:int):int=3*x*y*(x*x-y*y)%%7

Java 7, 46 44 by rink.attendant.6

int f(int a,int b){return(a*a-b*b)*a*b*3%7;}

Java 8, 25 23 by Kevin Cruijssen

a->b->(a*a-b*b)*a*b*3%7

PHP, 49 47 by rink.attendant.6

function x($a,$b){echo($a*$a-$b*$b)*3*$a*$b%7;}

Batch, 52 unclemeat

set/aa=(3*(%1*%1*%1*%2-%1*%2*%2*%2)%%7+7)%%7
echo %a%

CMD does not support true modulus natively (so can't handle negative numbers) - hence %%7+7)%%7.

LESS (as a parametric mixin), 62 60 by rink.attendant.6

.x(@a,@b){@r:mod(3*@a*@b*(@a*@a-@b*@b),7);content:~"'@{r}'"}

See my post below.

05AB1E, 10 8 by Emigna (-2 bytes by Kevin Cruijssen)

nÆs`3P7%

Try it online.

Haskell, 31 27 25 by Generic Display Name

a#b=3*a*b*(a*a-b*b)`mod`7

Try it online!

Excel, 27 by by Wernisch

=MOD(3*(A1^3*B1-A1*B1^3),7)

Excel VBA, 25 by Taylor Scott

?3*[A1^3*B1-A1*B1^3]Mod 7

Forth (gforth) 41 by reffu

: f 2>r 2r@ * 2r@ + 2r> - 3 * * * 7 mod ;

Try it online!

C#, 23 by Kevin Cruijssen

a=>b=>(a*a-b*b)*a*b*3%7


Mask an IP address and give its broadcast Background
Inspired by this Unix.SE question (and of course my own answer).
When an IP address is specified for an interface, it is often given in this dotted-decimal form:
a.b.c.d e.f.g.h

where a.b.c.d is the actual address and e.f.g.h is the netmask.
The netmask, when represented in binary, is basically a bunch of 1 bits followed by a bunch of 0 bits.  When the netmask is bitwise ANDed against the given IP address, result will be the network portion of the address, or simply the network address.  This will be programmed into the host's route table so that the host knows to send anything destined for this network out this interface.
The broadcast address for a network is derived by taking the network address (from above) and setting all the host-bits to 1.  The broadcast address is used to send to all addresses within the given network.
Challenge
Given a dotted-decimal IP address and valid netmask as input, provide the network address and broadcast address as output, also in dotted-decimal format.

Input must be address and mask as two strings in dotted-decimal format.  You may pass this as 2 separate strings, as list or array of 2 string elements or a single string with the address and mask separated by some sensible separator.
Output format is subject to the same constraints as input format.

Examples
Input                              Output

192.168.0.1 255.255.255.0          192.168.0.0 192.168.0.255
192.168.0.0 255.255.255.0          192.168.0.0 192.168.0.255
192.168.0.255 255.255.255.0        192.168.0.0 192.168.0.255
100.200.100.200 255.255.255.255    100.200.100.200 100.200.100.200
1.2.3.4 0.0.0.0                    0.0.0.0 255.255.255.255
10.25.30.40 255.252.0.0            10.24.0.0 10.27.255.255

JavaScript (ES6), 92 bytes

(a,m)=>a.split`.`.map((n,i)=>(v=m[i],m[i]=n&v|v^255,n&v),m=m.split`.`).join`.`+" "+m.join`.`

Explanation

(a,m)=>
  a.split`.`
  .map((n,i)=>(
      v=m[i],
      m[i]=n&v|v^255,
      n&v
    ),
    m=m.split`.`
  ).join`.`
  +" "+m.join`.`

Test

var solution = (a,m)=>a.split`.`.map((n,i)=>(v=m[i],m[i]=n&v|v^255,n&v),m=m.split`.`).join`.`+" "+m.join`.`
<input type="text" id="input" value="10.25.30.40 255.252.0.0" />
<button onclick="result.textContent=solution.apply(null,input.value.split` `)">Go</button>