Uzunluklarının n katını yazdıran programlar oluşturma


16

Negatif olmayan bir tam sayı verildiğinde n, çözümünüz çıktısı seçilen dilde bir program çıkarmalıdır.n süresi kadar bayt .

kurallar

  • Çözümünüzün çıkardığı programların dilini ve kodlamasını belirtmelisiniz ve çözümünüze farklı girdiler için farklı diller veya kodlamalar seçemezsiniz. Çıktı programınızın dili, çözümünüzün dili ile aynı olabilir veya olmayabilir.
  • Gönderiminizin yalnızca dilinizdeki tamsayıları işlemesi gerekir, ancak lütfen bu kuralı kötüye kullanmayın.

Bu yani bayt kısa teslim kazanır.

Misal

Farzedelim ki n4. Benim çözümüm çıktı f_8(benim hayali) dilimde çıktı veren bir program j3 1s+/2]!mz. Program çıkışı 3 uzunluğuna ve çıkışı 3 * 4 = 12 uzunluğuna sahiptir, bu nedenle çözüm giriş 4 için doğrudur.

Bunun yerine n1 olduğunu ve program çıktılarım olduğunu ffffpfpffp(10 bayt) varsayalım . ffffpfpffpSeçtiğim dilde programın 10 * 1 = 10 baytlık bir çıktı üretmesi gerekiyordu.


Şu anda, bu oldukça eksik. Bazı örnekler verebilir misiniz?
DJMcMayhem

3
Ben düşünüyorum yapmamız gerektiğini bildiği, ama spec okumak her zaman, daha az belli olur. çıktı bir programın çıktısını almak zorunda olduğumuz anlamına gelir. Karakter kümesi ve dil tüm tamsayılar için tutarlı olmalıdır. Bu hangi "karakter setine" atıfta bulunuyor?
Dennis

Boşverin, aslında yaptığımız anlamakta, dolayısıyla tüm ama cevaplar birini yaptı.
Dennis

1
@Dennis Başlığın vücuda aykırı olduğu anlaşılıyor. Belki Çıktı bir program çıktıları n kere uzunluğu o Ben doğru meydan anlıyorum if (Emin yapmam değilim), daha iyi bir başlık olurdu
Sisifos

1
nDize olarak alabilir miyiz ?
Shaggy

Yanıtlar:


7

JavaScript (ES6), 38 bayt

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

gösteri



3

brainfuck , 348 bayt

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

Çevrimiçi deneyin! Veya Ungolfed versiyonuna bakın (yani çalışmak zorunda olduğum şey)


feragat

Bunu insanca mümkün olduğunu düşündüğümden daha fazla zaman harcadım. Kız arkadaşımın onun üzerinde çalışmasına izin vermeme izin verdiği için teşekkür etmek istiyorum; sıra sıra benim kurtarıcı .

Nasıl çalışır?

İpucu yok.

Nasıl çalışır?

Tüm çıkışlar, hepsi aynı olan bir kod snippet'ine sahiptir:

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

Hadi üç bölüme ayıralım a,b,c

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

Giriş ibasitçe öne doğru tutturulur:

iabc

(örneğin; giriş 10 ise, o zaman i = '++++++++++')

Teksir - Girişi, girişe m, neşdeğer iki aynı numaraya böler

Ayarlayıcı - nProgramın uzunluğuna eşit olacak şekilde ayarlar

Yazıcı - m*nASCII karakterlerini yazdırır


Örnekteki girişin newlineASCII değeri 10 olan a olduğundan , girişin olduğuna dikkat edin 10. Eğer diğer küçük sayılar test etmek isterseniz, yerini ,ancak birçok +s' arzu.



2

Haskell , 55 bayt

f n=(++)<*>show$"main=putStr$[1.."++show n++"*2]>>'#':"

Çevrimiçi deneyin! Örnek kullanım: f 1aşağıdaki 54 bayt programını verir:

main=putStr$[1..1*2]>>'#':"main=putStr$[1..1*2]>>'#':"

Çevrimiçi deneyin! Aşağıdaki 54 bayt çıktıyı üretir:

#main=putStr$[1..1*2]>>'#':#main=putStr$[1..1*2]>>'#':

1

Python 3 -> HQ9 +, 11 bayt

'Q'.__mul__

Yapılması gerekiyordu

Çevrimiçi deneyin!


Genel Merkezi nerede test edebilirim?
Titus

1
Eh, Qsadece kendi kaynak kodunu yazdırır. Bunu burada test edebilirsiniz: hq9plus.alwaysdata.net . Bunun asla ciddi bir giriş olması gerekmiyordu
michi7x7 22:17

Bu işe yaramıyor. Eğer ben girişi 1, o zaman çıkış Q, dönüş çıkışları içinde Q. Quzunluğa sahip 1, ancak kodunuzun uzunluğu var 11.
NoOneIs Here

@NoOneIsHere 'çıktısının çıktısı programın n katı kadar bayt var.' (gönderilen program değil)
michi7x7 19:17

1
@NoOneIsHere bunu yapmaz: almnet.de/esolang/hq9plus.php (Dil belirtimi yalnızca "Kaynak kod dosyasının metninin tamamını yazdırır")
michi7x7 19:17

1

Java 8, 175 174 bayt

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]);}}

Örnekler:

n=1çıktılar :

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

(uzunluk = 89) 89 sıfır çıktı :

00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

n=10çıktılar :

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

(uzunluk = 90) 900 sıfır üretir :

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

n=100çıktılar :

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

(uzunluk = 91) 9100 sıfır çıktı :

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Açıklama:

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 bayt

«•.* 

Sonunda boşluk var

Açıklaması

«•.* 
«    # 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.

Çevrimiçi deneyin!


0

CJam, 8 13 bayt

q_,S\" 8+*S*"

Çevrimiçi Deneyin

Oluşturulan program boşluklar verir, bu yüzden söylemesi zor.


Ben bir metin çıktısı bir program çıktısı hakkında bölümü yorumlayan tek cevap bu düşünüyorum, ancak giriş birden fazla basamak varsa oranı kapalı.
Dennis

Oh yeah, duh. ,,
geokavel


0

Python → TECO, 20 bayt

Üretilen kod TECO'dayken cevap Python'da. Python, n kez VV12345\VVtekrarlanan bir işlevdir . TECO'nun açıklaması için buraya bakınız .

'VV12345\VV'.__mul__

0

PHP, 47 + 1 bayt

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

bir alt çizgi ve ardından boşluklar yazdırır.
Boru olarak çalıştırın -F; Çıktı programını -fveya ile çalıştırın -F.

Bu, (şu anda)
çok daha yüksek olan 64'ten fazla basamağa sahip girdi için başarısız olur PHP_INT_MAX.

Ancak, PHP_INT_MAX-18'den daha büyük girdiler için başarısız oluyor ... yine de uygun mu?


@HyperNeutrino: Bu, -18'den büyük girişler için başarısız olur PHP_INT_MAX. Bu diskalifiye oluyor mu?
Titus

Hayır, güzel diyeceğim :)
HyperNeutrino

0

PHP → Python 2, 40 + 1 bayt

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

tekrar eden bir Python programı yazdırır A. İle boru olarak çalıştırın -F.


0

Seri → Kömür, 22 bayt

Hangi kodlamayı kullanmam gerektiğinden emin değilim, çünkü bunlar bayt. Windows-1252 olarak yorumlanan baytlar:

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

PC-850 ile aynı bayt:

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

Kömürün kod sayfasındaki aynı baytlar:

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

Ortaya çıkan Kömür programı Plus(Length(Cast(n)), 9)bayt uzunluğundadır:

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

JavaScript (ES8), 43 41 39 bayt

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

Dene

Oluşturulan işlevin çıktısı, *bu Snippet'te s ile değiştirilen bir boşluk dizesidir .

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 bayt

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

Çevrimiçi deneyin!

Dizeyi döndüren anonim işlev

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

Hangi baskılar a( abunu bir boşluk izler) 23 nkez. İhtiyacım vardı, ''çünkü aksi takdirde catson boşluk karakterini basmazdı.


0

C, 94 bayt

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

bu 94 bayt olur, standart C'nin yazılması gerektiğini söyleyen son \ n içerir. Program argümanı yoksa veya <= 0 ise veya> 0xFFFFF hiçbir şey yazdırmazsa, 'program' uzunluğu (programın uzunluğu) * (programın argümanı) olarak 'r' karakterleri olarak döner

C:\>nameProg.exe 1
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

0

MATLAB (63 bayt)

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

Örneğin:

>> a(5)

ans =

repmat('a',1,80)

ve:

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

ans =

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.