Predict the Falling Rocks In this challenge, you are given a map of a two-dimensional terrain, viewed from the side. Unfortunately, some parts of the terrain are floating in the air, which means they'll come crashing down. Your job is to predict where they land.

The Input

Your input is one or more newline-separated strings of equal lengths, containing only the characters # (a number sign, signifying a rock) or . (a period, signifying empty space).

The Output

Your output has the same format as the input, but with the following modification. Let us view the input string as a two-dimensional grid of rocks. Every rock in the input which is connected to the bottom of the grid by a path of adjacent rocks is firm; other rocks are loose. Diagonally adjacent rocks are not considered to be adjacent. All the loose rocks will fall straight down, and end up as a stack on top of either a firm rock or the bottom row. The loose rocks are not attached to each other, so they fall individually, not as big formations. The output is the resulting grid.

Examples

The input

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

contains no loose rocks, so the output is identical to it.
The input

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

contains one loose rock at the top, which falls down on the firm rock under it. The output is

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

The input

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

has a large group of loose rocks on the left. The group breaks down as the rocks fall, so the output is

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

Clarifications

You can either take the input from STDIN and output to STDOUT, or write a function.
This is code-golf, so shortest program (in bytes) is the winner.
Standard loopholes are disallowed.

Perl 5: 98

98 including 2 command line flags.

#!perl -p0
1while/
/,($x="($`)")=~y!#!.!,s/#(.*
$)/%$1/+s/#$x?%|%$x?#/%$1$2%/s;1while s/#$x\./.$1#/s;y!%!#!

Explanation:

#!perl -p0 #read entire input to $_ and print at the end
/\n/;($x="($`)")=~y!#!.!; #calculate pattern matching space
                          #between two characters in the same column
                          #looks like "(......)"
1 while s/#(.*\n$)/%$1/+s/#$x?%|%$x?#/%$1$2%/s;
                          #flood fill solid rock with %
1 while s/#$x\./.$1#/s;   #drop loose rock
y!%!#!                    #change % back to #


Possibly quit your job with a polyglot Despite your protest, you have been put to work by your boss on a program that takes a single unsigned integer as input and prints the string "prime" if that integer is prime and "not prime" if it isn't. You may choose which language you do this in, as long as the resulting program is short; your boss very much appreciates a low character count. (He will actually manually count the characters after he prints out the source code.)
So you better get to it, the lowest character count wins.
The fun part
This is just between you and me, but your program should also be valid in another language. In this language though, it should print the string "If the boss finds this, I quit.". Make sure that your boss does not figure out there is a hidden insult when reading the code over and over as he keeps forgetting if he'd counted to 17 or 18 so far. For that reason you may not use any of the words in "the boss finds this quit" in part of the code nor can you use and anagrams of those 5 words.
Bonus challenge which I have created a bounty for
Write a program that actually looks like it just solves the first question to the untrained eye and doesn't seem to contain unnecessary characters. This includes comments and segments of code that obviously don't contribute anything. Ideally, a layman would believe that your program is actually as short as it can be without being unmanagable. A helpful comment here and there is okay though.
The rules for the bonus challenge are a bit looser, instead of being judged on easily measurable criteria, your program will be judged more on how it comes accross to me (and the voters of course)
I will be the final judge of which entry comes closest to deserving this bounty.
Edit:
After a few minutes of your boss counting, he had one of your colleages write a character counting program for him. So even characters that aren't visible count towards your character count.

Python 2 / Python 3 - 128

n=int(input())
s="Isf  tthhies ,b oIs sq ufiitn.d"
print(["not "*any([n%a<1for a in range(2,n)])+"prime",s[::2]+s[1::2]][1/2>0])

Identifies prime numbers with Python 2, get's you into trouble with Python 3.

Bonus

__help__ = """In the forloop I'm setting the values i to n.
To be a "notPrimes", it's n % i == 0 if: 1 < i, i < n. (We
do tests i<1/2 i==1, too). Then, prints resulting, prime text.
In case i==n: quit. Just if it aborts: try."""

# read integer from command line
n=int(input())

try:

    # primes = True
    notPrimes = False

    # try each i to n
    for i in range(n):

        # ignore 0 or 1
        if i < 1 / 2 or i == 1:
            continue

        # test divisibility
        if n % i == 0:
            notPrimes = True

    # print result
    if notPrimes:
        print("not prime")
    else:
        print("prime")

except:

    # if program aborts: print help and error code
    print(__help__ [::7])

Try it with Python 2 or Python 3! (In contrast to the golf version above the roles changed: Python 3 is the prime number identifier. Python 2 contains the Easter egg.)

Please, excuse my bad English in the help text! ;)

And I do use the word "quit". But somehow I need to describe when my program terminates. ;)


Code Golf: Letter-Ception The Challenge:

For an input of one letter X (upper or lower case from A to Z) and one digit N (0-9) print the corresponding letter X made of N * X.

The letter has to be from this list:

 AAA      BBBB       CCCC     DDDD      EEEEE     FFFFF      GGG      H   H
A   A     B   B     C         D   D     E         F         G         H   H
AAAAA     BBBB      C         D   D     EEEE      FFFF      G  GG     HHHHH
A   A     B   B     C         D   D     E         F         G   G     H   H
A   A     BBBB       CCCC     DDDD      EEEEE     F          GGG      H   H

IIIII         J     K   K     L         M   M     N   N      OOO
  I           J     K  K      L         MM MM     NN  N     O   O
  I           J     KKK       L         M M M     N N N     O   O
  I       J   J     K  K      L         M   M     N  NN     O   O
IIIII      JJJ      K   K     LLLLL     M   M     N   N      OOO

PPPP       QQQ      RRRR       SSSS     TTTTT     U   U     V   V     W   W
P   P     Q   Q     R   R     S           T       U   U     V   V     W   W
PPPP      Q   Q     RRRR       SSS        T       U   U     V   V     W   W
P         Q  QQ     R  R          S       T       U   U      V V      W W W
P          QQQQ     R   R     SSSS        T        UUU        V        W W

X   X     Y   Y     ZZZZZ
 X X       Y Y         Z
  X         Y         Z
 X X        Y        Z
X   X       Y       ZZZZZ

Examples:

input: a 1

output:

 AAA
A   A
AAAAA
A   A
A   A

input: A 0

output: A

input: A 2

output:

      AAA  AAA  AAA
     A   AA   AA   A
     AAAAAAAAAAAAAAA
     A   AA   AA   A
     A   AA   AA   A
 AAA                 AAA
A   A               A   A
AAAAA               AAAAA
A   A               A   A
A   A               A   A
 AAA  AAA  AAA  AAA  AAA
A   AA   AA   AA   AA   A
AAAAAAAAAAAAAAAAAAAAAAAAA
A   AA   AA   AA   AA   A
A   AA   AA   AA   AA   A
 AAA                 AAA
A   A               A   A
AAAAA               AAAAA
A   A               A   A
A   A               A   A
 AAA                 AAA
A   A               A   A
AAAAA               AAAAA
A   A               A   A
A   A               A   A

input: A -1

output: what ever: it doesn't matter

Additional Rules:

The input parameters can be separated by what ever character you
   want.
Each letter must use the capital of itself as the ascii-character to draw it.
Trailing spaces, new lines etc. are allowed
Instead of a program, you may write a function that takes the digit string as an argument. The output should be printed normally.
Stdout / Stderr doesn't matter, just pick one. If stuff gots printed on the other doesn't matter either.
Possible output formats can be printed to STDOUT, returned as a list of strings, returned as a character matrix, etc. as long as the result can simply be printed using the languages default print method.*

*: like the function f(a,1) returns the string and one can simply say print(f(a,1)) dont make the print() call part of the answer. (This was pointed out by Kevin Cruijssen and  Arnauld).

Winning:

This is code-golf, lowest byte-count wins. Have fun!

Edit: this question seems very identical to this however I would say it is not, as it should not only work for H but for each letter from the alphabet.. Guess you decide rather or not it is a duplicate.

JavaScript (ES8), 281 bytes

Takes input as (letter)(N). Returns a string.

c=>n=>(g=y=>y--?''.padEnd(w).replace(/./g,(_,x)=>(h=d=>~~(d/=5)?(P=parseInt)('hhvhefhfhfu111ufhhhfv1f1v11f1vehp1ehhvhhv444vehgggh979hv1111hhlrhhpljhehhhe11fhfuphheh9fhffge1u4444vehhhh4ahhhalhhhha4ah444ahv248v'[y/d%5+5*P(c,36)-50|0],36)>>x/d%5&1?h(d):' ':c)(w))+`
`+g(y):'')(w=5**n)

Try it online!

How?

Font encoding

The letters are \$5\times5\$, which means that each row can be encoded as a 5-digit binary value, i.e. \$0\$ to \$31\$ in decimal. These values can conveniently be stored as a single digit in Base36.

The pattern that is stored is mirrored both horizontally and vertically.

Example for 'F':

#####     ....#     00001      1     '1'
#....     ....#     00001      1     '1'
####. --> .#### --> 01111 --> 15 --> 'f' --> '11f1v'
#....     ....#     00001      1     '1'
#....     #####     11111     31     'v'

The whole font is stored as a single string of \$26\times5 = 130\$ characters.

To test the 'pixel' at \$(x,y)\$ for the \$n^{\text{th}}\$ letter, we do:

parseInt('hhvhefhfh...'[y + 5 * n], 36) >> x & 1

Main algorithm

Given \$n\$, we define \$w=5^n\$, which is the width of the final output.

For \$0\le x<w\$ and \$0\le y<w\$, we want to know if the output pixel at \$(x,y)\$ is set or not. We use the recursive function \$h\$, which tests the letter pixel located at:

$$\left(\left\lfloor\frac{x}{5^k}\right\rfloor\bmod 5,\left\lfloor\frac{y}{5^k}\right\rfloor\bmod 5\right)$$

for all \$k\$ in \$[0 \dots n-1]\$.

The function returns a space as soon as a blank pixel is detected at some depth, or the character corresponding to the input letter if all iterations are successful.


CSI: Minecraft Items Minecraft 1.12 will be released tomorrow, so let's celebrate!
Write code that takes in a non-negative integer N which represents the number of items of something in Minecraft. Output it in a way more helpful to players, giving the number of chests, stacks, and items N is equivalent to. Use the format
XcYsZi

where

X is the number of chests you can completely fill with N items,
Y is the number of stacks you can fill with the items remaining after filling chests,
Z if the number of items remaining after filling chests and stacks.

Note that:

64 items fit in a stack. (We'll ignore items that stack to 16 or don't stack.)
27 stacks fit in a chest. (These are single chests, not double chests.)

So it would never make sense if Y is more than 26 or if Z is more than 63.
A caveat with the format is that if there is zero of something, that term is not printed.

So, for example, if Y were zero and X and Z nonzero, the format would look like XcZi.

Likewise if Y and Z were zero and X nonzero, the format would be Xc.

The exception here is when N is zero. Then 0i is the output rather than an empty string.

You can assume all N items are of the same type, hence all stackable.
You may not output a list or tuple of three numbers. You must give a string with the exact "csi" notation, in that order, with no spaces or commas.
For reference, here's a chest completely filled with stacks of items:

Testcases
in -> out
0 -> 0i
1 -> 1i
2 -> 2i
62 -> 62i
63 -> 63i
64 -> 1s
65 -> 1s1i
66 -> 1s2i
127 -> 1s63i
128 -> 2s
129 -> 2s1i
200 -> 3s8i
512 -> 8s
1337 -> 20s57i
1664 -> 26s
1727 -> 26s63i
1728 -> 1c
1729 -> 1c1i
1791 -> 1c63i
1792 -> 1c1s
1793 -> 1c1s1i
4096 -> 2c10s
5183 -> 2c26s63i
5184 -> 3c
5200 -> 3c16i
9999 -> 5c21s15i
385026 -> 222c22s2i
1000000000 -> 578703c19s

The shortest code in bytes wins.

Jelly,  26  24 bytes

d64d1¦27Fża¥“csi”Fḟ0ȯ⁾0i

A full program taking the number and printing the result.
It does seem too long to me...

Try it online! or see the test suite.

How?

updating...

d64d1¦27Fża¥“csi”Fḟ0ȯ⁾0i - Main link: number n
 64                      - literal 64
d                        - divmod (whole divisions and remainder)
      27                 - literal 27
    1¦                   - apply to index 1 (the whole division from above)
   d                     - divmod
        F                - flatten into a single list (of three items i.e. [(n/64)/27, (n/64)%27, n%64]
            “csi”        - literal ['c','s','i']
           ¥             - last two links as a dyad:
         ż               -   zip
          a              -   logical and (any 0s in the divmod result become [0,0], others become [integer, character]
                 F       - flatten (from list of three lists to one list)
                  ḟ0     - filter discard zeros
                     ⁾0i - literal ['0','i']
                    ȯ    - logical or (non-vectorising)
                         - implicit print (smashed together representation, so [578703,'c',19,'i'] prints as 578703c19i)


Is this a Boggle pad? Given a list of case-insensitive ASCII letter strings ("words"), output whether the entire list can be found on some four-by-four configuration ("board") of letter squares, in which no square can be used more than once in a word, and in which words are formed by moving from any square to any adjacent square including diagonally.
You do not need to worry that the combination of squares that would allow for the list actually appears in a Boggle game. The words need not be actual words in any language. You should assume that if Q appears on the board, it's on a square of its own (unlike in actual Boggle).
Standard loopholes are banned, standard I/O rules apply, and you're golfing.

In the examples below, a slash signifies a newline.
Truthy examples

auuuuooiiaaoiee, euiaaiueeuua, ooouuueee, eueueuoaoa — All are on the board auii/euoa/ueoa/euio
swiop, byteba, ceropl, qoiz, aeis, lqoep — All are on the board abcb/rety/poiw/lqzs

Falsy examples

swiop, byteba, ceropl, qoiz, aeis, lqoep, wybez — There are fifteen distinct letters (abceilopqrstwyz) and a single word has two bs, so that's the sixteenth square. Thus there's only one e. But the e has nine distinct letters (abcioprtz) adjacent to it, which is impossible.
hskcbnzvgfa, lajdnzvfhgs, kajfbmxvshd, ldgckvbsanx — There are sixteen distinct letters (abcdfghjklmnsvxz). Of those, s is adjacent to all of abghkv, v is adjacent to all of bfgksxz, b is adjacent to all of cfmnsv, a is adjacent to all of fjklns, and f is adjacent to all of abghjv. But on an actual board only four squares are adjacent to more than five squares apiece.

Python 3, 215 bytes

def f(w):b=product(*[set("".join(w))]*16);return any(all(any(all(x-y in[1,-1,4,-4]for x,y in zip(q,q[1:]))for q in product(*[[x for x in range(16)if k[x]==c]for c in a]))for a in w)for k in b)
from itertools import*

Try it online!

This is never going to finish, so I can't really debug it or prove it works. I will try to find constant optimizations / test with reduced test cases, but if you spot a reason it would definitely fail, I will take it down / fix it.


Calculate COVID spread Because the coronavirus is still at large, I thought it would be fitting to have a epidemic-themed challenge.
Challenge
You are given a 2D array of people, where 1 represents someone with the virus, and 0 represents someone without the virus. Every day, the people with the virus infect their neighbours. You must calculate, given such a grid, how many days it will take to infect the population (i.e., every item is 1).
Rules

The input counts as Day 0, and every day after increases by 1 (you can count the first day as Day 1 if you want, but indicate that in your answer).
The grid items don't have to be 1s and 0s, they can be any truthy/falsy values. Every item in the grid is randomized to one of those values. Please specify which truthy/falsy values your program will/will not accept.
The input grid can be any size between 2x2 and 100x100. The grid does not have to be square. The grid size is randomized (i.e. you can't choose).
Diagonal squares do not count as adjacent.
This is code-golf, so the shortest answer wins!

Examples
[[1, 0, 0, 0, 1],  # Input
 [0, 1, 0, 0, 0],
 [0, 0, 0, 0, 0],
 [0, 0, 0, 1, 0]]

[[1, 1, 0, 1, 1],  # Day 1
 [1, 1, 1, 0, 1],
 [0, 1, 0, 1, 0],
 [0, 0, 1, 1, 1]]

[[1, 1, 1, 1, 1],  # Day 2
 [1, 1, 1, 1, 1],
 [1, 1, 1, 1, 1],
 [0, 1, 1, 1, 1]]

[[1, 1, 1, 1, 1],  # Day 3
 [1, 1, 1, 1, 1],
 [1, 1, 1, 1, 1],
 [1, 1, 1, 1, 1]]

output = 3

[[1, 0],  # Input
 [0, 0],
 [0, 0]]

[[1, 1],  # Day 1
 [1, 0],
 [0, 0]]

[[1, 1],  # Day 2
 [1, 1],
 [1, 0]]

[[1, 1],  # Day 3
 [1, 1],
 [1, 1]]

output = 3

Jelly, 10 bytes
ŒJạ€ŒṪ§Ṃ€Ṁ

Try it online!
-2 bytes thanks to Sisyphus
Calculate the Manhattan differences from all 0s to all 1s, and the answer is the maximum of the minimums (each row's minimum is the number of stages until it gets infected, so the number of stages needed is the maximum of the stages needed for each person).
Conveniently, if all elements are 1, this returns 0 since that's the default value for minmax.
If no person is infected in the initial state, this also returns 0.
Explanation
ŒJạ€ŒṪ§Ṃ€Ṁ  Main Link
ŒJ          Get all indices in the grid (2D indices in a matrix)
    ŒṪ      Get all truthy indices in the grid (finds all infected people)
  ạ€  §     Manhattan distance between each point to each truthy point
       Ṃ€   Minimum of each (minimum number of days for each person to get infected)
         Ṁ  Maximum (of each point's required days to get infected)


Calculate the difficulty of a Code Golf question Briefing
The difficulty of a Code Golf question can be calculated as such:
$$\text{clamp} \left( \left\lceil \left( \frac v a \div 700 \right) \times 10 \right\rceil, 0, 10 \right)$$
Where \$v\$ is the number of views a question has
and \$a\$ is the number of answers a question has
and \$⌈x⌉\$ is the ceiling operator.
Also:
$$\text{clamp}(x, min, max) = \begin{cases}
min & x < min \\
x   & min \le x \le max \\
max & max < x
\end{cases}$$
This question's current difficulty: ***
Task
Write a program that will take two integers (v and a) and output the difficulty in asterisks (*).
The input can be in the form of an array, a separated string or as separate function arguments
Test Data
Views   Answers Difficulty  Program Output
163     2       2           **
548     22      1           *
1452    24      1           *
1713    37      1           *
4162    32      2           **
3067    15      3           ***
22421   19      10          **********

Example with pseudocode
v: 1713
a: 37
out = clamp(ceil(((v/a)/700)*10), 0, 10); // evaluates to 1
//program will output '*'

The shortest code in bytes wins! Trailing/ leading spaces are allowed.

JavaScript (ES6), 40 39 bytes

v=>a=>"**********".substring(10-v/a/70)

Because substring provides the required clamping and "ceil"ing behaviour. Edit: Normally I'm too lazy to bother, but because it got 4 upvotes, I've followed @MarsUltor's advice to save 1 byte by currying.


Check If my String is Prime We define a prime character as a character that has a prime ASCII value. We define a prime string as a String that only contains prime characters.

Given a String that only contains printable ASCII, determine whether that String is prime.

Input / Output

You can take input either as a String or as a list of individual characters. You have to output two different and consistent values depending on whether the String is prime, following the standard rules for a decision-problem. You are guaranteed that the input will be non-empty.

Test Cases

Truthy cases (Prime Strings):

"aeg"
"aIS5"
"aaaaaaaaaaaaaa"
"/S/S"
"=;+"

Falsy cases (not Prime Strings):

"maTHS"
"Physics"
"\\\\"
"PPCG"
"Code Golf"
"Prime"

This is code-golf, so the shortest code in bytes wins! Standard rules for this tag apply.

Jelly, 4 bytes
OÆPẠ

Try it online!
Explanation
Remember that a string is an array of characters, so operations like O will apply to each individual character.
OÆPẠ
O        Ord; cast each character to a number
 ÆP      Is it ÆPrime? gives 1 for truthy and 0 for falsey
   Ạ     Ạll; returns 1 if the array contains no falsey values


Rearrange pixels in image so it can't be recognized and then get it back Create a program which can rearrange pixels in image so it can't be recognized.
However your program should able to convert it back to original image.

You can write two functions - for encoding and decoding, however one function which applied repeatedly gives original image (example in math - f(x) = 1 - x) is a bonus.

Also producing some pattern in output gives bonus too.

Image may be represented as 1D/2D array or image object if your language supports it.
Note that you can only change order of pixels!

Will be logical to select as winner code which produces less recognizable image, however I don't know how to measure it exactly, all ways I can imagine can be cheated. Therefore I chose this question to be popularity contest - let users choose what the best answer!

Test image 1 (800 x 422 px):

Test image 2 (800 x 480 px):

Please provide with code output image.

Python 2.7 (with PIL) - No Pseudorandomness

I break the image into 2 by 2 blocks (ignoring the remainder) and rotate each block by 180 degrees, then I do the same with 3 by 3 blocks, then 4, etc. up to some parameter BLKSZ. Then I do the same for BLKSZ-1, then BLKSZ-2, all the way back down to 3, then 2. This method reverses itself exactly; the unscramble function is the scramble function.

The code:

from PIL import Image
import math

im = Image.open("ST1.png", "r")
arr = im.load() #pixel data stored in this 2D array

def rot(A, n, x1, y1): #this is the function which rotates a given block
    temple = []
    for i in range(n):
        temple.append([])
        for j in range(n):
            temple[i].append(arr[x1+i, y1+j])
    for i in range(n):
        for j in range(n):
            arr[x1+i,y1+j] = temple[n-1-i][n-1-j]

xres = 800
yres = 480
BLKSZ = 50 #blocksize
for i in range(2, BLKSZ+1):
    for j in range(int(math.floor(float(xres)/float(i)))):
        for k in range(int(math.floor(float(yres)/float(i)))):
            rot(arr, i, j*i, k*i)
for i in range(3, BLKSZ+1):
    for j in range(int(math.floor(float(xres)/float(BLKSZ+2-i)))):
        for k in range(int(math.floor(float(yres)/float(BLKSZ+2-i)))):
            rot(arr, BLKSZ+2-i, j*(BLKSZ+2-i), k*(BLKSZ+2-i))

im.save("ST1OUT "+str(BLKSZ)+".png")

print("Done!")

Depending on the blocksize, you can make the computation eradicate all resemblance to the original image: (BLKSZ = 50)

Or make the computation efficient: (BLKSZ = 10)


Word search puzzle generation Given a list of strings, find the smallest square matrix that contains each of the initial strings. The strings may appear horizontally, vertically or diagonally and  forwards or backwards like in this question Word Search Puzzle.

Words should be placed in the square, with at least one word in each direction (horizontal, vertical and diagonal). Words should appear just one time.

So, the input is just a list of words. For example: CAT, TRAIN, CUBE, BICYCLE. One possible solution is:

B N * * * * *
* I * * C A T
* A C * * * *
* R * Y * * C
* T * * C * U
* * * * * L B
* * * * * * E

I replaced filling letters with asterisks just for clarity. The desired output should include random filling letters.

JavaScript (ES6), 595 628 680

Edit Some cleanup and merge:
- function P merged inside function R
- calc x and z in the same .map
- when solution found, set x to 0 to exit outer loop
- merged definiton and call of W

Edit2 more golfing, random fill shortened, outer loop revised ... see history for something more readable

Unlike the accepted answer, this should work for most inputs. Just avoid single letter words. If an output is found, it's optimal and using all 3 directions.

The constraint of avoiding repeating words is very hard.
I had to look for repeating word at each step adding word to the grid, and at each random fill character.

Main subfunctions:

P(w) true if palindrome word. A palindrom word will be found twice when checking for repeated words.
R(s) check repeating words on grid s
Q(s) fill the grid s with random characters - it's recursive and backtrack in case of repeating word - and can fail.
W() recursive, try to fill a grid of given size, if possibile.

The main function use W() to find an output grid, trying from a size of the longest word in input up to the sum of the length of all words.

F=l=>{
  for(z=Math.max(...l.map(w=>(w=w.length,x+=w,w),x=0));
      ++z<=x;
      (W=(k,s,m,w=l[k])=>w?s.some((a,p)=>!!a&&
            D.some((d,j,_,r=[...s],q=p-d)=>
              [...w].every(c=>r[q+=d]==c?c:r[q]==1?r[q]=c:0)
              &&R(r)&&W(k+1,r,m|1<<(j/2))
            )
          )
        :m>12&&Q(s)&&(console.log(''+s),z=x)
      )(0,[...Array(z*z-z)+99].map((c,i)=>i%z?1:'\n'))
    )
    D=[~z,-~z,1-z,z-1,z,-z,1,-1]
    ,R=u=>!l.some(w=>u.map((a,p)=>a==w[0]&&D.map(d=>n+=[...w].every(c=>u[q+=d]==c,q=p-d)),
      n=~([...w]+''==[...w].reverse()))&&n>0)
    ,Q=(u,p=u.indexOf(1),r=[...'ABCDEFGHIJHLMNOPQRSTUVWXYZ'])=>
      ~p?r.some((v,c)=>(r[u[p]=r[j=0|c+Math.random()*(26-c)],j]=v,R(u)&&Q(u)))||(u[p]=1):1
    //,Q=u=>u.map((c,i,u)=>u[i]=c!=1?c:' ') // uncomment to avoid random fill
}

Ungolfed and explained (incomplete, sorry guys it's a lot of work)

F=l=>
{
  var x, z, s, q, D, R, Q, W;
  // length of longest word in z
  z = Math.max( ... l.map(w => w.length))
  // sum of all words length in x
  x = 0;
  l.forEach(w => x += w.length);

  for(; ++z <= x; ) // test square size from z to x
  {
    // grid in s[], each row of len z + 1 newline as separator, plus leading and trailing newline
    // given z==offset between rows, total length of s is z*(z-1)+1
    // gridsize: 2, z:3, s.length: 7
    // gridsize: 3, z:4, s.length: 13
    // ...
    // All empty, nonseparator cells, filled with 1, so
    // - valid cells have a truthy value (1 or string)
    // - invalid cells have falsy value ('\n' or undefined)
    s = Array(z*z-z+1).fill(1)
    s = s.map((v,i) => i % z != 0 ? 1 : '\n');

    // offset for 8 directions
    D = [z+1, -z-1, 1-z, z-1, z, -z, 1, -1]; // 4 diags, then 2 vertical, then 2 horizontal

    // Function to check repeating words
    R = u => // return true if no repetition
      ! l.some( w => // for each word (exit early when true)
      {
          n = -1 -([...w]+''==[...w].reverse()); // counter starts at -1 or -2 if palindrome word
          u.forEach( (a, p) => // for each cell if grid
          {
            if (a == [0]) // do check if cell == first letter of word, else next word
               D.forEach( d => // check all directions
                 n += // word counter
                   [...w].every( c => // for each char in word, exit early if not equal
                     u[q += d] == c, // if word char == cell, continue to next cell using current offset
                     q = p-d  // starting position for cell
                   )
               ) // end for each direction
          } ) // end for each cell
          return n > 0 // if n>0 the word was found more than once
      } ) // end for each word

    // Recursive function to fill empty space with random chars
    // each call add a single char
    Q =
    ( u,
      p = u.indexOf(1), // position of first remaining empty cell
      r = [...'ABCDEFGHIJHLMNOPQRSTUVWXYZ'] // char array to be random shuffled
    ) => {
      if (~p) // proceed if p >= 0
        return r.some((v,c)=>(r[u[p]=r[j=0|c+Math.random()*(26-c)],j]=v,R(u)&&Q(u)))||(u[p]=1)
      else
        return 1; // when p < 0, no more empty cells, return 1 as true
    }
    // Main working function, recursive fill of grid
    W =
    ( k, // current word position in list
      s, // grid
      m, // bitmask with all directions used so far (8 H, 4V, 2 or 1 diag)
      w = l[k] // get current word
    ) => {
      var res = false
      if (w) { // if current word exists
        res = s.some((a,p)=>!!a&&
            D.some((d,j,_,r=[...s],q=p-d)=>
              [...w].every(c=>r[q+=d]==c?c:r[q]==1?r[q]=c:0)
              &&R(r)&&W(k+1,r,m|1<<(j/2))
            )
          )
      }
      else
      { // word list completed, check additional constraints
        if (m > 12 // m == 13, 14 or 15, means all directions used
            && Q(s) ) // try to fill with random, proceed if ok
        { // solution found !!
          console.log(''+s) // output grid
          z = x // z = x to stop outer loop
          res = x//return value non zero to stop recursion
        }
      }
      return res
    };
    W(0,s)
  }
}

Test in Firefox/FireBug console

F(['TRAIN', 'CUBE','BOX','BICYCLE'])

,T,C,B,O,X,B,H,
,H,R,U,H,L,I,H,
,Y,A,A,B,E,C,B,
,D,H,S,I,E,Y,I,
,H,E,R,L,N,C,T,
,G,S,T,Y,F,L,U,
,H,U,Y,F,O,E,H,

not filled

,T,C,B,O,X,B, ,
, ,R,U, , ,I, ,
, , ,A,B, ,C, ,
, , , ,I,E,Y, ,
, , , , ,N,C, ,
, , , , , ,L, ,
, , , , , ,E, ,

F(['TRAIN','ARTS','RAT', 'CUBE','BOX','BICYCLE','STORM','BRAIN','DEPTH','MOUTH','SLAB'])

,T,A,R,C,S,T,H,
,S,R,R,L,U,D,T,
,T,B,A,T,N,B,P,
,O,B,O,I,S,A,E,
,R,B,A,X,N,H,D,
,M,R,M,O,U,T,H,
,B,I,C,Y,C,L,E,

F(['AA','AB','AC','AD','AE','AF','AG'])

,A,U,B,C,
,T,A,E,Z,
,C,D,O,F,
,Q,C,G,A,

F(['AA','AB','AC','AD','AE','AF'])

output not filled - @nathan: now you can't add another Ax without repetitions. You'll need a bigger grid.

,A, ,C,
, ,A,F,
,D,E,B,


Length of the Longest Palindromic Substring A palindrome is a string which is the same when read forwards and backwards. For example "racecar" is a palindrome, but "Racecar" is not. A substring is a contiguous set of characters in a larger string. Your task is to write a program or method which takes a string or character array as input and outputs the length of the longest substring of that string which is a palindrome.

Examples

Input

banana

Ouput

5

This is because "anana" is a 5 character substring of "banana"

Input

abracadabra

Output

3

This is because both "aca" and "ada" are 3 characters.

Input

True

Output

1

This string has no palindromes that are more than 1 character.

If the input is the empty string the output must be 0.

This is code-golf so the shortest submission in any language wins.

Note: There have been slight variations of this question in the past, which have all had wording issues or been asking a variation of this question. You can see these:

Find the Longest Palindrome in a String by Removing Characters

Longest reverse palindromic DNA substring

How do I find the longest palindrome in a string?

Finding "sub-palindromes". - The purpose of this challenge is to print all palindromic substring, rather than the length of the longest. As such many of the answers to this question do not have close analogues.

Brachylog, 9 bytes
{s.↔}ᶠlᵐ⌉

Try it online!
Explanation
{   }ᶠ       Find all…
 s.            …substrings of the input…
  .↔           …which are their own reverse
      lᵐ     Map length
        ⌉    Max


maximum subarray variant Problem
There is a circular track containing fuel pits at irregular intervals. The total amount of fuel available from all the pits together is just sufficient to travel round the track and finish where you started. Given the the circuit perimeter, list of each fuel pit location and the amount of fuel they contain, find the optimal start point on the track such that you never run out of fuel and complete circuit.

Sample Input

(location, fuel)

(0/100, 6)
(2,16)
(18,1)
(30,45)
(84,5)
(92,27)

circuit length - 100, total fuel-100

JavaScript 140 chars

For the first solution, I assume that the fuel pits are provided in order order of location around the track and in the form:

var fuelPitInfo = [
    {
       location: 2,//The location from some point on the track
       fuelDistance: 1//The distance you can travel with the fuel from this stop
    },
    ..
]

Thus, a potential non code-golfed JavaScript function to calculate a working starting location is as follows (test fiddle):

function calculateStartingLocation(trackLength, fuelPitInfo) {
    for(i=0;;i++){
        var fuelPit = fuelPitInfo[i];
        var remainingFuelDistance = fuelPit.fuelDistance;
        for(j=i+1;;j++){
            var nextFuelPit = fuelPitInfo[j = j % fuelPitInfo.length];
            if (i == j) return fuelPitInfo[i].location;
            remainingFuelDistance -= (nextFuelPit.location - fuelPit.location + trackLength) % trackLength;
            if (remainingFuelDistance < 0) break;
            remainingFuelDistance += nextFuelPit.fuelDistance;
            fuelPit = nextFuelPit;
        }
    }
}

And the code-golfed function version (140 chars) is as follows (assuming location is replaced with l and fuelDistance is replaced with d in the provided fuelPitInfo object) (test fiddle):

function a(b,c){for(i=0;e=c[i],f=e.d;i++){for(j=i+1;g=c[j=j%c.length];){if(i==j++)return c[i].l;f-=(g.l-e.l+b)%b;if(f<0)break;f+=g.d,e=g;}}}


Grid Based Digital Logic (Duodyadic Tiles) Duodyadic tiles are kinds of square function blocks that take two inputs, one from their top side and one from their left side, and have two outputs, one on their right side and one on their bottom side. Each of their outputs is a separate function of both of their inputs.
For example, if # represents a generic tile, the right output R is a function f of inputs T and L, and the bottom output B is another function g of T and L:
 T
L#R         R = f(T, L)
 B          B = g(T, L)

(The tiles are termed "duo" since there are two functions, and "dyadic" since both functions have two arguments.)
Tiles can then be composed together on a grid, the outputs of one tile going directly into the inputs of the tiles it neighbors. Here for example, the right output of the left # goes into the left input of the right #:
 AB         D = f(f(A, C), B)
C##D        E = g(A, C)
 EF         F = g(f(A, C), B)

You can imagine that given a set of duodyadic tiles, each with specific functionality, complex (and potentially useful) compositions could be made.
In this challenge, we'll only be concerned with the traditional set of ten logic based duodyadic tiles, where all the inputs and outputs are single-bit binary numbers (zeros or ones). We'll use a separate ASCII character to denote each type of tile.
The tile characters and their input-output relations are as follows:
(T is for top input, L for left input, R for right output, B for bottom output.)

Zero: 0 or   (space) → R = 0, B = 0
One: 1 → R = 1, B = 1
Cross: + → R = L, B = T
Mirror: \ → R = T, B = L
Top only: U → R = T, B = T
Left only: ) → R = L, B = L
Not: ! → R = not L, B = not T
And: & → R = L and T, B = L and T
Or: | → R = L or T, B = L or T
Xor: ^ → R = L xor T, B = L xor T

Challenge
Write a program or function that takes in a rectangular grid of the characters 0 1+\U)!&|^ that represents a "circuit" made using the ten logic based duodyadic tiles. You also need to take in two strings of 0's and 1's; one will be the left input column and one will be the top input row. Your program/function needs to print/return the bottom output row and the right output column (also in 0's and 1's).
For example, in this grid
+++
+++

all the inputs flow straight across the grid to the outputs
 ABC
D+++D
E+++E
 ABC

so an input of 010/01 would have output 010/01:
 010
0+++0
1+++1
 010

The exact output of your program would be [bottom output row]\n[right output column] or [bottom output row]/[right output column]:
010
01

or
010/01

If you wrote a function, you could return the two strings in a tuple or list (or still print them).
Details

Take the three inputs as strings in any reasonable manner (preferably in the order grid, top row, left column): command line, text file, sdtin, function arg.
You can assume the input row and column lengths will match the grid dimensions and will only contain 0's and 1's.
Your grid must use the proper characters (0 1+\U)!&|^). Remember that 0 and   mean the same thing.

Test Cases
(Read I/O as top/left → bottom/right.)
Nand:
&!

00/0 → 01/1
00/1 → 01/1
10/0 → 01/1
10/1 → 11/0
All ones:
1111
1\+\
1+\+
1\+\

Any input should result in 1111/1111.
Xor from Nand: (note the column of trailing spaces)
\)+\
U&!&
+! !
\&!&
   !

00000/00000 → 00000/00000
00000/10000 → 00010/00000
10000/00000 → 00010/00000
10000/10000 → 00000/00000
Zig zag:
+++\00000000
000\!!!!\000
00000000\+++

The first bit of the left input becomes the last bit of the right output. Everything else is 0.
000000000000/000 → 000000000000/000
000000000000/100 → 000000000000/001
Propagation:
)))
UUU
U+U
U+U
UUU

The first bit of the left input goes to all the outputs.
000/00000 → 000/00000
000/10000 → 111/11111
Here's a pastebin of all 1×1 grid test cases.
Scoring
The shortest submission in bytes wins.
Bonus: What cool "circuits" can you make?
P.S. Don't bother Googling "duodyadic tiles". I made them up yesterday ;D
If you want to discuss expanding this idea into a full-fledged programming language, come to this chatroom.

C, 332 309 272 270 266 259 247 225 bytes

#define C(x)*c-x?
i,k,T,L,m;f(c,t,l)char*c,*t,*l;{while(L=l[i]){for(k=0;T=t[k];c++)L=C(49)C(43)C(92)C(85)C(41)C(33)C(38)C('|')C(94)T=48:(T^=L-48):(T|=L):(T&=L):(T^=1,L^1):(T=L):T:(m=T,T=L,m):L:(T=49),t[k++]=T;c++;l[i++]=L;}}

View results online here!
This defines a function void f(char*, char*, char*), which should take the board as its first input, then the top row of input, and then the left row of input.
Here's what I used to test it:
#include "stdio.h"
int main() {
    char buf[1024],top[33],left[33];
    /* Copy and paste an example circuit as the first input,
       and put a 'Q' immediately after it.
       Note that the Q is never touched by the function f, and is used
       solely as a delimiter for input. */
    scanf("%[^Q]Q ",buf);
    /* Then enter your top inputs */
    scanf("%[01]%*[^01]", top);
    /* Then your left ones */
    scanf("%[01]", left);
    /* OUTPUT: Bottom\nRight */
    f(buf, top, left);
    return 0;
}

Thus, by inputting Sp3000's 2-bit multiplier:
UUUU))))
UU++)))&
UUU+)  U
UU++&))U
U++&+)^U
U)&\&)UU
   U+^UU
   \&UUUQ
11110000
00000000

We get:
00001001
11111111

On another note, with Sp3000's half adder in mind, I'd like to see a full adder... One of you guys did it! I don't think the system stands on its own as a programming language, but it's been very interesting. This seems like an excellent target for metagolf, though!
A Short Explanation:
Here's the unraveled, commented code:
/* We define the first half of the ?: conditional operator because, well,
   it appears over and over again. */
#define C(x)*c-x?
/* i,k are counting variables
   T,L are *current* top and left inputs */
i,k,T,L,m;
f(c,t,l)char*c,*t,*l;{
    /* The outer loop iterates from top to bottom over l and c */
    while(L=l[i]){
        /* Inner loop iterates from left to right over t and c */
        for(k=0;T=t[k];c++)
            /* This line looks awful, but it's just a bunch of character
            comparisons, and sets T and L to the output of the current c */
            L=C(49)C(43)C(92)C(85)C(41)C(33)C(38)C('|')C(94)T=48:(T^=L-48):(T|=L):(T&=L):(T^=1,L^1):(T=L):T:(m=T,T=L,m):L:(T=49),
            /* Write our output to our input, it will be used for the next row */
            t[k++]=T;
        c++; /*Absorbs the newline at the end of every row */
        /* Keep track of our right-most outputs,
        and store them in the handy string passed to the function. */
        l[i++]=L;
    }
    /* Bottom output is now stored entirely in t, as is right output in l */
}

We iterate over c, left to right (then top to bottom), rewriting the t inputs each time and pushing out a right-most output which is shoved into the l string. We can imagine this as replacing the top row of c with 1's and 0's iteratively, and keeping track of the bits that are pushed out at the right.
Here's a more visual sequence, row by row:
 111
1&+^  =>  110 ->0  =>     ->0  =>     0 Thus, "01" has been written to l,
1+&+     1+&+         110 ->1         1
                                  110   And "110" is stored currently in t.

This obviously gets more complicated with different symbols and sizes, but the central idea holds. This works only because data never flows up or left.


Convert string to time This challenge is inspired by this other.

The challenge

Write a program or a function in any programming language that given as input a string representing a time in English (see below, for further details) it outputs or prints the equivalent in the 24 hours "digital" format HH:MM.

Shortest code in bytes wins, standard loopholes are forbidden.

Input format

Your program should be able to handle all this kind of inputs:

one minute past 'HOUR'
'MINUTES' minutes past 'HOUR'
quarter past 'HOUR'
half past 'HOUR'
one minute to 'HOUR'
'MINUTES' minutes to 'HOUR'
quarter to 'HOUR'
'HOUR'
'HOUR12' 'MINUTES' AM
'HOUR12' 'MINUTES' PM

where: MINUTES is a number from 1 to 59 written in English with hyphen; HOUR is the name of an hour in one of the formats:

midnight
noon
midday
'HOUR24' o'clock
'HOUR12' o'clock AM
'HOUR12' o'clock PM

HOUR12 is a number from 1 to 12 written in English with hyphen; and HOUR24 is a number from 1 to 23 written in English with hyphen.

Some examples

midnight                                  ->   00:00
midday                                    ->   12:00
twelve o'clock                            ->   12:00
quarter to midnight                       ->   23:45
twenty-two minutes past eight o'clock PM  ->   20:22
thirty-four minutes to fifteen o'clock    ->   14:26
six o'clock AM                            ->   06:00
one minute to twenty-one o'clock          ->   20:59
seven thirteen AM                         ->   07:13
nine fourteen PM                          ->   21:14

Good luck!

Ruby, 653 597 Bytes
P=/ past | to /;T=%w{q twen thirty fourty fifty sixty el twe thi fourte fifte sixt sevent eighte ninet o tw th fo fi si s e n t}.zip([15,*(2..6).map{|i|i*10},*11..19,*1..10]).to_h;D={'middnight'=>0,'midday'=>12,'noon'=>12};n=->s{s.split('-').reduce(0){|p,v|(Array(T.find{|k,_|v.start_with? k}).last||0)+p}};i=->s{m=0;s=s.gsub(/^\s+|\s+$/,'');c=s.split(P);(c.reverse! if s.match(P));h=D[c[0]]||n.(c[0].gsub(/ o\'clock (A|P)m/,''));h+=(s.end_with?('PM') ? 12 : 0);m=n.(c[1]||c[0].split(' ')[1]) if c[1]||c[0].match(/^\w+ (?!o'clock)/);(m=60-m;h=(h-1)%24)if s.match(/ to /);(sprintf '%02d:%02d',h,m)}

Ungolfed:
P=/ past | to /
# configuration for translating english words to numbers
T=%w{q twen thirty fourty fifty sixty el twe thi fourte fifte sixt sevent eighte ninet o tw th fo fi si s e n t}.zip([15,*(2..6).map{|i|i*10},*11..19,*1..10]).to_h
D={'middnight'=>0,'midday'=>12,'noon'=>12}

# proc for translating english word groups to a number
n=-> s {
  s.split('-').reduce(0) { |p,v|
    (Array(T.find {|k,_| v.start_with? k}).last || 0) + p
  }
}

i=-> s {
  m=0
  s=s.gsub(/^\s+|\s+$/,'')
  c=s.split(P)
  (c.reverse! if s.match(P))

  # set the hour
  h=D[c[0]]||n.(c[0].gsub(/ o\'clock (A|P)m/,''))
  h+=(s.end_with?('PM') ? 12 : 0)

  # set the minute
  m=n.(c[1]||c[0].split(' ')[1]) if c[1]||c[0].match(/^\w+ (?!o'clock)/)

  # adjust for 'past'
  (m=60-m;h=(h-1)%24)if s.match(/ to /)

  sprintf '%02d:%02d',h,m
}

Verification script used:
examples = <<EXAMPLES
midnight                                  ->   00:00
midday                                    ->   12:00
twelve o'clock                            ->   12:00
quarter to midnight                       ->   23:45
twenty-two minutes past eight o'clock PM  ->   20:22
thirty-four minutes to fifteen o'clock    ->   14:26
six o'clock AM                            ->   06:00
one minute to twenty-one o'clock          ->   20:59
seven thirteen AM                         ->   07:13
nine fourteen PM                          ->   21:14
EXAMPLES

examples.split("\n").each do |example|
  text, expected = example.split(/\s+->\s+/)
  r = i.(text)
  raise "Unexpected result for \"#{text}\". Got \"#{r}\", expected \"#{expected}\"" unless r == expected
  print "."
end

Thank you to Kevin Lau for 47 bytes of optimization


Prime Powers of Primes For the purpose of this challenge, a Prime Power of a Prime (PPP) is defined as a number that can be defined as a prime number to the power of a prime number.  For example, 9 is a PPP because it can be represented as 3^2.  81 on the other hand is not a PPP because it can only be represented as 3^4, and 4 is not prime.  The first few PPPs are: 4, 8, 9, 25, 27, 32, 49, 121, 125, 128, 169, 243, 289, 343...  This is OEIS sequence A053810

Your Task:

Write a program or function that for an input integer n returns/outputs the nth PPP, either 1-indexed or 0-indexed, whichever you prefer.

Input:

An integer between 0 and 1,000, received through any reasonable method.

Output:

The PPP at the index indicated by the input.

Test Cases:

These are 1-indexed, and so, if your program takes 0-indexed input, the same output should be arrived at for the stated input - 1.

3  -> 9
6  -> 32
9  -> 125

Scoring:

This code-golf,lowest score in bytes wins!

05AB1E (legacy),  9  7 bytes

Saved 2 bytes thank to @KevinCruijssen

µNÓ0Kp»

Try it online!

µ           # while counter_variable != input:
 N          #   push iteration counter                       e.g. 125
  Ó         #   get prime exponents                          -> [0, 0, 3]
   0K       #   filter out zeros                             -> [3]
     p      #   is prime?                                    -> [1]
      »     #   join with newlines: we use » instead of J
            #   so that [0,1] is not interpreted as truthy   -> 1
            #   implicit: if 1, increment counter_variable


Arbitrary Base Conversion Create a routine that takes an array of blocks in one numeric base system, and convert them to an array of blocks in another numeric base system.  Both the from and to systems are arbitrary and should be accepted as a parameter.  The input array can be an arbitrary length (If using a language where array lengths are not stored with the array, such as C, a length parameter should be passed to the function).

Here's how it should work:

fromArray = [1, 1]
fromBase = 256
toBase = 16
result = convertBase(fromArray, fromBase, toBase);

Which should return [0, 1, 0, 1] or possibly [1, 0, 1] (leading 0s are optional since they don't change the value of the answer).

Here are some test vectors:

Identity Test Vector

fromArray = [1, 2, 3, 4]
fromBase = 16
toBase = 16
result = [1, 2, 3, 4]

Trivial Test Vector

fromArray = [1, 0]
fromBase = 10
toBase = 100
result = [10]

Big Test Vector

fromArray = [41, 15, 156, 123, 254, 156, 141, 2, 24]
fromBase = 256
toBase = 16
result = [2, 9, 0, 15, 9, 12, 7, 11, 15, 14, 9, 12, 8, 13, 0, 2, 1, 8]

Really Big Test Vector

fromArray = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
fromBase = 2
toBase = 10
result = [1, 2, 3, 7, 9, 4, 0, 0, 3, 9, 2, 8, 5, 3, 8, 0, 2, 7, 4, 8, 9, 9, 1, 2, 4, 2, 2, 3]

Non-even Base Vector

fromArray = [41, 42, 43]
fromBase = 256
toBase = 36
result = [1, 21, 29, 22, 3]

Other criteria / rules:

All integer variables should fit within a standard 32 bit signed integer for all sane input ranges.
You may convert to an intermediary representation, as long as the intermediary is nothing more than an array of 32 bit signed integers.
Expect to handle bases from 2 through 256.  There isn't any need to support higher bases than that (but if you would like to, by all means).
Expect to handle input and output sizes at least up to 1000 elements.  A solution that scales to 2^32-1 elements would be better, but 1000 is just fine.
This isn't necessarily about having the shortest code that will meet these rules.  It's about having the cleanest and most elegant code.

Now, this isn't exactly trivial to do, so an answer that almost works might be accepted!

Python
# divides longnum src (in base src_base) by divisor
# returns a pair of (longnum dividend, remainder)
def divmod_long(src, src_base, divisor):
  dividend=[]
  remainder=0
  for d in src:
    (e, remainder) = divmod(d + remainder * src_base, divisor)
    if dividend or e: dividend += [e]
  return (dividend, remainder)

def convert(src, src_base, dst_base):
  result = []
  while src:
    (src, remainder) = divmod_long(src, src_base, dst_base)
    result = [remainder] + result
  return result


The teacher is always wrong, flip his answer Your dumb teacher is always wrong, so flip his answer.

Change these responses

True -> False
Yes -> No
0 -> 1
Yeah -> Nope

and vice versa. Keeping punctuation and the first letter's capitalization counts. Only one condition will be passed to the program.

You only need to accept the following test cases:

True <-> False
True. <-> False.
true <-> false
true. <-> false.
Yes <-> No
Yes. <-> No.
yes <-> no
yes. <-> no.
0 <-> 1
Yeah <-> Nope
yeah <-> nope
Yeah. <-> Nope.
yeah. <-> nope.

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

05AB1E, 45 41 40 39 38 bytes

Code:

“‰¦žä¥æ€¸pe…Ü€¸“ð¡2ôDí«D€™«vy`:D_D¹Êiq

Explanation:

It first starts with the compression:

“‰¦žä¥æ€¸pe…Ü€¸“

This is a compressed version of "true false yeah nope yes no". After that, we split on the spaces with ð¡, resulting into:

['true', 'false', 'yeah', 'nope', 'yes', 'no']

We slice this array into pieces of 2 with 2ô, resulting into:

[['true', 'false'], ['yeah', 'nope'], ['yes', 'no']]

We duplicate this array and reverse each element of it with Dí. Then we append this to our first array with «, resulting into:

[['true', 'false'], ['yeah', 'nope'], ['yes', 'no'], ['false', 'true'], ['nope', 'yeah'], ['no', 'yes']]

To get the titlecased words, we duplicate the array again and convert each word to titlecase with €™. Finally, this is appended to the initial array. So, the final list is:

[['true', 'false'],
 ['yeah', 'nope'],
 ['yes', 'no'],
 ['false', 'true'],
 ['nope', 'yeah'],
 ['no', 'yes'],
 ['True', 'False'],
 ['Yeah', 'Nope'],
 ['Yes', 'No'],
 ['False', 'True'],
 ['Nope', 'Yeah'],
 ['No', 'Yes']]

The imporant part here is that Nope comes before No. Eventually, we get to this part of the code:

vy`:D_D¹Êiq

Explanation:

v            # For each in the array...
 y`          #   Push the array (containing 2 words) and flatten.
   :         #   Replace the first word with the second.
    D_       #   Duplicate and negate (resulting 0 into 1 and 1 into 0).
                 If this is not possible, this results into nothing.
      D      #   Duplicate the top of the stack again.
       ¹Ê    #   If it's not equal to the inital input string...
         iq  #     Quit the program and implicitly print the processed string.

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


Overwrite a string on a tape Take the string abcdfghjk. To overwrite it, starting from f, with the string wxyz, you would continue along the original, replacing each character with the one from the replacement string. The result would be abcdwxyzk.
Now, consider a string which would be too long to fit, like lmnopqrs. Starting at f you would get abcdlmnop, then hit the end of the string. In order to continue, you wrap back to the beginning, resulting in qrsdefghi. With a long enough string, you could even wrap around multiple times.
Task:
You should take three inputs: the original string, the replacement string, and an index to start replacing at. This can be zero or one indexed.
Test Cases:
"This is a string"  "That"                  0   ->  "That is a string"
"This is a string"  "That"                  5   ->  "This That string"
"This is a string"  "That"                  14  ->  "atis is a striTh"
"hi"                "Hello there!"          0   ->  "e!"
"hi"                "Hello there!"          1   ->  "!e"
"over"              "write multiple times"  0   ->  "imes"
"over"              "write multiple times"  3   ->  "mesi"

Other:
This is code-golf, shortest answer per language in bytes wins!

Python 3, 39 bytes

def f(x,y,z):
	for x[z%len(x)]in y:z+=1

Try it online!
-5 bytes thanks to ovs for spotting the trick with cleverly using python's for loop specifics


Find the fastest swim relay (shortest path of unique nodes and types) fastest relay time = lowest possible total integer value of
(a freestyle swimmers time) + (1 breastroke swimmers time) + (another backstroke swimmers time) + (another butterfly swimmers time)

Each swimmer must be unique to the relay (no duplicates)
Each stroke must be used once

Input Data: array of dictionaries, where each single dictionary represents a swimmer's swim times for each stroke. Each dictionary has the named properties of 'fly','back','breast','free':

Example Input:

[
{'Fly': 10, 'Breast': 48.26, 'Free': 28.43, 'Back': 34},
{'Fly': 47.51, 'Breast': 24, 'Free': 28.47, 'Back': 10},
{'Fly': 26, 'Breast': 46.44, 'Free': 10, 'Back': 30},
{'Fly': 37.81, 'Breast': 10, 'Free': 24, 'Back': 49},
{'Fly': 38.31, 'Breast': 29, 'Free': 20, 'Back': 10}
]

Example Output:

40

(this is an easy case where the best relay is simply the fastest person in each stroke; other times you might need to have the 3rd fastest breastroker swim breastroke in order to get the lowest overall time!)

Example Measurement of a relay using the first 4 swimmers in the data set above:

swimmer 1 swims fly and his time is 10
total += 10
swimmer 2 swims back and his time is 10
total += 10
swimmer 3 swims fly and his time is 10
total += 10
swimmer 4 swims breast and his time is 10
best relay total for these 4 people = 40

Output Data: should be a single float or integer value representing the total time of the best relay. (a legal relay includes a fly swimmer, a back swimmer, a breast swimmer, and a free swimmer, each leg of the relay swam by a unique swimmer)

EDIT: brute force vs dynamic parameter removed.

Meh, I'm no Python programmer by any stretch of the imagination. Hell, some would even hesitate to call me a programmer. But as nobody else has answerred this, why not post my solution? If anything else, it was fun just to brush up on the very Python basics:

swimmers = [{'Fly': 10, 'Breast': 48.26, 'Free': 28.43, 'Back': 34},
{'Fly': 47.51, 'Breast': 24, 'Free': 28.47, 'Back': 10},
{'Fly': 26, 'Breast': 46.44, 'Free': 10, 'Back': 30},
{'Fly': 37.81, 'Breast': 10, 'Free': 24, 'Back': 49},
{'Fly': 38.31, 'Breast': 29, 'Free': 20, 'Back': 10}]

bestTime = float('inf')

for fly in range(len(swimmers)):
    for breast in range(len(swimmers)):
        for free in range(len(swimmers)):
            for back in range(len(swimmers)):
                if len(set([fly,breast,free,back])) > 3:
                    current = swimmers[fly]['Fly'] + swimmers[breast]['Breast'] + swimmers[free]['Free'] + swimmers[back]['Back']
                    if current < bestTime:
                        bestTime = current

print bestTime


Create an application that restarts itself after n-seconds once In your favorite programming language, create an application that restarts itself once, after n seconds.

You need to find a way to restart after exiting the program. EG: run cmd to do it for you. Make sure it waits an amount of seconds specified by the user before restarting

For clarification: You can run a second program, or compile one at runtime to do the work for you.

Also, make sure the program works every time you execute it, not only once.

Example of algorithm:

If hasntrestartedalready
    read i
    exit
    wait(i)
    restart
end if

Least amount of bytes wins.

Batch, 34 28 bytes

timeout/t %1
if %1 neq [] %0

Input time in seconds as the first argument. If no argument is present, as well as after restarting, it spews out error messages (follow both commands with 2>NUL to get rid of them). The new instance opens in the same window (OP said it's allowed).


Generate valid Fibonacci tilings Background

The Fibonacci tiling is a tiling of the (1D) line using two segments: a short one, S, and a long one, L (their length ratio is the golden ratio, but that's not relevant to this challenge). For a tiling using these two prototiles to actually be a Fibonacci tiling, the following conditions have to be fulfilled:

The tiling must not contain the subsequence SS.
The tiling must not contain the subsequence LLL.
If a new tiling is composed by performing all of the following substitutions, the result must still be a Fibonacci tiling:

LL → S
S → L
L → (empty string)

Let's look at some examples:

SLLSLLSLLSLS

This looks like a valid tiling, because it doesn't contain two *S*s or three *L*s but let's perform the composition:

LSLSLSLL

That still looks fine, but if we compose this again, we get

LLLS

which is not a valid Fibonacci tiling. Therefore, the two previous sequences weren't valid tilings either.

On the other hand, if we start with

LSLLSLSLLSLSLL

and repeatedly compose this to shorter sequences

LSLLSLLS
LSLSL
LL
S

all results are valid Fibonacci tilings, because we never obtain SS or LLL anywhere inside those strings.

For further reading, there is a thesis which uses this tiling as a simple 1D analogy to Penrose tilings.

The Challenge

Write a program or function which, given a non-negative integer N, returns all valid Fibonacci tiling in the form of strings containing N characters (being S or L).

You may take input via function argument, STDIN or ARGV and return or print the result.

This is code golf, the shortest answer (in bytes) wins.

Examples

N      Output
0      (an empty string)
1      S, L
2      SL, LS, LL
3      LSL, SLS, LLS, SLL
4      SLSL, SLLS, LSLS, LSLL, LLSL
5      LLSLL, LLSLS, LSLLS, LSLSL, SLLSL, SLSLL
...
8      LLSLLSLS, LLSLSLLS, LSLLSLLS, LSLLSLSL, LSLSLLSL, SLLSLLSL, SLLSLSLL, SLSLLSLL, SLSLLSLS

APL (Dyalog Unicode), 43 bytes

(1+∘÷⍣=1){'LS'[∪2</⍺|(⍺×(⍳÷⊢)2*⍵)∘.+⍳⍵]}1∘+

Try it online!
This uses the alternative formulation (actually the first one) shown in the linked paper: the closest integer staircase to the line \$y = x/\phi\$, where \$\phi\$ is the golden ratio \$\frac{\sqrt5+1}{2}\$.
Given the initial vertical offset from the line \$h\$ (which can be positive or negative), the next term (one of LS) can be determined by the following rule:

If \$h<0\$ (below the line), \$h←h+1\$ and emit S.
Otherwise (over the line), \$h←h-(\phi-1)\$ and emit L.

Since \$h-(\phi-1) = h+1-\phi\$, we can always increment and take modulo \$\phi\$ of it. Then the condition \$h<0\$ changes to \$h<\phi-1\$, but it doesn't affect the resulting sequence of terms.
Then the problem becomes to sample enough values for initial \$h\$ so that we can get all possible sequences of SL for any given length \$n\$. I choose \$2^{n+1}\$ points uniformly spaced over the interval \$[0,\phi)\$, which works for small \$n\$, and the gap size reduces faster than that induced by the collection of lines \$y=x/\phi+c\$, each passing through some lattice point inside \$0 \le x \le n\$.
Finally, I determine the actual SL terms by checking each consecutive pair: S if left < right, L otherwise, and take unique sequences.
(1+∘÷⍣=1){'LS'[∪2</⍺|(⍺×(⍳÷⊢)2*⍵)∘.+⍳⍵]}1∘+  ⍝ Input: n
(1+∘÷⍣=1){...}1∘+  ⍝ Pass n+1 and phi to the inner dfn...
⍳⍵            ⍝ Range 0..n
∘.+           ⍝ Outer product by addition...
(⍺×(⍳÷⊢)2*⍵)  ⍝ 2^(n+1) uniformly separated numbers in [0,phi)
⍺|            ⍝ Modulo phi
2</           ⍝ Pairwise comparison in row direction
              ⍝ (1 if right is higher, 0 otherwise)
∪             ⍝ Take unique rows
'LS'[...]     ⍝ Map 0, 1 to L, S


Split a word into parts with equal scores Assuming A=1, B=2... Z=26, and the value of a word is the sum of these letter values, it is possible to split some words into two pieces such that they have equal values.

For example, "wordsplit" can be broken into two pieces like so: ordsl wpit, because o+r+d+s+l = w+p+i+t.

This was a challenge given to us by my computing teacher - it is an old Lionhead Studios challenge, apparently. I have solved it in Python, and will post my answer shortly.

Challenge: The shortest program which can list all the possible splits which have equal scores. Note that it only has to list one for each group of letters - ordsl wpit is the same as rdosl wtip, for example. It is easier to list them in the order they come in the word.

Bonus:

If you highlight pairs where both words are valid English words (or some permutation of the letters is), using a word list of some kind. (This could be done by placing an asterisk next to each or some other method, but make it clear.)
Adding the option for removing duplicates (this should not be the default.)
Supporting more than two splits, for example, three, four or even n-way splits.

Perl, 115 118 123

@_=~/./g;for$i(1..1<<@_){$l=$
r;$i&1<<$_?$l:$r+=64-ord$_[$_
]for 0..$#_;$l-$r||$i&1<<$_&&
print$_[$_]for 0..$#_;say""}

Run with perl -nE '<code goes here>'. That 'n' is counted in the code size.

Respaced:

@_ = /./g;
for $i (1 .. 1<<@_) {
  $l = $r;
  $i & 1<<$_ ? $l : $r -= 64 - ord $_[$_] for 0 .. $#_;

  $l - $r      ||
  $i & 1<<$_   &&
  print $_[$_]
    for 0 .. $#_;

  say ""
}

With comments and variable names:

# split a line of input by character
@chars = /./g;

# generate all binary masks of same length
for $mask (1 .. 1<<@_) {

  # start at "zero"
  $left_sum = $right_sum;

  # depending on mask, choose left or right count
  # 1 -> char goes left; 0 -> char goes right
  $mask & 1<<$_ ? $left_sum : $right_sum
    -= 64 - ord $chars[$_]   # add letter value
      for 0 .. $#chars;      # for all bits in mask

  # if left = right
  $left_sum - $right_sum ||

  # if character was counted left (mask[i] = 1)
  $mask & 1<<$_          &&

  # print it
  print $chars[$_]

  # ...iterating on all bits in mask
    for 0 .. $#chars;

  # newline
  say ""
}

Some of the tricks used:

1..1<<@_ covers the same bit range as 0..(1<<@_)-1 , but is shorter. (note that considering the problem from further away, including the range boundaries multiple times wouldn't result in a wrong output anyway)
$left_range and $right_range aren't reset to actual "0" numeric zero: since we just accumulate and compare them in the end, all we need is them to start at the same value.
subtracting 64-ord$_[$_] instead of adding ord$_[$_]-64 wins an invisible character: since it ends with a delimiter, it makes the space before for unnecessary.
Perl lets you assign to a variable determined by the ternary conditional operator: cond ? var1 : var2 = new_value.
boolean expressions chained with && and || are used instead of proper conditionals.
$l-$r is shorter than $l!=$r
will output a newline even on splits that don't balance.  Empty lines are ok by the rules!  I asked!


Chain words crossword-style The challenge

Given a list of words ["Programming", "Puzzles", "Code", "Golf"] output the words crossword-style:

      P r o g r a m m i n g
      u
      z
      z
  G   l
C o d e
  l   s
  f

The Algorithm

You have to process the list in the given order.
The words are printed in alternating orientations, starting horizontally.
The two words intersect at the first letter in the first word which is also present in the second word. If this letter occurs multiple times in the seond word, take the first one.

Example:
["no", "on"] becomes:

o
n o

and not

n o
  n

Additional notes

Adjacent words in the list will have at least one common letter. ["Hi", "there"] is not a valid input.
Words will never collide. There will always be enough space to print the a word at the first possible intersection. ["Hello", "there", "end", "hello"] is not a valid input
The matching is case-sensitive.
Words can expand to the left and to the top.
The letters of the horizontal words have to be separated by one space.
The input list will contain at least two words.
All words will match the regex: [A-Za-z]+
You may print as many trailing whitespaces or newlines as you want, as long as the words are correctly chained.
On the other hand you may not add additional leading whitespaces. The word which floats to the left the most has zero leading spaces, the other lines have so many leading spaces that it all lines up correctly.
You program has to be able to deal with an arbitrary amount of words

Rules

Function or full program allowed.
Default rules for input/output.
Standard loopholes apply.
This is code-golf, so lowest byte-count wins. Tiebreaker is earlier submission.

Test cases

Input list on the first line, output starts on the second line.

["Stack", "Exchange"]
    E
    x
    c
    h
S t a c k
    n
    g
    e

["This", "site", "graduated", "finally"]
    f
    i       s
    n   T h i s
g r a d u a t e d
    l       e
    l
    y

Happy Coding!

ANSI C, 385 390 Characters

int N,a=1,x,y,d=1,u,k,l;int main(int c,char**v){for(;a<c;)N+=strlen(v[a++]);int H=N*2,W=N*4,m=H,n=N,q=m,w=n;char*p,F[W][H],*o;memset(F,32,W*H);for(a=1;a<c;a++){q=(x=m)<q?m:q;w=(y=n)<w?n:w;m=-1;for(p=v[a];*p;p++){F[x][y]=*p;if(m<0&&a<c-1&&(o=strchr(v[a+1],*p))){u=o-v[a+1];m=d?x:x-u*2;n=d?y-u:y;}if(d)x+=2;else y++;}d=!d;}for(l=w;l<H;l++){for(k=q;k<W;)putchar(F[k++][l]);putchar(10);}}

Call it like this: ./crossword This site graduated finally

Ungolfed version:

int N,a=1,x,y,d=1,u,k,l;
int main(int c, char **v) {
    for(;a<c;)
        N+=strlen(v[a++]);
    int H = N*2, W = N*4, m = H, n = N, q=m, w=n;
    char *p,F[W][H], *o;
    memset(F, 32, W*H);
    for (a=1; a < c; a++) {
        q=(x=m)<q?m:q;
        w=(y=n)<w?n:w;
        m=-1;
        for (p=v[a]; *p; p++) {
            F[x][y] = *p;
            if (m<0&&a<c-1&&(o = strchr(v[a+1], *p))) {
                u = o-v[a+1];
                m = d ? x : x-u*2;
                n = d ? y-u : y;
            }
            if (d) x+=2; else y++;
        }
        d=!d;
    }
    for (l = w; l < H; l++) {
        for (k = q; k < W;)
            putchar(F[k++][l]);
        putchar(10);
    }
}

Thank you tucuxi for the tips!


The Great Pyramid of Quine The task is a rather simple quine challenge with a twist, you must output your source code in the shape of a pyramid. The shape of a pyramid is defined below:
       1
      234
     56789
    ABCDEFG
   HIJKLMNOP
  QRSTUVWXYZa
 bcdefghijklmn
......etc......

The main limitation of this challenge is that your quine must contain exactly enough bytes as to not obstruct the pattern of the pyramid. For instance, the following program lengths would work:
1-byter: 1st layer of the pyramid (not allowed by definition of a quine).
4-byter: 1st and 2nd layers of the pyramid.
9-byter: 1st, 2nd and 3rd layers of the pyramid.
etc...

So, if your program was:
QWERTY

It would not be valid, because it would arrange like:
  Q
 WER
TY

However, if your program was QWERTYUIO, it would be fine:
  Q
 WER
TYUIO

Rules

Standard loopholes are obviously disallowed, no reading your own source.
The pyramid must be centered, trailing characters are allowed, but not required.

Also, any character may be used to center the pyramid, doesn't have to be (char)32.

Your quine must be able to be shaped into a pyramid.

It must retain the original ordering of your sourcecode.
Your source-code may NOT contain the character being used to format the pyramid.
E.G. if your sourcecode contains a space, you'll need another char for the format.

You may use comments in your quine to "pad" to the correct size.

Obviously, these must be output as part of the quine.

If the program contains newlines/tabs, they aren't part of the quine and should be omitted in the output.
The shape is counted in characters, not bytes; if the shape is malformed you're not doing it right.

The lowest possible score here should be 4.

05AB1E, 36 bytes

"34çs«DJā·<£õK.cJ?"34çs«DJā·<£õK.cJ?

Try it online!

If trailing characters are allowed also means at the end of the output, 0"D34çýā·<£.c"D34çýā·<£.c is a layer shorter at 25 bytes.


T minus time to ransom! The WannaCrypt ransomware has struck and it is attacking networks right, left and center. A network is defined by an m*n binary matrix (a),  which has a a[i][j] = 1 if a computer is infected and a[i][j] = 0 if it is not. At the end of each hour, all computers that are a neighbour (which shares a side or a corner with) of an infected computer are infected by the ransomware..

Your job is to calculate the time after which all computers in the network will be infected by the virus.

Also, do keep in mind that the shortest code wins.

Input

The first 2 lines contains the values of m and n respectively.
The next m lines contain a binary string of length n corresponding to the computers of the network.

Output

An integer which is equal to the mumber of hours after which the whole network will be infected by the ransomware.

Input Constraints

1 <= m,n <= 1000

Sample Test Cases

Test Case 1

Sample Input

2
2
11
11

Sample Output

0

Test Case 2

Sample Input

3
4
0101
0001
0001

Sample Output

2

Test Case 3

Sample Input

2
2
10
00

Sample Output

1

P.S: Take input in any format that doesn't violate the ordering of [m,n,matrix]
P.P.S: m and n are optional inputs. The only compulsory input is the matrix.

Python 2, 90 bytes

g=lambda a:min(min(a))or-~g(map(lambda*c:map(max,(0,)+c[:-1],c,c[1:]),*a))
lambda a:g(a)/2

Try it online!

Accepts a matrix as a list of lists of 0 and 1.

How it works

g=lambda a:min(min(a))or…

If the smallest element of the matrix is 1 (it is completely infected), return 1; otherwise…

                        -~g(…                                            )

return 1 plus the recursive result on the following modified matrix…

                            map(lambda*c:…                           ,*a)

for each old column c…

                                         map(max,(0,)+c[:-1],c,c[1:])

produce a new row by zipping max over the down-shifted, original, and up-shifted versions of c.  (map fills in the gap at the end of c[1:] with None, which is falsy and smaller than both 0 and 1.)

Each iteration of g computes all vertical infections, then transposes the matrix.  This way, every 2 iterations of g compute all horizontal, vertical, and diagonal infections.

lambda a:g(a)/2

Because the base case of g with a fully infected matrix gave 1 rather than 0, the parity works out such that floored division by 2 always gives the correct result.


DCSS morgue file parser In this challenge, you need to parse morgue files from the roguelike game Dungeon Crawl Stone Soup and output it to STDOUT.

What are these morgue files??

When you die, a text file is generated with that character's data inside. You can see what equipment the character had, what happened during the last few turns, and how many monsters he has killed.

You can find a example morgue file here

The challenge

Your job is to make a program that takes one of those files from STDIN, parses it, and outputs the data to STDOUT.

To make this challenge a bit easier, you only have to parse the first block of text. (up until The game lasted <time> (<turns> turns).

You need to parse and output the following information:

The version number.
The score.
The character name, title, race and class.
The character level.
The cause of death/victory.
The amount of turns the run lasted.

Example:

Dungeon Crawl Stone Soup version <version number> character file.

<score> <name> the <title> (level <level>, 224/224 HPs)
         Began as a <race> <class> on Mar 16, 2015.
         Was the Champion of the Shining One.
         <cause of death/victory>

         The game lasted 16:11:01 (<turns> turns).

Test Cases

Test case 1 - Victory

Input file

Example output - Victory:

Version: 0.16.0-8-gd9ae3a8 (webtiles)
Score: 16059087
Name: Ryuzilla the Conqueror
Character: Gargoyle Berserker
Level: 27
Cause of Death/Victory: Escaped with the Orb and 15 runes on Mar 17 2015!
Turns: 97605

Test case 2 - Death

Input file

Example output - Death:

Version: 0.16-a0-3667-g690a316 (webtiles)
Score: 462
Name: 8Escape the Ruffian
Character: Bearkin Transmuter
Level: 6
Cause of Death/Victory: Slain by an orc wielding a +0 trident (3 damage) on level 4 of the Dungeon.
Turns: 3698

Rules

This is code-golf so the shortest code wins.
In the event of a tie, the oldest answer wins.
No standard loopholes.
File input must be taken from STDIN
Output must be sent to STDOUT
The labels before the output (ex. Turns:) are optional.

Ungolfed sample code for inspiration

Morgue file generation code in DCSS

F#, 377 bytes

open System.Text.RegularExpressions
let s=System.String.IsNullOrWhiteSpace>>not
let m f=Regex.Match((f+"").Split[|'\r';'\n'|]|>Seq.filter s|>Seq.take 8|>Seq.reduce(fun a z->a+z.Trim()), ".*n (.*) c.*\.([0-9]+) (.*) \(l.* (.*),.*a (.*) o.*\.(?:(S.*)|W.*(E.*)).*.T.*\((.*) .*\).").Groups|>Seq.cast<Group>|>Seq.skip 1|>Seq.map(fun z ->z.Value)|>Seq.filter s|>Seq.iter(printfn"%s")


ICS Maritime Flag alphabet The International Code of Signals flag alphabet  is used by ships for communication, particularly for static signals.

Your challenge is to write a program or function that will take a string from STDIN or as an argument, and display the corresponding text in the ICS flag alphabet. If your language does not display to the screen, saving to a file is acceptable.

Your program or function shall support letters A-Z in upper and lower case, plus Space and Newline. Behaviour with other characters is undefined.

The display shall be large enough to display capable of displaying at least 8 flags horizontally and 6 flags vertically. Behaviour is undefined if the right hand edge is reached before a newline is received, or if the message is too long to fit the display vertically.

The flag alphabet is as shown below (Roman letters are for reference only, they are not required in the output.)

Dimensions

There is no universally agreed standard for the dimensions of these flags, so for the purpose of this challenge the following shall apply:

Flags shall be 60x60 pixels, with a 30 pixel gap between them both horizontally and vertically.

The swallowtail cut on A and B shall be 15 pixels deep.

All other lines shall be horizontal, vertical, or at 45 degrees.

The features shall be located by dividing the flag into an imaginary NxN grid of side 3,4,5 or 6 squares. Refer to the above image, but for further clarification:

A,E,H,K, L and U are based on a 2x2 grid : width of each colour zone shall be 30pixels. Also the points of the diamond in F shall be halfway along each side of the flag.

J and T are based on a 3x3 grid: each band shall be 20 pixels.

P,N and S are based on a 4x4 grid. Also the diagonal lines of Y shall split the edges of the flag into 4.

C,D,R and X shall be based on a 5x5 grid. Bands and arms of crosses shall be 12 pixels wide.

G,W,M,V are based on a 6x6 grid. Bands of G and borders of W shall be 10 pixels wide.
Arms of crosses on M and V shall cover the first and last 10 pixels of each edge of the flag, leaving triangle zones measuring 40 pixels along the long edge.

The circle of I shall be in the centre of the flag and have diameter 30 pixels.

An error of +/-1 pixel from the above text is permitted. If your language only supports scalable graphics, you may interpret "pixels" to mean "units."

Colours

Colours shall be red, white, blue, yellow and black as defined by your language or its documentation. If your language does not define colours, you may use the following:
Red FF0000,
White FFFFFF,
Blue 0000FF,
Yellow FFFF00,
Black 0000000.

Background shall be grey (r,g and b channels equal, between 25% and 75% intensity.)

Scoring /Loopholes

This is codegolf. Shortest code in bytes wins.

Standard loopholes are disallowed.

No builtin or library functions for displaying flags may be used. Output shall be non-text (and in particular, unicode characters shall not be used to build up the flag shape.)

Example

JFK got
my VHS
PC
and XLR
web quiz

should produce the following

CJam, 464 bytes

You thought CJam didn't have image manipulation functions? Well, you thought right! But I wasn't going to let that stop me.

"P3
690 690 4
"3a3*a690_@*a*qeuN/{0:U;{_'C<.5*:N;i[{XY+Z<[E8][9C]?XY<=}WWWW{XH<9F?}C{YC/[9FCF]=}{YC/3&9E?}{YH<9F?}{X29.5:R-zYR-z+H>FC?}{XA/1&9E?}{XH<FC?}{XR-_*YR-_*+F_*>E8?}{YK/(9F?}{XH<E9?}{XH<YH<^8E?}{XY+Z-A/XY-A/e&9F?}{XF/YF/^1&F9?}{XY<EC?}{XH-F/YH-F/|9F?}E{XHm6/YHm6/e&CE?}{XH-F/YH-F/|F9?}{XK/[CF9]=}{XH<YH<^FC?}{XY+Z-A/XY-A/e&FC?}{XR-zYR-ze>iA/[CF9]=}{XHm6/YHm6/e&F9?}{XY+F/1&CE?}]=:P~!!{60:Z{Z30:HYH-z-N*-{YV+_2$=XU+P2b1>4f*tt}fX}fY}*U90+:U;}/V90+:V;}/`"[]"-

This program outputs the image in the best way CJam can: as text that represents the image when saved as a PPM file. Don't even try running it with the online interpreter, by the way; you'll blow the stack. Run it with the Java interpreter and pipe the output to a file with a command like java -jar cjam-0.6.4.jar flags.cjam > flags.ppm. Once you've provided your input, send an EOF (may need to be immediately after a newline) with ctrl+D on Unix or ctrl+Z on Windows.

Sample

If it's really desired, I can try to paste the original ~3MB image source somewhere. But here's the result opened in GIMP and conerted to a PNG:

ABCDEFG
hijklmn
OPQRSTU
vwxyz z

Explanation

The image header, easily identifiable in the source, consists of the magic number, width, height, and maximum channel value. So the output is a 690*690 image (enough for 8*8 60px flags with 30px of spacing between them) with each R, G, and B value ranging from 0 to 4.

The image data is initialized as a 690*690*3 array filled with 3's, making the whole image light gray. Then the input is read, converted to uppercase, and split into lines. The lines are processed in a loop, incrementing the flag Y coordinate by 90 each iteration, and in each line, each character is processed in a loop, incrementing the flag X coordinate by 90 each iteration. Now the magic begins.

Each character is mapped to a flag's pixel function that, when called, returns the color of the pixel at the position (X, Y) on the flag. This is where most of the hard work went: concisely describing 26 images as mathematical functions. Each of these functions returns a color value from 8-15. This range takes advantage of the fact that, when converted to base 2, the resulting bit array can be interpreted as [1, R, G, B]. The first element can be removed and the rest multiplied by 4 to easily give a pixel value in the desired format that covers all the possible flag colors (as well as green, cyan, and magenta). It also works out nicely that there are one-character variables initialized to 10-15, and since varaibles don't need a space to syntactically separate them, any two colors besides black and blue can be entered next to each other without needing any spacing.

Once the function is retrieved, it's just a matter of iterating over both of X and Y from 0-60, calling the function at each step, and writing the result back to the image data array. An astute observer might notice that the color values returned by each flag function don't allow gray, though. So there's a bit of extra logic to skip spaces. But there are still the swallowtail cuts on 'A' and 'B'. So there's a bit of extra logic there, too. If the character value is less than 'C', a value is set such that the upper bound on the X loop varies correctly with respect to Y and the cut-out areas are never drawn.

Overall, I'm pretty happy with how this came out. It took a lot of work, but it was fun. Some flags don't perfectly match the reference image, but I think I got all the shapes to be within 1px of the target (if any are off by more than that, let me know and I'll fix them). And there's definitely still potential to optimize, as there's a fair amount of redundancy between the 26 flag functions.

Ineresting first attempt, 559 bytes

Altough I never quite finished this, I'll post it too, because it's pretty interesting. Instead of modelling each flag by a function of (X, Y) → color, flags are drawn as a composition of simple shapes. But I was worried about needing to write a substantial amount of rendering code for each different shape. After a lot of pondering, I realized I could render them all, with some clever overlapping and overdrawing, with just one pseudo-shape: all the points within a specified distance of a specified point, where the definition of "distance" is variable. Chessboard distance gives a square, Manhattan distance gives a diamond, and Euclidean distance gives a circle. This meant every shape had the same five parameters (color, distance mode, x, y, and max distance) and I only needed to write one shape data decoder and one rendering function with a small bit of distance mode logic.

"P3
690 690 4
"3a3*a690_@*a*qeuN/{0:U;{_'C<.5*:N;i[[8EX30:Q0Q9X60:ZQQCXQZQ]LLLL[F9TTQQ]Ca[9FTQ42QCTQ54QFTQ66Q9TQ78Q][E9TIQI9T42QI][9FTQZQ][FCXQQQ][E9T40QQET50QQ9TZQQET70QQ9T80QQ][FCTZQQ][E8YQQF][9FTQAQ9TQ9~Q][E9TZQQ][8ETTTQETZZQ][F9XQTK9XZQK9XQZK9XTQK][F4{4{JW^1&6*9+TJ)F*W)F*F}fJ}fW][CEX0ZZ][9FTQQF]Ea[E[TZ]_m*{CT@~24}/][F9TQQF][9FTAQQCT9~QQ][FCTTTQCTZZQ]C9$1>9a/Fa*+[9FTQQKCTQQA]9 6$1>Ca/Fa*+[C7{7\-_1&2*C+X@TT@F*}/]]=_!!{([TQQQ]+\+}*5/{~:R;.5-:H;.5-:G;:M;2b1>4f*:O;Z{ZQWQ-z-N*-{JG-{zM_!+#}:P~WH-PM{+}{e>}?RP<{WV+_2$=JU+Ott}*}fJ}fW}/U90+:U;}/V90+:V;}/`"[]"-


Catenary Between Two Points (Hanging Chain) This is one of several challenges left for the community by Calvin's Hobbies.

The curve that an idealised hanging rope or chain makes is a catenary.

Image by Bin im Garten, via Wikimedia Commons. Used under the CC-By-SA 3.0 licence.

Write a program that will draw a catenary, as an image, in quadrant 1 of the plane given two points (x1,y1), (x2,y2), and the "rope length" L. L will be greater than the distance between the two points.

You must also draw axes on the left and bottom sides of the image (400x400 px min) for scale. Only draw the quadrant from x and y in range 0 to 100. (You may assume the points are in range.)

Dots, or something similiar, should be drawn at the (x1,y1), (x2,y2) endpoints to distinguish them. The curve should only be drawn in the space between these points.

Python + NumPy + Matplotlib, 1131

Just to get us started, here's an attempt that uses no knowledge of calculus or physics other than the fact that the catenary minimizes the energy of a chain. Hey, my algorithm may not be efficient, but at least it's not implemented efficiently either!

import math
import random
import numpy as np
import matplotlib.pyplot as plt
length, x0, y0, x1, y1 = input(), input(), input(), input(), input()
chain = np.array([[x0] + [length / 1000.]*1000, [y0] + [0.] * 1000])
def rotate(angle, x, y):
 return x * math.cos(angle) + y * math.sin(angle), -x * math.sin(angle) + y  * math.cos(angle)
def eval(chain, x1, y1):
 mysum = chain.cumsum(1)
 springpotential = 1000 * ((mysum[0][-1] - x1) ** 2 + (mysum[1][-1] - y1)  ** 2)
 potential = mysum.cumsum(1)[1][-1]
 return springpotential + potential
def jiggle(chain, x1, y1):
 for _ in xrange(100000):
  pre = eval(chain, x1, y1)
  angle = random.random() * 2 * math.pi
  index = random.randint(1,1000)
  chain[0][index], chain[1][index] = rotate(angle, chain[0][index], chain[1][index])
  if( pre < eval(chain, x1, y1)):
   chain[0][index], chain[1][index] = rotate(-angle, chain[0][index], chain[1][index])
jiggle(chain, x1, y1)
sum = chain.cumsum(1)
x1 = 2 * x1 - sum[0][-1]
y1 = 2 * y1 - sum[1][-1]
jiggle(chain, x1, y1)
sum = chain.cumsum(1)
plt.plot(sum[0][1:], sum[1][1:])
plt.show()


Sequence avoiding near collision Task

Find a sequence of all numbers between min and max where every number differs from every other number in the sequence by at least "d" digits.

Example of sub-sequence

For min = 0, max = 1000 and d = 2, the following is part of one possible solution sequence:

123 ← Good
132 ← Good
145 ← Good
146 ← Bad

Notes

This is a bit practical. I was thinking about this as a problem that has kept cropping up over the years. Basically it's a pattern in URL shorteners / prize codes / conference room codes / etc...

I'd like to be able to hand out codes from a list, and have each code be:
A - Simple to type, and B - Be somewhat unlikely to accidentally conflict with another code because of a typing mistake.

There's no reason to work in base ten. I've expressed the problem that way for clarity, but in real cases we'd take advantage of letters as well.

Sub-Note

This is not that practical. If you use just six "digits" (allowing numbers and capital letters), then you have over two billion choices. That seems like plenty for most cases except for the URL shortener. Still I was thinking it would be nice to be able to generate a random number from that space and be able to quickly check that it was at least "d" different from all others that had been handed out up to that point. Generating a solution sequence is not quite the same problem, but it seemed interesting and I'm hoping that someone comes up with a clever way to structure the data in order to make it efficient to search for these near collisions.

Here's a terrible, brute force way of generating a sequence. I haven't attempted to do much to make it fast, though there are probably several simple gains to be had here. I'm trying to think of a way to make this at least a couple of orders of magnitude faster rather than finding improvements of a few percent.

public static IEnumerable<int> GetDifferentCodes(int min, int digits, int minDifference)
{
    var max = Math.Pow(10, digits) - 1;
    var goodCodes = new List<int>();
    var goodCodeDigits = new List<short[]>();

    for (var i = min; i < max; i++)
    {
        var newDigits = GetDigits(i, digits);

        if (!goodCodeDigits.All(goodCode => HasMinDiff(goodCode, newDigits, digits, minDifference)))
            continue;
        goodCodes.Add(i);
        goodCodeDigits.Add(newDigits);
    }
    return goodCodes;
}

private static readonly int[] Powers = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000};

private static short[] GetDigits(int num, int digits)
{
    var ret = new short[digits];
    for (var i = 0; i < digits; i++)
    {
        ret[i] = (short) ((num/Powers[i]) % 10);
    }
    return ret;
}

private static bool HasMinDiff(short[] goodDigits, short[] digitsToCheck, int digits, int minDiff)
{
    var difference = 0;
    for (var i = 0; i < digits; i++)
    {
        if (goodDigits[i] == digitsToCheck[i]) continue;
        if (++difference >= minDiff) return true;
    }
    return false;
}


Find the optimal pattern Given a string s composed of lowercase letters, such as

aabaaababbbbaaba

and a positive integer n, such as 4, output a length-n string t such that when t is repeated to the length of s, they have as many chars in common as possible. For the given example, the optimal output would be aaba, because it has thirteen chars in common with the target string:

s: aabaaababbbbaaba
t: aabaaabaaabaaaba (aaba)
   ^^^^^^^^  ^ ^^^^

and no possible t has more. However, for aaaaaab, there are two possible outputs: aaaa and aaba, which each have 6 chars in common with the target string:

s: aaaaaab
t: aaaaaaaa (aaaa)
   ^^^^^^

s: aaaaaab
t: aabaaaba (aaba)
   ^^ ^^^^

Either aaaa or aaba can be outputted, or both if you'd like. Note that s is not ever repeated; the trailing a in both repeated values of t is simply ignored.

Test cases

Inputs -> Valid outputs
1 a -> a
1 aa -> a
2 aa -> aa
1 ab -> a b
2 ab -> ab
1 abb -> b
2 abb -> ab bb
2 ababa -> ab
2 abcba -> ab
2 aabbbbb -> bb  (ab is not a valid output here)
3 aababba -> aab abb
3 aababbaa -> aab
3 asdasfadf -> asf
3 asdasfadfsdf -> asf adf
2 abcdefghijklmnopqrstuvwxyzyx -> yx
2 supercalifragilisticexpialidocious -> ic ii
3 supercalifragilisticexpialidocious -> iri ili ioi
4 supercalifragilisticexpialidocious -> scii
5 supercalifragilisticexpialidocious -> iapic
2 eeeebaadbaecaebbbbbebbbbeecacebdccaecadbbbaceebedbbbddadebeddedbcedeaadcabdeccceccaeaadbbaecbbcbcbea -> bb be
10 bbbbacacbcedecdbbbdebdaedcecdabcebddbdcecebbeeaacdebdbebaebcecddadeeedbbdbbaeaaeebbedbeeaeedadeecbcd -> ebbbdbeece ebdbdbeece
20 aabbbaaabaaabaaaabbbbabbbbabbbabbbbbabbaaaababbbaababbbaababaaaabbaaabbaabbbabaaabbabbaaabbaaaaaaaba -> aabbbbaaabbabbbaabba

Rules

You may assume the input will only ever be a non-empty string of lowercase letters and a positive integer no greater than the length of the string.
You may take the inputs in any standard format and in either order.
You may output a single string, or more than one in the form of an array, separated by newlines or spaces, etc.
Your code must finish for each test-case in less than 1 minute on any fairly modern computer.
This is code-golf, so make your code as short as possible.

Jelly, 11 bytes

sZµṢŒrUṀṪµ€

Try it online!

Wasn't expecting to beat Dennis on this one, so tried to FGITW it (after trying several possibilities; there's more than one way to make 11). I came in shorter, much to my surprise.

Takes the string then the count as command-line arguments. Outputs on stdout.

Explanation

sZµṢŒrUṀṪµ€
s            Split {the first input} into {the second input}-sized groups
 Z           Transpose
  µ      µ€  On each of the transposed groups:
   Ṣ           Sort it;
    Œr         Run-length encode it;
      U        Rearrange it to the form {count, letter};
       Ṁ       Take the largest element (i.e. largest count)
        Ṫ      Take the second element of the pair (i.e. just the letter)

This uses the insight that the letter in each position of the pattern must be the most common letter corresponding to that position. We can find the letters corresponding to a particular pattern via splitting into pattern-sized groups, and transposing. The main reason this solution is so long is that Jelly doesn't seem to have a short way to find the mode of a list (I made several attempts, but they're all at least six bytes long).

Jelly, 10 bytes, based on @Dennis' solution

⁸ċ$ÞṪ
sZÇ€

Try it online!

This is a combination of @Dennis' solution and my own; there was a five-byte mode in that solution, which I stole for this solution. (I already had solutions based on ⁸ċ, but couldn't get below six bytes with it; I hadn't thought of using Þ.)

Explanation

µ…µ€ and Ç€ (with the … on the previous line) are both three bytes long (the latter needs a newline), and equivalent. Normally I use the former, but the latter's more flexible, as it allows you to use ⁸ to mention the argument.

This makes it possible to sort (Þ) by the number of occurrences in ⁸ (⁸ċ), then take the last element (Ṫ), to find the mode in just five characters.


Print a 10 by 10 grid of asterisks Background
This is a standard textbook example to demonstrate for loops.
This is one of the first programs I learnt when I started learning programming ~10 years ago.
Task
You are to print this exact text:
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********

Specs

You may have extra trailing newlines.
You may have extra trailing spaces (U+0020) at the end of each line, including the extra trailing newlines.

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


An Séimhiú agus an tUrú An Séimhiú agus an tUrú

In Irish Gaelic (Gaeilge) there are a number of ways that the start of a word can be changed. The most common of these are lenition (an séimhiú) and eclipsis (an t-urú)

Lenition involves adding the letter h as the second letter. For example, the word "bean" (woman) would be lenited to "bhean".

Eclipsing adds a prefix to the word. The prefix is determined by the first letter of the word. For example, the word "capall" (horse) starts with a c. Its eclipsis is g. So when the word "capall" is eclipsed it becomes "gcapall".

Challenge

Write a function or program that takes a word and returns both its lenited and eclipsed forms.

Lenition

Only words beginning with:

b
c
d
f
g
m
p
s
t

are lenited. Words beginning with other letters are not changed.

Some examples:

bean       bhean
capall     chapall
Sasana     Shasana
lón        lón
Ífreann    Ífreann

Eclipsis

If a word starts with any of the following letters, it is prefixed by its respective eclipsis:

Letter   Eclipsis
b        m
c        g
d        n
f        bh
g        n
p        b
t        d

Words that don't start with those letters remain unchanged.

Examples:

bean        mbean
capall      gcapall
cailín      gcailín
doras       ndoras
fuinneog    bhfuinneog
Gaeilge     nGaeilge
Sasana      Sasana

There are other changes that can happen to the start of a word, but we'll just focus on these ones.

Rules

The input is only one word. Words will only contain a-z, A-Z or the fada vowels á, Á, é, É, í, Í, ó, Ó, ú and Ú.

To make it a bit more simple the word itself doesn't necessarily need to be an Irish word, just that it is treated like one in the code. So inputting delta should return dhelta and ndelta.

For this challenge you can assume that the input words have not already been lenited or eclipsed (in Irish, a word is only lenited or eclipsed once. You would never end up with "bhhean" or "ngcapall").

Standard rules apply, including the default I/O rules. Similarly, default loopholes are forbidden.

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

Test cases

Input      Lenited     Eclipsed
bean       bhean       mbean
capall     chapall     gcapall
fuinneog   fhuinneog   bhfuinneog
Sasana     Shasana     Sasana
Gaeilge    Ghaeilge    nGaeilge
lón        lón         lón
áthas      áthas       áthas
Ífreann    Ífreann     Ífreann

JavaScript (ES6),  98  97 bytes
Returns an array [lenited, eclipsed].
s=>[(x=[...'2n1111gbnd1m1','bh',2][parseInt(c=s[0],30)*17%22])>'1'?c+'h'+s.slice(1):s,x>{}?x+s:s]

Try it online!
How?
We define the following lookup table:
A = [ ...'2n1111gbnd1m1', 'bh', 2 ]

//     0    1    2    3    4    5    6    7    8    9    10   11   12   13  14
A = [ '2', 'n', '1', '1', '1', '1', 'g', 'b', 'n', 'd', '1', 'm', '1', 'bh', 2 ]

where:

a single character (or the string "bh") is used for eclipsis; all letters that trigger eclipsis also trigger lenition
\$1\$ means that there's no eclipsis and no lenition
\$2\$ means that there's no eclipsis but there is lenition

The first letter of the input word is converted from Base30 to decimal, multiplied by \$17\$ and then reduced with a modulo \$22\$. The result is used to pick the correct value from \$A\$.
Any result above \$14\$ yields undefined, and so does any letter in the range u-z or any fada vowel. An undefined value is interpreted the same way as \$1\$ (no eclipsis, no lenition).
  1st letter | from Base30 | * 17 | mod 22 | A[n]
-------------+-------------+------+--------+-----------
      a      |      10     |  170 |   16   | undefined
      b      |      11     |  187 |   11   | 'm'
      c      |      12     |  204 |    6   | 'g'
      d      |      13     |  221 |    1   | 'n'
      e      |      14     |  238 |   18   | undefined
      f      |      15     |  255 |   13   | 'bh'
      g      |      16     |  272 |    8   | 'n'
      h      |      17     |  289 |    3   | '1'
      i      |      18     |  306 |   20   | undefined
      j      |      19     |  323 |   15   | undefined
      k      |      20     |  340 |   10   | '1'
      l      |      21     |  357 |    5   | '1'
      m      |      22     |  374 |    0   | '2'
      n      |      23     |  391 |   17   | undefined
      o      |      24     |  408 |   12   | '1'
      p      |      25     |  425 |    7   | 'b'
      q      |      26     |  442 |    2   | '1'
      r      |      27     |  459 |   19   | undefined
      s      |      28     |  476 |   14   | 2
      t      |      29     |  493 |    9   | 'd'
 u-z or fada |     NaN     |  NaN |  NaN   | undefined


Recursively concatenated cumulative sums of [N] with M iterations Take two positive integers N and M and create the concatenated cumulative sums of [N], with M iterations. Output the result of the last iteration.

Definition of the concatenated cumulative sum:

Start with a number N and define a sequence X = [N]
Append to X the cumulative sums of X
Repeat step 2 M times.

The cumulative sum of a vector, X = [x1, x2, x3, x4] is: [x1, x1+x2, x1+x2+x3, x1+x2+x3+x4].

Example with N = 1 and M = 4:

P = the cumulative sum function.

M = 0: [1]
M = 1: [1, 1]                    -  X = [1, P(1)] = [[1], [1]]
M = 2: [1, 1, 1, 2]              -  X = [X, P(X)] = [[1, 1], [1, 2]]
M = 3: [1, 1, 1, 2, 1, 2, 3, 5]  -  X = [X, P(X)] = [[1, 1, 1, 2], [1, 2, 3, 5]]
M = 4: [1, 1, 1, 2, 1, 2, 3, 5, 1, 2, 3, 5, 6, 8, 11, 16]

Note that the first X = [1] is not counted as an iteration. You may choose to take M = 5 for the above example (thus counting X = [1] as one iteration).

This is OEIS A107946

Test cases:

N = 5, M = 1
5, 5

N = 2, M = 3
2, 2, 2, 4, 2, 4, 6, 10

N = 4, M = 6
4, 4, 4, 8, 4, 8, 12, 20, 4, 8, 12, 20, 24, 32, 44, 64, 4, 8, 12, 20, 24, 32, 44, 64, 68, 76, 88, 108, 132, 164, 208, 272, 4, 8, 12, 20, 24, 32, 44, 64, 68, 76, 88, 108, 132, 164, 208, 272, 276, 284, 296, 316, 340, 372, 416, 480, 548, 624, 712, 820, 952, 1116, 1324, 1596

This is code-golf, so shortest code wins. Optional input and output formats.

Haskell, 35 bytes

n!m=iterate((++)<*>scanl1(+))[n]!!m

Try it online!

Thanks to H.PWiz for -18 bytes