edit this statistic or download as text // json
Identifier
Values
=>
0=>1 1=>1 00=>1 01=>2 10=>2 11=>1 000=>1 001=>2 010=>3 011=>2 100=>2 101=>3 110=>2 111=>1 0000=>1 0001=>2 0010=>3 0011=>2 0100=>3 0101=>4 0110=>2 0111=>2 1000=>2 1001=>2 1010=>4 1011=>3 1100=>2 1101=>3 1110=>2 1111=>1 00000=>1 00001=>2 00010=>3 00011=>2 00100=>3 00101=>4 00110=>2 00111=>2 01000=>3 01001=>3 01010=>5 01011=>4 01100=>2 01101=>3 01110=>2 01111=>2 10000=>2 10001=>2 10010=>3 10011=>2 10100=>4 10101=>5 10110=>3 10111=>3 11000=>2 11001=>2 11010=>4 11011=>3 11100=>2 11101=>3 11110=>2 11111=>1 000000=>1 000001=>2 000010=>3 000011=>2 000100=>3 000101=>4 000110=>2 000111=>2 001000=>3 001001=>3 001010=>5 001011=>4 001100=>2 001101=>3 001110=>2 001111=>2 010000=>3 010001=>3 010010=>3 010011=>3 010100=>5 010101=>6 010110=>4 010111=>4 011000=>2 011001=>2 011010=>4 011011=>3 011100=>2 011101=>3 011110=>2 011111=>2 100000=>2 100001=>2 100010=>3 100011=>2 100100=>3 100101=>4 100110=>2 100111=>2 101000=>4 101001=>4 101010=>6 101011=>5 101100=>3 101101=>3 101110=>3 101111=>3 110000=>2 110001=>2 110010=>3 110011=>2 110100=>4 110101=>5 110110=>3 110111=>3 111000=>2 111001=>2 111010=>4 111011=>3 111100=>2 111101=>3 111110=>2 111111=>1 0000000=>1 0000001=>2 0000010=>3 0000011=>2 0000100=>3 0000101=>4 0000110=>2 0000111=>2 0001000=>3 0001001=>3 0001010=>5 0001011=>4 0001100=>2 0001101=>3 0001110=>2 0001111=>2 0010000=>3 0010001=>3 0010010=>3 0010011=>3 0010100=>5 0010101=>6 0010110=>4 0010111=>4 0011000=>2 0011001=>2 0011010=>4 0011011=>3 0011100=>2 0011101=>3 0011110=>2 0011111=>2 0100000=>3 0100001=>3 0100010=>3 0100011=>3 0100100=>3 0100101=>4 0100110=>3 0100111=>3 0101000=>5 0101001=>5 0101010=>7 0101011=>6 0101100=>4 0101101=>4 0101110=>4 0101111=>4 0110000=>2 0110001=>2 0110010=>3 0110011=>2 0110100=>4 0110101=>5 0110110=>3 0110111=>3 0111000=>2 0111001=>2 0111010=>4 0111011=>3 0111100=>2 0111101=>3 0111110=>2 0111111=>2 1000000=>2 1000001=>2 1000010=>3 1000011=>2 1000100=>3 1000101=>4 1000110=>2 1000111=>2 1001000=>3 1001001=>3 1001010=>5 1001011=>4 1001100=>2 1001101=>3 1001110=>2 1001111=>2 1010000=>4 1010001=>4 1010010=>4 1010011=>4 1010100=>6 1010101=>7 1010110=>5 1010111=>5 1011000=>3 1011001=>3 1011010=>4 1011011=>3 1011100=>3 1011101=>3 1011110=>3 1011111=>3 1100000=>2 1100001=>2 1100010=>3 1100011=>2 1100100=>3 1100101=>4 1100110=>2 1100111=>2 1101000=>4 1101001=>4 1101010=>6 1101011=>5 1101100=>3 1101101=>3 1101110=>3 1101111=>3 1110000=>2 1110001=>2 1110010=>3 1110011=>2 1110100=>4 1110101=>5 1110110=>3 1110111=>3 1111000=>2 1111001=>2 1111010=>4 1111011=>3 1111100=>2 1111101=>3 1111110=>2 1111111=>1 00000000=>1 00000001=>2 00000010=>3 00000011=>2 00000100=>3 00000101=>4 00000110=>2 00000111=>2 00001000=>3 00001001=>3 00001010=>5 00001011=>4 00001100=>2 00001101=>3 00001110=>2 00001111=>2 00010000=>3 00010001=>3 00010010=>3 00010011=>3 00010100=>5 00010101=>6 00010110=>4 00010111=>4 00011000=>2 00011001=>2 00011010=>4 00011011=>3 00011100=>2 00011101=>3 00011110=>2 00011111=>2 00100000=>3 00100001=>3 00100010=>3 00100011=>3 00100100=>3 00100101=>4 00100110=>3 00100111=>3 00101000=>5 00101001=>5 00101010=>7 00101011=>6 00101100=>4 00101101=>4 00101110=>4 00101111=>4 00110000=>2 00110001=>2 00110010=>3 00110011=>2 00110100=>4 00110101=>5 00110110=>3 00110111=>3 00111000=>2 00111001=>2 00111010=>4 00111011=>3 00111100=>2 00111101=>3 00111110=>2 00111111=>2 01000000=>3 01000001=>3 01000010=>3 01000011=>3 01000100=>3 01000101=>4 01000110=>3 01000111=>3 01001000=>3 01001001=>3 01001010=>5 01001011=>4 01001100=>3 01001101=>3 01001110=>3 01001111=>3 01010000=>5 01010001=>5 01010010=>5 01010011=>5 01010100=>7 01010101=>8 01010110=>6 01010111=>6 01011000=>4 01011001=>4 01011010=>4 01011011=>4 01011100=>4 01011101=>4 01011110=>4 01011111=>4 01100000=>2 01100001=>2 01100010=>3 01100011=>2 01100100=>3 01100101=>4 01100110=>2 01100111=>2 01101000=>4 01101001=>4 01101010=>6 01101011=>5 01101100=>3 01101101=>3 01101110=>3 01101111=>3 01110000=>2 01110001=>2 01110010=>3 01110011=>2 01110100=>4 01110101=>5 01110110=>3 01110111=>3 01111000=>2 01111001=>2 01111010=>4 01111011=>3 01111100=>2 01111101=>3 01111110=>2 01111111=>2 10000000=>2 10000001=>2 10000010=>3 10000011=>2 10000100=>3 10000101=>4 10000110=>2 10000111=>2 10001000=>3 10001001=>3 10001010=>5 10001011=>4 10001100=>2 10001101=>3 10001110=>2 10001111=>2 10010000=>3 10010001=>3 10010010=>3 10010011=>3 10010100=>5 10010101=>6 10010110=>4 10010111=>4 10011000=>2 10011001=>2 10011010=>4 10011011=>3 10011100=>2 10011101=>3 10011110=>2 10011111=>2 10100000=>4 10100001=>4 10100010=>4 10100011=>4 10100100=>4 10100101=>4 10100110=>4 10100111=>4 10101000=>6 10101001=>6 10101010=>8 10101011=>7 10101100=>5 10101101=>5 10101110=>5 10101111=>5 10110000=>3 10110001=>3 10110010=>3 10110011=>3 10110100=>4 10110101=>5 10110110=>3 10110111=>3 10111000=>3 10111001=>3 10111010=>4 10111011=>3 10111100=>3 10111101=>3 10111110=>3 10111111=>3 11000000=>2 11000001=>2 11000010=>3 11000011=>2 11000100=>3 11000101=>4 11000110=>2 11000111=>2 11001000=>3 11001001=>3 11001010=>5 11001011=>4 11001100=>2 11001101=>3 11001110=>2 11001111=>2 11010000=>4 11010001=>4 11010010=>4 11010011=>4 11010100=>6 11010101=>7 11010110=>5 11010111=>5 11011000=>3 11011001=>3 11011010=>4 11011011=>3 11011100=>3 11011101=>3 11011110=>3 11011111=>3 11100000=>2 11100001=>2 11100010=>3 11100011=>2 11100100=>3 11100101=>4 11100110=>2 11100111=>2 11101000=>4 11101001=>4 11101010=>6 11101011=>5 11101100=>3 11101101=>3 11101110=>3 11101111=>3 11110000=>2 11110001=>2 11110010=>3 11110011=>2 11110100=>4 11110101=>5 11110110=>3 11110111=>3 11111000=>2 11111001=>2 11111010=>4 11111011=>3 11111100=>2 11111101=>3 11111110=>2 11111111=>1 000000000=>1 000000001=>2 000000010=>3 000000011=>2 000000100=>3 000000101=>4 000000110=>2 000000111=>2 000001000=>3 000001001=>3 000001010=>5 000001011=>4 000001100=>2 000001101=>3 000001110=>2 000001111=>2 000010000=>3 000010001=>3 000010010=>3 000010011=>3 000010100=>5 000010101=>6 000010110=>4 000010111=>4 000011000=>2 000011001=>2 000011010=>4 000011011=>3 000011100=>2 000011101=>3 000011110=>2 000011111=>2 000100000=>3 000100001=>3 000100010=>3 000100011=>3 000100100=>3 000100101=>4 000100110=>3 000100111=>3 000101000=>5 000101001=>5 000101010=>7 000101011=>6 000101100=>4 000101101=>4 000101110=>4 000101111=>4 000110000=>2 000110001=>2 000110010=>3 000110011=>2 000110100=>4 000110101=>5 000110110=>3 000110111=>3 000111000=>2 000111001=>2 000111010=>4 000111011=>3 000111100=>2 000111101=>3 000111110=>2 000111111=>2 001000000=>3 001000001=>3 001000010=>3 001000011=>3 001000100=>3 001000101=>4 001000110=>3 001000111=>3 001001000=>3 001001001=>3 001001010=>5 001001011=>4 001001100=>3 001001101=>3 001001110=>3 001001111=>3 001010000=>5 001010001=>5 001010010=>5 001010011=>5 001010100=>7 001010101=>8 001010110=>6 001010111=>6 001011000=>4 001011001=>4 001011010=>4 001011011=>4 001011100=>4 001011101=>4 001011110=>4 001011111=>4 001100000=>2 001100001=>2 001100010=>3 001100011=>2 001100100=>3 001100101=>4 001100110=>2 001100111=>2 001101000=>4 001101001=>4 001101010=>6 001101011=>5 001101100=>3 001101101=>3 001101110=>3 001101111=>3 001110000=>2 001110001=>2 001110010=>3 001110011=>2 001110100=>4 001110101=>5 001110110=>3 001110111=>3 001111000=>2 001111001=>2 001111010=>4 001111011=>3 001111100=>2 001111101=>3 001111110=>2 001111111=>2 010000000=>3 010000001=>3 010000010=>3 010000011=>3 010000100=>3 010000101=>4 010000110=>3 010000111=>3 010001000=>3 010001001=>3 010001010=>5 010001011=>4 010001100=>3 010001101=>3 010001110=>3 010001111=>3 010010000=>3 010010001=>3 010010010=>3 010010011=>3 010010100=>5 010010101=>6 010010110=>4 010010111=>4 010011000=>3 010011001=>3 010011010=>4 010011011=>3 010011100=>3 010011101=>3 010011110=>3 010011111=>3 010100000=>5 010100001=>5 010100010=>5 010100011=>5 010100100=>5 010100101=>5 010100110=>5 010100111=>5 010101000=>7 010101001=>7 010101010=>9 010101011=>8 010101100=>6 010101101=>6 010101110=>6 010101111=>6 010110000=>4 010110001=>4 010110010=>4 010110011=>4 010110100=>4 010110101=>5 010110110=>4 010110111=>4 010111000=>4 010111001=>4 010111010=>4 010111011=>4 010111100=>4 010111101=>4 010111110=>4 010111111=>4 011000000=>2 011000001=>2 011000010=>3 011000011=>2 011000100=>3 011000101=>4 011000110=>2 011000111=>2 011001000=>3 011001001=>3 011001010=>5 011001011=>4 011001100=>2 011001101=>3 011001110=>2 011001111=>2 011010000=>4 011010001=>4 011010010=>4 011010011=>4 011010100=>6 011010101=>7 011010110=>5 011010111=>5 011011000=>3 011011001=>3 011011010=>4 011011011=>3 011011100=>3 011011101=>3 011011110=>3 011011111=>3 011100000=>2 011100001=>2 011100010=>3 011100011=>2 011100100=>3 011100101=>4 011100110=>2 011100111=>2 011101000=>4 011101001=>4 011101010=>6 011101011=>5 011101100=>3 011101101=>3 011101110=>3 011101111=>3 011110000=>2 011110001=>2 011110010=>3 011110011=>2 011110100=>4 011110101=>5 011110110=>3 011110111=>3 011111000=>2 011111001=>2 011111010=>4 011111011=>3 011111100=>2 011111101=>3 011111110=>2 011111111=>2 100000000=>2 100000001=>2 100000010=>3 100000011=>2 100000100=>3 100000101=>4 100000110=>2 100000111=>2 100001000=>3 100001001=>3 100001010=>5 100001011=>4 100001100=>2 100001101=>3 100001110=>2 100001111=>2 100010000=>3 100010001=>3 100010010=>3 100010011=>3 100010100=>5 100010101=>6 100010110=>4 100010111=>4 100011000=>2 100011001=>2 100011010=>4 100011011=>3 100011100=>2 100011101=>3 100011110=>2 100011111=>2 100100000=>3 100100001=>3 100100010=>3 100100011=>3 100100100=>3 100100101=>4 100100110=>3 100100111=>3 100101000=>5 100101001=>5 100101010=>7 100101011=>6 100101100=>4 100101101=>4 100101110=>4 100101111=>4 100110000=>2 100110001=>2 100110010=>3 100110011=>2 100110100=>4 100110101=>5 100110110=>3 100110111=>3 100111000=>2 100111001=>2 100111010=>4 100111011=>3 100111100=>2 100111101=>3 100111110=>2 100111111=>2 101000000=>4 101000001=>4 101000010=>4 101000011=>4 101000100=>4 101000101=>4 101000110=>4 101000111=>4 101001000=>4 101001001=>4 101001010=>5 101001011=>4 101001100=>4 101001101=>4 101001110=>4 101001111=>4 101010000=>6 101010001=>6 101010010=>6 101010011=>6 101010100=>8 101010101=>9 101010110=>7 101010111=>7 101011000=>5 101011001=>5 101011010=>5 101011011=>5 101011100=>5 101011101=>5 101011110=>5 101011111=>5 101100000=>3 101100001=>3 101100010=>3 101100011=>3 101100100=>3 101100101=>4 101100110=>3 101100111=>3 101101000=>4 101101001=>4 101101010=>6 101101011=>5 101101100=>3 101101101=>3 101101110=>3 101101111=>3 101110000=>3 101110001=>3 101110010=>3 101110011=>3 101110100=>4 101110101=>5 101110110=>3 101110111=>3 101111000=>3 101111001=>3 101111010=>4 101111011=>3 101111100=>3 101111101=>3 101111110=>3 101111111=>3 110000000=>2 110000001=>2 110000010=>3 110000011=>2 110000100=>3 110000101=>4 110000110=>2 110000111=>2 110001000=>3 110001001=>3 110001010=>5 110001011=>4 110001100=>2 110001101=>3 110001110=>2 110001111=>2 110010000=>3 110010001=>3 110010010=>3 110010011=>3 110010100=>5 110010101=>6 110010110=>4 110010111=>4 110011000=>2 110011001=>2 110011010=>4 110011011=>3 110011100=>2 110011101=>3 110011110=>2 110011111=>2 110100000=>4 110100001=>4 110100010=>4 110100011=>4 110100100=>4 110100101=>4 110100110=>4 110100111=>4 110101000=>6 110101001=>6 110101010=>8 110101011=>7 110101100=>5 110101101=>5 110101110=>5 110101111=>5 110110000=>3 110110001=>3 110110010=>3 110110011=>3 110110100=>4 110110101=>5 110110110=>3 110110111=>3 110111000=>3 110111001=>3 110111010=>4 110111011=>3 110111100=>3 110111101=>3 110111110=>3 110111111=>3 111000000=>2 111000001=>2 111000010=>3 111000011=>2 111000100=>3 111000101=>4 111000110=>2 111000111=>2 111001000=>3 111001001=>3 111001010=>5 111001011=>4 111001100=>2 111001101=>3 111001110=>2 111001111=>2 111010000=>4 111010001=>4 111010010=>4 111010011=>4 111010100=>6 111010101=>7 111010110=>5 111010111=>5 111011000=>3 111011001=>3 111011010=>4 111011011=>3 111011100=>3 111011101=>3 111011110=>3 111011111=>3 111100000=>2 111100001=>2 111100010=>3 111100011=>2 111100100=>3 111100101=>4 111100110=>2 111100111=>2 111101000=>4 111101001=>4 111101010=>6 111101011=>5 111101100=>3 111101101=>3 111101110=>3 111101111=>3 111110000=>2 111110001=>2 111110010=>3 111110011=>2 111110100=>4 111110101=>5 111110110=>3 111110111=>3 111111000=>2 111111001=>2 111111010=>4 111111011=>3 111111100=>2 111111101=>3 111111110=>2 111111111=>1 0000000001=>2 0010000001=>3 0010101101=>6 0010101011=>8 0010100111=>5 0010011101=>3 0010011011=>3 0010010111=>4 0010001111=>3 0001110101=>5 0001110011=>2 0001101101=>3 0001101011=>5 0001100111=>2 0001011101=>4 0001011011=>4 0001010111=>6 0001001111=>3 0000111101=>3 0000111011=>3 0000110111=>3 0000101111=>4 0000011111=>2 0000000000=>1 0000000110=>2 0000011000=>2 0000011110=>2 0000010010=>3 0001100000=>2 0001100110=>2 0001111000=>2 0001111110=>2 0001110010=>3 0001001000=>3 0001001110=>3 0001000010=>3 0001011010=>4 0010101010=>9 0010101000=>7 0010101100=>6 0010100100=>5 0010010100=>5 0001010100=>7 0010101110=>6 0010100000=>5 0010000100=>3 0000010100=>5 0000000010=>3 0000001110=>2 0000111110=>2 0000000100=>3 0000001010=>5 0000010110=>4 0000101110=>4 0001011110=>4 0001101110=>3 0001110110=>3 0001111010=>4 0001111100=>2 0000000101=>4 0000001101=>3 0000011101=>3 0001111101=>3 0000001001=>3 0000010101=>6 0000101101=>4 0010110001=>4 0001100001=>2 0001000001=>3 0000111111=>2 0001110100=>4 0001101100=>3 0010011100=>3 0001011100=>4 0000111100=>2 0001101010=>6 0010011010=>4 0000111010=>4 0010100110=>5 0010010110=>4 0001010110=>6 0000110110=>3 0010001110=>3 0001101001=>4 0000110001=>2 0000010001=>3 0000001100=>2 0000011001=>2 0000110011=>2 0000110100=>4 0000000011=>2 0000011011=>3 0001101111=>3 0000110101=>5 0010000010=>3 0001000011=>3 0010011110=>3 0001010000=>5 0001000100=>3 0001010101=>8 0001001011=>4 0001100011=>2 0001110111=>3 0010000000=>3 0000000111=>2 0000001111=>2 0001111111=>2 0000001011=>4 0000010111=>4 0001011111=>4 0001111001=>2 0000011010=>4 0000101010=>7 0000100101=>4 0010010001=>3 0010000101=>4 0010010101=>6 0010010011=>3 0000101011=>6 0001000111=>3 0000100111=>3 0010010010=>3 0001001010=>5 0001001001=>3 0001000101=>4 0000100011=>3 0000100100=>3 0000100010=>3 0010110000=>4 0000011100=>2 0000001000=>3 0000101100=>4 0010101111=>6 0000101000=>5 0010001000=>3 0001001100=>3 0001000110=>3 0001100100=>3 0001100010=>3 0000100110=>3 0000110010=>3 0010010000=>3 0001010010=>5 0001000000=>3 0001011001=>4 0001100101=>4 0001110001=>2 0010011001=>3 0010100101=>5 0010101001=>7 0010011111=>3 0000111001=>2 0010001101=>3 0001001101=>3 0001010001=>5 0001010011=>5 0001111011=>3 0010011000=>3 0001011000=>4 0000100000=>3 0010001011=>4 0010000111=>3 0000010011=>3 0010001100=>3 0010000110=>3 0000110000=>2 0000100001=>3 0010100011=>5 0010100001=>5 0000111000=>2 0001101000=>4 0000010000=>3 0000101001=>5 0010100010=>5 0010001001=>3 0010000011=>3 0010001010=>5 0001110000=>2
search for individual values
searching the database for the individual values of this statistic
/ search for generating function
searching the database for statistics with the same generating function
click to show known generating functions       
Description
The length of the longest alternating subword.
This is the length of the longest consecutive subword of the form $010...$ or of the form $101...$.
Code
# code from https://codereview.stackexchange.com/questions/164326

def zigzags(input):
    input = iter(input)
    stack = None
    try:
        stack = [next(input)]
        while True:
            if len(stack) < 2:
                stack.append(next(input))
            else:
                stack = stack[-2:]
            a, b = stack
            if a == b:
                yield (a,)
                stack = [b]
                continue
            zig = a > b
            while True:
                prev = stack[-1]
                this = next(input)
                if prev == this or zig == (prev > this):
                    break
                stack.append(this)
                zig = not zig
            yield tuple(stack)
            stack.append(this)
    except StopIteration:
        pass
    if stack:
        yield tuple(stack)

def statistic(input):
    return max(len(z) for z in zigzags(input))

Created
Sep 12, 2017 at 16:26 by Christian Stump
Updated
Jan 14, 2021 at 22:36 by Martin Rubey