To nie jest wyzwanie, ale pytanie, doszedłem do wniosku, że z tego powodu
Tematy niezwiązane z wyzwaniem, które są związane z rozwiązywaniem zagadek programistycznych lub szczególnym rodzajem wyzwania, są również na temat.
Teraz przejdź do pytania:
Czy można napisać kod JavaScript zawierający tylko 5 liter? JSFuck już to robi z 6 symbolami, !+[]()
ale zastanawiam się, czy !
postać jest potrzebna.
JSFuck działa z kombinacją rzutowania na ciąg znaków (przez dodanie pustej tablicy), rzutowania na liczbę (przez napisanie + na początku) i rzutowania na wartość logiczną przez negację. Na przykład:
[] \\ Empty array
+[] \\ Cast to number -> 0
!+[] \\ Negate -> true
!+[]+[] \\ Cast to string -> "true"
Z tego ciągu możemy wyodrębnić wszystkie litery za pomocą nawiasów kwadratowych z cyfrą w środku, a dowolną liczbę można utworzyć, dodając razem prawdę tyle razy.
W ten sposób można znaleźć wiele liter i połączyć je w łańcuchy. Najważniejszym ciągiem, który można utworzyć, jest "constructor"
to, że można go użyć do uzyskania Function
dowolnej funkcji, a tego obiektu można użyć do wykonania ciągów jako JavaScript:
[]["find"] \\ the function Array.prototype.find
[]["find"]["constructor"] \\ the Function object
[]["find"]["constructor"](string)() \\ same as eval(string)
Jak widać, !
ma 2 zastosowania tutaj:
- Tworzenie liczb w celu wybrania liter z ciągów znaków.
- Przesyłanie na boolean, aby uzyskać
"true"
i"false"
.
Pierwszy z tych 2 można również wykonać przy użyciu modułu ++
inkrementora, a nie bezpośrednio 0
, ale można go użyć na elementach wewnątrz tablicy:
+[] \\ 0
[+[]] \\ [0]
[+[]][+[]] \\ [0][0] -> 0
++[+[]][+[]] \\ ++[0][0]-> 1
++[[]][+[]] \\ also works because ++ casts to number
Dzięki temu wszystkie liczby można tworzyć bez !
.
Drugi jest trudniejszy. Znaczenie "true"
i "false"
leży w literach "r"
i "s"
, które oba pojawiają się w "constructor"
. Mam już znaleźć wszystkie kolejne litery "constructor"
za pomocą "undefined"
, "Infinity"
, "NaN"
i oddając funkcje ciągów.
Tak więc ostateczne pytanie: (jak) możesz tworzyć booleany, litery "r"
i "s"
JavaScript, używając tylko +[]()
?
List "l"
może również pomóc. Można go uzyskać w formie, null
ale nie udało mi się uzyskać tej wartości za pomocą tych 5 symboli. Można go na przykład użyć do otrzymania logicznych wartości, jeśli mamy już "s"
:
[]["includes"]() \\ false
[+[]]["includes"](+[]) \\ true
Pismo "l"
i "k"
razem daje dostęp do "r"
:
([]+[])["link"]() \\ "<a href="undefined"></a>"
Każdy sposób uzyskania wartości logicznej null
lub dowolnej litery r s l k
byłby bardzo przydatny!
Biblioteka tego, co mamy:
Array.prototype.find: [] [(([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + ( ++ [[]] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] Nieskończoność: + ((++ [[]] [+ []] + []) + (([] [[]] + []) [(++ [[]] [+ []]) + (+ + [[]] [+ []]) + (++ [[]] [+ []])]) + (++ [[]] [+ []] + []) + (+ []) + (+ []) + (+ [])) NaN: + [] [[]] nieokreślony: [][[]] 0: + [] 1: ++ [[]] [+ []] 2: (++ [[]] [+ []]) + (++ [[]] [+ []]) 3: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) 4: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[] ] [+ []]) 5: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[] ] [+ []]) + (++ [[]] [+ []]) 6: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) 7: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) 8: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) 9: (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) a: (+ [] [[]] + []) [++ [[]] [+ []]] c: ([] [(([[] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] d: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []])] e: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [ + []])] f: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [ + []]) + (++ [[]] [+ []])] i: ([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [ + []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] n: ([] [[]] + []) [++ [[]] [+ []]] o: ([] [(([[] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] t: (+ ((++ [[]] [+ []] + []) + (([] [[]] + []) [(++ [[]] [+ []]) + ( ++ [[]] [+ []]) + (++ [[]] [+ []])]) + (++ [[]] [+ []] + []) + (+ [] ) + (+ []) + (+ [])) + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ [] ])] u: ([] [[]] + []) [+ []] v: ([] [(([[] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]))] y: (+ ((++ [[]] [+ []] + []) + (([] [[]] + []) [(++ [[]] [+ []]) + ( ++ [[]] [+ []]) + (++ [[]] [+ []])]) + (++ [[]] [+ []] + []) + (+ [] ) + (+ []) + (+ [])) + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ [] ]) + (++ [[]] [+ []])] I: (+ ((++ [[]] [+ []] + []) + (([] [[]] + []) [(++ [[]] [+ []]) + ( ++ [[]] [+ []]) + (++ [[]] [+ []])]) + (++ [[]] [+ []] + []) + (+ [] ) + (+ []) + (+ [])) + []) [+ []] N: (+ [] [[]] + []) [+ []] „”: ([] [(([[] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (+ + [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + [ ]) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [+ (++ [[]] [+ [] ] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (+ + [[]] [+ []]) + (++ [[]] [+ []]))]] (: ([] [(([[] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [+ (++ [[]] [+ []] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]))]] ): ([] [(([[] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [+ (++ [[]] [+ []] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])))] {: ([] [(([[] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [+ (++ [[]] [+ []] + [] + ((++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])))] }: ([] [(([[] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + [] ) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [+ ((++ [[]] [+ [] ]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + [] + ((++ [[]] [+ []]) + ( ++ [[]] [+ []])))] .: (+ (++ [[]] [+ []] + [] + (++ [[]] [+ []]) + ([] [[]] + []) [(++ [ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] + (++ [[]] [+ [] ] + [] + (+ []) + (+ []))) + []) [++ [[]] [+ []]] ,:[[]] [([] [(([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + ( ++ [[]] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [(++ [[]] [+ [ ]]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] + ([] [(([] [[]] + []) [ (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [ + []])]) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + ( ++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[] ] + []) [++ [[]] [+ []]]) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [ []] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []] )] + ([] [[]] + []) [++ [[]] [+ []]] + ([] [(([] [[]] + []) [(++ [ ]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) ]) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[] ] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + (([] [[]] + []) [++ [[]] [+ []]]) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [ + []])])] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])] + (+ [] [[]] + []) [++ [[]] [+ []]] + (+ ((++ [[]] [+ []] + []) + (([] [[]] + []) [(++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []])]) + ( ++ [[]] [+ []] + []) + (+ []) + (+ []) + (+ [])) + []) [(++ [[]] [+ [] ]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[]] [+ []]) + (++ [[ ]] [+ []]) + (++ [[]] [+ []])]] ([[]]) + []
eval
2453 znaki window
.