Script che genera uno script che stampa un determinato input


29

Scrivi un pezzo di codice che accetta una stringa come input e genera un pezzo di codice nella stessa lingua che, una volta eseguito, produrrà la stringa di input iniziale.

Deve essere in grado di gestire qualsiasi combinazione di caratteri AZ, az e 0-9.

Esempio in Python:

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

Dato l'ingresso di testing123, tornerà print('testing123').

Dato che si tratta di , vincerà la risposta più breve in byte.


Può essere una funzione?
totalmente umano il

@manatwork (S) l'ha modificato proprio ora.
NoOneIsHere

L'input deve essere una stringa? O può essere un numero intero?
Shaggy,

Deve essere in grado di gestire sia input di numeri interi sia stringhe.
Quarzico,

2
Possiamo generare una funzione secondo i defauts su meta?
JAD

Risposte:


28

pl , 0 byte

Codice:

Provalo online!

Spiegazione:

Un programma vuoto in pl è semplicemente un programma cat, che fornisce esattamente lo stesso input.

In pl, tutti i caratteri ASCII sono essenzialmente variabili, ma quando la variabile non esiste (ancora), si assume che facciano parte di una stringa.


3
Sapevo che c'era una lingua come questa, ma non riuscivo a trovarla però :(
Stephen

2
Allo stesso modo, vedi Cat, che è un linguaggio interpretato come Python. Le distribuzioni Linux più moderne vengono fornite con un catinterprete. ;)
Quuxplusone,

1
Questa soluzione funziona anche per /// se si considera che l'input viene aggiunto al codice sorgente del programma (poiché /// non ha alcun meccanismo per l'input). /// è una delle molte lingue (penso) in cui i caratteri alfanumerici all'inizio del programma vengono semplicemente emessi.
Tanner Swett,

6
Puoi pubblicare la versione non golfata? ;)
maxathousand

17

brainfuck , 56 55 33 byte

1 byte salvato grazie a Gravitron e 22 byte salvati grazie a Jo King!

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

Provalo online!

L'output richiede un interprete che esegue il wrapping sul underflow della memoria e ha EOI = 0. TIO ha un tale interprete.

Spiegazione

--[>+<++++++]inizializza il nastro con un singolo +.

Il ciclo di input:

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

Altre soluzioni

Ogni linea è la sua soluzione.

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

1
+1. Non conosco Brainfuck, ma non riesco a immaginare di provare a risolvere un problema come questo con esso.
Jakob,

Puoi salvare 1 byte sostituendo il +++++++++++++++con +++[>+++++<-]>(Da costanti brainfuck )
Graviton

@Graviton Oh, bello, grazie
Conor O'Brien,

non lo hai sostituito nella spiegazione
Destructible Lemon

4
Non conosci Brainfuck? Ti insegnerò in un commento! Iniziamo su un nastro di 0's, con un puntatore a un valore. +incrementa il valore, -decrementa il valore, >sposta il puntatore a destra, <sposta il puntatore a sinistra, ,legge l'input sul puntatore come carattere ASCII, .genera il valore del puntatore come carattere ASCII, [avvia un loop e ]passa al corrispondente [se il il valore del puntatore non lo è 0. Non sono bravo a spiegare, ma è così facile Brainfuck. E Nice golf Conor!
Zacharý,

13

Mornington Crescent , 27640 byte

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

Provalo online!

Spiegazione

Innanzitutto, un rapido aggiornamento su Mornington Crescent:

  • ogni stazione può contenere una stringa di lunghezza arbitraria o un bigint
  • c'è anche un accumulatore che contiene anche una stringa o un bigint
  • tutte le stazioni iniziano con il proprio nome come valore
  • all'inizio, l'accumulatore contiene l'input del tuo programma
  • ogni volta che vai in una stazione, il valore della stazione e l'accumulatore vengono scambiati
  • alcune stazioni sono speciali e ignorano questo comportamento
  • la linea che usi per raggiungere una stazione non ha importanza
  • si inizia a Mornington Crescent
  • per terminare il programma, vai anche a Mornington Crescent
  • alla fine, viene stampato il valore dell'accumulatore

Poiché la stampa di stringhe è difficile (vedere il programma "Hello, World!" Di Mornington Crescent di Martin Ender ), avremo bisogno di un modello semplice che possa essere utilizzato per produrre stringhe generiche. Dal momento che la lunghezza dei programmi generati non ha importanza, mi sono deciso su questo:

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

Dovremo generare ciascun personaggio separatamente e concatenarli, poiché l'approccio di sottostringa usato da Martin è molto più difficile da implementare nel caso generale. Paddington è la stazione che esegue la concatenazione di stringhe. Quando arrivi a Paddington, succede quanto segue:

accumulator, paddington = paddington + accumulator, accumulator

Questo comportamento viene utilizzato per inizializzare Paddington sulla stringa vuota che si presume sia l'input.

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

Vai a Seven Sisters, che imposta l'accumulatore su 7 e conservalo in banca. La banca è l'unico modo per copiare i valori: Hammersmith è una copia di sola lettura del valore della banca.

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

Dividi 7 per 7 per ottenere 1, un divisore di tutti i valori ASCII che dobbiamo supportare.

Take District Line to Hammersmith
Take District Line to Upminster

Per ogni personaggio, inizia copiando 1 in 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

Aggiungi altri se necessario.

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

Termina andando su Upminster solo una volta, per conservare il nuovo valore nell'accumulatore invece di memorizzarlo di nuovo. Portalo su Charing Cross per trasformare il valore ASCII in un carattere e aggiungerlo alla stringa. Le ultime due righe sono lì perché ho letto male le specifiche, quindi mi fermerò qui e golferò prima il mio programma.


(disclaimer: ho appena imparato questa lingua) Circa lo stesso identico approccio a cui riesco a pensare (7/7 = 1). Ma perché non impostare Upminister solo una volta all'inizio del programma?
user202729

@ user202729 Come funzionerebbe? / Take District Line to Upminster
Curiosità

Sembra che ho frainteso le specifiche . Ma è esattamente quello che dice lì ... qualcuno deve modificare il wiki.
user202729


7

Carbone, 1 byte

θ

Per impostazione predefinita, una stringa di caratteri ASCII .. ~stampa semplicemente se stessa, quindi non resta che stampare l'input.


Stavo per aggiungere questa stessa risposta. :-)
Charlie

@CarlosAlejo Beh, non è come se ci fosse una risposta diversa ...
Neil

2
Bene, c'è : P
ASCII il

@ Touché solo ASCII!
Neil,

6

C (gcc) , 89 87 58 56 byte

Hai salvato due byte grazie a Jakob!

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

Provalo online!


"Deve essere in grado di gestire qualsiasi combinazione di caratteri AZ, az e 0-9." Dopo tutto, potresti voler seguire la strategia delle fughe.
Jakob,

@Jakob sì, ho appena letto che: /, grazie
Conor O'Brien il

Avevo appena finito di scrivere il regex di escaper per una soluzione Java quando l'ho letto. Bummer.
Jakob,

@Jakob Sì, lo stesso per me, ma con eacal. RIP
Conor O'Brien,

È possibile utilizzare putsnel programma stampato per salvare 2 byte, giusto? O è un problema che si aggiunge a una nuova riga?
Jakob,

5

Japt , 2 byte

iQ

Provalo online!

iè una funzione che inserisce una stringa specificata in corrispondenza di un indice specificato nell'input. Qè una variabile che assume per impostazione predefinita un segno di virgolette "e, poiché non viene fornito alcun indice, per impostazione predefinita è 0. Il risultato finale è un segno di virgolette inserito all'inizio della stringa, che Japt termina automaticamente durante l'esecuzione.

Funziona su stringhe contenenti qualsiasi cosa tranne ", {o \, anche se ovviamente la stringa è garantita da caratteri alfanumerici, quindi non importa.



4

MATLAB / Ottava , 15 byte

@(t)['disp ',t]

Provalo online!

Ho completamente ignorato il fatto che il programma deve solo gestire caratteri alfanumerici o, soprattutto, non ha bisogno di gestire caratteri spaziali. Questo significa che possiamo usare la sintassi 'command', che usa significativamente meno byte.

MATLAB, 27 byte

Per completezza, ecco una versione in grado di gestire input arbitrari:

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

Definisce una funzione anonima che accetta la stringa te la converte nel programma. Curiosamente, questo non funziona in Octave, che sembra avere idee diverse su cosa mat2strdovrebbe fare.


Non posso provarlo, ma penso: @(t)['disp ',mat2str(t)]dovrebbe funzionare ...?
Stewie Griffin,

@StewieGriffin Non funziona perché mat2straggiunge le virgolette, che non sono necessarie nella sintassi dei comandi. Ho avuto la sintassi della funzione combinata con mat2strper gestire gli spazi nell'input, ma nel rileggere la sfida, questo non è effettivamente necessario, tagliando il conteggio dei conti quasi a metà. Grazie!
Sanchises,

Ho pensato che le virgolette fossero necessarie se ci fossero spazi nell'input ma potrei sbagliarmi. Non ho notato che l'ingresso era solo alfanumerico ...
Stewie Griffin,


@StewieGriffin Hai ragione, ho giudicato male il modo in cui funziona la sintassi dei comandi. Tuttavia, la sintassi dei comandi sembra essere piena di sorprese: provala online!
Sanchises,

3

Befunge-98 (FBBI) , 21 16 12 byte

-5 byte grazie a NieDzejkob
-4 byte grazie a Jo King

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

Provalo online!

Uscite 't,'e,'s,'t,@per un input ditest

Come?

Inizialmente il puntatore si sposta verso est:

#,           # 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

Se non è rimasto più input, ~inverte la direzione del puntatore:

 ,           print @
#            skip nothing
           @ terminate

3

Emojicode , 88 byte

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

Provalo online!

Ingresso:

anyString

Produzione:

🏁🍇😀🔤anyString🔤🍉

Output dello script:

anyString

2

QBIC , 7 byte

?@?@`+;

Spiegazione

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

Esecuzione del campione

Command line: lala
?@lala

L'output è una stringa letterale contenente l'input, preceduta da un PRINTcomando.


2

Lotto 11 byte

Sono sicuro che c'è via per ridurlo, ma questo è piuttosto piccolo.

set/p=echo 

La ripartizione:

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

In inglese:

All'utente viene chiesto di immettere una frase iniziale echo. Quindi l'utente può digitare qualunque cosa e il programma termina (es.; echo hello world!). Questo ci lascia con un programma che, una volta eseguito, verrà emesso hello world!.

Sì, lo spazio bianco dovrebbe essere lì


Non conosco batch (e questo è molto tempo fa), ma questo sembra sbagliato. La parte non echoverrebbe eco nella console e non l'output del programma?
Jakob,

@Jakob sorprendentemente no, è essenzialmente equivalente dal punto di vista funzionale all'esempio di pitone fornito nella sfida iniziale.
Graviton,

Oops - quello che volevo dire è che dubito che il programma produca il testo digitato dall'utente. Probabilmente ha appena fatto eco alla console, giusto?
Jakob,

@Jakob Right, che equivale alla stampa. L'esempio stampa una funzione di stampa mentre il mio echo una funzione di eco.
Graviton,

OK, ma l'esempio stampa l'intero programma allo standard. Il tuo programma stampa solo echo allo standard. In effetti, (presumo) se l'input proviene da un file o pipe, tutto ciò che vedresti è il prompt. È stato consentito questo tipo di output?
Jakob,

2

V, 2 byte

ii

In Vim, ipassa alla modalità di inserimento e consente l'inserimento di testo. In questo caso, inserisce solo il idavanti al testo di input (per creare il secondo programma). V è compatibile con Vim, ma aggiunge un implicito <esc>alla fine del programma, quindi non devo preoccuparmene qui.


2

PowerShell, 9 byte

"'$args'"

virgolette singole o doppie in PowerShell possono essere usate per contenere stringhe, ma solo le virgolette doppie consentono l'espansione variabile.

con un input di fooquesto verrà 'foo'generato che è un programma PowerShell valido che generafoo


2

Cubicamente , 87 byte

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 

Provalo online!

Una porta della mia risposta qui . Esisteva già una sfida per prendere input e output in codice cubico che ha prodotto quell'input, e ho avuto una risposta in Cubically quindi ... profitto?


Salva un paio di byte - rimuovere gli argomenti da %6s e @6s; ora possono essere chiamati implicitamente. (Puoi anche farlo sulla tua risposta sul thread del cubificatore.)
MD XF



1

SOGL V0.12 , 2 byte

$+

Provalo qui! (si aspetta input in pila, quindi ,viene aggiunto per facilità d'uso)

$spinge , +unisce questo dopo l'input nello stack.


Puoi usare "" `per ".
NoOneIsHere il

@NoOneIsHere sì, questo ha un senso .. Utilizzato ovunque altro tranne dove è il più utile .-.
dzaima,

1

Perl 6 , 19 byte

say "say "~get.perl

Provalo

Questo dovrebbe funzionare per qualsiasi input Unicode in NFC


Puoi rimuovere lo spazio?
NoOneIsHere

@NoOneIsHere La rimozione di entrambi gli spazi comporterebbe un errore di due termini in una riga. Perl 6 ha spazi bianchi significativi, ma è significativo solo in quanto deve essere presente o non essere presente. (ci sono modi per rinunciare a entrambi)
Brad Gilbert b2gills

1

8 ° , 34 37 byte

Codice

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

Esempio

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

1

PHP , 12 byte

<?=$argv[1];

Provalo online!

Questo deve essere eseguito dalla riga di comando con l'input come argomento parametro. E sì, genera semplicemente la stringa di input, ma questo è PHP valido: qualsiasi cosa al di fuori dei <?php ?>delimitatori viene emessa non elaborata.

Ecco lo script prodotto dall'input "testing123" in azione come dimostrazione: provalo online!


1
questo non funzionerà perfettamente se la stringa di input contiene <?php, sia chiaro;)
Andrea

@Andrea Leggi la domanda: "Deve essere in grado di gestire qualsiasi combinazione di caratteri AZ, az e 0-9." Quindi "<? Php" non è un input valido ...
WebSmithery il

1
aw, è troppo facile :(
Andrea,

1

MATL , 2 byte

&D

Provalo online!

Avvolge semplicemente la stringa tra virgolette usando &D, che è l'equivalente di MATLAB, MATLAB mat2str, una funzione appositamente creata per creare qualcosa che, quando evallo desse, darà la matrice originale (o in questo caso, stringa).

Il "programma" risultante è solo la stringa di input racchiusa tra virgolette, che viene quindi inserita nello stack e visualizzata implicitamente.


1

eacal , 38 byte

strap string put string 
put strap arg

Provalo online!

Aggiunge semplicemente la stringa put stringalla stringa di memoria, quindi aggiunge l'argomento, che viene stampato.


1

Lotto, 14 byte

@echo @echo(%*

Funziona anche con caratteri speciali se vengono citati usando "s anziché ^.


Forse @echo.@echo.%*sarebbe più corretto? L'input potrebbe essere potenzialmente vuoto.
Conor O'Brien,

@ ConorO'Brien Beh, non ho bisogno del primo .perché non è mai vuoto, e ho usato un (secondo caso perché è più affidabile di ., ma grazie comunque per i suggerimenti!
Neil,

np! Mi piace la simmetria tra il @echo.s lol
Conor O'Brien il

1

Ly , 14 byte

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

Provalo online!

Spiegazione

"\""&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 byte

-22 byte grazie a Wheat Wizard

Include +2 per -cr

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

Provalo online!

# 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

Carota , 1 byte

#

Come funziona

# //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

Un'alternativa, anche a 1 byte è:

$

Funziona come sopra ma accetta solo la prima riga di input. Visto che l'input sarà sempre e solo [A-Za-z0-9]questo va bene.


Considerando che le specifiche affermano solo che è necessario gestire AZ, az e 0-9, non è questo in competizione?
jkelm,

@jkelm Devo aver perso quella parte, quindi sì, questo è in competizione.
TheLethalCoder

Funzionerebbe per l'input 01?
uno spaghetto il

@quartata Credo di sì, è da un po 'che non uso Carrot.
TheLethalCoder
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.