Script que gera um script que imprime uma determinada entrada

29

Escreva um pedaço de código que aceite uma string como entrada e emita um pedaço de código no mesmo idioma que, quando executado, produzirá a string de entrada inicial.

Ele deve poder manipular qualquer combinação de caracteres AZ, az e 0-9.

Exemplo em Python:

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

Dada a entrada de testing123, ele retornará print('testing123').

Como esse é o , a resposta mais curta em bytes será vencedora.

Quartzico
fonte
Pode ser uma função?
totallyhuman
@manatwork (S), ele editou agora.
NoOneIsHere
A entrada deve ser uma sequência? Ou pode ser um número inteiro?
Shaggy
Deve ser capaz de lidar com entradas inteiras e de sequência.
Quartzic 13/08/19
2
Podemos gerar uma função de acordo com os padrões da meta?
JAD

Respostas:

28

pl , 0 bytes

Código:

Experimente online!

Explicação:

Um programa vazio em pl é simplesmente um programa de gato, produzindo exatamente o mesmo que a entrada.

Em pl, todos os caracteres ASCII são essencialmente variáveis, mas quando a variável ainda não existe, pl assume que eles fazem parte de uma string.

Adnan
fonte
3
Eu sabia que havia uma linguagem como essa, mas não consegui encontrá-la :(
Stephen
2
Na mesma linha, veja Cat, que é uma linguagem interpretada como Python. A maioria das distribuições Linux modernas é fornecida com um catintérprete. ;)
Quuxplusone 13/08/19
11
Essa solução também funciona para /// se você considerar que a entrada deve ser anexada ao código-fonte do programa (já que /// não possui mecanismo de entrada). /// é uma das muitas línguas (acho) em que caracteres alfanuméricos no início do programa são simplesmente gerados.
precisa saber é o seguinte
6
Você pode postar a versão ungolfed? ;)
maxathousand 15/08/19
17

brainfuck , 56 55 33 bytes

1 byte salvo graças ao Gravitron e 22 bytes salvos graças a Jo King!

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

Experimente online!

A saída requer um intérprete que agrupe no fluxo insuficiente de memória e tenha EOI = 0. O TIO possui um intérprete.

Explicação

--[>+<++++++]inicializa a fita com um único +.

O loop de entrada:

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

Outras soluções

Cada linha é sua própria solução.

+++[>+++++<-]>[>++++>+++<<-]>>-->,[[-<.>]<+++.---<.>>,]
--[>+<++++++],[[->.<]>+++.++++++++++++++++.-------------------<,]
++++++++++[>++++++>++++>++++<<<-]>>+++>++++++>,[[-<<.>>]<.<<.>>>,]
++++++++++[>++++++>++++>++++<<<-]>++>+++>++++++>,[[-<<.>>]<.<<.>>>,]
Conor O'Brien
fonte
11
+1. Não conheço Brainfuck, mas não consigo imaginar tentar resolver um problema como esse com ele.
Jakob
Você pode salvar 1 byte, substituindo o +++++++++++++++com +++[>+++++<-]>(De constantes brainfuck )
Graviton
@Graviton Oh, legal, graças
Conor O'Brien
você não substituí-lo na explicação
Destrutível Lemon
4
Você não conhece Brainfuck? Eu vou te ensinar em um comentário! Começamos com uma fita de 0's, com um ponteiro para um valor. +incrementa o valor, -diminui o valor, >move o ponteiro para a direita, <move o ponteiro para a esquerda, ,lê a entrada no ponteiro como um caractere ASCII, .gera o valor do ponteiro como um caractere ASCII, [inicia um loop e ]pula para o correspondente [se o O valor do ponteiro não é 0. Sou péssimo em explicar, mas é assim que Brainfuck é fácil. E bom golfe Conor!
Zachary
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

Experimente online!

Explicação

Primeiro, uma rápida atualização sobre Mornington Crescent:

  • cada estação pode conter uma corda de comprimento arbitrário ou um bigint
  • há também um acumulador que também contém uma corda ou um bigint
  • todas as estações começam com seu próprio nome como valor
  • no início, o acumulador contém a entrada do seu programa
  • cada vez que você vai a uma estação, o valor da estação e o acumulador são trocados
  • algumas estações são especiais e substituem esse comportamento
  • a linha que você usa para chegar a uma estação não importa
  • você começa em Mornington Crescent
  • para finalizar o programa, você também vai a Mornington Crescent
  • no final, o valor do acumulador é impresso

Como a impressão de strings é difícil (consulte o programa Mornington Crescent "Hello, World!" De Martin Ender ), precisaremos de um modelo simples que possa ser usado para gerar strings genéricos. Como a duração dos programas gerados não importa, decidi sobre isso:

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

Precisamos gerar cada caractere separadamente e concatená-los, pois a abordagem de substring usada por Martin é muito mais difícil de implementar no caso geral. Paddington é a estação que executa a concatenação de cadeias. Quando você chega a Paddington, acontece o seguinte:

accumulator, paddington = paddington + accumulator, accumulator

Esse comportamento é usado para inicializar Paddington na cadeia vazia que é considerada a 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

Vá para Seven Sisters, que define o acumulador como 7, e armazene-o no banco. O Banco é a única maneira de copiar valores - Hammersmith é uma cópia somente do valor do 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

Divida 7 por 7 para obter 1, um divisor de todos os valores ASCII que precisamos oferecer suporte.

Take District Line to Hammersmith
Take District Line to Upminster

Para cada personagem, comece copiando o 1 para 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

Adicione mais conforme necessário.

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

Conclua indo até Upminster apenas uma vez, para manter o novo valor no acumulador em vez de armazená-lo novamente. Vá para Charing Cross para transformar o valor ASCII em um caractere e anexá-lo à string. As duas últimas linhas estão lá porque eu li mal a especificação, então vou parar por aqui e jogar meu programa primeiro.

NieDzejkob
fonte
(aviso: acabei de aprender esse idioma) Sobre exatamente a mesma abordagem em que consigo pensar (7/7 = 1). Mas por que você não configura o Upminister apenas uma vez no início do programa?
user202729
@ user202729 Como isso funcionaria? / Fato de divertimento: repetida Take District Line to Upminsterlinhas calcular a sequência de Fibonacci
NieDzejkob
Parece que eu não entendi bem as especificações . Mas é exatamente o que diz lá ... alguém precisa editar o wiki.
usar o seguinte comando
7

Geléia , 1 byte

Woo builtins!

O interno desvaloriza a entrada.

Experimente online!

Um mais interessante:

⁾“”j

Une a sequência "" "" pela entrada.

Experimente online!

fireflame241
fonte
11
Para o segundo, acho que você pode fazer ”“;por -1.
Erik the Outgolfer
7

Carvão, 1 byte

θ

Por padrão, uma sequência de caracteres ASCII .. ~simplesmente se imprime, restando apenas imprimir a entrada.

Neil
fonte
Eu estava indo para adicionar esta mesma resposta. :-)
Charlie
@CarlosAlejo Bem, não é como se houvesse uma resposta diferente ...
Neil
2
Bem, existe : P
somente ASCII
@ Touché somente ASCII!
Neil
6

C (gcc) , 89 87 58 56 bytes

Economizou dois bytes graças a Jakob!

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

Experimente online!

Conor O'Brien
fonte
"Ele deve poder manipular qualquer combinação de caracteres AZ, az e 0-9." Você pode querer seguir a estratégia de escapes, afinal.
Jakob
@Jakob sim Acabei de ler que: /, graças
Conor O'Brien
Eu também tinha acabado de escrever o escaper regex para uma solução Java quando li isso. Vadio.
Jakob
@ Jakob Sim, o mesmo para mim, mas com eacal. RIP
Conor O'Brien
Você pode usar putsno programa impresso para economizar 2 bytes, certo? Ou é um problema que ele acrescenta uma nova linha?
Jakob
5

Japonês , 2 bytes

iQ

Experimente online!

ié uma função que insere uma sequência especificada em um índice especificado na entrada. Qé uma variável que tem como padrão aspas "e, como não há nenhum índice fornecido, esse padrão é 0. O resultado final é uma aspas inserida no início da string, que o Japt termina automaticamente ao executar.

Isso funciona em strings que contêm qualquer coisa ", exceto , {ou \, embora, é claro, é garantido que a string consiste em caracteres alfanuméricos, portanto isso não importa.

ETHproductions
fonte
4

Python 2 , 22 bytes

print'print%r'%input()

Experimente online!

totalmente humano
fonte
2
Uma solução alternativa de 22 bytes é print'print'+`input()`.
precisa saber é
Isso não funcionaria. inputem Python 2 é equivalente a eval(raw_input()). Portanto, tem que ser uma expressão pitônica para funcionar.
precisa saber é o seguinte
Sim, isso é permitido. --- Deixe-me encontrar a meta apropriada ...--- Aha, encontrei.
totallyhuman
4
21 bytes
LyricLy
4

MATLAB / oitava , 15 bytes

@(t)['disp ',t]

Experimente online!

Eu ignorei completamente o fato de que o programa só precisa manipular caracteres alfanuméricos ou, principalmente, não precisa manipular caracteres de espaço. Isso significa que podemos usar a sintaxe 'command', que usa significativamente menos bytes.

MATLAB, 27 bytes

Para completar, aqui está uma versão que pode lidar com entradas arbitrárias:

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

Define uma função anônima que pega a string te a converte no programa. Curiosamente, isso não funciona no Octave, que parece ter idéias diferentes do que mat2strdeve fazer.

Sanchises
fonte
Não posso testar isso, mas penso: @(t)['disp ',mat2str(t)]deve funcionar ...?
Stewie Griffin
@ StewieGriffin Isso não funciona porque mat2stradiciona aspas, que não são necessárias na sintaxe do comando. Eu tinha a sintaxe da função combinada mat2strpara lidar com espaços na entrada, mas, ao reler o desafio, isso não é realmente necessário, cortando o número de bytes quase pela metade. Obrigado!
Sanchises
Eu pensei que as aspas eram necessárias se houvesse espaços na entrada, mas eu poderia estar errado. Eu não percebi que a entrada foi de apenas alfanumérico ou ...
Stewie Griffin
Assim (não destruído).
Stewie Griffin
@ StewieGriffin Você está certo, julguei mal a maneira como a sintaxe de comando funciona. No entanto, a sintaxe do comando parece cheia de surpresas: Experimente online!
Sanchises
3

Befunge-98 (FBBI) , 21 16 12 bytes

-5 bytes graças a NieDzejkob
-4 bytes graças a Jo King

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

Experimente online!

Saídas 't,'e,'s,'t,@para uma entrada detest

Quão?

Inicialmente, o ponteiro se move para o leste:

#,           # 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 não houver mais entrada, ~inverta a direção do ponteiro:

 ,           print @
#            skip nothing
           @ terminate
ovs
fonte
3

Emojicode , 88 bytes

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

Experimente online!

Entrada:

anyString

Saída:

🏁🍇😀🔤anyString🔤🍉

Saída do script:

anyString
X1M4L
fonte
2

QBIC , 7 bytes

?@?@`+;

Explicação

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

Amostra de execução

Command line: lala
?@lala

A saída é uma literal de cadeia de caracteres que contém a entrada, precedida por um PRINTcomando.

steenbergh
fonte
2

Lote 11 bytes

Tenho certeza de que há distância para diminuí-lo, mas isso é bem pequeno.

set/p=echo 

O colapso:

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

Em inglês:

O usuário é solicitado a inserir uma frase inicial echo. Em seguida, o usuário pode digitar o que quer e o programa termina (por exemplo; echo hello world!). Isso nos deixa com um programa que, quando executado, será exibido hello world!.

Sim, o espaço em branco deve estar lá

Graviton
fonte
Não sei lote (e isso é de muito tempo atrás), mas isso parece errado. A echoparte não seria ecoada em texto no console e não seria programada?
19418 Jakob
@Jakob, supostamente não, é essencialmente funcionalmente equivalente ao exemplo de python dado no desafio inicial.
Graviton
Opa - o que eu quis dizer é que duvido que o programa envie o texto que o usuário digita. Provavelmente está ecoando no console, certo?
Jakob
@Jakob Right, que é equivalente à impressão. O exemplo imprime uma função de impressão enquanto o meu reproduz uma função de eco.
Graviton
OK, mas o exemplo imprime o programa inteiro na saída padrão. Seu programa imprime apenas echo na saída padrão. De fato, (presumo) se a entrada vier de um arquivo ou canal, tudo o que você verá é o prompt. Esse tipo de saída foi permitido?
19418 Jakob
2

V, 2 bytes

ii

No Vim, imuda para o modo de inserção e permite inserir texto. Nesse caso, apenas insere o itexto na frente do texto de entrada (para criar o segundo programa). V é compatível com Vim, mas adiciona um implícito <esc>ao final do programa, portanto não preciso me preocupar com isso aqui.

nmjcman101
fonte
2

PowerShell, 9 bytes

"'$args'"

aspas simples ou duplas no PowerShell podem ser usadas para conter cadeias de caracteres, mas apenas aspas duplas permitem expansão variável.

com uma entrada foodessa saída, 'foo'que é um programa válido do powershell que gerafoo

colsw
fonte
2

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

Experimente online!

Um porto da minha resposta aqui . Já existia um desafio para obter entrada e saída do código Cubically que produzia essa entrada, e eu tinha uma resposta no Cubically para ... lucro?

Kamil Drakari
fonte
Salve alguns bytes - remova os argumentos de %6s e @6s; agora eles podem ser chamados implicitamente. (Você também pode fazer isso em sua resposta no segmento cubifier.)
MD XF
2

D, 92 89 bytes

void main(){import std.stdio;write(`void main(){import std.stdio;"`~readln~`".write;}`);}

Experimente online!

Zacharý
fonte
2

Python 2 , 17 bytes

'print%r'.__mod__

Experimente online!

ovs
fonte
Isso falha para1
NoOneIsHere
2
@NoOneIsHere o desafio requer ter uma string como entrada. Se você passar '1'para a função, ela será print'1'
exibida
Oh, me desculpe. Eu não percebi isso.
NoOneIsHere
1

SOGL V0.12 , 2 bytes

$+

Experimente aqui! (espera entrada na pilha, por isso ,é adicionada para facilitar o uso)

$empurra , +junta-se a isso após a entrada na pilha.

dzaima
fonte
Você pode usar `" `para ".
NoOneIsHere 13/08
@NoOneIsHere sim, isso faz sentido .. Usou-o em qualquer outro lugar, exceto onde é o mais útil .-.
Dzaima 13/08
1

Perl 6 , 19 bytes

say "say "~get.perl

Tente

Isso deve funcionar para qualquer entrada Unicode na NFC

Brad Gilbert b2gills
fonte
Você pode remover o espaço?
NoOneIsHere
@NoOneIsHere A remoção de qualquer espaço resultaria em um erro de dois termos consecutivos. O Perl 6 possui um espaço em branco significativo, mas é significativo apenas porque precisa estar lá ou não estar lá. (existem maneiras de optar fora de ambos embora)
Brad Gilbert b2gills
1

8o , 34 37 bytes

Código

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

Exemplo

ok> "Print 42" f
"Print 42" .
ok> "Print 42" .
Print 42
Chaos Manor
fonte
1

PHP , 12 bytes

<?=$argv[1];

Experimente online!

Isso deve ser executado na linha de comando com a entrada como argumento do parâmetro. E sim, simplesmente gera a string de entrada - mas isso é PHP válido: qualquer coisa fora do<?php ?> delimitadores é processada sem saída.

Aqui está o script produzido pela entrada 'testing123' em ação como uma demonstração: Experimente online!

WebSmithery
fonte
11
isso não vai funcionar muito bem se a cadeia de entrada contém <?php, você mente;)
Andrea
@ Andrea Leia a pergunta: "Ele deve ser capaz de lidar com qualquer combinação de caracteres AZ, az e 0-9." So '<? Php' é uma entrada inválida ...
WebSmithery
11
aw, isso é muito fácil :(
Andrea
1

MATL , 2 bytes

&D

Experimente online!

Simplesmente envolve a string entre aspas usando &D, o que é equivalente ao MATL do MATLABmat2str , uma função especificamente criada para criar algo que, quando evald, fornecerá a matriz original (ou, nesse caso, string).

O 'programa' resultante é apenas a sequência de entrada entre aspas, que é empurrada na pilha e exibida implicitamente.

Sanchises
fonte
1

eacal , 38 bytes

strap string put string 
put strap arg

Experimente online!

Simplesmente anexa a sequência put stringà sequência de memória e depois o argumento, que é impresso.

Conor O'Brien
fonte
1

Lote, 14 bytes

@echo @echo(%*

Também funciona para caracteres especiais se forem citados usando "s em vez de ^.

Neil
fonte
Talvez @echo.@echo.%*seria mais correto? A entrada pode estar potencialmente vazia.
Conor O'Brien
@ ConorO'Brien Bem, eu não preciso do primeiro .porque nunca está vazio, e usei um (para o segundo caso, porque é mais confiável do que ., mas obrigado pelas sugestões de qualquer maneira!
Neil
np! Eu apenas gosto da simetria entre a @echo.s lol
Conor O'Brien
1

Ly , 14 bytes

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

Experimente online!

Explicação

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

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

Flacidez Cerebral , 92 68 bytes

-22 bytes graças ao Assistente de Trigo

Inclui +2 para -cr

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

Experimente 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)
}<>
Riley
fonte
1

Pitão , 2 1 byte

z

Experimente online!

Apenas gera a entrada. Requer seqüências de caracteres entre aspas.

-1 byte graças a KarlKastor

Ninguém está aqui
fonte
Você pode apenas fazer +\"? ( \xchar literal + implícito Q)
ETHproductions
@ETHproductions Ainda melhor,+N
NoOneIsHere 13/08
Bom, eu não conheço Pyth tão bem assim :-)
ETHproductions
1

Cenoura , 1 byte

#

Como 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

Uma alternativa, também com 1 byte, é:

$

Isso funciona da mesma forma que o acima, mas apenas leva a primeira linha de entrada. Vendo como entrada só será possível, [A-Za-z0-9]isso é bom.

TheLethalCoder
fonte
Considerando apenas as especificações que você precisa para lidar com AZ, az e 0-9, isso não está competindo?
jkelm
@ jkelm Devo ter perdido essa parte, então sim, isso está competindo.
TheLethalCoder
Isso funcionaria para entrada 01?
um Spaghetto
@ Quartata Eu acredito que sim, já faz um tempo desde que eu usei a Cenoura.
TheLethalCoder