A palavra infinita de Fibonacci é uma sequência infinita específica de dígitos binários, calculada por concatenação repetida de palavras binárias finitas.
Vamos definir que uma sequência de palavras de Fibonacci-tipo (ou FTW sequência ) é qualquer sequência ⟨W n ⟩ que é formado como se segue.
Comece com duas matrizes arbitrárias de dígitos binários. Vamos chamar essas matrizes de W -1 e W 0 .
Para cada n> 0 , deixar W n ≔ W n-1 ∥ W N-2 , onde ∥ denota concatenação.
Uma conseqüência da definição recursiva é que W n é sempre um prefixo de W n + 1 e, portanto, de todos os W k, de modo que k> n . Num certo sentido, isso significa que a sequência ⟨W n ⟩ converge para uma palavra infinito.
Formalmente, seja W ∞ ser a matriz só infinito de tal modo que W n é um prefixo de W ∞ para todo n ≥ 0 .
Chamaremos qualquer palavra infinita formada pelo processo acima de FTW infinito .
Tarefa
Escreva um programa ou função que aceite duas palavras binárias W -1 e W 0 como entrada e imprima W ∞ , respeitando as seguintes regras adicionais:
Você pode aceitar as palavras em qualquer ordem; como duas matrizes, uma matriz de matrizes, duas cadeias, uma matriz de cadeias ou uma única cadeia com um delimitador de sua escolha.
Você pode imprimir os dígitos da palavra infinita sem um delimitador ou com um delimitador consistente entre cada par de dígitos adjacentes.
Para todos os efeitos, suponha que seu código nunca fique sem memória e que seus tipos de dados não sejam excedidos.
Em particular, isso significa que qualquer saída para STDOUT ou STDERR resultante de uma falha será ignorada.
Se eu executar seu código na minha máquina (Intel i7-3770, 16 GiB RAM, Fedora 21) por um minuto e canalizar sua saída
wc -c
, ele deverá imprimir pelo menos um milhão de dígitos de W ∞ para (W -1 , W 0 ) = (1, 0) .Aplicam-se as regras de código-golfe padrão .
Exemplo
Seja W -1 = 1 e W 0 = 0 .
Então W 1 = 01 , W 2 = 010 , W 3 = 01001 , W 4 = 01001010 … e W ∞ = 010010100100101001001010… .
Esta é a palavra infinita de Fibonacci.
Casos de teste
Todos os casos de teste contêm os primeiros 1.000 dígitos do FTW infinito.
Input: 1 0
Output: 0100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010100100101001001
Input: 0 01
Output: 0100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010100100101001001
Input: 11 000
Output: 0001100000011000110000001100000011000110000001100011000000110000001100011000000110000001100011000000110001100000011000000110001100000011000110000001100000011000110000001100000011000110000001100011000000110000001100011000000110000001100011000000110001100000011000000110001100000011000110000001100000011000110000001100000011000110000001100011000000110000001100011000000110001100000011000000110001100000011000000110001100000011000110000001100000011000110000001100000011000110000001100011000000110000001100011000000110001100000011000000110001100000011000000110001100000011000110000001100000011000110000001100000011000110000001100011000000110000001100011000000110001100000011000000110001100000011000000110001100000011000110000001100000011000110000001100011000000110000001100011000000110000001100011000000110001100000011000000110001100000011000000110001100000011000110000001100000011000110000001100011000000110000001100011000000110000001100011000000110001100000011000000110001100000011000110000001100000011
Input: 10 010
Output: 0101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001001010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010010100101001001010010010100101001001010010100100101001001010
Input: 101 110
Output: 1101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101101011101011101101011101011101101011101101011101011101101011101101011101011101101011101011101101011101