Skip to content

Instantly share code, notes, and snippets.

@seoh
Last active December 27, 2015 00:49
Show Gist options
  • Save seoh/7239983 to your computer and use it in GitHub Desktop.
Save seoh/7239983 to your computer and use it in GitHub Desktop.
Synapsoft the second-half 2013 recruitment
function synap(number) {
var buff = [];
while( number >= 0 ) {
buff.push( String.fromCharCode(number%26 + 65) );
number = Math.floor(number/26)-1;
}
return buff.reverse().join('');
}
function fillZero(number, digit) {
number = '' + number;
return Array(digit-number.length+1).join(0) + number;
}
Array.apply(null, Array(1000))
.map(function(e, i){return fillZero(i,3) + ' = ' + synap(i);})
.forEach(function(e){console.log(e);});

see also

엑셀과 같은 스프레드시트에서, 컬럼 이름은 첫번째가 A, 두번째가 B... 같은 식인데, 26번째인 Z 다음부터는 AA, AB,.. 처럼 됩니다. 숫자를 입력받으면 그 순서에 대응되는 엑셀 컬럼을 출력하는 프로그램을 작성하세요.

프로그래밍 언어의 제약은 없으며, 외부 라이브러리를 쓰시는 경우 용도를 같이 명시해 주세요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment