Wynik
# # # # # ##### ## # ## #### ####### # # ## #### ## ## # ### ####### # # # # ##### ### # # # # ### ##### ##### # # # ####### ### # ### # ## #### ## # # ### # ####### ## # ## ##### ##### # # # ## # # # # ##### # ## ## ####### # ####### #### ## # ### ### # # # # # ##### # # # # ### ##### # #### ####### ### # ## ## ## # # ####### # # ## ##### # # # # ##### ## # # ####### # # ## ## ## # ### ####### #### # ##### ### # # # # ##### # # # # # ### ### # ## #### ####### # ####### ## ## # ##### # # # # ## # # # ##### ##### ## # ## ####### # ### # # ## #### ## # ### # ### ####### # # # ##### ##### ### # # # # ### ##### # # # # ####### ### # ## ## #### ## # # ####### #### ## # ## ##### # # # # # # ## #### # # # # ### ####### ## # # ## ##### ## # ### # # ## # ### ####### ##### ### # # # # # ## #### #### ## # # # # # # # # ##### ## #### ####### # #### ## ## # ### # # # # ##### # # ### ##### ##### # ####### ### # ### # ## ## # # ### # ####### # ## ##### ##### # # ## # # # ## ## ####### #### ### # # # # # # # # ### #### ####### ## ## # # # ##
Dozwolone spacje końcowe. Najkrótsze rozwiązanie wygrywa.
wskazówka 1:
dzięki @Tahg za poprawienie podpowiedzi 1
Odpowiedzi:
SOGL V0.12 ,
171614 bajtówWypróbuj tutaj!
W późniejszej aktualizacji
č▓
można usunąć dla 12 bajtów - które konwertują ToS z tablicy tablic znaków, ciąg wielowierszowy na tablicę ciągów -[["#","#"],[" ","#"]] -> ["##"," #"]
-, ponieważ┼
- dołączenie poziome - nie radzi sobie dobrze z tablicami tablic znaków - któreI
tworzy, ponieważ służy również do obracania tablicy. W SOGL tablica tablic znaków powinna być = tablica ciągów, ale wiele rzeczy jeszcze nie obsługuje…Wyjaśnienie:
źródło
JavaScript (ES6),
233217213198182170163122 bajtówEdycja: Zapisano
1418 bajtów dzięki @Shaggy. Zaoszczędzono 3 bajty dzięki @ngn. Oszczędność kolejnych 12 bajtów dzięki dwóm pracującym razem. Zaoszczędzono 41 bajtów, kradnąc obserwacje @ user202729, że ćwiartki używają odbić, a nie rotacji. Nie golfowany:źródło
f=
tutaj liczyć ? Nawiasem mówiąc, ładnie zrobione.f=
liczenia bajtów, ale fragment kodu nie działa bez niego.LOGO,
375341297295278 + 3 bajtyDodaj 3 bajty ze względu na
-p
flagę, która domyślnie włącza tryb perspektywy, więc nie trzeba uruchamiaćperspective
polecenia, oszczędza ogółem 9 bajtów.Użyj FMSLogo w systemie Windows z formatem nowej linii Unix (LF) (FMSLogo ma problem z analizowaniem formatu nowej linii CR)
Niestety nie ma „Wypróbuj online!” link, ponieważ nie mogę znaleźć trybu perspektywy wsparcia tłumacza online.
Pomysł: narysuj obraz obrazu, a następnie pobierz piksele z obrazu i wydrukuj jako dane wyjściowe.
Podział obrazu na proste powtarzające się części:
.
Skorzystaj z podpowiedzi powyżej. Ponieważ jednak LOGO nie obsługuje odbicia, możemy to tylko zasymulować, wchodząc w
perspective
tryb 3D ( ) i obracając żółwia o 180 stopni wokół osi równoległej do ekranu komputera.This defines a helper function
g
, which given 2 parametersl
(image side length) andw
(procedure used to draw the image), draw 3 copies of its reflected image. (see hint in the question) The procedureh
perform the main procedure.źródło
90 fd
->90fd
and save a few bytes.05AB1E,
3026 bytesTry it online!
źródło
CJam, 30 bytes
Try it online!
źródło
Python 2,
205195 ... 145144142144 bytesTry it online!
Inspired by Neil's JS answer.
źródło
n>>1
isn/=2
.a
is defined and then used once. Replacing its reference with its value could save four bytes.[...[x],...[x]][z]
selection.Haskell,
126125113106103 bytesA direct implementation of hint1 in the spoiler.
Function
m
generates the next iteration. The main functions appliesm
6 times. Details tom
:Edit: @ngn saved a byte and @Laikoni another 3. Thanks!
źródło
n$n$n$n$n$n["#"]
is shorter thaniterate n["#"]!!6
:)e=[]:e;foldr(zipWith(:))e
instead ofimport Data.List;transpose
and then shortenzipWith
.Java 7,
259 238 237200 bytesSaved 2 bytes by removing the {} on the x loop, thanks ngn
Saved 19 bytes from various assignment changes, thanks Jonathan
Saved 24 bytes for print vs return (didn't know this was allowed), and
Saved 13 bytes for loop changes, thanks Nevay
Try it online!
My first challenge, and I think respectable for Java. Uses hint 1, (which is wrong btw, but I can't write comments). It can probably be golfed further, this pass was basically as is, without pretty printing.
źródło
s=1
from your for loop and replacingint s,t,x,y;
withint s=1,t,x,y;
.n[s-1-y][x]=o[y][x];n[y][t-1-x]=o[y][x];
->n[s-1-y][x]=n[y][t-1-x]=o[y][x];
.J,
3027 bytesTry it online!
Original version.
Try it online!
źródło
Python 2, 586 bytes
Try it online.
Python 2,
10321025 bytesI like this one more. But it is much longer. It could be golfed down but there is no need for that. officialaimm's approach is much shorter.
-7 thanks to Jonathan Frech
Try it online.
źródło
[t]railing spaces
, though your solution omits some spaces.x=='!'
->x<'#'
if x.isdigit()
->if"/"<x<"@"
Mathematica,
11290 bytesThanks to Jonathan Frech for help saving 2 bytes!
Try it online! (Mathics)
For some reasons, Mathics prints leading spaces in all lines except the first one when print multiline string. Also Mathics doesn't support operator
.Explanation:
{{Reverse@#,Reverse/@#},{" "+0#,#}}
: Represent the reverse-horizontally, reverse-vertically, replace-all-by-" "
, and transpose (
is transpose operator in Mathematica), corresponding to different ways to reflect or rotate the image.~Flatten~{{1,3},{2,4}}
: Flatten in particular dimensions.Nest[ ... ,{{"#"}},6]
: Apply the function inside to{{"#"}}
6 times.~Riffle~"<literal newline character>"
: Riffle a newline character between each line.""<>
: Join all strings together.źródło
Reverse
withR
and defineR=Reverse;
to save two bytes.C# (.NET Core),
10161002980955 bytesSaved 14 bytes thanks to Kevin Cruijssen!
Saved 47 bytes thanks to Jonathan Frech!
Try it online!
Explanation
The format of the output is stored inside an array of signed 64-bit numbers, which fits perfectly since each line is 64 characters long. Empty spaces are represented by
0
and#
is represented by1
.The numbers are then converted to their binary string, zeros are padded left until the string is 64 characters wide and then the
and
0
and1
characters are replaced with#
.The code is stored inside a lamba function, more specifically a
System.Func<string>
.Some constants in the
long[]
are shortened by performing some bit-shifting.źródło
long[] n=new[]
?l
is not needed, you can probably save even more bytes.Charcoal, 42 bytes
Try it online! Link is to verbose version of code. Would be 25 bytes if this worked:
Explanation:
Manually generate the first recursion, since it's not possible to rotate around (1, 0.5). (Such a rotation would only make sense if it was 180°.)
Loop over the first five powers of 2 (1, 2, 4, 8, 16).
Reflect the canvas vertically. This completes the top left quarter of the result.
Rotate the canvas 180° around a point half-way up the right-hand side. The copy ends up in the correct position for the top right quarter of the result.
Rotate the canvas 90° around the bottom right corner. The copy of the top right corner ends up in the correct position for the bottom right corner of the result. The copy of the top left corner is extraneous.
Trim the canvas to the size we want. The trim starts at the cursor or the top left of the canvas, whichever is bottom rightmost. The cursor is therefore sent to (0, -1000) to ensure that it doesn't interfere with the trim.
źródło
Dyalog APL, 29 bytes
Try it online!
źródło
((⊖,⌽)⍪∊,⍉)⍣6⍪⍕#
with⎕ML←0
.Python 2,
715711 bytesTry it online!
źródło
Perl 5, 452 bytes
451 bytes code + 1 for
-p
.Packs all the data into the string, rather than stealing @Neil's correct answer.
Reversible output from
xxd
for 451 byte file:Try it online!
źródło
Jq 1.5,
538535488476 bytesThis is a straightforward representation.
I haven't attempted any fancy encodings yet.Replaced 0,0 pairs with Z function.Thanks again to Jonathan Frech for helping eliminate 3 bytes!
Character count
Sample run
źródło
B: rec
and16) as $l|
.if.==0then" "else"#"end
->if.>0then"#"else" "end
.Python 2,
174164154 bytes (based on matrix operations)Try it online!
źródło
import *
->import*
;in s.tolist()
->in s
Canvas, 10 bytes
Try it here!
źródło
JavaScript (Node.js), 1233 bytes
Try it online!
źródło
C# (.NET Core),
976969 bytesTry it online!
źródło
<s>969</s>
to cross out the previous bytes.C# (.NET Core), 739 bytes
Try it online!
Uses the same approach is this other answer.
źródło
K (ngn/k),
323127 bytesTry it online!
6{
}/
6 times do+x
transpose|x
reverse vertically+|+x
reverse horizontally,
concatenate vertically,'
concatenate horizontally,[A;B]
is the same asA,B
. it helps avoid parentheses aroundA
and around the whole expression""x
use the elements ofx
as indices in the empty string. out-of-bounds indexing produces spaces, so this expression will return an all-spaces matrix, same size asx
źródło