Script que genera un script que imprime una entrada dada


29

Escriba un fragmento de código que tome una cadena como entrada y genere un fragmento de código en el mismo idioma que, cuando se ejecute, generará la cadena de entrada inicial.

Debe poder manejar cualquier combinación de caracteres AZ, az y 0-9.

Ejemplo en Python:

import sys
print "print('" + sys.argv[1]  + "')"

Dada la entrada de testing123, volverá print('testing123').

Como se trata de , la respuesta más corta en bytes ganará.


¿Puede ser una función?
Totalmente humano el

@manatwork (S) lo editó hace un momento.
NoOneIsHere

¿La entrada debe ser una cadena? ¿O puede ser un número entero?
Shaggy

Debe poder manejar entradas enteras y de cadena.
Quartzic

2
¿Podemos generar una función según los valores predeterminados en meta?
JAD

Respuestas:


28

pl , 0 bytes

Código:

Pruébalo en línea!

Explicación:

Un programa vacío en pl es simplemente un programa cat, que genera exactamente lo mismo que la entrada.

En pl, todos los caracteres ASCII son esencialmente variables, pero cuando la variable no existe (todavía), pl supone que son parte de una cadena.


3
Sabía que había un lenguaje como este, pero no pude encontrarlo :(
Stephen

2
En la misma línea, vea Cat, que es un lenguaje interpretado como Python. La mayoría de las distribuciones de Linux modernas se entregan con un catintérprete. ;)
Quuxplusone

1
Esta solución también funciona para /// si considera que la entrada se agrega al código fuente del programa (ya que /// no tiene ningún mecanismo para la entrada). /// es uno de los muchos idiomas (creo) donde los caracteres alfanuméricos al comienzo del programa son simplemente de salida.
Tanner Swett

66
¿Puedes publicar la versión sin golf? ;)
maxathousand

17

brainfuck , 56 55 33 bytes

¡1 byte guardado gracias a Gravitron y 22 bytes guardados gracias a Jo King!

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

Pruébalo en línea!

La salida requiere un intérprete que se ajuste al desbordamiento de memoria y tenga EOI = 0. TIO tiene tal intérprete.

Explicación

--[>+<++++++]Inicializa la cinta con un sencillo +.

El bucle de entrada:

,[[->.<]>+++.--.-<,]
,                     take input
 [                ,]  while input is nonzero:
  [->.<]                  output `+` input times
        >+++.             output `.` (`+` + 3)
             --.          output `,` (`.` - 2)
                -<        restore `+` and move back to input

Otras soluciones

Cada línea es su propia solución.

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

1
+1. No conozco Brainfuck, pero no puedo imaginar tratar de resolver un problema como este con él.
Jakob

Puede guardar 1 byte reemplazando el +++++++++++++++con +++[>+++++<-]>(De las constantes brainfuck )
Graviton

@Graviton Oh, genial, gracias
Conor O'Brien

no lo reemplazaste en la explicación
Destructible Lemon

44
¿No sabes Brainfuck? Te enseñaré en un comentario! Comenzamos en una cinta de 0's, con un puntero a un valor. +incrementa el valor, -disminuye el valor, >mueve el puntero a la derecha, <mueve el puntero a la izquierda, ,lee la entrada al puntero como un carácter ASCII, .emite el valor del puntero como un carácter ASCII, [inicia un bucle y ]salta al correspondiente [si el El valor del puntero no lo es 0. Soy malo para explicar, pero así de fácil es Brainfuck. Y bonito golf Conor!
Zacharý

13

Mornington Crescent , 27640 bytes

Take Northern Line to Moorgate
Take Circle Line to Moorgate
Take Circle Line to Westminster
Take Circle Line to Hammersmith
Take Circle Line to Aldgate
Take Circle Line to Bank
Take Circle Line to Barbican
Take Circle Line to Victoria
Take Circle Line to Victoria
Take Victoria Line to Seven Sisters
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Bayswater
Take District Line to Barons Court
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Mile End
Take District Line to Cannon Street
Take Circle Line to Moorgate
Take Circle Line to Hammersmith
Take Circle Line to Cannon Street
Take Circle Line to Hammersmith
Take Circle Line to Cannon Street
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Mile End
Take District Line to Barking
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Bakerloo Line to Paddington
Take Circle Line to Royal Oak
Take Circle Line to Tower Hill
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Mile End
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Bank
Take Circle Line to Baker Street
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Baker Street
Take Circle Line to Bank
Take Circle Line to Bank
Take District Line to Barking
Take District Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Liverpool Street
Take Circle Line to Bank
Take District Line to Barking
Take District Line to Bank
Take District Line to Gunnersbury
Take District Line to Upminster
Take District Line to East Ham
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Sloane Square
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take Circle Line to Cannon Street
Take District Line to Gunnersbury
Take District Line to Mile End
Take District Line to East Ham
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Plaistow
Take District Line to Mile End
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take District Line to Barking
Take District Line to Bank
Take District Line to Barking
Take District Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Wood Lane
Take Circle Line to Liverpool Street
Take Circle Line to Bank
Take Circle Line to Liverpool Street
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take District Line to Barking
Take District Line to Bank
Take District Line to Barking
Take District Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Dagenham East
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Mile End
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Mile End
Take District Line to Victoria
Take Circle Line to Bank
Take Circle Line to Victoria
Take Circle Line to Hammersmith
Take District Line to Mile End
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Upminster
Take District Line to Mile End
Take Central Line to Bank
Take Circle Line to Victoria
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Wood Lane
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take District Line to Elm Park
Take District Line to Bank
Take Circle Line to Wood Lane
Take Circle Line to Bank
Take Circle Line to Bank
Take District Line to Barking
Take District Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take District Line to Barking
Take District Line to Bank
Take Circle Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Bank
Take Central Line to Northolt
Take Central Line to Bank
Take Circle Line to Bank
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Mile End
Take District Line to Barons Court
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take District Line to Upminster
Take District Line to Mile End
Take District Line to Wimbledon
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Wood Lane
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Tower Hill
Take Circle Line to Bank
Take Circle Line to Wood Lane
Take Circle Line to Bank
Take Circle Line to Bank
Take District Line to Barking
Take District Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take District Line to Barking
Take District Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Mile End
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Baker Street
Take Circle Line to Bank
Take Circle Line to Bank
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Bakerloo Line to Waterloo
Take Northern Line to Bank
Take Circle Line to Bank
Take Central Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Wood Lane
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Blackfriars
Take Circle Line to Bank
Take Circle Line to Wood Lane
Take Circle Line to Bank
Take District Line to Barking
Take District Line to Paddington
Take Circle Line to Bank
Take Circle Line to Victoria
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Victoria
Take Circle Line to Wood Lane
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Wood Lane
Take Circle Line to Bank
Take Circle Line to Paddington
Take Circle Line to Victoria
Take Circle Line to Victoria
Take Victoria Line to Euston
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Wood Lane
Take Circle Line to Paddington
Take Circle Line to Bank
Take Central Line to Northolt
Take Central Line to Bank
Take District Line to Southfields
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Baker Street
Take Circle Line to Bank
Take Circle Line to Bank
Take District Line to Upminster
Take District Line to Ravenscourt Park
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Mile End
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take District Line to Upminster
Take District Line to Mile End
Take Central Line to Bank
Take Circle Line to Bank
Take Northern Line to Old Street
Take Northern Line to Bank
Take Circle Line to Bank
Take District Line to Gunnersbury
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take District Line to Mile End
Take Central Line to Theydon Bois
Take Central Line to Mile End
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Bank
Take Northern Line to Old Street
Take Northern Line to Bank
Take Circle Line to Bank
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Mile End
Take District Line to Acton Town
Take Piccadilly Line to Cockfosters
Take Piccadilly Line to Acton Town
Take District Line to Acton Town
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Wood Lane
Take Circle Line to Paddington
Take Circle Line to Wood Lane
Take Circle Line to Bank
Take District Line to Elm Park
Take District Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bayswater
Take Circle Line to Paddington
Take Circle Line to Bayswater
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Aldgate
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bayswater
Take Circle Line to Bank
Take Circle Line to Aldgate
Take Circle Line to Bank
Take Circle Line to Bank
Take District Line to Barking
Take District Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bayswater
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bayswater
Take District Line to Barking
Take District Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Barbican
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Barbican
Take Circle Line to Bank
Take Circle Line to Bank
Take District Line to East Ham
Take District Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take District Line to Elm Park
Take District Line to Bank
Take Central Line to Chancery Lane
Take Central Line to Bank
Take Circle Line to Bank
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Bank
Take District Line to Plaistow
Take District Line to Bank
Take Circle Line to Hammersmith
Take District Line to Mile End
Take Central Line to Bank
Take Circle Line to Bank
Take Circle Line to Farringdon
Take Circle Line to Bank
Take Circle Line to Bank
Take Central Line to Mile End
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Bank
Take Northern Line to Brent Cross
Take Northern Line to Bank
Take Circle Line to Bank
Take Central Line to Mile End
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take Circle Line to Notting Hill Gate
Take Circle Line to Notting Hill Gate
Take District Line to Upminster
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Farringdon
Take Circle Line to Bank
Take Circle Line to Tower Hill
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Farringdon
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Farringdon
Take Circle Line to Bank
Take Circle Line to Bank
Take District Line to Southfields
Take District Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take District Line to Elm Park
Take District Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take District Line to Elm Park
Take District Line to Paddington
Take Circle Line to Blackfriars
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Royal Oak
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take District Line to Barons Court
Take District Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Blackfriars
Take Circle Line to Paddington
Take Circle Line to Blackfriars
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Royal Oak
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Farringdon
Take Circle Line to Paddington
Take Circle Line to Paddington
Take District Line to Southfields
Take District Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Embankment
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take District Line to East Ham
Take District Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Aldgate
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take District Line to East Ham
Take District Line to Bank
Take District Line to Barking
Take District Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Barbican
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take District Line to West Ham
Take District Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Aldgate
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take District Line to Barons Court
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Victoria
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Wood Lane
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Aldgate
Take Circle Line to Paddington
Take Circle Line to Aldgate
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take District Line to Barking
Take District Line to Paddington
Take Circle Line to Bank
Take District Line to Barking
Take District Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take District Line to Barking
Take District Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Moorgate
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Aldgate
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Central Line to Chancery Lane
Take Central Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take District Line to Barking
Take District Line to Paddington
Take Circle Line to Westminster
Take Circle Line to Paddington
Take District Line to Plaistow
Take District Line to Bank
Take Circle Line to Moorgate
Take Circle Line to Hammersmith
Take Circle Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Bank
Take Circle Line to Bank
Take Circle Line to Paddington
Take Circle Line to Westminster
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Aldgate
Take Circle Line to Temple
Take Circle Line to Hammersmith
Take District Line to Mile End
Take Central Line to Bank
Take Circle Line to Aldgate
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Bank
Take Circle Line to Westminster
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Mile End
Take Central Line to Bank
Take Circle Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Bank
Take Circle Line to Tower Hill
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take Circle Line to Notting Hill Gate
Take Circle Line to Notting Hill Gate
Take District Line to Upminster
Take District Line to Tower Hill
Take Circle Line to Bank
Take Circle Line to Temple
Take Circle Line to Bank
Take Circle Line to Bayswater
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Bayswater
Take Circle Line to Tower Hill
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take Circle Line to Notting Hill Gate
Take Circle Line to Notting Hill Gate
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Embankment
Take Circle Line to Hammersmith
Take Circle Line to Tower Hill
Take Circle Line to Bank
Take Circle Line to Embankment
Take Northern Line to Angel
Take Northern Line to Bank
Take Central Line to Marble Arch
Take Central Line to Bank
Take Circle Line to Bank
Take Circle Line to Westminster
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Aldgate
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Aldgate
Take Circle Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Mile End
Take Central Line to Bank
Take Circle Line to Aldgate
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Mile End
Take Central Line to Bank
Take Circle Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Bank
Take Circle Line to Tower Hill
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take Circle Line to Notting Hill Gate
Take Circle Line to Notting Hill Gate
Take District Line to Upminster
Take District Line to Embankment
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Piccadilly Line to Bounds Green
Take Piccadilly Line to Hammersmith
Take Circle Line to Embankment
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Cannon Street
Take Circle Line to Hammersmith
Take Circle Line to Cannon Street
Take District Line to Acton Town
Take District Line to Acton Town
Take Piccadilly Line to Bounds Green
Take Piccadilly Line to Holborn
Take Central Line to Holborn
Take Central Line to Bank
Take Circle Line to Hammersmith
Take District Line to West Ham
Take District Line to Bank
Take Circle Line to Aldgate
Take Circle Line to Aldgate
Take Metropolitan Line to Chalfont & Latimer
Take Metropolitan Line to King's Cross St. Pancras
Take Victoria Line to Seven Sisters
Take Victoria Line to Euston
Take Victoria Line to Euston
Take Northern Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Tower Hill
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Stepney Green
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Stepney Green
Take Hammersmith & City Line to Moorgate
Take Circle Line to Moorgate
Take Metropolitan Line to Chalfont & Latimer
Take Metropolitan Line to Moorgate
Take Circle Line to Moorgate
Take Circle Line to Bank
Take Circle Line to Bank
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Tower Hill
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take Piccadilly Line to Russell Square
Take Piccadilly Line to Russell Square
Take Piccadilly Line to Acton Town
Take District Line to Acton Town
Take District Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Bank
Take District Line to East Ham
Take District Line to Bank
Take Circle Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take District Line to East Ham
Take District Line to Tower Hill
Take Circle Line to Bank
Take District Line to West Ham
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Angel
Take Northern Line to Bank
Take Circle Line to Moorgate
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Barbican
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Moorgate
Take Circle Line to Bank
Take Northern Line to Morden
Take Northern Line to Bank
Take Circle Line to Bank
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Victoria
Take Victoria Line to Seven Sisters
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take District Line to Mile End
Take District Line to Embankment
Take Northern Line to Kennington
Take Northern Line to Bank
Take Circle Line to Bank
Take Central Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Liverpool Street
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Aldgate
Take Metropolitan Line to Croxley
Take Metropolitan Line to Aldgate
Take Circle Line to Aldgate
Take Circle Line to Bank
Take Circle Line to Bank
Take District Line to Gunnersbury
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take District Line to Gunnersbury
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to West Brompton
Take District Line to Gunnersbury
Take District Line to Mile End
Take District Line to Acton Town
Take District Line to Mile End
Take District Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Victoria
Take Victoria Line to Seven Sisters
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take District Line to Mile End
Take District Line to Acton Town
Take District Line to Acton Town
Take Piccadilly Line to Hounslow Central
Take Piccadilly Line to Acton Town
Take District Line to Acton Town
Take District Line to Mile End
Take District Line to Gunnersbury
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Gunnersbury
Take District Line to Paddington
Take Circle Line to Bank
Take Circle Line to Bank
Take Northern Line to Mornington Crescent

Pruébalo en línea!

Explicación

Primero, un repaso rápido en Mornington Crescent:

  • cada estación puede contener una cadena de longitud arbitraria o un bigint
  • También hay un acumulador que también contiene una cuerda o un bigint
  • todas las estaciones comienzan con su propio nombre como valor
  • Al principio, el acumulador contiene la entrada de su programa
  • Cada vez que va a una estación, el valor de la estación y el acumulador se intercambian
  • algunas estaciones son especiales y anulan este comportamiento
  • la línea que usas para llegar a una estación no importa
  • comienzas en Mornington Crescent
  • para finalizar el programa, también vas a Mornington Crescent
  • al final, se imprime el valor del acumulador

Dado que imprimir cadenas es difícil (consulte el programa "Hello, World!" De Martin Ender Mornington Crescent ), necesitaremos una plantilla simple que pueda usarse para generar cadenas genéricas. Como la duración de los programas generados no importa, me decidí por esto:

Take Northern Line to Bank
Take Northern Line to Bank
Take District Line to Paddington

Tendremos que generar cada carácter por separado y concatenarlos, ya que el enfoque de subcadena utilizado por Martin es mucho más difícil de implementar en el caso general. Paddington es la estación que realiza la concatenación de cadenas. Cuando llegas a Paddington, sucede lo siguiente:

accumulator, paddington = paddington + accumulator, accumulator

Este comportamiento se usa para inicializar Paddington en la cadena vacía que se supone que es la entrada.

Take District Line to Victoria
Take Victoria Line to Seven Sisters
Take Victoria Line to Euston
Take Victoria Line to Euston
Take Northern Line to Bank

Vaya a Seven Sisters, que establece el acumulador en 7, y guárdelo en el Banco. El Banco es la única forma de copiar valores: Hammersmith es una copia de solo lectura del valor del Banco.

Take District Line to Hammersmith
Take District Line to Cannon Street
Take District Line to Hammersmith
Take District Line to Cannon Street
Take District Line to Bank

Divide 7 entre 7 para obtener 1, un divisor de todos los valores ASCII que necesitamos admitir.

Take District Line to Hammersmith
Take District Line to Upminster

Para cada personaje, comience copiando el 1 en Upminster.

Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster

Agregue más si es necesario.

Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Bank
Take District Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Bakerloo Line to Paddington
Take Bakerloo Line to Paddington
Take Bakerloo Line to Charing Cross
Take Northern Line to Embankment

Termine yendo a Upminster solo una vez, para mantener el nuevo valor en el acumulador en lugar de almacenarlo nuevamente. Llévelo a Charing Cross para convertir el valor ASCII en un carácter y añádalo a la cadena. Las últimas dos líneas están allí porque he leído mal la especificación, por lo que me detendré aquí y comenzaré mi programa primero.


(descargo de responsabilidad: acabo de aprender este idioma) Sobre el mismo enfoque que se me ocurre (7/7 = 1). Pero, ¿por qué no configuras Upminister solo una vez al comienzo del programa?
user202729

@ user202729 ¿Cómo funcionaría eso? / Dato Take District Line to Upminster
curioso

Parece que entendí mal la especificación . Pero eso es exactamente lo que dice allí ... alguien necesita editar la wiki.
user202729


7

Carbón, 1 byte

θ

Por defecto, una cadena de caracteres ASCII ... ~simplemente se imprime, por lo que solo queda imprimir la entrada.


Iba a agregar esta misma respuesta. :-)
Charlie

@CarlosAlejo Bueno, no es como si hubiera una respuesta diferente ...
Neil

2
Bueno, hay : P
Solo ASCII

@ ASCII solo Touché!
Neil

6

C (gcc) , 89 87 58 56 bytes

¡Ahorré dos bytes gracias a Jakob!

main(a,c)char**c;{printf("main(){puts(\"%s\");}",c[1]);}

Pruébalo en línea!


"Debe poder manejar cualquier combinación de caracteres AZ, az y 0-9". Es posible que desee seguir con la estrategia de escape después de todo.
Jakob

@Jakob, sí, acabo de leer eso: /, gracias
Conor O'Brien

También acababa de terminar de escribir la expresión regular de escape para una solución Java cuando leí eso. Gorrón.
Jakob

@Jakob Sí, lo mismo para mí, pero con eacal. RIP
Conor O'Brien

Puede usar putsen el programa impreso para guardar 2 bytes, ¿verdad? ¿O es un problema que añada una nueva línea?
Jakob

5

Japt , 2 bytes

iQ

Pruébalo en línea!

ies una función que inserta una cadena especificada en un índice especificado en la entrada. Qes una variable que por defecto está entre comillas ", y dado que no hay un índice dado, esto por defecto es 0. El resultado final es una comilla insertada al comienzo de la cadena, que Japt finaliza automáticamente cuando se ejecuta.

Esto funciona en cadenas que contienen cualquier cosa ", excepto , {o \, aunque, por supuesto, la cadena está garantizada por caracteres alfanuméricos, por lo que esto no importa.



4

MATLAB / Octave , 15 bytes

@(t)['disp ',t]

Pruébalo en línea!

Pasé por alto por completo el hecho de que el programa solo necesita manejar caracteres alfanuméricos o, lo que es más importante, no necesita manejar caracteres de espacio. Esto significa que podemos usar la sintaxis de 'comando', que usa significativamente menos bytes.

MATLAB, 27 bytes

Para completar, aquí hay una versión que puede manejar entradas arbitrarias:

@(t)['disp(',mat2str(t),41]

Define una función anónima que toma la cadena ty la convierte al programa. Curiosamente, esto no funciona en Octave, que parece tener ideas diferentes de lo que mat2strdebería hacer.


No puedo probar esto, pero pienso: ¿ @(t)['disp ',mat2str(t)]debería funcionar ...?
Stewie Griffin

@StewieGriffin Eso no funciona porque mat2stragrega comillas, que no son necesarias en la sintaxis de comandos. Tenía la sintaxis de la función combinada mat2strpara manejar espacios en la entrada, pero al releer el desafío, eso no es realmente necesario, reduciendo el bytecount casi a la mitad. ¡Gracias!
Sanchises

Pensé que las comillas eran necesarias si había espacios en la entrada, pero podría estar equivocado. No me di cuenta de que la entrada era alfanumérica tampoco ...
Stewie Griffin


@StewieGriffin Tienes razón, calculé mal la forma en que funciona la sintaxis de comandos. Sin embargo, la sintaxis de comandos parece estar llena de sorpresas: ¡ Pruébelo en línea!
Sanchises

3

Befunge-98 (FBBI) , 21 16 12 bytes

-5 bytes gracias a NieDzejkob
-4 bytes gracias a Jo King

#,~'',,',,'@

Pruébalo en línea!

Salidas 't,'e,'s,'t,@para una entrada detest

¿Cómo?

Inicialmente, el puntero se mueve hacia el este:

#,           # skips the next instruction
  ~          push a byte of input
   '',       push ' and print it
      ,      print the byte of input
       ',,   push , and print it 
          '@ push @ to the stack

Si no queda más entrada, ~invierte la dirección del puntero:

 ,           print @
#            skip nothing
           @ terminate

3

Emojicode , 88 bytes

🐖😍➡️🔡🍇🍎🍪🔤🏁🍇😀❌🔤🔤🐕🔤❌🔤🍉🔤🍪🍉

Pruébalo en línea!

Entrada:

anyString

Salida:

🏁🍇😀🔤anyString🔤🍉

Salida de script:

anyString

2

QBIC , 7 bytes

?@?@`+;

Explicación

?           PRINT on the screen
 @  `       a literal
  ?@         question mark and at
     +;     and append the input

Ejecución de la muestra

Command line: lala
?@lala

El resultado es un literal de cadena que contiene la entrada, precedido por un PRINTcomando.


2

Lote de 11 bytes

Estoy seguro de que hay que hacerlo más pequeño, pero esto es bastante pequeño.

set/p=echo 

La caida:

set             ::Define new variable
   /p           ::Create prompt
     =          ::Define a variable in prompt
      echo      ::Prompt begins with 'echo '

En inglés:

Se le pide al usuario que ingrese una frase principal echo. Luego, el usuario puede escribir lo que sea, y el programa termina (por ejemplo, echo hello world!). Esto nos deja con un programa que, cuando se ejecuta, generará resultados hello world!.

Sí, se supone que el espacio en blanco debe estar allí


No sé lote (y esto es de hace mucho tiempo), pero esto se ve mal. ¿La echoporción no sería texto repetido en la consola y no salida del programa?
Jakob

@Jakob, supuestamente no, es esencialmente funcionalmente equivalente al ejemplo de Python dado en el desafío inicial.
Graviton

Vaya, lo que quise decir es que dudo que el programa muestre el texto que escribe el usuario. Probablemente solo se hizo eco en la consola, ¿verdad?
Jakob

@Jakob Right, que es equivalente a imprimir. El ejemplo imprime una función de impresión mientras que la mía echos una función de eco.
Graviton

OK, pero el ejemplo imprime todo el programa al estándar. Su programa imprime solo echo con salida estándar. De hecho, (supongo) si la entrada proviene de un archivo o una tubería, todo lo que vería es el aviso. ¿Se ha permitido ese tipo de salida?
Jakob

2

V, 2 bytes

ii

En Vim, icambia al modo de inserción y permite insertar texto. En este caso, solo inserta idelante del texto de entrada (para crear el segundo programa). V es compatible con Vim, pero agrega un implícito <esc>al final del programa, así que no necesito preocuparme por eso aquí.


2

PowerShell, 9 bytes

"'$args'"

las comillas simples o dobles en powershell se pueden usar para contener cadenas, pero solo las comillas dobles permiten la expansión variable.

con una entrada de fooesta salida, 'foo'que es un programa de PowerShell válidofoo


2

Cúbicamente , 87 bytes

U3D1R3L1F3B1U1D3~:7+1(-1@3(-1%1)6:1+3111@6%1-31111+004@6:1+11111%6:1+45@6:1-1%6~:7+1)6 

Pruébalo en línea!

Un puerto de mi respuesta aquí . Ya existía un desafío para tomar entrada y salida Código cúbico que producía esa entrada, y tenía una respuesta en Cubically así que ... ¿ganancia?


Guarde algunos bytes: elimine los argumentos de %6sy @6s; ahora pueden llamarse implícitamente. (También puede hacerlo en su respuesta en el hilo del cubificador).
MD XF



1

SOGL V0.12 , 2 bytes

$+

Pruébalo aquí! (espera entrada en la pila, por lo que ,se agrega para facilitar su uso)

$empuja , +une eso después de la entrada en la pila.


Puede usar `" `para ".
NoOneIsHere

@NoOneIsHere sí, eso tiene sentido ... Lo usé en todas partes excepto donde es más útil .-.
dzaima

1

Perl 6 , 19 bytes

say "say "~get.perl

Intentalo

Esto debería funcionar para cualquier entrada Unicode en NFC


¿Puedes quitar el espacio?
NoOneIsHere

@NoOneIsHere Eliminar cualquiera de los espacios daría como resultado un error de dos términos seguidos. Perl 6 tiene un espacio en blanco significativo, pero solo es significativo porque tiene que estar allí o no. (Sin embargo, hay formas de optar por no participar)
Brad Gilbert b2gills

1

8 , 34 37 bytes

Código

: f >s "\"" tuck s:+ s:+ " ." s:+ . ;

Ejemplo

ok> "Print 42" f
"Print 42" .
ok> "Print 42" .
Print 42

1

PHP , 12 bytes

<?=$argv[1];

Pruébalo en línea!

Esto se debe ejecutar desde la línea de comandos con la entrada como argumento de parámetro. Y sí, simplemente genera la cadena de entrada, pero eso es PHP válido: cualquier cosa fuera de los <?php ?>delimitadores se genera sin procesar.

Aquí está el script producido por la entrada 'testing123' en acción como demostración: ¡ Pruébelo en línea!


1
esto no funcionará del todo bien si la cadena de entrada contiene <?php, fíjate;)
Andrea

@Andrea Lea la pregunta: "Debe poder manejar cualquier combinación de caracteres AZ, az y 0-9". Entonces '<? Php' es una entrada no válida ...
WebSmithery

1
aw, eso es demasiado fácil :(
Andrea

1

MATL , 2 bytes

&D

Pruébalo en línea!

Simplemente envuelve la cadena entre comillas usando &D, que es el equivalente de MATL a MATLAB mat2str, una función específicamente hecha para hacer algo que, cuando eval'd, dará la matriz original (o en este caso, cadena).

El 'programa' resultante es solo la cadena de entrada envuelta entre comillas, que por lo tanto se inserta en la pila y se muestra implícitamente.



1

Lote, 14 bytes

@echo @echo(%*

Funciona también para caracteres especiales si se citan usando "s en lugar de ^.


Quizás @echo.@echo.%*sería más correcto? La entrada podría estar potencialmente vacía.
Conor O'Brien

@ ConorO'Brien Bueno, no necesito el primero .porque nunca está vacío, y utilicé un (para el segundo caso porque es más confiable que ., pero gracias por las sugerencias de todos modos.
Neil

¡notario público! Simplemente me gusta la simetría entre el @echo.s lol
Conor O'Brien

1

Ly , 14 bytes

"\""&i"\"&o"&o

Pruébalo en línea!

Explicación

"\""&i"\"&o"&o

"\""           # push `"`
    &i         # take input
      "\"&o"   # push `"&o`
            &o # output stack
               # test -> "test"&o
               # "test"&o = push "test" and output stack


1

Brain-Flak , 92 68 bytes

-22 bytes gracias al asistente de trigo

Incluye +2 para -cr

{<>(((((()()()()()){}){}){})())<>{({}[()])<>((({}[()])()))<>}{}}<>

Pruébalo en línea!

# For every character
{

   # Put ")(" on the off stack
   <>(((((()()()()()){}){}){})())<>

   # for 0 to the ASCII value of this character
   {({}[()])

      # Replace the ")" with "(" and add "))"
      <>((({}[()])()))<>

   # End for
   }{}

# end for and switch to the off stack for printing (in reverse order because of -r)
}<>


1

Zanahoria , 1 byte

#

Cómo funciona

# //Takes the input and places it onto the string stack
  //This is then output implicitly

{input} //The next program then consists of the input string
        //This is then placed directly onto the string stack
        //Then output implicitly

Una alternativa, también a 1 byte es:

$

Esto funciona igual que el anterior pero solo toma la primera línea de entrada. Ver como entrada solo será [A-Za-z0-9]esto está bien.


Teniendo en cuenta que las especificaciones solo afirman que necesita manejar AZ, az y 0-9, ¿no es esto competitivo?
jkelm

@jkelm Debo haber perdido esa parte, entonces sí, esto está compitiendo.
TheLethalCoder

¿Funcionaría esto para la entrada 01?
un spaghetto

@quartata Creo que sí, ha pasado un tiempo desde que usé Carrot.
TheLethalCoder
Al usar nuestro sitio, usted reconoce que ha leído y comprende nuestra Política de Cookies y Política de Privacidad.
Licensed under cc by-sa 3.0 with attribution required.