길이의 n 배를 인쇄하는 프로그램 생성


16

음수가 아닌 정수가 주어지면 n솔루션에서 선택한 언어로 프로그램을 출력해야합니다.n 시간이 출력 된 프로그램의 바이트 수만큼 인 프로그램을 출력해야합니다.

규칙

  • 솔루션이 출력하는 프로그램의 언어 및 인코딩을 지정해야하며 솔루션의 다른 입력에 대해 다른 언어 또는 인코딩을 선택할 수 없습니다. 출력 프로그램의 언어는 솔루션의 언어와 같거나 같지 않을 수 있습니다.
  • 제출 한 언어 범위의 정수만 처리하면되지만이 규칙을 남용하지 마십시오.

이것은 이므로 바이트 단위의 최단 제출이 이깁니다.

n4 라고 가정하자 . 내 솔루션은 f_8(가상) 언어 출력으로 프로그램을 출력한다 j3 1s+/2]!mz. 프로그램 출력의 길이는 3이고 출력의 길이는 3 * 4 = 12이므로 솔루션은 입력 4에 적합합니다.

대신 n1이고 내 프로그램 출력 ffffpfpffp(10 바이트) 이라고 가정하십시오 . ffffpfpffp선택한 언어로 된 프로그램 은 10 * 1 = 10 바이트의 출력을 생성해야합니다.


현재로서는이 수치가 상당히 불분명합니다. 몇 가지 예를 들어 주시겠습니까?
DJMcMayhem

3
나는 생각 나는 우리가 어떻게해야하는지 알아,하지만 난 사양을 읽을 때마다, 나는 덜 특정된다. 출력 된 프로그램보다 n 배 많은 바이트를 가진 텍스트를 출력하면 텍스트와 프로그램을 출력해야 함을 의미합니다. 문자 세트와 언어는 모든 정수에 대해 일관성이 있어야합니다. 이것은 어떤 "문자 세트"를 의미합니까?
Dennis

신경 끄시 고, 나는 실제로 오해를, 그래서 제외한 모든 답변을했다.
Dennis

1
@Dennis 제목이 본문과 모순되는 것처럼 보이지 않습니다. 어쩌면 도전을 올바르게 이해한다면 ( 길이 가 확실하지 않은 경우) 길이의 n 배를 출력하는 프로그램이 더 나은 타이틀 일 것입니다.
Sisyphus

1
우리 n는 줄로 취할 수 있습니까 ?
Shaggy

답변:


7

자바 스크립트 (ES6), 38 바이트

n=>`(x="${n}")=>(x+1/7+1e9).repeat(x)`

데모



3

brainfuck , 348 바이트

--[>+<++++++]>>--[>+<++++++]>++[-<+>]----[>+<----]>---[-<+>]----[>+<----]>-[-<+>]-[>+<---]>++++++[-<+>]-[>+<---]>++++++++[-<+>]--[>+<++++++]>+++[-<+>]<[<],[->.<]>>>>>.<<<.>>.<<<.>>>.<<<.>>>.<<<.>>...>>>.<<....<<.>>>.<<..<<.>>>..<<.......>>>>.<<<..<<.>.....>>>.<<.>>.>>.<<<<<.>>>>.<<.<<.>>.>.<<<.>>.<<<.>>...<<.>>>..>>.<<.>.<<<.>.<<.>>>.>>.<<<..>>>.

온라인으로 사용해보십시오! 또는 Ungolfed 버전 (즉, 내가 작업해야했던 것)을 참조하십시오


기권

나는 인간적으로 가능하다고 생각했던 것보다 더 많은 시간을 보냈습니다. 나는 그녀가이 일을 할 수있게 해 준 여자 친구에게 감사하고 싶다. 뿐만 아니라 나의 구세주 .

어떻게 작동합니까?

실마리 없음.

어떻게 작동합니까?

모든 출력에는 모두 동일한 코드 스 니펫이 있습니다.

[->+>+>+<<<]>>>>-[<<+>>-------]<<+-----[<[.-]>->[->+<<<+>>]>[-<+>]<<]

그것을 세 부분으로 나누겠습니다 a,b,c

a : [->+>+>+<<<]>>>>               THE DUPLICATOR
b : -[<<+>>-------]<<+-----        THE ADJUSTER
c : [<[.-]>->[->+<<<+>>]>[-<+>]<<] THE PRINTER

입력 i은 단항식으로 전면에 고정됩니다.

iabc

(예 : 입력이 10 인 경우 i = '++++++++++')

복제기 - 두 개의 동일한 번호로 입력 분할 m, n입력에 상응하는,

조절기 - n프로그램 길이와 같도록 조절 합니다

프린터m*n -ASCII 문자를 인쇄 합니다


이 예제의 입력은 newline이며 ASCII 값은 10이므로 입력은 10입니다. 다른 작은 숫자를 테스트하려면 원하는 ,많은 숫자로 바꾸십시오 +.




1

파이썬 3- > HQ9 +, 11 바이트

'Q'.__mul__

해야 했어요

온라인으로 사용해보십시오!


본부를 어디에서 테스트 할 수 있습니까?
Titus

1
글쎄, Q그냥 자신의 소스 코드를 인쇄합니다. hq9plus.alwaysdata.net에서 테스트 할 수 있습니다 . 이것은 심각한 항목이 있어야되지 않았다
michi7x7

작동하지 않습니다. 입력 1하면 출력 Q하고 출력 Q합니다. Q길이 1는 있지만 코드 길이는 같습니다 11.
NoOneIsHere9

@NoOneIsHere '이 출력은 출력 된 프로그램보다 n 배 많은 바이트를 갖습니다.' (제출 된 프로그램 아님)
michi7x7

1
@NoOneIsHere이되지 않습니다 almnet.de/esolang/hq9plus.php (언어 사양은 "인쇄합니다 전체 소스 코드 파일의 텍스트"상태)
michi7x7

1

자바 (8), (175) 174 바이트

interface M{static void main(String[]a){System.out.printf("interface M{static void main(String[]a){int i=(88+%s)*%s;for(;i-->0;System.out.print(0));}}",a[0].length(),a[0]);}}

예 :

n=1출력 :

interface M{static void main(String[]a){int i=(88+1)*1;for(;i-->0;System.out.print(0));}}

89 개의 0을 출력하는 (length = 89) :

00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

n=10출력 :

interface M{static void main(String[]a){int i=(88+2)*10;for(;i-->0;System.out.print(0));}}

900의 0을 출력하는 (길이 = 90) :

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

n=100출력 :

interface M{static void main(String[]a){int i=(88+3)*100;for(;i-->0;System.out.print(0));}}

9100 0을 출력하는 (길이 = 91) :

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

설명:

interface M{                                // Class:
  static void main(String[]a){              //  Mandatory main method
    System.out.printf("interface M{static void main(String[]a){
                                            //   Print a new program with:
      int i=(88+%s)*%s;                     //    Integer containing (88*A)+B
      for(;i-->0;System.out.print(0));}}",  //    And print that many zeroes
        a[0].length(),                      //     Where A is the length of the number
                                            //     (0-9 = 1; 10-99 = 2; 100-999 = 3; etc.)
        a[0]);}}                            //     and B is the number itself

0

RProgN 2 , 7 5 바이트

«•.* 

후행 공간으로

설명

«•.* 
«    # Yield a function from the remaining string.
 •.  # Append a space and stringify, which builds the original program (Because stringifying a function removes noops, which spaces are)
   * # Repeat the implicit input times.

온라인으로 사용해보십시오!


0

CJam, 8 13 바이트

q_,S\" 8+*S*"

온라인으로 사용해보십시오

생성 된 프로그램은 공백을 출력하므로 구분하기가 어렵습니다.


텍스트를 올바르게 출력하는 프로그램 출력에 대한 부분을 해석하는 유일한 대답이라고 생각하지만 입력에 두 자리 이상이 있으면 비율이 해제됩니다.
Dennis

오 예, duh. ,,
geokavel


0

Python → TECO, 20 바이트

대답은 파이썬이고 생성 된 코드는 TECO입니다. 파이썬을 반환하는 함수이고 VV12345\VV반복하여 N 개의 시간. TECO에 대한 설명은 여기 를 참조 하십시오 .

'VV12345\VV'.__mul__

0

PHP, 47 + 1 바이트

<?="<?=str_pad(_,",strlen($argn)+18,"*$argn);";

밑줄 하나 뒤에 공백을 인쇄합니다. ;
로 파이프로 실행 또는로 -F출력 된 프로그램을 실행하십시오 .-f-F

64 자리를 초과하여 입력하는
경우 PHP_INT_MAX(현재) 보다 훨씬 높습니다 .

그러나 PHP_INT_MAX-18 보다 큰 입력에 대해서는 실패합니다 ... 여전히 자격이 있습니까?


@HyperNeutrino : PHP_INT_MAX-18 보다 큰 입력에서는 실패합니다 . 실격됩니까?
Titus

아냐, 난 괜찮다고 말할거야 :)
HyperNeutrino

0

PHP → Python 2, 40 + 1 바이트

print "A"*<?=13+strlen($argn),"*",$argn;

반복되는 As 를 인쇄하는 Python 프로그램을 인쇄합니다 . 로 파이프로 실행하십시오 -F.


0

배치 → 숯, 22 바이트

바이트 형식이므로 어떤 인코딩을 사용해야하는지 잘 모르겠습니다. 다음은 Windows-1252로 해석 된 바이트입니다.

@set/p=Á%1ñªÉñ«Ìñ¹<nul

PC-850과 동일한 바이트 :

@set/p=┴%1±¬╔±½╠±╣<nul

Charcoal의 코드 페이지에서 동일한 바이트 :

@set/p=A%1θ×Iθ⁺Lθ⁹<nul

결과 숯 프로그램의 Plus(Length(Cast(n)), 9)길이 는 바이트입니다.

A       Assign
 %1      (String representation of n)
   θ      To variable q
        Implicitly print a number of `-`s equal to:
×        Product of:
 Iθ       Cast of q to integer
 ⁺        Sum of:
  Lθ       Length of q
  ⁹        Integer constant 9


0

자바 스크립트 (ES8), 43 41 39 바이트

n=>`f=_=>"".padEnd(${n}*(88+f).length)`

그것을 테스트

생성 된 함수의 출력은 *이 스 니펫에서 s 로 대체되는 공백 문자열입니다 .

g=
n=>`f=_=>"".padEnd(${n}*(88+f).length)`

o.innerText=(h=n=>`Function: ${x=g(n)}\nLength:   ${x.length}\nOutput:   "${x=eval(x)().replace(/./g,"*")}"\nLength:   `+x.length)(i.value=10);oninput=_=>o.innerText=h(+i.value)
<input id=i type=number><pre id=o>


0

R , 46 바이트

function(n)sprintf("cat(rep('a',%d*23),'')",n)

온라인으로 사용해보십시오!

문자열을 반환하는 익명 함수

cat(rep('a',n*23),'')

어떤 인쇄 a(의 그 a뒤에 공백) 23 시간의 n시간. ''그렇지 않으면 cat마지막 공백 문자를 인쇄하지 않기 때문에 필요했습니다 .


0

C, 94 바이트

main(int c,char**a){if(c>1){c=atoi(a[1]);if(c>0&&c<0xFFFFFF){c*=94;while(c--)printf("r");}}}

이것은 표준 바이트 C가 쓰여야한다고 마지막 \ n을 포함하는 94 바이트입니다. 프로그램 인수가 없거나 <= 0이거나> 0xFFFFF 인 경우 아무 것도 표시하지 않으면 (프로그램의 길이) * (프로그램의 인수)로 'r'문자로 리턴

C:\>nameProg.exe 1
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

0

MATLAB (63 바이트)

a=@(n)['repmat(''a'',1,',num2str(n*(15+numel(num2str(n)))),')']

예를 들면 다음과 같습니다.

>> a(5)

ans =

repmat('a',1,80)

과:

>> repmat('a',1,80)

ans =

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.