Lienzo , 5 4 bytes

3

Lienzo , 5 4 bytes

║Q↷↷

Primera respuesta de Canvas, así que comencemos con una fácil. :)

-1 byte gracias a @dzaima .

Las barras inclinadas se convierten automáticamente al reflejar o girar en Canvas.
Podría haber sido 1 byte ( Pruébelo en línea ), pero desafortunadamente también transforma los puntos .en comillas simples 'cuando se refleja horizontalmente.

Pruébalo en línea.

Explicación:

         # (Take the multi-line input implicitly as canvas object)
        # Palindromize the canvas object (without overlap)
       # Output it with a trailing newline (without popping)
  ↷↷    # Rotated the canvas object that's still on the stack by 90 degrees twice
         # (and output it implicitly as well at the end)
Kevin Cruijssen
fuente

Respuestas:

2

Windows PowerShell, 99 103 117 126 129

filter x{$_-split'/'-replace'\\','/'-join'\'}$input|%{$_+-join($_[40..0]|x)}|%{$_
$s=,($_|x)+$s}
$s

Notas:

  • Desafortunadamente, esto necesita dos cosas en las que PowerShell es notoriamente malo mientras juega golf: invertir una cadena (o secuencia de valores) y transliterar cosas en una cadena. Estoy bastante seguro de que esto es al menos el doble que una solución Perl of Ruby.

Prueba:

> gc in| .\map.ps1
+------+
|./..\.|
|/....\|
|\..../|
|.\../.|
+------+

> gc in2
+\/
/\/
> gc in2| .\map.ps1
+\/\/+
/\/\/\
\/\/\/
+/\/\+

Historia

  • 2011-02-09 11:10 (129) - Primer intento.
  • 2011-02-09 11:27 (126): OFSpara guardar -joiny almacenar 99..0en una variable.
  • 2011-02-09 once y treinta y uno (117) - -replaceva en contra de las matrices, por lo que no necesito tres -replaces, pero puedo hacer una -split, -replace, -joinen su lugar.
  • 2011-02-09 15:03 (105) - En lugar de hacer lo mismo dos veces, hazlo una vez y revertirlo. Y poner una asignación entre paréntesis hace que escupe su valor en la tubería :-)
  • 2011-02-09 15:08 (103) - No necesito $amás ya 99..0que no se usa con tanta frecuencia por ahora.
  • 2011-02-09 15:17 (99) - No es necesario que haya espacios en blanco después de la filterdefinición. Se eliminó $xy, en su lugar, se recopiló cada línea durante la primera ejecución en una matriz y luego se emitió para la segunda mitad.
Joey
fuente
2

Ruby - 88 87 caracteres

t=->s{s.tr'/\\\\','\\\\/'}
puts a=$<.map{|l|l.chop!+t[l.reverse]}
puts a.reverse.map &t

Prueba de funcionamiento

D:\tmp>ruby cg_sym_map.rb < sym_map.in.
+------+
|./..\.|
|/....\|
|\..../|
|.\../.|
+------+
Wile E. Coyote
fuente
1
Bien, me gusta la asignación de put.
Ah, ahí está mi desaparición ;-) Sabía que llegaría eventualmente
Joey
2

Carbón , 5 4 bytes

S‖M⌈

-1 byte gracias a @Neil .

El carbón de leña se encarga automáticamente de reflejar las barras inclinadas correctamente.

Pruébelo en línea (detallado) o Pruébelo en línea (puro) .

Explicación:

Tome la entrada como una cadena:

InputString()
S

Refleje el espejo hacia la derecha y hacia abajo ( :⌈es una opción para :Right, :Down):

ReflectMirror(:⌈)
‖M⌈
Kevin Cruijssen
fuente
Desde entonces, @ ASCII-only ha agregado algunos más multidireccionales, incluido el que le da derecho y hacia abajo en un solo byte.
Neil
@Neil ¿Cómo se usa en el código detallado? :RightDownPor supuesto, no será el resultado que queremos.
Kevin Cruijssen
Los multidireccionales solo toman un :prefijo en modo detallado.
Neil
@Neil Entonces :Right:Down, ¿ ::RightDowno algo más? Sin embargo, ninguno de estos dos resultados dará un en la versión codificada con el -vlargumento. ¿Qué debería ser el código detallado para obtener S‖M⌈cuando se usa el -vlarg?
Kevin Cruijssen
ReflectMirror(:⌈)
Neil
1

Perl, 80 caracteres

print reverse map{s@.*@($b=$&)=~y:/\\:\\/:,$&.reverse$b@e;print;y@/\\@\\/@;$_}<>
ninjalj
fuente
1

Shell Scripting !!

#!/bin/sh

rm temp
touch temp
file=$1
for STRING in `cat $1`
do
   printf $STRING >> temp
   for ((COUNT=0; COUNT<${#STRING}; COUNT++))
   do
      RECORD[$COUNT]=${STRING:$COUNT:1}
   done
   for ((REV_COUNT=${#STRING}; REV_COUNT>=0; REV_COUNT--))
      do
        if [ "${RECORD[$REV_COUNT]}" = "\\" ]; then
            printf "/" >> temp
        elif [ "${RECORD[$REV_COUNT]}" = "/" ]; then
            printf "\\" >> temp
        else
           printf "${RECORD[$REV_COUNT]}" >> temp
        fi
      done
   echo >> temp
done
cat temp
tac temp > temp2
for STRING in `cat temp2`
do
   for ((COUNT=0; COUNT<${#STRING}; COUNT++))
   do
      RECORD[$COUNT]=${STRING:$COUNT:1}
   if [ "${RECORD[$COUNT]}" = "\\" ]; then
            printf "/"
   elif [ "${RECORD[$COUNT]}" = "/" ]; then
            printf "\\"
   else
           printf "${RECORD[$COUNT]}"
   fi
   done
echo
done

I / O

./solution in

+------+
|./..\.|
|/....\|
|\..../|
|.\../.|
+------+
Aman ZeeK Verma
fuente
1

CJam, 26 bytes

CJam es más nuevo que este desafío, por lo que esta respuesta no es elegible para la marca de verificación verde, pero de todos modos fue un ejercicio divertido

qN/{{_W%"\/"_W%er+}%z}2*N*

Pruébalo aquí.

Explicación

qN/{{_W%"\/"_W%er+}%z}2*N*
qN/                        "Read STDIN and split on newlines.";
   {                 }2*   "Execute this block twice.";
    {             }%       "Map this block onto each line.";
     _W%                   "Duplicate and reverse.";
        "\/"               "Push the string '\/'.";
            _W%            "Duplicate and reverse.";
               er          "Character transliteration, swaps slashes and backslashes.";
                 +         "Append to first half of the line.";
                    z      "Zip, i.e. transpose the map.";
                        N* "Join with newlines.";

La transposición al final lleva a que se realice el segundo giro a lo largo de las columnas. Al final, volvemos a transponer el mapa, por lo que terminamos con la orientación original.

Martin Ender
fuente
1

Powershell, 95 bytes

Inspirado por la respuesta de Joey .

filter x{$_;$_[40..0]|%{$_-split'/'-replace'\\','/'-join'\'}},($args|%{-join(,($_|% t*y)|x)})|x

Nota: 40porque el autor publica el comentario Let's say the input is at most 16 rows and 40 characters.

Script de prueba:

$f = {

filter x{$_;$_[40..0]|%{$_-split'/'-replace'\\','/'-join'\'}}
,($args|%{-join(,($_|% t*y)|x)})|x

}

@(
    ,( ("+---",
        "|./.",
        "|/.."),
        "+------+",
        "|./..\.|",
        "|/....\|",
        "|\..../|",
        "|.\../.|",
        "+------+")
    ,( ("+\/",
        "/\/"),
        "+\/\/+",
        "/\/\/\",
        "\/\/\/",
        "+/\/\+")
    ,( ("+---",
        "|...",
        "|..\"),
        "+------+",
        "|......|",
        "|..\/..|",
        "|../\..|",
        "|......|",
        "+------+")
) | % {
    $m,$expected = $_
    $result = &$f @m
    "$result"-eq"$expected"
    $result
}

Salida:

True
+------+
|./..\.|
|/....\|
|\..../|
|.\../.|
+------+
True
+\/\/+
/\/\/\
\/\/\/
+/\/\+
True
+------+
|......|
|..\/..|
|../\..|
|......|
+------+
mazzy
fuente
0

Rubí - 105

t=->s{s.tr '/\\\\','\\\\/'}
$<.read.split.map{|l|print l+=t[l.reverse]+"
"
l}.reverse.map{|l|print t[l]}
Arnaud Le Blanc
fuente
0

Golfscript - 44 caracteres

n%{.-1%'/'/{'\\'/'/'*}%'\\'*+}%.-1%{-1%}%+n*

resultado

$ cat in2
+-/|/\
/\|//-
$ cat in2 | golfscript codegolf-761.gs 
+-/|/\/\|\-+
/\|//--\\|/\
\/|\\--//|\/
+-\|\/\/|/-+

Otro script que solo funciona, por ejemplo, y no se voltea para '\' - 32 caracteres

n%{.-1%'/'/'\\'*+}%.-1%{-1%}%+n*

resultado

$ cat in
+---
|./.
|/..
$ cat in | golfscript codegolf-761.gs 
+------+
|./..\.|
|/....\|
|\..../|
|.\../.|
+------+
$ 

fuente
`\` también necesita ser volteado.
Nabb
@Nabb, gracias, eso hizo que mi código fuera enorme: P
TU
Marca: Use variables para cadenas repetidas si lo hace más corto. Aunque hay algunos otros trucos que puedes intentar resolver antes de publicar mi respuesta más tarde.
Nabb
@Nabb, gracias, intentaré averiguarlo y dejarme tener 30 minutos: D
@Nabb, todavía no puedo entender, puedes publicar el tuyo.
USTED
0

Haskell , 76 bytes

c '/'='\\';c '\\'='/';c x=x;i=(c<$>)
q#x=x++q(reverse x)
f=((i<$>)#).map(i#)

Pruébalo en línea!

-- Only / and \ get converted, all other chars are passed as is
c '/'='\\';c '\\'='/';c x=x

-- "Invert" the string (that is switch all / and \ in it)
-- Just map our conversion function over the string
i = (c<$>)

-- Helper: Concatenate a list with its reversed copy (with the given function applied to the copy)
q # x = x ++ q (reverse x)

-- the resulting function:
f = ((i<$>)#) . -- produce the lower half of the image by reversing the upper half and inverting slashes in each line
    map (i#) -- produce the upper half or the image (by concating each input line with its reversed, inverted version)
Max Yekhlakov
fuente
0

MS-SQL 2017, 243 bytes

entrada :

DECLARE @s VARCHAR (100) = '+ ---' + CHAR (10) + '| ...' + CHAR (10) + '| .. \';

comprimido :

declare @t TABLE (l INT IDENTITY (1,1), s CHAR (40)); INSERT INTO @t (s) SELECT value + TRANSLATE (REVERSE (value), '\ /', '/ \') FROM STRING_SPLIT (@ s, char (10)); SELECCIONAR s DE (SELECCIONAR l, s DE @t UNIÓN TODOS SELECCIONAR 1e3-l, TRADUCIR (s, '\ /', '/ \') DESDE @t) b ORDENAR POR l

legible por humanos :

declare @t TABLE (l INT IDENTITY (1,1), s CHAR (40));
INSERTAR EN @t (s)
  SELECCIONAR valor + TRADUCIR (REVERSO (valor), '\ /', '/ \')
  FROM STRING_SPLIT (@ s, char (10));

SELECCIONAR 
DESDE(
   SELECCIONE l, s DE @t 
   UNIÓN TODO 
   SELECCIONE 1e3-l, TRADUCIR (s, '\ /', '/ \') DESDE @t
  )si 
ORDEN POR l

salida (como texto en, por ejemplo, estudio de gestión):

+ ------ +                                
| ...... |                                
| .. \ / .. |                                
| ../ \ .. |                                
| ...... |                                
+ ------ +                                

(6 filas afectadas)
marcin f
fuente