Calculate a probability exactly and quickly [This is a partner question to Calculate a probability exactly ]

This task is about writing code to compute a probability exactly and quickly. The output should be a precise probability written as a fraction in its most reduced form. That is it should never output 4/8 but rather 1/2.

For some positive integer n, consider a uniformly random string of 1s and -1s of length n and call it A. Now concatenate to A its first value. That is A[1] = A[n+1] if indexing from 1.  A now has length n+1. Now also consider a second random string of length n whose first n values are -1, 0, or 1 with probability 1/4,1/2, 1/4 each and call it B.

Now consider the inner product of A[1,...,n] and B and the inner product of A[2,...,n+1] and B.

For example, consider n=3. Possible values for A and B could be A = [-1,1,1,-1] and B=[0,1,-1]. In this case the two inner products are 0 and 2.

Your code must output the probability that both inner products are zero.

Copying the table produced by Martin Büttner we have the following sample results.

n   P(n)
1   1/2
2   3/8
3   7/32
4   89/512
5   269/2048
6   903/8192
7   3035/32768
8   169801/2097152

Languages and libraries

You can use any freely available language and libraries you like. I must be able to run your code so please include a full explanation for how to run/compile your code in linux if at all possible.

The task

Your code must start with n=1 and give the correct output for each increasing n on a separate line. It should stop after 10 seconds.

The score

The score is simply the highest n reached before your code stops after 10 seconds when run on my computer.  If there is a tie, the winner be the one to get to the highest score quickest.

Table of entries

n = 64 in Python. Version 1 by Mitch Schwartz
n = 106 in Python.  Version June 11 2015 by  Mitch Schwartz
n = 151 in C++. Port of Mitch Schwartz's answer by kirbyfan64sos
n = 165 in Python. Version June 11 2015 the "pruning" version by Mitch Schwartz with  N_MAX = 165.
n = 945 in Python by Min_25 using an exact formula. Amazing!
n = 1228 in Python by Mitch Schwartz using another exact formula (based on Min_25's previous answer).
n = 2761 in Python by Mitch Schwartz using a faster implementation of the same exact formula.
n = 3250 in Python using Pypy by Mitch Schwartz using the same implementation. This score needs pypy MitchSchwartz-faster.py |tail to avoid console scrolling overhead.

Python

A closed-form formula of p(n) is

An exponential generating function of p(n) is

where I_0(x) is the modified Bessel function of the first kind.

Edit on 2015-06-11:
- updated the Python code.

Edit on 2015-06-13:
- added a proof of the above formula.
- fixed the time_limit.
- added a PARI/GP code.

Python

def solve():
  # straightforward implementation

  from time import time
  from itertools import count

  def binom(n, r):
    return facts[n] // (facts[r] * facts[n - r])

  def p(N):
    ans = 0
    for i in range(1 + N // 2):
      t = binom(2 * (N - 2 * i), N - 2 * i)
      t *= binom(N, 2 * i)
      t *= binom(4 * i, 2 * i)
      ans += t
    e = (ans & -ans).bit_length() - 1
    numer = ans >> e
    denom = 1 << (3 * N - 1 - e)
    return numer, denom

  facts = [1]
  time_limit = 10.0 + time()

  for i in count(1):
    facts.append(facts[-1] * (2 * i - 1))
    facts.append(facts[-1] * (2 * i))

    n, d = p(i)

    if time() > time_limit:
      break

    print("%d %d/%d" % (i, n, d))

solve()

PARI/GP

p(n) = polcoeff( (exp(x/2) + 1) * besseli(0, x/4) ^ 2, n) * n!;

Proof:
This problem is similar to a 2-dimensional (restricted) random walk problem.

If A[i] = A[i+1], we can move from (x, y) to (x+1, y+1) [1 way], (x, y) [2 ways] or (x-1, y-1) [1 way].

If A[i] != A[i+1], we can move from (x, y) to (x-1, y+1) [1 way], (x, y) [2 ways] or (x+1, y-1) [1 way].

Let a(n, m) = [x^m]((x+1)^n + (x-1)^n), b(n) = [x^n](1+x)^{2n} and c(n) be the number of ways to move from (0, 0) to (0, 0) with n steps.

Then, c(n) = \sum_{i=0}^n a(n, i) * b(i) * b(n-i).

Since p(n) = c(n) / 8^n, we can get the above closed-form formula.


Divide and divide and conquer Sometimes, when I'm idly trying to factor whatever number pops up in front of me¹, after a while I realize it's easier than I thought. Take 2156 for example: it eventually occurs to me that both 21 and 56 are multiples of 7, and so certainly 2156 = 21 x 100 + 56 is also a multiple of 7.

Your task is to write some code that identifies numbers that are easier to factor because of a coincidence of this sort.

More precisely:

Write a program or function that takes a positive integer n as input, and returns a truthy value if there exists a divisor d (greater than 1) such that n can be chopped in two to yield two positive integers, each of which is a multiple of d; return a falsy value if not.

"Chopped in two" means what you think: the usual base-10 representation of n partitioned at some point into a front half and a back half to yield two other base-10 integers. It's okay if the second integer has a leading zero (but note that it must be a positive integer, so splitting 1230 into 123 and 0 is not valid).
The truthy and falsy values can depend on the input. For example, if any nonzero integer is truthy in your language of choice, then you are welcome to return the divisor d or one of the "pieces" of n (or n itself for that matter).
For example, any even number with at least two digits in the set {2, 4, 6, 8} will yield a truthy value: just split it after the first even digit. Also for example, any prime number n will yield a falsy value, as will any one-digit number.
Note that it suffices to consider prime divisors d.
You may assume the input is valid (that is, a positive integer).

This is code-golf, so the shortest code in bytes wins. But solutions in all languages are welcome, so we can strive for the shortest code in each language, not just the shortest code overall.

Test cases

(You only have to output a truthy or falsy value; the annotations below are just by way of explanation.) Some inputs that yield truthy values are:

39  (3 divides both 3 and 9)
64  (2 divides both 6 and 4)
497  (7 divides both 49 and 7)
990  (splitting into 99 and 0 is invalid; but 9 divides both 9 and 90)
2233  (11 divides both 22 and 33)
9156  (3 divides both 9 and 156; or, 7 divides both 91 and 56)
11791  (13 divides both 117 and 91)
91015  (5 divides both 910 and 15)
1912496621  (23 divides both 1912496 and 621; some splittings are multiples of 7 as well)
9372679892  (2473 divides both 937267 and 9892; some splittings are multiples of 2 as well)

Some inputs that yield falsy values are:

52
61
130  (note that 13 and 0 is not a valid splitting)
691
899
2397
9029
26315
77300  (neither 7730 and 0 nor 773 and 00 are valid splittings)
2242593803

¹ yes I really do this

Retina, 31 29 bytes

,$';$`
\d+
$*
;(11+)\1*,\1+;

Try it online!

Outputs a positive integer for valid inputs and zero for invalid ones.

I wouldn't recommend waiting for the larger test cases...

Explanation

,$';$`

At each position of the input insert a comma, then everything before that position, then a semicolon, then everything after this position. What does that do? It gives us all possible splittings of a number (split by ,, separated by ;), and then the input again at the end. So input 123 becomes

,123;1,23;12,3;123,;123
     ^     ^     ^

where I've marked the original input characters (the stuff that isn't marked is what we inserted). Note that this creates invalid splittings that aren't actual splittings and it also doesn't care whether the trailing component is all zeros, but we'll avoid accepting those later. The benefit of creating the invalid splittings is that we know that each valid splitting has a ; in front and after it, so we can save two bytes on word boundaries.

\d+
$*

Convert each number to unary.

;(11+)\1*,\1+;

Match a splitting by matching both halves as multiples of some number that's at least 2.


Correlation Coefficient of Words This is going to be relatively quick...

Challenge

Given a lower-case word as input, calculate the Pearson's Correlation Coefficient between the letter position of the word (nth letter within the word, x), and the letter position within the alphabet (nth letter of the alphabet, y).

Background

Pearson's Correlation Coefficient is worked out for data sets x and y, as:

where x and y are the respective data sets as explained above (and further below), and n is the length of the string.

Examples

  Input: forty
  Output: 0.964406804

Explanation:

  Letters: f o r t y
  Alphabet Number (y): 6 15 18 20 25
  Letter Position (x): 1 2 3 4 5
  Length of word (n): 5

Correlation coefficient is worked out from the above formula.

  Input: bells
  Output: 0.971793199

Explanation:

  Letters: b e l l s
  Alphabet Number (y): 2 5 12 12 19
  Letter Position (x): 1 2 3 4 5
  Length of word (n): 5

Correlation coefficient is once again worked out from the above formula.

Rules

Input must provide the word as a lower-case alphabetic string with no spaces (assumed input). The delivery of this string is entirely up to you (file, STDIN, function, array, carrier pigeon, etc.)
Output is in the form of a numeric that will, by the formula, provide r, such that -1 <= r <= 1. Delivery of the output, once again, is entirely up to you.
No silly loop holes
This is not code-golf, as I'm sure there will be many languages that may have native statistical functions. Instead, this will be a popularity contest, so most votes wins here, so make your entry count... I'll be throwing in a bounty for the most creative answer that attracts my attention a little later down the line...

Any questions/comments?

R, 63 bytes
s=strsplit(scan(,""),"")[[1]];cor(match(s,letters),1:length(s))

Ungolfed :
#Takes the input and splits it, letters by letters
s=strsplit(
           scan(,""),
           "")[[1]];

#Finds the positions of each letters in the lowercase alphabet, and correlates them with
#their position in the word
cor(
    match(s,letters),
    1:length(s)
    )


Java Asterisk Rectangle For my CS class, my instructor has given us the assignment of creating a rectangle made of asterisks with diagonal lines drawn through it in Java.
He also told us to write it in as few bytes as possible. I've gotten it down to 190 bytes, but I need to find a few to simplify this code even more to decrease bytes. Can anyone help me with this?
This code is functional:
interface d{static void main(String[]a){for(int z=0,w=new Byte(a[0]),h=new Byte(a[1]);z<h*w;){int y=z/w,x=z++%w;System.out.print((x>w-2)?"*\n":(y%(h-1)*x*((y-x)%3)==0)?"*":" ");}}}

Input is 10 10.
Output:
**********
**  *  * *
* *  *  **
*  *  *  *
**  *  * *
* *  *  **
*  *  *  *
**  *  * *
* *  *  **

Logically, there should be an asterisk (*) every time i == j and i+j==w-1(for diagonals), i == 0 and j == 0 (for top line and left side) and j == w-1 and i==h-1  (for right side and bottom line).
class d {
    public static void main(String[] a) {
        for(int i=0,w=new Byte(a[0]),h=new Byte(a[1]);i<h;i++) {
            for(int j=0;j<w;j++) {
                System.out.print(i==0 || j==0 || i==h-1 || i+j==w-1 || j==w-1 || i==j ? "*":" ");
            }
            System.out.println();
        }
    }
}


A083569: Smallest m not occurring earlier such that m+n is prime Define a 1-indexed sequence as follows:

A083569(1) = 1
A083569(n) where n is an integer greater than 1, is the smallest integer m not occurring earlier such that m+n is a prime number.

Your task is to take in n and return A083569(n).

 n  A083569(n)
 1  1
 2  3
 3  2
 4  7
 5  6
 6  5
 7  4
 8  9
 9  8
10 13
11 12
12 11
13 10
14 15
15 14
16 21
17 20
18 19
19 18
20 17

More testcases can be found here. The original sequence on OEIS can be found here.

This is code-golf. Shortest answer in bytes wins. Standard loopholes apply.

Haskell, 87 86 83 80 74 69 bytes

Thanks to xnor for suggesting some changes that saved 3 bytes!

f n=[m|m<-[1..],all((>0).mod(n+m))[2..n+m-1],all((/=m).f)[1..n-1]]!!0

Try it online!

I'm new to Haskell, and Haskell golfing, feedback is appreciated!

Explanation

We define a function f n.  We define f n to be the first element !!0 of the list:

[m|m<-[1..],all((>0).mod(n+m))[2..n+m-1],all((/=m).f)[1..n-1]]

Broken down that is:

[m|          # Numbers m
m<-[1..],    # From the integers greater than 0
all          # Forall x
(>0).mod(n+m)# n+m mod x is not zero
[2..n+m-1]   # from the integers from 2 to n+m-1
all          # Forall
((/=m).f)    # when f is applied the result is not m
[1..n-1]     # from the integers from 1 to n-1


Generating Word Grids Given input n, produce a word grid of size n, in as few bytes as possible.

Details

The number provided will always be odd. The centre square of the grid must always be empty (a space character). The letters that fill the grid must be chosen at random from the English Scrabble letter distribution of letters. That is, each tile must be chosen at random, with uniform probability, from the following 100 characters:

??EEEEEEEEEEEEAAAAAAAAAIIIIIIIIIOOOOOOOONNNNNNRRRRRRTTTTTTLLLLSSSSUUUUDDDDGGGBBCCMMPPFFHHVVWWYYKJXQZ

where ? denotes blank tiles.

As with a Scrabble board, some tiles in this board will also be bonus tiles for a higher score. These tiles are only visible on a board with a size of 9 or more. and should be visible every 3 rows from the centre square in a pattern emanating outwards, but should never appear on the outermost letters. Bonus squares are denoted using lowercase letters, with blank tiles identified as ! instead of ?. Please see this visual demonstration or the reference implementation for more examples on how to correctly distribute bonus tiles.

Examples

Input: 5

Output:

VNZNT
IFOSN
UD VD
ZIOO?
KTLED

Input: 9

Output:

UWDESTKPW
ItDBaDEdI
TERMDYSTR
ROANJLEFT
EkCI OOsT
IPAJPGM?Y
MZLORETVI
G!EGgPUeI
MNROYOEER

Reference implementation.

Rules

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

Any reasonable format can be used for I/O, assuming it is consistent.
You should be able to handle grids at least up to 999.
All standard loopholes are forbidden.

Jelly,  67 65 64 66 64  63 bytes
”?;ØAx“³Ċu~Ṿr¥rṇ⁽ȦƑ’ḃ12¤µŒl⁾?!yW,WKF€
H3ṬṚ¤ṁ‘1¦ṚŒḄ0,0j«þ`ị¢X€€Y

A monadic link taking a number and returning a list of characters, or a full program printing the result.
Try it online! (I prefer it using G rather than Y since that's more square)
How?
”?;ØAx“³Ċu~Ṿr¥rṇ⁽ȦƑ’ḃ12¤µŒl⁾?!yW,WKF€ - Link 1, getLetterSets: no arguments
”?                                    - literal '?'
   ØA                                 - yield uppercase alphabet
  ;                                   - concatenate
                       ¤              - nilad followed by link(s) as a nilad:
      “³Ċu~Ṿr¥rṇ⁽ȦƑ’                  -   base 250 number
                    ḃ12               -   converted to bijective base 12 (frequencies)
     x                                -   times (repeat each)
                        µ             - start a new monadic chain, call that uppers
                         Œl           - to lower-case
                           ⁾?!        - literal ['?','!']
                              y       - translate (change '?'s to '!'s)
                               W      - wrap (that) in a list
                                 W    - wrap (uppers) in a list
                                ,     - pair
                                  K   - join with a space, ' '
                                   F€ - flatten €ach (both flattens the wrapped lists
                                      -               AND makes the lone ' ' into [' '])

H3ṬṚ¤ṁ‘1¦ṚŒḄ0,0j«þ`ị¢X€€Y - Main link: number, n                 e.g. 13
H                         - halve                                     6.5
    ¤                     - nilad followed by link(s) as a nilad:
 3                        -   literal three                           3
  Ṭ                       -   untruth                                 [0,0,1]
   Ṛ                      -   reverse                                 [1,0,0]
     ṁ                    - mould like (implicit range(int(right)))   [1,0,0,1,0,0]
        ¦                 - sparse application:
       1                  - ...to indices: 1
      ‘                   - ...action: increment                      [2,0,0,1,0,0]
         Ṛ                - reverse                                   [0,0,1,0,0,2]
          ŒḄ              - bounce                          [0,0,1,0,0,2,0,0,1,0,0]
            0,0           - literal [0,0]                             [0,0]
               j          - join                          [0,0,0,1,0,0,2,0,0,1,0,0,0]
                  `       - repeat left argument as right argument with:
                 þ        -   outer product using:       [[0,0,0,0,0,0,0,0,0,0,0,0,0],
                «         -     minimum                   [0,0,0,0,0,0,0,0,0,0,0,0,0],
                          -                               [0,0,0,0,0,0,0,0,0,0,0,0,0],
                          -                               [0,0,0,1,0,0,1,0,0,1,0,0,0],
                          -                               [0,0,0,0,0,0,0,0,0,0,0,0,0],
                          -                               [0,0,0,0,0,0,0,0,0,0,0,0,0],
                          -                               [0,0,0,1,0,0,2,0,0,1,0,0,0],
                          -                               [0,0,0,0,0,0,0,0,0,0,0,0,0],
                          -                               [0,0,0,0,0,0,0,0,0,0,0,0,0],
                          -                               [0,0,0,1,0,0,1,0,0,1,0,0,0],
                          -                               [0,0,0,0,0,0,0,0,0,0,0,0,0],
                          -                               [0,0,0,0,0,0,0,0,0,0,0,0,0],
                          -                               [0,0,0,0,0,0,0,0,0,0,0,0,0]]
                    ¢     - call the last link (1) as a nilad (the letter sets)
                   ị      - index into - gets the correct letter sets for each cell
                     X€€  - random-choice for €ach cell in €ach row
                        Y - join with newlines
                          - if running as a full program: implicit print


Checking a file contains only null bytes Your goal is to write a program or function that takes in as input a string representing the path to a file, and outputs a truthy value if that file is not empty and contains no non-null bytes -- i.e., all bits are 0 -- and a falsey value otherwise.

I realize it is a very simple problem and I guess I could hack
something, but I suspect there must be some short and elegant way of
doing it, and that gave me the idea to make a challenge out of it.

This is code-golf, so shortest code in bytes wins. (My own preference would go to the fastest solution, but that is too implementation dependent...)

Related questions: Pad a file with zeros

Motivation : This is only to tell where the problem comes from, in case you are interested. You do not need to read it.

ISO images of CDs and DVDs, copied with "dd" or other
means, often terminate with a sequence of useless blocks containing
only null bytes. Standard techniques to remove these blocks are known
and simple (see
https://unix.stackexchange.com/questions/74827/ )
but they may sometimes remove non null useful data because the medium
can lie about its own size. So I want to check that the removed
blocks contain only null bytes. Removing these blocks is important for defining a normalised version of ISO-images.

Pyth, 6 5 bytes
!sCM'

Try it online!
Takes a filename from STDIN, opens and reads the file, converts it to a list of ints (think Python ord) sums the list (will return 0 iff file is all null bytes), and nots the result, printing it.

Hey,
This looks a lot like a general programming question. These belong on Stack Overflow. However, from the comments under the main post, I can see that this was not your intent. That said, I feel that the discussion has been unnecessarily hostile on both sides, so I've decided to pick up the slack and give you the proper PPCG welcome!
Generally, we ask that any challenges are first posted to our sandbox for proper feedback. You can take a look at the current submissions in there to see what format we prefer for challenges. Please give it a try next time!
Just in case we've all misunderstood you and you are looking for a general solution, here's a solution in Python 3:
def main(string):
    with open(string) as file:
        return not any(map(ord,file.read()))


Draw this diamond pattern The below pattern will form the basis of this challenge.

     /\
     \/
     /\
    /  \
   /    \
/\/      \/\
\/\      /\/
   \    /
    \  /
     \/
     /\
     \/

Given an input width and height, each >=1, output the above ASCII art pattern repeated that many times, joining (and overlapping) at the small diamonds.

For example, here is an input with width = 2 and height = 1:

     /\        /\
     \/        \/
     /\        /\
    /  \      /  \
   /    \    /    \
/\/      \/\/      \/\
\/\      /\/\      /\/
   \    /    \    /
    \  /      \  /
     \/        \/
     /\        /\
     \/        \/

Here is an input width = 3 and height = 2:

     /\        /\        /\
     \/        \/        \/
     /\        /\        /\
    /  \      /  \      /  \
   /    \    /    \    /    \
/\/      \/\/      \/\/      \/\
\/\      /\/\      /\/\      /\/
   \    /    \    /    \    /
    \  /      \  /      \  /
     \/        \/        \/
     /\        /\        /\
     \/        \/        \/
     /\        /\        /\
    /  \      /  \      /  \
   /    \    /    \    /    \
/\/      \/\/      \/\/      \/\
\/\      /\/\      /\/\      /\/
   \    /    \    /    \    /
    \  /      \  /      \  /
     \/        \/        \/
     /\        /\        /\
     \/        \/        \/

Rules and I/O

Input and output can be given by any convenient method.
You can print it to STDOUT or return it as a function result.
Either a full program or a function are acceptable.
Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Canvas, 26 25 24 21 18 bytes

４／╬/╬⁰ｒ：⤢ｎ↷⁸｛Ａ×├ｍ↷

Try it here!

-3 bytes by fixing ｍ not repeating canvas

Explanation:

4/╬                 quad-palindromize a 4-long diagonal - big inner diamond
   /╬               quad-palindromize "/" - small diamond
     ⁰r             join the two vertically, centered
       :⤢n          overlap with transpose
           ↷        and rotate the thing clockwise
            ⁸{      for each input
              A×      times 10
                ├     plus 2
                 m    mold the canvas to that width
                  ↷   and rotate clockwise, setting up for the next iteration


Simplifying Radicals Given integers a and b in the format a√b (a on the square root of b), make a program that will reduce b and increase a until the radical statement is fully simplified.

Example

input
a = 1
b = 16

output
4 root 1

In this instance, 1√16 = 4√1

Bonus - 25 chars for the ability to simplify radicals other than square root using another variable, c.

Python, 71-25=46 63-25=38 chars

f=lambda a,b:max((a*i,b/i/i)for i in range(1,b)if b%(i*i)==0)

g=lambda a,b,c:max((a*i,b/i**c)for i in range(1,b)if b%i**c==0)

f is 61, chars. g is 63 but gets a 25 char bonus.


How many minimum days will he take to complete N units of work? A person has to complete N units of work; the nature of work is the same.
In order to get the hang of the work, he completes only one unit of work in the first day.
He wishes to celebrate the completion of work, so he decides to complete one unit of work in the last day.
He is only allowed to complete x, x+1 or x-1 units of work in a day, where x is the units of work completed on the previous day.
Your task is to create a program or function that will compute the minimum number of days will he take to complete N units of work.
Sample Input and Ouput:
input -> output (corresponding work_per_day table)
-1    -> 0      []
0     -> 0      []
2     -> 2      [1,1]
3     -> 3      [1,1,1]
5     -> 4      [1,1,2,1] or [1,2,1,1]
9     -> 5      [1,2,3,2,1]
13    -> 7      [1,2,2,2,3,2,1]

Input may be taken through STDIN or as function argument, or in any appropriate way.
Output may be printed or as the result of a function, or in any appropriate way.
This is code-golf. Shortest solution wins.

Pyth, 8 bytes

tfg/*TT4

How it works:

tfg/*TT4   Q is implicitly assigned to the input.
 f         test for T=1,2,3,... returning the first successful case
   /*TT4   whether T * T / 4
  g     Q  is greater than or equal to the input (second argument implied)
t          and subtract 1 from the first successful case

Try it online!

In pseudo-code:

for(int T=1;;T++)
    if(T*T/4 >= Q)
        return T-1;

bonus, 22 bytes

"should return 7 for -1"

+tfg/*TT4?>Q0Q-2Q1*4g1

Try it online!


Which answer did this user write? This is an answer-chaining challenge where each answer must take an integer \$N\$ as input and return the 1-indexed ID of the answer which was written by the user whose ID is \$N\$.
You may want to sort by oldest to get the answers in the logical order.
Rules

I will post the first answer.
You are only allowed to post one answer, so that a user ID is linked to one and only one answer ID.
You are only supposed to support user IDs that were used in the previous answers and your own user ID. (So your code may return anything or crash when given an unknown user ID.)
The maximum code size is set to 50 bytes. So the challenge will end when nobody is able to add a new ID without exceeding this size.
You may use any language, no matter which ones were used before. It is recommended to use verbose languages early in the chain, while they still have a chance to compete.
The last valid answer in the chain on January 19, 2022 at 18:00 UTC wins the challenge.

Please include in your post the list of ID pairs, updated with your new entry:
[your_user_ID] -> [your_answer_ID]

Also make sure to include the ID of your answer in the header.
Examples
The first answer is written by user Arnauld (58563):
1. JavaScript (ES6), 4 bytes
_=>1

Try it online!
Updated list:
58563 -> 1

This code returns 1 when given 58563 (my user ID) ... or any other input. That's fine because 1 is the only possible output at this point (see rule #3).
The second answer is written by user JohnDoe (123456) (who actually doesn't exist yet):
2. Python 2, 14 bytes
lambda n:2-n%2

Try it online!
Updated list:
58563 -> 1
123456 -> 2

This code returns 1 when given 58563 or 2 when given 123456.

7. Julia, 17 bytes
works due to Int64 overflowing to negative numbers

x->(x-8479)^6%5+5

Try it online!
Updated list:
58563 -> 1
80214 -> 2
95792 -> 3
89930 -> 4
86147 -> 5
97857 -> 6
98541 -> 7

I found those numbers by guessing and brute-forcing :

for i in Iterators.product(-9999:9999,1:20,1:20)
    d = diff(((L.+i[1]) .^ i[3]) .% i[2])
    if all(==(-1), d) || all(==(1),d)
        println(i)
        println(((L.+i[1]) .^ i[3]) .% i[2])
        break
    end
end

Try it online!


Find the length of a number's "base-jumping" path Consider a positive integer N written in base b. A sequence is generated from this number by finding the largest digit d in the expansion of N and writing N in base d+1, repeating until the base the number is written in can be decreased no further. For example, the sequence generated by 346 (10) in starting base 16 has length 6: 15A (16) = 295 (11) = 346 (10) = 1003 (7) = 11122 (4) = 110211 (3). Note that the next term in the sequence would be in base 3 again, which is invalid since the base does not decrease.

The goal of this code golf challenge is to write a program/function that takes two inputs (a decimal integer and a starting base - order doesn't matter and the two numbers must be integers) and outputs the length of the sequence generated according to the above rules.

Some test cases:

(24, 4) = 2
(19, 10) = 1
(346, 16) = 6
(7557, 97) = 20

Jelly, 7 bytes

b@Ṁ‘ɗƬL

A dyadic Link accepting b on the left and N on the right which yields the sequence length.

Try it online!

How?

b@Ṁ‘ɗƬL - Link: b; N
     Ƭ  - Collect up until no longer unique, applying:
    ɗ   -   last three links as a dyad - i.e. f(X[initially b], N):
 @      -     with swapped arguments:
b       -       convert (N) to base (X)
  Ṁ     -     maximum
   ‘    -     incremented
      L - length


Pi Hunting - find an index of Pi whose value matches its index Given π to an arbitrary number of places, your challenge is to locate indices of π where the index (1,2,3,4...) and the string of numbers from that index carry the same value for the length of the index.

That sounds complex, so let's look at an example!

Indices will count from +1 upwards through natural whole integers, skipping 0 as the first index:

1, 2, 3, 4,.... up to an arbitrary whole positive number.

If the number being used (instead of π) was:

123456789101112

then for each index value 1... the sequence of numbers at that index position would match with the value of the index.

At position 1 the string '1' can be found

123456789101112
^

At position 2 the string '2' can be found

123456789101112
 ^

If this sequence continue to 10, you'd find that at position 10 the sequence '10' is found.

123456789101112
         ^

However, when you reach position 11, you find '01', not '11'.

123456789101112
          ^

Given an input value of π of the format:

3.14159...

and taking off 3. to give 14159... using indices start at 1, so the first string found at index 1 is "1", the first string found at index 2 is "4", etc.

Find the shortest code to locate the first 4 indices where the set of characters at that index position have the same numerical sequence as the numbers that make up the index.

Shortest wins!

Built-ins are allowed

Examples of finding the nth digit of pi:

Find the nth decimal of pi

The major step here is to make the comparison of the nth digit and 'n' to determine if there's a match.

** First Match **

3.14159265

1 : finds '1'

A simple psuedo-code approach might be similar to the following, except this one doesn't account for "3." or the index being off by 1:

assume input=pi to any arbitrary length supported with '3.' removed

for(var index=0, maximumInputLength=input.length; index < maxmimumInputLength; index++) {
 var indexString = '' + i;
 var indexLength = indexString.length;
 if(indexString.substr(index, indexLength) == indexString) {
    // index found at index'th position
 } else {
    // index not found at index'th position
 }
}

This style of solution will return '6' found in the 6th index position and '27' found in the 27th index position.

Given 141 592 6 (6 is in the 7th position starting at 0).

To verify if an answer is correct, you can use the above code to find the nth digit of pi and compare to the value of 'n' in your language of choice!

Thank you for the great feedback in helping me write a better first question.

Clarifications:

Is π given as an input - YES

Python 2, 64 bytes

i=1
while i<len(P):
	if int(P[i:i+len(str(i))])==i:print i
	i+=1

As you said, pi's digits are given, so I chose the variable P to contain the entire digit string.
The full code first downloads one billion digits of pi to a file using cURL and then reads in that file to process it.

"Setting up pi's digits."; exec'import os\nN,f=200000000,"pi.txt"\nif not os.path.exists(f):os.system("curl https://stuff.mit.edu/afs/sipb/contrib/pi/pi-billion.txt>"+f)\nP=open(f,"r").read()[1:N+2][:-1]'
"Search through pi.";      exec'i=1\nwhile i<len(P):\n\tif int(P[i:i+len(str(i))])==i:print i\n\ti+=1'

Though, when one knows the answer, a simple plaintext output is actually shorter (29 bytes).

print"1,16470,44899,79873884"

This series of numbers is also known to the OEIS (http://oeis.org/A057680).


Negative Fibonacci Numbers You probably all know the fibonacci sequence:

fibonacci(n)=fibonacci(n-1)+fibonacci(n-2)
fibonacci(0)=0
fibonacci(1)=1

Your task is as simple as it could be:

Given integer N compute fibonacci(n)

but here is the twist:

Also do negative N

Wait. What?

fibonacci(1)=fibonacci(0)+fibonacci(-1)

so

fibonacci(-1)=1

and

fibonacci(-2)=fibonacci(0)-fibonacci(1)=-1

and so on...

This is a code-golf so shortest programm in bytes win.
You may submit a function or a full programm
N is in [-100,100]

Testcase(s) in CSV:

-9;-8;-7;-6;-5;-4;-3;-2;-1;0;1;2;3;4;5;6;7;8
34;-21;13;-8;5;-3;2;-1;1;0;1;1;2;3;5;8;13;21

Hint:

   n<0 and n&1==0:
 fibonacci(n)=fibonacci(abs(n))*-1

Mathematica, 9 bytes

Fibonacci

Yes, this built-in function supports negative numbers.


Code golf the best permutation Challenge

Given an integer n ≥ 4, output a permutation of the integers [0, n-1] with the property that no two consecutive integers are next to each other.  The value of a permutation pi is the sum of abs(pi[i] - i) for all indices i.

Examples

(1, 3, 0, 2) has value  6
(0, 2, 4, 1, 3)  has value 6
(0, 2, 4, 1, 3, 5) has value 6
(0, 2, 4, 1, 5, 3, 6) has value 8

Score of your answer

The score of your answer is the sum of the values of your permutations for n = 4 .. 14 plus the number of bytes your code takes.  The lower the score, the better.  Your code must give valid output for all those values of n.

You must be able to run your submission to completion on your machine.

In case of ties,  time of last edit that resulted in the relevant score will be the decider.

Isn't this the same question as this one?

Answers to the linked question will not be competitive for this question as they make no effort to optimize the value of a permutation. For example for n=10, the permutation [1, 3, 5, 7, 9, 0, 2, 4, 6, 8] given by most of the answers there gives a value of 30. You can do much better than that.

For the permutation part of the question, the optimal value overall is at most 120.  (Thank you to @Laikoni.)   Whereas Dennis's answer to the previous question scores 222. (Thank you to @user202729.)

CJam (60 bytes + 120 = 180 score)

{_5/4*8e!961=7_)er<:A\,^e!{A\+}%{2ew::-:z1&!},{_$.-:z1b}$0=}

Online test suite with integrated scoring

Extension up to n=24

Dissection

{
  _5/4*        e# Work out how much of the hard-coded prefix to use
  8e!961=7_)er e# Prefix [0 2 4 1 3 5 8 6]
               e# I identified this by brute forcing up to n=10 and looking for patterns
               e# I then used the identified prefix [0 2 4 1] to brute-force further
  <:A          e# Take the desired prefix of the hard-coded array, and store a copy in A
  \,^e!        e# Generate all permutations of the values in [0 .. n-1] which aren't in A
  {A\+}%       e# Prepend A to each of them
  {            e# Filter...
    2ew::-     e#   Take each difference of two consecutive elements
    :z         e#   Find their absolute values
    1&         e#   Test whether 1 is among those absolute values
    !          e#   Reject if it is
  },
  {            e# Sort by...
    _$.-       e#   Take pairwise differences of permutation with the identity
    :z         e#   Absolute values
    1b         e#   Add them (by interpreting in base 1)
  }$
  0=           e# Take the first
}


Remove surrounding zeroes of a 2d array This is a 2-dimensional version of this question.

Given a non-empty 2-dimensional array/matrix containing only non-negative integers:

$$ \begin{bmatrix}
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} \\
{\color{Red}0} & {\color{Red}0} & 0 & 1 & 0 \\
{\color{Red}0} & {\color{Red}0} & 0 & 0 & 1 \\
{\color{Red}0} & {\color{Red}0} & 1 & 1 & 1 \\
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0}
\end{bmatrix} $$

Output the array with surrounding zeroes removed, i.e. the largest contiguous subarray without surrounding zeroes:

$$ \begin{bmatrix}
0 & 1 & 0 \\
0 & 0 & 1 \\
1 & 1 & 1
\end{bmatrix} $$

Examples:

$$ \begin{bmatrix}
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} \\
{\color{Red}0} & {\color{Red}0} & 0 & 1 & 0 \\
{\color{Red}0} & {\color{Red}0} & 0 & 0 & 1 \\
{\color{Red}0} & {\color{Red}0} & 1 & 1 & 1 \\
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0}
\end{bmatrix}
\mapsto
\begin{bmatrix}
0 & 1 & 0 \\
0 & 0 & 1 \\
1 & 1 & 1
\end{bmatrix}
$$

Input:
[[0, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 0, 1, 1, 1], [0, 0, 0, 0, 0]]

Output:
[[0, 1, 0], [0, 0, 1], [1, 1, 1]]

$$ \begin{bmatrix}
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} \\
{\color{Red}0} & 0 & 0 & 3 \\
{\color{Red}0} & 0 & 0 & 0 \\
{\color{Red}0} & 5 & 0 & 0 \\
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0}
\end{bmatrix}
\mapsto
\begin{bmatrix}
0 & 0 & 3 \\
0 & 0 & 0 \\
5 & 0 & 0
\end{bmatrix}
$$

Input:
[[0, 0, 0, 0], [0, 0, 0, 3], [0, 0, 0, 0], [0, 5, 0, 0], [0, 0, 0, 0]]

Output:
[[0, 0, 3], [0, 0, 0], [5, 0, 0]]

$$ \begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}
\mapsto
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}
$$

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

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

$$ \begin{bmatrix}
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} \\
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} \\
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0}
\end{bmatrix}
\mapsto
\begin{bmatrix}
\end{bmatrix}
$$

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

Output:
[]

$$ \begin{bmatrix}
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} \\
1 & 1 & 1 & 1 \\
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0}
\end{bmatrix}
\mapsto
\begin{bmatrix}
1 & 1 & 1 & 1
\end{bmatrix}
$$

Input:
[[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0]]

Output:
[[1, 1, 1, 1]]

$$ \begin{bmatrix}
{\color{Red}0} & 1 & {\color{Red}0} & {\color{Red}0} \\
{\color{Red}0} & 1 & {\color{Red}0} & {\color{Red}0} \\
{\color{Red}0} & 1 & {\color{Red}0} & {\color{Red}0}
\end{bmatrix}
\mapsto
\begin{bmatrix}
1 \\
1 \\
1
\end{bmatrix}
$$

Input:
[[0, 1, 0, 0], [0, 1, 0, 0], [0, 1, 0, 0]]

Output:
[[1], [1], [1]]

$$ \begin{bmatrix}
1 & 1 & 1 & 1 \\
1 & 2 & 3 & 1 \\
1 & 1 & 1 & 1
\end{bmatrix}
\mapsto
\begin{bmatrix}
1 & 1 & 1 & 1 \\
1 & 2 & 3 & 1 \\
1 & 1 & 1 & 1
\end{bmatrix}
$$

Input:
[[1, 1, 1, 1], [1, 2, 3, 1], [1, 1, 1, 1]]

Output:
[[1, 1, 1, 1], [1, 2, 3, 1], [1, 1, 1, 1]]

Wolfram Language (Mathematica), 42 bytes
#&@@CellularAutomaton[{,{},0{,}},{#,0},0]&

Try it online!
Cellular automata are indeed the answer to life, the universe, and everything.1
How?
CellularAutomaton accepts an input array and an optional background value. Thus, {#,0} specifies that a cellular automaton rule should be applied to the input, assuming a background of 0s.
A neat thing here is that CellularAutomaton crops the output so that no border of background cells is present (because otherwise the output lies on an infinite plane).
The code applies the rule {Null, {}, {0, 0}} -- applying the head Null to the 0-radius neighbor of each cell (i.e. only the center: the cell itself) -- exactly 0 times. The result of this is the original input, but with background removed (i.e. cropping out surrounding 0s).

1. See the bytecount of my answer? ;)


Short Deadfish Numbers Deadfish is one of the best known non Turing-complete programming languages. It has only one accumulator (which starts at 0) to store data, and only four commands:
i - Increment the accumulator
s - Square the accumulator
d - Decrement the accumulator
o - Output the accumulator

A Deadfish program may look like:
iiisdo

And that would print:
8

The challenge
Create a program that will input a number and output Deadfish code to display the number.(Or make a function that takes the number as a parameter and returns the code.) It must work for any integer from 0 to 255
Goal
Try to make your code make the shortest code possible to generate the given number. For example:
iiiiiiiiio

and
iiiso

each print 9, but the second is shorter.
Scoring
Your score is:
The number of characters in your source code +
The sum of the lengths of your output for all numbers from 1-255
-100 if the language you chose is Deadfish :)

Lowest score wins!

In the original challenge I only had the sum of 6 numbers(9,17,99,100 and 123).
This was from me wanting to not make everyone test for every number, and I wanted the shortest code to be relevant. Then I realized that programmers are good at making scripts to test things like that, and I would rather have this be a contest for best algorithm with golfing as a tiebreaker.
Therefor I changed this, as suggested by Martin Büttner.

ES6 JavaScript 2126 + 311 = 2437 score

m=Math;s=n=>[b=m.min(m.sqrt(n)+.5|0,15),n-b*b];f=n=>(n<0?'d':'i').repeat(m.abs(n));g=(n,t)=>n<4?f(n):g((t=s(n))[0])+'s'+f(t[1]);q=n=>((x=g(n)).length>(z=[...n+''].map((k,i,a)=>i?(a[i-1]==a[i]?'':(y=f((l=s(k))[0]-a[i-1])+(l[0]?'s':'')+f(l[1])).length>m.abs(Q=a[i]-a[i-1])?f(Q):y):g(k)).join('o')).length?z:x)+'o'

Semi-commented:

m = Math; // Keep a reference to math
// This function returns the closest perfect square and the distance from that square to the number
// E.g. s(10) --> [3, 1] because 3^2 + 1 = 10
s = n => [b = m.min(m.sqrt(n) + .5 | 0, 15), n - b * b];
// This creates a bunch of "d"s or "i"s
// E.g. f(3) --> "iii" or f(-2) --> "dd"
f = n => Array(m.abs(n) + 1).join(n < 0 ? 'd' : 'i');
// This constructs the number as a number rather than by digit
g = (n, t) => n < 4 ?
              // If n is less than 4, then we can just increment in normally (base case)
              f(n) :
              // Otherwise, build the square root recursively and shift
              g((t = s(n))[0]) + 's' + f(t[1]);
// This maps based on digits (constructs the number by digit)
// This has now been removed and replaced inline because it is only used once
d = n => (a = [...(n + '')]).map((k, i) => i ? (a[i - 1] == a[i] ? '' : f((l = s(k))[0] - a[i - 1]) + (l[0] ? 's' : '') + f(l[1])) : g(k)).join('o');
// For the official function, compare the digit-method and nondigit-method and return the best one
q = n => ((x = g(n)).length > (z = d(n)).length ? z : x) + 'o'

This takes advantage of the fact that in deadfish, you can print more than one character.

Example: 10 compiles to iodo which is "print one, decrement, print zero."

Usage:

q(10) // --> iodo
q(16) // --> iisso

Here's json data of output:

{
    "0": "o",
    "1": "io",
    "2": "iio",
    "3": "iiio",
    "4": "iiso",
    "5": "iisio",
    "6": "iisiio",
    "7": "iiisddo",
    "8": "iiisdo",
    "9": "iiiso",
    "10": "iodo",
    "11": "ioo",
    "12": "ioio",
    "13": "ioiio",
    "14": "ioiso",
    "15": "iissdo",
    "16": "iisso",
    "17": "iissio",
    "18": "iissiio",
    "19": "ioiiso",
    "20": "iioddo",
    "21": "iiodo",
    "22": "iioo",
    "23": "iioio",
    "24": "iioso",
    "25": "iisiso",
    "26": "iisisio",
    "27": "iisisiio",
    "28": "iioisdo",
    "29": "iioiso",
    "30": "iiiodddo",
    "31": "iiioddo",
    "32": "iiiodo",
    "33": "iiioo",
    "34": "iiioio",
    "35": "iiioiio",
    "36": "iisiiso",
    "37": "iisiisio",
    "38": "iiiosdo",
    "39": "iiioso",
    "40": "iisoddddo",
    "41": "iisodddo",
    "42": "iisoddo",
    "43": "iisodo",
    "44": "iisoo",
    "45": "iisoio",
    "46": "iisoiio",
    "47": "iisoiiio",
    "48": "iisodsdo",
    "49": "iisodso",
    "50": "iiisddsio",
    "51": "iiisddsiio",
    "52": "iisiodddo",
    "53": "iisioddo",
    "54": "iisiodo",
    "55": "iisioo",
    "56": "iisioio",
    "57": "iisioiio",
    "58": "iisioiiio",
    "59": "iisioddso",
    "60": "iiisdsddddo",
    "61": "iiisdsdddo",
    "62": "iiisdsddo",
    "63": "iiisdsdo",
    "64": "iiisdso",
    "65": "iiisdsio",
    "66": "iisiioo",
    "67": "iisiioio",
    "68": "iisiioiio",
    "69": "iisiioiiio",
    "70": "iiisdsiiiiiio",
    "71": "iiisdsiiiiiiio",
    "72": "iiisddodddddo",
    "73": "iiisddoddddo",
    "74": "iiisddodddo",
    "75": "iiisddoddo",
    "76": "iiisddodo",
    "77": "iiisddoo",
    "78": "iiissdddo",
    "79": "iiissddo",
    "80": "iiissdo",
    "81": "iiisso",
    "82": "iiissio",
    "83": "iiissiio",
    "84": "iiissiiio",
    "85": "iiissiiiio",
    "86": "iiisdoddo",
    "87": "iiisdodo",
    "88": "iiisdoo",
    "89": "iiisdoio",
    "90": "iiissiiiiiiiiio",
    "91": "iiisoddddddddo",
    "92": "iiisodddddddo",
    "93": "iiisoddddddo",
    "94": "iiisodddddo",
    "95": "iiisoddddo",
    "96": "iiisodddo",
    "97": "iiisoddo",
    "98": "iiisodo",
    "99": "iiisoo",
    "100": "iodoo",
    "101": "iodoio",
    "102": "iodoiio",
    "103": "iodoiiio",
    "104": "iodoiiso",
    "105": "iodoiisio",
    "106": "iodoiisiio",
    "107": "iodoiiisddo",
    "108": "iodoiiisdo",
    "109": "iodoiiiso",
    "110": "ioodo",
    "111": "iooo",
    "112": "iooio",
    "113": "iooiio",
    "114": "iooiso",
    "115": "iooisio",
    "116": "iooisiio",
    "117": "iooiisddo",
    "118": "iooiisdo",
    "119": "iooiiso",
    "120": "ioioddo",
    "121": "ioiodo",
    "122": "ioioo",
    "123": "ioioio",
    "124": "ioioso",
    "125": "ioiosio",
    "126": "ioiosiio",
    "127": "ioioisddo",
    "128": "ioioisdo",
    "129": "ioioiso",
    "130": "ioiiodddo",
    "131": "ioiioddo",
    "132": "ioiiodo",
    "133": "ioiioo",
    "134": "ioiioio",
    "135": "ioiioiio",
    "136": "ioiioiiio",
    "137": "ioiiosddo",
    "138": "ioiiosdo",
    "139": "ioiioso",
    "140": "ioisoddddo",
    "141": "ioisodddo",
    "142": "ioisoddo",
    "143": "ioisodo",
    "144": "ioisoo",
    "145": "ioisoio",
    "146": "ioisoiio",
    "147": "ioisoiiio",
    "148": "ioisodsdo",
    "149": "ioisodso",
    "150": "ioisiodddddo",
    "151": "ioisioddddo",
    "152": "ioisiodddo",
    "153": "ioisioddo",
    "154": "ioisiodo",
    "155": "ioisioo",
    "156": "ioisioio",
    "157": "ioisioiio",
    "158": "ioisioiiio",
    "159": "ioisioddso",
    "160": "ioisiioddddddo",
    "161": "ioisiiodddddo",
    "162": "ioisiioddddo",
    "163": "ioisiiodddo",
    "164": "ioisiioddo",
    "165": "ioisiiodo",
    "166": "ioisiioo",
    "167": "ioisiioio",
    "168": "iissdddsdo",
    "169": "iissdddso",
    "170": "iissdddsio",
    "171": "iissdddsiio",
    "172": "iissdddsiiio",
    "173": "iissdddsiiiio",
    "174": "ioiisddodddo",
    "175": "ioiisddoddo",
    "176": "ioiisddodo",
    "177": "ioiisddoo",
    "178": "ioiisddoio",
    "179": "ioiisddoiio",
    "180": "ioiisdoddddddddo",
    "181": "ioiisdodddddddo",
    "182": "ioiisdoddddddo",
    "183": "ioiisdodddddo",
    "184": "ioiisdoddddo",
    "185": "ioiisdodddo",
    "186": "ioiisdoddo",
    "187": "ioiisdodo",
    "188": "ioiisdoo",
    "189": "ioiisdoio",
    "190": "iissddsddddddo",
    "191": "iissddsdddddo",
    "192": "iissddsddddo",
    "193": "iissddsdddo",
    "194": "iissddsddo",
    "195": "iissddsdo",
    "196": "iissddso",
    "197": "iissddsio",
    "198": "ioiisodo",
    "199": "ioiisoo",
    "200": "iioddoo",
    "201": "iioddoio",
    "202": "iioddoiio",
    "203": "iioddoiiio",
    "204": "iioddoiiso",
    "205": "iioddoiisio",
    "206": "iioddoiisiio",
    "207": "iioddoiiisddo",
    "208": "iioddoiiisdo",
    "209": "iioddoiiiso",
    "210": "iiododo",
    "211": "iiodoo",
    "212": "iiodoio",
    "213": "iiodoiio",
    "214": "iiodoiso",
    "215": "iiodoisio",
    "216": "iiodoisiio",
    "217": "iiodoiisddo",
    "218": "iiodoiisdo",
    "219": "iiodoiiso",
    "220": "iiooddo",
    "221": "iioodo",
    "222": "iiooo",
    "223": "iiooio",
    "224": "iiooso",
    "225": "iissdso",
    "226": "iissdsio",
    "227": "iissdsiio",
    "228": "iiooisdo",
    "229": "iiooiso",
    "230": "iioiodddo",
    "231": "iioioddo",
    "232": "iioiodo",
    "233": "iioioo",
    "234": "iioioio",
    "235": "iioioiio",
    "236": "iioioiiio",
    "237": "iioiosddo",
    "238": "iioiosdo",
    "239": "iioioso",
    "240": "iiosoddddo",
    "241": "iiosodddo",
    "242": "iiosoddo",
    "243": "iiosodo",
    "244": "iiosoo",
    "245": "iiosoio",
    "246": "iiosoiio",
    "247": "iiosoiiio",
    "248": "iiosodsdo",
    "249": "iiosodso",
    "250": "iiosiodddddo",
    "251": "iiosioddddo",
    "252": "iiosiodddo",
    "253": "iiosioddo",
    "254": "iiosiodo",
    "255": "iiosioo"
}

That was generated by this code:

var c = {}, result = 0;
for (var i = 0; i <= 255; ++i) result += (c[i] = q(i)).length;

which prints result = (the result) and c = the thing above.

This gets a remarkably high score despite being pretty simple. It searches for the nearest perfect square, calculates the square root of that perfect square, adds 's', and increments/decrements appropriately.

Old version which didn't use the fact that "10" = "print one, print zero"

m=Math;s=n=>[b=m.sqrt(n)+.5|0,n-b*b];f=(n)=>Array(m.abs(n)+1).join('id'[+(n<0)]);g=(n,t)=>n<4?f(n):g((t=s(n))[0])+'s'+f(t[1]);q=n=>g(n)+'o'


Randomly pick one number that is different than two other random numbers Two random numbers A and B have been generated to be either 1, 2, or 3
your job is to randomly pick a third number C that can also be 1, 2 or 3. But, C cannot equal A or B.

A can equal B.
If A = B, then C has only two numbers left it can be.
If A ≠ B, C has only one number it can be.
Assume A and B have already been chosen for you

This is how A and B would be created in Python
A = random.randrange(1,4)
B = random.randrange(1,4)

Assume this is already in your code.
This is the shortest I've come up with in Python
while True:
    C = random.randrange(1,4)
    if C != A and C != B:
        break

Here are some acceptable values for A, B and C.

1,2,3
1,1,2
2,3,1
3,3,2

Here are some unacceptable values for A, B and C.

1,2,1
2,3,3
1,1,1
3,2,3

Ruby, 22 characters

([1,2,3]-[A,B]).sample

Still not sure if I understood the question correctly ...


Draw the Stickman Wars Picture of me drafting this challenge with my advanced drawing skills.

Background

The Stickman wars happened long ago, when Earth's dominant species was made of nothing but sticks. Historians regret the fact that there were no painters or cameras back then, we could use some pictures of that war in today's history books. That's where your coding powers become useful. Stickmen are very easily drawed and Historians managed to find some data about how many stickmen fought the wars¹. Now it's up to you to recreate an image of the moment right before the war began!

Here are the brave stickmen involved in the war:

  O  /
|/|\/
| |
 / \  Swordsman

 O A
/|\|
 | |
/ \| Spearman

   .
 .' *.
 ' O *
' \|/ .
.  |  *
'./ \*. Mage

 O
/|\
 |
/ \ Villager

 O
/|\
/ \ Infant

Input

Receive via stdin or equivalent a representation of every stickman who appeared on each side of the battlefield. For example, if two Swordmen fought on the right side and two spearmen on the left side, your input can be {Sword: 2}, {Spear: 2}, [2,0,0,0,0], [0,2,0,0,0] or a "WW", "SS".

Output

A representation of every brave stickmen in a battle field, according to the rules below. It can be shown on stdout or saved to a file, whatever rocks your boat.

Rules

On the left side will be every stickmen of the first array/string/object your program received.
Those stickmen must look exactly like the ones shown before on this question.
The order of the left side army must be Infants Villagers Mages Swordsmen Spearmen.
The right side army will behave just the same, but with the characters and the order mirrored.
Each stickman will be separated by 1 space.
Each class will be separated by 3 spaces.
The armies will be separated by 8 spaces.
Since stickmen don't fly, you must draw the ground using hyphen-minuses -.
The ground must end on the same column the last stickman of the right army ends.

Example

Let's assume my program expects two arrays with length 5 and each value in the array represents, in order, Infants Villagers Mages Swordsmen Spearmen.

Input: [1,1,2,3,1] [0,0,1,1,1]

               .       .                                                           .
             .' *.   .' *.                                                       .* '.
       O     ' O *   ' O *      O  /   O  /   O  /    O A        A O   \  O      * O '
 O    /|\   ' \|/ . ' \|/ .   |/|\/  |/|\/  |/|\/    /|\|        |/|\   \/|\|   . \|/ '
/|\    |    .  |  * .  |  *   | |    | |    | |       | |        | |      | |   *  |  .
/ \   / \   './ \*. './ \*.    / \    / \    / \     / \|        |/ \    / \    .*/ \'.
---------------------------------------------------------------------------------------

Final Considerations

Please note that standard loopholes apply and that the mage is completely asymmetrical just because.

The result of most upvoted answer will be the "cover image" of this challenge. The shortest answer by the end of the month (08/31/2014) will be selected as the winner.

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

¹Citation needed

JavaScript (E6) 336 344 356 369 424 478 522 570
Edit 6 Last edit was buggy. Bug fix and shortened. That's all I hope.
Edit 5 Finally found a way to get rid of multiply by 23 - bothered me from start. Plus another change to the input (@William shout when it's too much). Now the function expects one array parameter, containing 2 subarrays. Without this change it's 349 - still an improvement
Edit 4 Shaved some more bytes and a little change to input format.
With the new input format a missing class is represented as an empty array element. So D([1,,2,3,1],[,3,1,1,2]) instead of D([1,0,2,3,1],[0,3,1,1,2]). I think it still obeys the rules.
Edit 3 Golfed more. No changes to the algorithm, but abusing a lot of array.map and local functions to avoid for loops.
Edit 2 String compression, the right way ...
Edit Added string compression, a lot of work and not much gained. Now the mirror stickmen are generated from a template, not stored.
Made a few tries, first running. To be golfed.
NB Kolmogorow-business still to be tackled.
Test In FireFox console. Change 'return' with Add 'alert(...)' to have an output statement (albeit not useful at all)
console.log(D([[1,,2,3,1],[,3,1,1,2]]))
Output
         .       .                                                                 .
       .' *.   .' *.                                                             .* '.
       ' O *   ' O *      O  /   O  /   O  /    O A        A O  A O    \  O      * O '     O   O   O
 O    ' \|/ . ' \|/ .   |/|\/  |/|\/  |/|\/    /|\|        |/|\ |/|\    \/|\|   . \|/ '   /|\ /|\ /|\
/|\   .  |  * .  |  *   | |    | |    | |       | |        | |  | |       | |   *  |  .    |   |   |
/ \   './ \*. './ \*.    / \    / \    / \     / \|        |/ \ |/ \     / \    .*/ \.'   / \ / \ / \
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Golfed Code
D=a=>
  (J=v=>v.join(''))((l=[r=n=' ',3,6,13,19,23]).map(_=>f=(F=f=>J(a[f].map((c,q)=>
  ("9.299.' *.87O2' O *3O21 O A O 1|0' 0|1 .|1|01 1|0|1|0 | .2|2*| |4| |1 01 0'.1 0*. 1 021 0|"[R='replace'](/[2-9]/g,x=>n.repeat(x))
   .slice(l[q]-r,l[q+1]-r)[R](/\d/g,x=>'\\/'[x^f])+n).repeat(c)+n+n
  ))+n)(0)+J([...F(1)].reverse(r-=23))+'\n'))+f[R](/./g,'¯')

Code (edit 2)
D=(a,b)=>{
  F=(s,f)=>(s=s[R](/\d/g,x=>'/\\'[x^f]),f?s:[...s].reverse().join('')),
  v="9.299.' *.87O2' O *3O21 O A O 1|0' 0|1 .|1|01 1|0|1|0 | .2|2*| |4| |1 01 0'.1 0*. 1 021 0|"
    [R='replace'](/\d/g,x=>x>1?' '.repeat(x):x),
  l=[0,3,6,13,19,23];
  for(o='',r=0;v[r];r+=23,f=F(z,1)+'  '+F(w,0),o+=f+'\n',f=f[R](/./g,'¯'))
    for(z=w=p='';p<10;++p)
      if(c=(p<5?a:b)[q=p%5])x=(v.slice(r+l[q],r+l[q+1])+' ').repeat(c)+'  ',p<5?z+=x:w+=x
  return o+f
}

Ungolfed code (1st version)
D=(a,b)=>{
  v="         .                .                    .' *.            .* '.               O  ' O *   O  / O A * O ' \\  O  A O  O /|\\' \\|/ .|/|\\/ /|\\|. \\|/ ' \\/|\\||/|\\/|\\ | .  |  *| |    | |*  |  .   | || | / \\/ \\'./ \\*. / \\  / \\|.*/ \\'.  / \\ |/ \\"
  l=[0,3,6,13,19,23,30,36,40]
  o=''
  for(r=0;r<6;++r)
  {
    z=w=''
    for(p=0;p<10;p++)
    {
      c=a[p]||b[p-5];
      if (c)
      {
        q = p<7 ? p%5 : p-2
        x = (v.slice(r*40+l[q],r*40+l[q+1])+' ').repeat(c)
        if (p<5)
          z+=x+'  ';
        else
          w=x+'  '+w
      }
    }
    f = z + '     ' + w
    o += f + '\n'
    f = '¯'.repeat(f.length-3)
  }
  return o+f
}


List prime-factorized natural numbers up to N in ascending order For a given n list prime factorization of all natural numbers between 1 and n in ascending order. For example, for n = 10 the output would be:

1:
2: 2^1
3: 3^1
4: 2^2
5: 5^1
6: 2^1 3^1
7: 7^1
8: 2^3
9: 3^2
10: 2^1 5^1

Requirements:

You cannot just iterate over the numbers and factor each of them. (Unless you know how to factor a number in logarithmic time, and then I doubt you'd be wasting your time solving puzzles.) This is too inefficient.
The output should be as in the example above: On each line the number and the list of its prime factors.
Consider that n can be very large, so it might be infeasible to generate all the factorizations into memory and then sort them at the end. (But if you have a clever solution that violates this, post it too.)

Below is my attempt, in R5RS scheme (disclaimer: I'm not actually a Schemer (yet!), so pardon the (probably) terrible code).

(define count 10)

; `factors` is our vector of linked-lists of factors.  We're adding to these
; as we go on.
(define factors (make-vector count 'not-found))
(vector-set! factors 0 '())

; `primes-so-far` contains all the prime numbers we've discovered thus far.
; We use this list to speed up the dividing of numbers.
;   `primes-so-far-last` is a ref to the last entry in the `primes-so-far`
; list, for O(1) appending to the list.
(define primes-so-far '(dummy))
(define primes-so-far-last primes-so-far)

;; Helpers
(define (factor-ref n)
  (vector-ref factors (- n 1)))

(define (factor-cached? n)
  (not (eq? (vector-ref factors (- n 1)) 'not-found)))

(define (factor-put n factor)
  (let* ((rest        (/ n factor))
         (factor-cell (cons factor (factor-ref rest))))
    (vector-set! factors (- n 1) factor-cell)
    factor-cell))

(define (prime-append n)
  (let ((new-prime-cell (cons n '())))
    (set-cdr! primes-so-far-last new-prime-cell)
    (set!     primes-so-far-last new-prime-cell)
    new-prime-cell))

;; The factor procedure (assumes that `[1..n-1]` have already been factorized).
(define (factor n)
  (define (divides? m n)
    (= (modulo n m) 0))

  ; n       the number to factor.
  ; primes  the list of primes to try to divide with.
  (define (iter n primes)
    (cond ((factor-cached? n)
           (factor-ref n))

          ((null? primes)
           ; no primes left to divide with; n is prime.
           (prime-append n)
           (factor-put n n)) ; the only prime factor in a prime is itself

          ((divides? (car primes) n)
           (factor-put n (car primes))
           (factor-ref n))

          (else
           (iter n (cdr primes)))))

  (iter n (cdr primes-so-far)))

(define (print-loop i)
  (if (<= i count)
      (begin
        (display i)
        (display ": ")
        (display (factor i))
        (newline)
        (print-loop (+ i 1)))))

(print-loop 1)

Prints as:

1: ()
2: (2)
3: (3)
4: (2 2)
5: (5)
6: (2 3)
7: (7)
8: (2 2 2)
9: (3 3)
10: (2 5)

(Not exactly like in the task description, but all you'd have to do to get that output is to fold the list and merge repetitions of the same number, during the output part of the code.  The internal representation/algorithm would still be the same.)

The idea is to cache the previously computed values, but make use of the fact that the factors of n is the first prime factor of n and the prime factors of (n / first-factor).  But the latter is already known, so we just re-use the already existing list of factors for that smaller number.  Thus, for each number in [1..n] which is not prime, a single cons cell is stored.

For each number, a single cons cell is created and stored.  Thus, this approach should run with O(n) storage usage.  I've no clue if it's possible to neatly express the time-complexity.


In Search of a Soulmate Given a nonempty finite list of integers, output a truthy value if there are exactly two equal entries and all other entries are distinct, and a falsey value otherwise.
Examples
truthy:
[1,1]
[1,2,1]
[1,6,3,4,4,7,9]

falsey:
[0]
[1,1,1]
[1,1,1,2]
[1,1,2,2]
[2,1,2,1,2]
[1,2,3,4,5]

Python 3, 30 28 bytes

lambda m:len({*m})+1==len(m)

Try it online!

{*m} casts the list to a set object, an unordered list of items without duplicates. Doing this will always decrease the length of the list by the number of duplicates in it. By computing how much the length has changed, we can easily tell if the list had a single duplicate and return the result of the test.

-2 bytes thanks to ovs.


Enumerate a Cell Notation So we're all hopefully familiar with Spreadsheet 'A1' cell notation.

It's simply an alphanumeric representation of the positioning of said cell within a grid.
The letter(s) represent the column positioning of the cell, and the number represents the row.

The 'letter' part can consist of 1 or more letters from the 26 letter English alphabet, all of which must be capital letters. These map to numbers through the use of 26-adic bijective numeration.
The 'number' part can consist of any positive, non-zero integer.

The challenge, write a program that given the A1 notation of any cell as a single string, can output a string containing the column position represented as a number, followed by a space and then the row number.

Sample Input/Outputs below:

A1
>>1 1
B10
>>2 10
AC4
>>29 4
AAC753
>>705 753
F123
>>6 123
GL93
>>194 93

This is my first challenge, hence the relative simplicity and potential poorness of the criteria.

EDIT: String must be letters followed by numbers and the winning criteria is the shortest code length (if that can be a thing)

EDIT: Related to this but does the reverse process with a different starting index. Some may argue that this fact makes the linked puzzle more interesting.

Microsoft Excel, 43 Bytes.
=COLUMN(INDIRECT(A1))&" "&ROW(INDIRECT(A1))

I couldn't help myself, I just had to use the right tool for the job.
Takes input on A1.
Test Cases


m3ph1st0s's programming puzzle 3 (C): “Easy bug” This is the 3rd of my series of C/C++ puzzles; in case you missed the first 2 they are here:
(1) m3ph1st0s's programming puzzle 1 (C++)
(2) m3ph1st0s's programming puzzle 2 (C++): "Call hard!"

I must say that my puzzles are 100% original. If not, I will always state so in the text.
 My 3rd puzzle has 2 parts as follows:

Puzzle 3.1

This part (3.1) is not an original puzzle of mine, it is collected from some internet page I've read a while ago. I use it here as a starting point and a warm-up for you. Solve this one and then move on to the 2nd part.

Some one tried to print the "+" sign 20 times and came up with the following program:

#include <stdio.h>
int main() {
   int i;
   int n = 20;
   for( i = 0; i < n; i-- )
      printf("+");
   return 0;
}

The fact that it did not have the expected result is obvious - the program never ends. Fix it!
Easy?
Now fix the program by changing ONLY ONE CHARACTER - non-space character of course! For this challenge there are 3 solutions. Find all 3 of them. Just to make it clear: the program must output 20 "+" signs and must end fast. Before criticizing me on what "fast" means, I'll say it means at most a couple of seconds (which by the way is too much but just to make it crystal clear).

Puzzle 3.2

EDITED
It was pointed to me earlier that the solution for the 3.2.2 puzzle might be compiler-dependent. In order to eliminate any possible discussion on the subject, I'll modify the idea and improve it on a next puzzle when I'll take extra care not to generate controversy.
 However, in order to keep this puzzle going, I'll make a small modification for 3.2.2 (the solution will be easier but cleaner).

When I first saw the puzzle I found it pretty awesome. I did manage to solve it but not immediately since it requires some careful attention.
 If you are here it means you too solved it. If you did so by writing a program to replace all possible characters with all possible values and test every solution, you are lost. Hard working guy though.
 Now having corrected the program that writes 20 "+" signs:

3.2.1: Insert one single letter and nothing more in the code so that the result is valid and outputs the same thing in all 3 corrected programs. Needless to say, the letter must be before the enclosing } of main (I say that because I don't want to hear people who just put a letter after the program and somehow their compiler was very friendly).

EDITED (see bellow) - For these final questions consider that the counter i starts from -1 instead of 0.

3.2.1.5: Repeat all previous problems with the condition that the output is at least 19 "+" signs (but still a finite output). Changing spaces is allowed. Now you might have found more solutions than in the first case. Some of these will most definitely fit for the 3.2.2 question.

3.2.2: Choose another value to initialize the variable n so that the resulting output will remain the same for at least one corrected programs in 3.2.1.5(not necessarily for all of them).

LAST EDIT1: changing the program so that it outputs 21 "+" signs is still a good solution, as the original text did not say "exactly" 20 signs. However, the infinite output is forbidden. Obviously this doesn't mean let's all start outputting hundreds of "+"signs since it's not forbidden. But eliminating a beautiful 21 output would not be in the spirit of this competition.

LAST EDIT2: considering LAST EDIT1 and accepting space changing it seems that now we have 5 possible solutions, four of which have already been pointed out in the responses. The last challenge however hasn't been touched and I must make it clear once more: n must be assigned another value, solutions that assign 20 to n by some tricks won't do it (like n=20L). Also I prefer to see the 3rd solution that does not change spaces.

LAST EDIT3: I've edited the last questions, please read!

The challenge is to solve both parts of the puzzle. The first one to do it wins.

I hope it's all clear, if not please post any questions and I'll edit as quickly as possible. Cheers.
emphasized text

3.1

for( i = 0;-i < n; i-- )
for( i = 0; i < n; n-- )
for( i = 0; i + n; i-- )

Any of these changes will make the program output 20 '+' signs. This one is close:

for( i = 0;~i < n; i-- )

It outputs 21 '+' signs.

3.2.1

I found at least 112 ways to solve this problem inserting one letter. Not all of them may work on all compilers.

int n = 20L;
int n = 20f;
int n = 20d;
uint n = 20;

for( i = 0L; ... )
for( i = 0f; ... )
for( i = 0d; ... )

iprintf("+");
printf("+x");
printf("x+");

For the last two, substitute any letter for x to give you 104 possible solutions. Using either of the last two lines will change the output, but the output will still be the same for all 3 corrected programs.

3.2.2

All I've come up with are some things that get cast back to the number 20 on assignment to int.

int n = 20L;
int n = 20.001;
int n = 20.999;
int n = 20 + 0x100000000L;


Martin vs Dennis - Round 1: Who has more rep? I know there have been a lot of challenges about "the two best code-golfers in the world", but this one is a bit more unique, being Round 1 in a series of (future) challenges involving the two of them.

Your task is to write a program or function that returns two different non-whitespace ASCII strings, corresponding to the one who has more reputation at the moment the program is ran, between Dennis ♦ and Martin Ender ♦. The tricky part is that you must output the exact string "tie" in case the reputation is identical (not likely), and the two different non-whitespace ASCII strings mentioned above should be different than "tie" *.
No input can be taken, such as usernames or user ids. As usual, URL shorteners are forbidden, and so are the common loopholes.
Examples:
Let the chosen string for Dennis be "D" and the chosen one for Martin Ender be "M" (should be specified)

If Dennis' rep > Martin Ender's rep => D
If it's the other way around => M
If it's a tie => tie

IMPORTANT! Voting on posts by Dennis & Martin for the  sole purpose of affecting a tie in order to test the solutions below constitutes targeted voting which is forbidden across the Stack Exchange network. If you want to test that a solution properly outputs tie then change the IDs in it to those of 2 users you know to be tied. See this Meta post for more details.

*I think no one would have used that, anyway

05AB1E, 65 64 bytes
Code:
•в=6{•5ôvy’ƒËŠˆ.Â‚‹º.ŒŒ/†š/ÿ’.w’„Ö="Âˆ"’¡1èт£þ}})ZQā*O<“D M·‡“#è

Uses the 05AB1E encoding.

Explanation:
•в=6{• converts the number в=6{ from base 255 to base 10, resulting in 1201208478. The first half being the ID of Dennis (12012) and the second half being the ID of Martin (8478). Split into pieces of 5 using 5ô to get the following array:
['12012', '08478']

Luckily, we can leave the leading zero from Martin's ID, since this will still work (check the link before clicking to see the leading zero).
We now loop through this array using vy and construct the following string from this 05AB1E code:
’ƒËŠˆ.Â‚‹º.ŒŒ/†š/ÿ’  -->  codegolf.stackexchange.com/users/ÿ

Whereas ÿ is the current element of the iterator (using string interpolation) Try it online!
After constructing the link, .w reads all data from the link, resulting into a huge amount of text. To scrape the reputation from this, we need to split on the string title="reputation". Or in a more compressed version: ’„Ö="Âˆ"’. Split on this piece of string (with ¡) and get the second element (with 1è) and keep the first 100 characters (with т£).
Now, our scraped text looks a bit like this:
>
        139,883 reputation

<div class="ba

This part is easy, we just remove anything but digits to remain the reputation number, for which we have a builtin (þ). We end the loop and wrap everything into an array }}).
Finally, we can go on to processing the reputation numbers:
ZQā*O<“D M·‡“#è   -   On stack: an array in the format [Dennis rep, Martin rep]

Z                 # Get the maximum of the array
 Q                # Check for equality with the array
  ā*              # Multiply by it's index (1-indexed)
    O<            # Sum and decrement by 1
      “D M·‡“#    # Push the array ['D', 'M', 'tie']
              è   # Get the element on the index of the sum

Which results in either D, M or tie.


Count up diagonally! We have lots of horizontal axis for numbers, but I honestly think they're kind of boring. Your task today is to build me a portion of a diagonal axis between two distinct non-negative integers given as input.

How to build a diagonal axis?

Let's take an example, with the input 0, 5. Our axis should look like this:

0
 1
  2
   3
    4
     5

However, our axis should look nice for numbers that have more digits too! If the input is, for instance 0, 14, the new axis should be:

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

The idea is that the first digit of next number on the axis must always be placed exactly after the last digit of the previous number. To understand the idea even better, here is another example with 997, 1004:

997
   998
      999
         1000
             1001
                 1002
                     1003
                         1004

Rules

You may assume that input is in ascending or descending order (you may choose between 5,3 and 3,5).
You may also assume that the difference between the two integers is lower than 100.
You may have a leading newline or a consistent leading space (on each line). Trailing spaces / newlines are fine as well.
Default Loopholes are forbidden.
You can take input and provide output by any standard mean.
This is code-golf, so the shortest code in bytes in every language wins!

Other Test Cases

1, 10:

1
 2
  3
   4
    5
     6
      7
       8
        9
         10

95, 103:

95
  96
    97
      98
        99
          100
             101
                102
                   103

999999, 1000009:

999999
      1000000
             1000001
                    1000002
                           1000003
                                  1000004
                                         1000005
                                                1000006
                                                       1000007
                                                              1000008
                                                                     1000009

05AB1E, 8 7 6 bytes
Thanks to Magic Octopus Urn for saving a byte!
It somehow works, but honestly I have no idea why.
Code
Ÿvy.O=

Uses the 05AB1E encoding. Try it online!
Explanation
Ÿ          # Create the range [a, .., b] from the input array
 vy        # For each element
   .O      #   Push the connected overlapped version of that string using the
                 previous version of that string. The previous version initially
                 is the input repeated again. Somehow, when the input array is
                 repeated again, this command sees it as 1 character, which gives
                 the leading space before each line outputted. After the first
                 iteration, it reuses on what is left on the stack from the
                 previous iteration and basically attaches (or overlaps) itself
                 onto the previous string, whereas the previous string is replaced
                 by spaces and merged into the initial string. The previous string
                 is then discarded. We do not have to worry about numbers overlapping
                 other numbers, since the incremented version of a number never
                 overlaps entirely on the previous number. An example of 123 and 456:

                 123
                    456

                 Which leaves us "   456" on the stack.
     =     #   Print with a newline without popping


Alignment on Triangular Grids Hexagonal grids have been become a fairly popular twist for challenges about 2-dimensional data recently. However, it seems that the equally interesting triangular grids have been largely neglected so far. I'd like to rectify that with a rather simple challenge.

First, how do we represent a triangular grid? Consider the following example (ignore the right diagram for now):

The cells neatly fall onto a regular grid (the difference to a regular grid being only which cells are considered adjacent):

1234567
89abcde
fghijkl
mnopqrs

Now, as the right diagram shows, a triangular grid has three main axes: a horizontal and two diagonal ones.

Highlighting these in the ASCII grid:

AVAVAVA
VAabcAV
fVAiAVl
mnVAVrs

The Challenge

You're given a rectangular string representing a triangular grid (where the top left corner is an upwards-pointing triangle). Most of the cells with be ., but exactly two cells will be #, e.g.:

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

Determine whether the two # are aligned along any of the three axes of the grid (i.e. whether they lie on a single row in any of the three directions highlighted above). For this example, the answer is "no".

You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.

Input may be a single string delimited by linefeeds or some other convenient character, or a list of strings. You may use any two (consistent) printable ASCII characters in place of . and #.

Output should be a truthy value if the highlighted cells are aligned and a falsy value otherwise.

Standard code-golf rules apply.

Test Cases

Truthy grids:

.#..#.

#
#

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

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

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

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

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

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

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

Falsy grids:

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

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

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

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

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

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

Snails, 40 39 bytes
\#{z|=(ul.ul.`,l~a~)(l.a3|.a|d.ea5}.,\#

\#    ,, match '#'
{
  z |  ,, Either turn in any octinilear direction, or do all the other stuff before the }
  =(   ,, If this assertion succeeds, the starting cell is an "upwards-pointing triangle"
    ul.ul.`,  ,, Go one cell up or left twice, any number of times.
              ,, This should have been one byte shorter with ul.`2 , or ul.`2+? but
              ,, the parsing of ` is buggy.
    l~a~   ,, Check that we are on the top-left cell by matching out-of-bounds to the left and then northeast
  )
  ( l.a3 |  ,, Move leftward once, then set direction to northwest; or
    .a   |  ,, Move right (the initial direction) once, then set direction to northeast; or
    d.ea5   ,, Move down once, then set direction to either northwest or northeast
}
.,    ,, Match any number of arbitrary chars (moving in the current direction)
\#    ,, match '#'


Generate a sequence with unique subsequences The string 2123132133 has the property that no subsequence of length 3 is the same as any other subsequence of length 3.

Your task is to build a program that will output as long of a string as possible that satisfies this property for sequences of length 9 with the characters from 1 to 9.

The source code of your program may not be longer than 16 kilobytes (16,384 bytes). The program that wins is the one that outputs the longest sequence of digits from 1 to 9 such that no subsequence of 9 digits is the same.

What I'm starting with here is a De Bruijn sequence.  Stealing some reference code on the topic, here is my submission:

#!/usr/bin/env python

def de_bruijn(k, n):
    """ De Bruijn sequence for alphabet size k and subsequences of length n. """
    a = [0] * k * n
    sequence = []
    def db(t, p):
        if t > n:
            if n % p == 0:
                for j in range(1, p + 1):
                    sequence.append(a[j])
        else:
            a[t] = a[t - p]
            db(t + 1, p)
            for j in range(a[t - p] + 1, k):
                a[t] = j
                db(t + 1, t)
    db(1, 1)
    return sequence

seq = de_bruijn(9, 9) # cyclic
seq = seq + seq[:8]   # extended to max
print(''.join(map(lambda n: chr(49+n), seq)))

After running for ten minutes, the output is a 387,420,497 digit sequence.  This is 9^9 + 8 digits, as expected.  (Thank you @PeterTaylor for the +8 tip on the cyclic output.)


Magic: The Gathering Combat with Abilities Related
Goal:
Given two creatures with optional combat abilities, return unique but consistent values that represent which creatures died, if any.
Input:
#Longest form:
[[P,T, "<abilities>"], [P,T, "<abilities>"]]
#Shortest form:
[[P,T], [P,T]]

Each creature will be given in the form of [P,T,"<abilities>"]. It will be in the form [P,T], [P,T,""], or [P,T,0] if it has no abilities, your choice on form. P is an integer >=0, T is an integer >=1. <abilities> is a subset of "DFI", or can be represented via a single number/bitstring if you wish. Order of the flags is also up to you.
Combat Mechanics:
Each creature has two stats, Power and Toughness in that order, and optional abilities. A creature's power is >=0. A creature's Toughness is >=1.
Each creature will simultaneously do damage equal to its power to the opposing creature (unless one has first-strike). If the value is greater than or equal to the opponent's toughness, it will die (unless it is indestructible).
Example: Alice is a 2/2, Bob is a 3/4, both with no abilities. Alice will do 2 damage to Bob and take 3 damage in return. Alice's toughness is 2 so it will die, Bob's toughness is 4 so it will live.
There are only 3 optional abilities we will consider for this (although there are more in the game). These will be one character flags:

[D]eathtouch: Any amount of damage (X>0) is considered lethal.
[F]irst Strike: Will deal its damage first, able to kill the other creature before it can attack back. If both creatures have First Strike, Resolve combat as normal.
[I]ndestructible: No amount of damage is considered lethal, including Deathtouch.

Output:
Any consistent value for each of the following four cases. State the four values in your answer, please. Example return value in parens:

Neither creature died (0)
1st creature died (1)
2nd creature died (2)
Both creatures died (3)

Rules:

Input is guaranteed to have two correctly formatted creatures.
If you are using characters for abilities, you can assume they're ordered how you want but post the order used if relevant.
If you are using a number/bitstring for abilities, post what encoding you're using. e.g.: 111 is D/F/I, 7 is D/F/I, etc.
If a creature has no abilities, It can also be taken as [P,T, ""] or number equivalent
Standard Loopholes Forbidden
This is code-golf so shortest code wins.

Examples:
Input: [[2,2], [1,1]]
Output: 2nd Dies

Input: [[0,2], [0,1]] #0/2 vs 0/1
Output: Neither Die

Input: [[2,1], [2,1]] #2/1 vs 2/1
Output: Both Die

Input: [[1,1, "D"], [2,2]] #1/1 Deathtoucher vs 2/2
Output: Both Die

Input: [[2,2], [0,1, "D"]] #2/2 vs 0/1 Deathtoucher
Output: 2nd Dies

Input: [[2,2], [1,1, "DF"]] #2/2 vs 1/1 Deathtouch First-striker
Output: 1st Dies

Input: [[0,2, "D"], [0,1, "DF"]] #0/2 Deathtoucher vs 0/1 Deathtouch First-striker
Output: Neither Die

Input: [[2,2], [2,2, "F"]] #2/2 vs 2/2 First-striker
Output: 1st Dies

Input: [[2,2, "I"], [1,1, "DF"]] #2/2 Indestructible vs 1/1 Deathtouch First-striker
Output: 2nd Dies

Input: [[9999,9999], [1,1, "I"]] #9999/9999 vs 1/1 Indestructible
Output: Neither Die

Input: [[2,2, "F"], [1,1, "F"]] #2/2 First-Striker vs 1/1 First-Striker
Output: 2nd Dies

#9/9 Deathtouch, Indestructible First-Striker vs 9/9 Deathtouch, Indestructible First-Striker
Input: [[9,9, "DFI"], [9,9, "DFI"]]
Output: Neither Die


Rearrange a number into alphabetical order Given a non-negative integer (n), create a function that returns n in alphabetical order, according to the literal spelling of each digit in n.

Examples:

Input: 101
>> one, zero, one
>> one, one, zero
Output: 110

Input: 31948
>> three, one, nine, four, eight
>> eight, four, nine, one, three
Output: 84913

Input: 5544
>> five, five, four, four
>> five, five, four, four
Output: 5544

Input: 1234567890
Output: 8549176320

Note: the operations in the example are illustrative only and do not need to be included in the output. Only the alphabetically-sorted number needs to be returned.

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

Edit: the input can be taken in any desired format that best suits your language, and the output can be produced similarly by returning from the function or printing. The input will always be a natural number (including 0) and will not contain leading 0's.

Relevant OEIS entry (A057846) found by @DomHastings

Perl 6,  32  28 bytes

{+[~] .comb.sort: *.Str.uniname}
{+[~] .comb.sort: *.uniname}

Explanation:

{
  # turn the following into a Numeric
  +

  # fold the following list using string concatenation operator
  [~]

    # split $_ into individual characters
    # (implicit method call on implicit parameter)
    .comb

    .sort:
    *.uniname # sort by the Unicode name of the character (digit)
}

Test:

#! /usr/bin/env perl6
use v6.c;
use Test;

my @tests = (
  101 => 110,
  31948 => 84913,
  5544 => 5544,
  1234567890 => 8549176320,
);

# give the lambda a lexical name for clarity
my &int-sort = {+[~] .comb.sort: *.uniname}

plan 3 * @tests;

for @tests -> $_ ( :key($input), :value($expected) ) {
  put '';
  isa-ok $input, Int, "input ($input) is an Int";

  my $output = int-sort $input;

  is $output, $expected, .gist;
  isa-ok $output, Int, "output ($output) is an Int"
}

1..12

ok 1 - input (101) is an Int
ok 2 - 101 => 110
ok 3 - output (110) is an Int

ok 4 - input (31948) is an Int
ok 5 - 31948 => 84913
ok 6 - output (84913) is an Int

ok 7 - input (5544) is an Int
ok 8 - 5544 => 5544
ok 9 - output (5544) is an Int

ok 10 - input (1234567890) is an Int
ok 11 - 1234567890 => 8549176320
ok 12 - output (8549176320) is an Int


Shortest Python 3 for sum of arithmetic progression Input: from STDIN number of vertices in Graph \$2 \leq N \leq 100\$.
Rules: [Code size] = max ([code length without spaces, tabs and newlines], [total code length divided by 4])
Math formulation: In the graph of N vertices, between each pair of vertices can be 3 road states:

there is no road
there is a road from A to B
there is a road from B to A

Find the number of different graphs on given vertices.
We can apply next formula (number of different road states in pow of pairs number): $$\huge3 ^ {\frac{n(n - 1)}{2}}$$.
My Python 3 37 bytes solution here:
n = int(input())
print(3 ** ((n ** 2 - n) // 2))

I know that exists 34 bytes solution. Then I started to think about 1 liner, and find next formula for sum of arithmetic progression, which use N only once:
$$\frac{(2n - 1) ^ 2}{8} - \frac18$$
Unfortunately the code only increased:
x = 2 * int(input()) - 1
print(3 ** ((x ** 2 - 1) // 8))

Python 3, 34 bytes

print(3**sum(range(int(input()))))

Try it online!
In Python 2 this is just print 3**sum(range(input())) for 28.


All your base 97 are belong to us Many programming languages are written using solely printable ASCII, tabs and newlines. These 97 characters are then stored in 8-bit bytes (which are actually capable of holding 256 different characters!), which is just terribly inefficient - especially in code-golfing, where every byte counts! In this challenge, you will be able to reduce your score by using base conversion.
Challenge
Your program/function takes a string or character array as input, which it then interprets as a base-97 number. It then converts this to a  base-256 number, and counts the number of symbols (i.e., bytes) necessary to represent this number. This count will be the output/return value of your program/function.
A simple example using base-2 and base-10 (binary and decimal): if the input is 10110, the output would be 2, since 101102=2210 (two digits necessary to represent output). Similarly, 11012 becomes 1310, giving an output of 2 as well, and 1102 becomes 610, so then the output would be 1.
The input string can contain all 95 printable ASCII characters  , as well as newline \n and literal tab \t, which creates a source alphabet  of 97 symbols for your base conversion. The exact alphabet will thus be (substituting the \t and \n with actual literal tab and newline; note the literal space following the newline):
\t\n !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

Note that the order of this alphabet is important: for example, base-97 \t corresponds to decimal 0, and ! corresponds to decimal 3.
Some testcases: (you do not need to handle an empty string)
Input                             Output
'example@domain.com'                  15
'All your base are belong to us!'     26
'       abcd'                          9
'~      abcd'                         10
'ABCDEFGHIJK'                          9
'zyxwvutsrpq'                         10
'{".~"}.~'                             7
'\t\t\t\t\t\t\t\t'                     1 (with \t a literal tab; the result is 0, which can be represented with 1 byte)
'!\t\t\t\t\t\t\t\t'                    7 (with \t a literal tab)

Scoring

If your entry uses only printable ASCII, newline and/or tab:
The score of your program will be the output of your program, when given its own source code as input.

If your entry uses any characters that are not printable ASCII, newline or tab:
The score of your program is simply the number of bytes, like in code-golf.

Python 2, score 73  72 71

Edit: -1 thanks to @Jonathan Allan

def f(l,z=0):
&#9for i in map(ord,l):z+=i-[30,9][i&lt32];z*=97
&#9print(len(bin(z))-2)/8or 1

Try it online!


Convert a CSS selector to HTML A CSS selector is made up of five elements:

The element type (tag name)
The id of the element
The classes of the element
The attributes of the element
Operators to chain these element selectors

This challenge will only involve the first four--also taking into account operators would make more than one element be generated and that's a bit too complex for this challenge. Maybe a future one. ;)

Input: A CSS selector, not including any operators. The element type will always be present, but the rest of the portions may not be.

Output: An html element representing the selector.

Examples:

In: div
Out:

In: div[with-data="cool-data"][foo]
Out:

In: span.nice.tidy.cool
Out:

In: button#great-button.fancy[data-effect="greatness"]
Out: <button id="great-button" class="fancy" data-effect="greatness"></button>

In: custom-element#secret[secret-attribute="secret value!!"]
Out: <custom-element id="secret" secret-attribute="secret value!!"></custom-element>

In: element#id.class1.class2[attribute1][foo="bar"]
Out: <element id="id" class="class1 class2" attribute1 foo="bar"></element>

You may assume that the input selector will always have the different parts in order (element type, id, class, attributes).
You may assume that the provided attribute selectors will never be an attribute text search (^=, $=, *=).
You may assume that the input word characters (element type, attribute names, class names, ids) will always match the regex [a-z0-9_-]
You may have extra whitespace anywhere except for inside strings (attribute values)

This is code-golf, so the shortest answer (in bytes) wins. Standard loop-holes apply.


Create a grid as close to a square as possible Create a function or program that makes a grid as close to an square as possible

You will be given an integer N as input, whole numbers (1,2,3,25, etc)
The output must be a perfect rectangular grid of N letters as close to a square as possible
The (wannabe)square must consist of one of the the letters O or X as specified by user

Points:

Hardcoded to only O or X: +1
A param(0/1, true/false, something similar) to rotate output (like with 5 or 8): -10
Design the square (use both O and X in some sort of pattern): -5

A pattern is considered valid if it contains both types of characters (where x/y-axis >= 3) and the pattern stays the same when flipped horizontally or vertically (exchanging Xs with Os is allowed)

Examples

INPUT: 4         INPUT: 5       INPUT: 8              INPUT: 9
OO               OOOOO          XXXX                  XOX
OO                              XXXX                  OXO
                                or rotated 90deg      XOX

Examples which aren't allowed (not same length row or columns)

BAD RESULT: 5a        BAD RESULT: 5b      BAD RESULT: 8
OOO                   OO                  OOO
OO                    OO                  OOO
                      O                   OO

If possible please provide an online example.

CJam, 16 (31 - 10 - 5)

This takes two integers are input, first one being 0 or 1 for direction and second one being the number of O or X in the grid.

It prints an alternate O and X.

:X"OX"*X<\Xmqi){(_X\%}g_X\/?/N*

This is just the function body, to try it out add l~ in front of the code like:

l~:X"OX"*X<\Xmqi){(_X\%}g_X\/?/N*

and give input like

0 10

to get output like

OXOXO
XOXOX

or input like

1 10

for

OX
OX
OX
OX
OX

Try it online here

How it works:

l~                                 "Put the two input integers to stack";
  :X                               "Assign the number of cells to X";
    "OX"*                          "Take string "OX" and repeat it X times";
         X<                        "Slice it to take only first X characters";
           \                       "Swap top two stack elements, now string is at bottom";
            Xmqi)                  "Take square root of X, ceil it and put on stack";
                 {(_X\%}g          "Keep decrementing until it is perfectly divisible by X";
                         _X\/      "Copy it, divide X by that and put it on stack";
                             ?     "Based on first input integer, take either of numbers";
                              /    "Divide the XOXO string that many times";
                               N*  "Join the string parts with a new line";

Example run:

l~ed:X"OX"*edX<ed\edXmqi)ed{(_X\%}ged_edXed\ed/ed?ed/edN*ed

#INPUT:
1 10

#OUTPUT:
Stack: [1 10]

Stack: [1 "OXOXOXOXOXOXOXOXOXOX"]

Stack: [1 "OXOXOXOXOX"]

Stack: ["OXOXOXOXOX" 1]

Stack: ["OXOXOXOXOX" 1 4]

Stack: ["OXOXOXOXOX" 1 2]

Stack: ["OXOXOXOXOX" 1 2 2]

Stack: ["OXOXOXOXOX" 1 2 2 10]

Stack: ["OXOXOXOXOX" 1 2 10 2]

Stack: ["OXOXOXOXOX" 1 2 5]

Stack: ["OXOXOXOXOX" 2]

Stack: [["OX" "OX" "OX" "OX" "OX"]]

Stack: ["OX
OX
OX
OX
OX"]

OX
OX
OX
OX
OX


It's a find-a-movie challenge This is a simple(ish) web scraping challenge.

Input

Your code should take an MPAA film rating and a number from 0 to 100 as input. It can do this in any way you find convenient.

Output

Your code should return the name of any movie which has a) that film rating and b) the numerical score on the Tomatometer from rottentomatoes.

If there is no such movie it can output anything you like.

The possible MPAA film ratings are G, PG, PG-13, R, NC-17, NR.

Your code may report one or more movies, that is up to you.

To clarify, your code is meant to access the web to get the answers to queries.

Example

Say the input is "PG, 98" then your code could output "Zootropolis".

Please show an example of your code working with the film rating PG and score 98 along with your answer.

Bash, 182 bytes

curl "https://www.rottentomatoes.com/api/private/v2.0/browse?minTomato=$2&maxTomato=$2&type=dvd-streaming-all" 2>/dev/null|grep -o "{[^}]*aRating\":\"$1\""|grep -Po 'title":"\K[^"]*'

Usage:

$ bash script PG 98
The Island President
Inside Out
Zootopia
Paddington
Love & Friendship
Long Way North (Tout en haut du monde)


J, 33 26 bytes

0.46%92^39%~*@".{3+".,~1-#

Try it online!

Takes input as a string with gauges less than zero as a string of zeroes. Finds the index of that string and divides 0.46 (the diameter of 0000) by the 39th root of 92 (the ratio between gauges) that many times.

Explanation

0.46%92^39%~*@".{3+".,~1-#  Input: string S
                         #  Length of S
                       1-   Subtract it from 1
                   ".,~     Eval S and append it, forms [1-len(S), eval(S)]
                 3+         Add 3 to each
            *@".            Sign of the eval
                {           Use that to index into the previous list
        39%~                Divide by 39
     92^                    Raise 92 to that power
0.46%                       Divide 0.46 by that and return


Can you spot the liar? It's the end of the year, you and your friends have just received your grades and ranks for the GOLF101 class. On a chat group, everyone sends their grade and rank to see who's got the best one.
Problem: someone is lying.
Here is an excerpt from the chat:
<A> I'm ranked 1 with a grade of 85.
<B> Ranked 3, got 50.
<C> Ranked 1st, prof. gave me 65/100.
<D> Got ranked second with 70/100

Obviously here, student C is lying (at least) on their rank; they can't be 1st with a grade of 65 since both A and D got a better grade.
There can also be cases where someone is lying but we can't know who, specifically.
Rank | Grade
-------------
  2     71
  1     80
  3     60
  2     70

Here, one of the two rank-2 students is lying (since two students can't have the same rank while having different grades) but we can't know which one.
Challenge
Create a function or program that, when given a sequence of (rank, grade) tuples which contains exactly one lie, returns the index of the lie in the list or a sentinel value if is impossible to know.
A lie is a tuple that, when removed from the list, makes the list valid (i.e. without any conflicting ranks/grades).
A valid list contains all the possible ranks starting from 1 (or 0 if you use 0-indexing), so the rank sequence 1 2 3 is valid while 2 3 4 is not. The only way to not have every possible rank is when there are equal grades, in which case you can get sequences like 1 2 2 or 1 2 3 3 3.
Multiple tuples may have the same grade, in which case they will have the same rank, and other tuples' ranks will not be affected. Two tuples having the second-best grade will lead to the sequence 1 2 2 4 ....
The input format is not fixed, you may use whatever is easier to parse for your language (a 2D int array, a list of tuples, a list of strings containing space-separated ints). The logic is more important than the parser's implementation details.
The output format is not fixed either. The "index" returned may be 0-based or 1-based, and the sentinel value can be anything that is clearly distinguishable from an index (if you're using 1-based indexing, 0 is a valid sentinel value).
Test Cases
Rank | Grade
-------------
  2     71
  1     80
  3     60
  2     70

Output: impossible to know
Rank | Grade
-------------
  1     85
  3     50
  1     65
  2     70

Output: third student
Rank | Grade
-------------
  1     85
  3     50
  1     65
  2     70

Output: third student
Additional cases, thanks to @tsh:

[(1, 100), (2, 60), (3, 90), (3, 90)] -> invalid input because we can't remove a single item to get a valid list
[(1, 100), (1, 100), (2, 90), (3, 90)] -> fourth (if we remove the third we get an invalid list with ranks [1, 1, 3])

This is code-golf, so the lowest byte count for each language wins!
EDIT: printing multiple values is a valid sentinel as long as you specify it. 0-indexing for ranks is fine too.

J, 49 47 22 bytes
[:I.1(-:\:~i.])/@|:\.]

Try it online!
-14 bytes after reading xigoi's idea of comparing the first index matches to the ranks.
Thanks to tsh for a test case showing that we needed "length not equal to 1" rather than "length greater than 1" as the failure criterion.
Returns 0-based index if exactly one liar is found, and 0 or multiple values otherwise.  Takes "length" by 2 matrix with 0-indexed rank list as left column, score list as right column.

1...\.] For each 1-item outfix (list with item removed), apply the verb...
(...)/@|: Transpose and put the verb in parens between the two rows, so that the rank list is its left arg, and the score list is its right arg.
-:\:~i.] Does the rank list match -: the first index of the score list i.] within the score list sorted descending \:~?  We now have a 0-1 list, where 1 indicates a liar.
[:I. Return the indexes of all ones.