무한 피보나치 워드는 특정 유한 이진 워드의 반복 연결하여 계산 이진수의 무한 시퀀스이다.
우리는 것을 정의 할 피보나치 형 단어 시퀀스 (또는 FTW 시퀀스 ) 임의의 시퀀스이다 ⟨W N ⟩ 다음과 같이 형성된다.
2 개의 임의의 이진수 배열로 시작합니다. 우리가 이러한 배열 부르 자 W -1 과 W 0 .
각각의 n> 0에 대해 , W n ≔ W n-1 ∥ W n-2로 하자. 여기서 ∥는 연결을 나타낸다.
재귀 정의의 결과는 즉 W N 항상의 접두사 W , N + 1 , 따라서, 모든 W K 되도록 N> K . 어떤 의미에서,이 수단 시퀀스 ⟨W N ⟩ 무한 워드로 수렴.
형식적하자 W가 ∞ 되도록 단지 무한 배열이 W가 N 의 접두어 W ∞ 모든 N ≥ 0 .
위의 과정으로 형성된 무한 단어를 무한 FTW 라고 부릅니다 .
태스크
두 개의 이진 단어 W -1 및 W 0 을 입력으로 받아들이고 W ∞를 인쇄 하고 다음과 같은 추가 규칙을 준수 하는 프로그램 또는 함수를 작성하십시오 .
어떤 순서로든 단어를 받아 들일 수 있습니다. 두 개의 배열, 배열의 배열, 두 개의 문자열, 문자열의 배열 또는 선택한 구분 기호가있는 단일 문자열.
구분자없이 또는 인접한 각 쌍의 쌍 사이에 일관된 구분자를 사용하여 무한 단어의 숫자를 인쇄 할 수 있습니다.
모든 목적을 위해 코드에 메모리가 부족하지 않으며 데이터 유형이 오버플로되지 않는다고 가정하십시오.
특히 이는 충돌의 결과 인 STDOUT 또는 STDERR에 대한 출력이 무시됨을 의미합니다.
내 기계 (Intel i7-3770, 16 GiB RAM, Fedora 21)에서 1 분 동안 코드를 실행하고 출력을으로 파이프하면 (W -1 , W 0 )에 대해
wc -c
최소 백만 자릿수의 W ∞ 를 인쇄해야합니다 = (1, 0) 입니다.표준 코드 골프 규칙이 적용됩니다.
예
W -1 = 1 이고 W 0 = 0 이라고하자 .
이어서 W 1 = 01 , W (2) = 010 , W (3) = 01001 , W 4 = 01,001,010 ... 및 W ∞ = 010,010,100,100,101,001,010 ... .
이다 무한 피보나치 단어입니다.
테스트 사례
모든 테스트 사례에는 무한 FTW의 처음 1,000 자리가 포함됩니다.
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