Skip to content

Commit

Permalink
add new css, new mappings and syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahCooperMQ committed Oct 15, 2024
1 parent 8e7e129 commit ec27f5d
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 151 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PyWTF `a-z()+`

PyWTF is an esoteric and educational programming style based on JSFuck and inspired by [this tweet](https://x.com/chordbug/status/1834642829919781369). It uses only built-in functions to execute code.
PyWTF is an esoteric and educational programming style based on JSFuck and inspired by [this tweet](https://x.com/chordbug/status/1834642829919781369). It uses only built-in functions to execute code. **It currently represents all characters below `0x7f` in 49 characters or less.**

It does not depend on a browser, so you can even run it with Python (to come).

Expand All @@ -13,11 +13,10 @@ By [@sealldev](https://twitter.com/sealldev) and [friends](https://github.com/se
The following source will do an `print(1)`:

```python
exec(chr(ord(str(int(not())+int(not())))+ord(next(reversed(str(object())))))+
next(iter(str(range(not()))))+chr(ord(str(int()))+ord(next(reversed(hex(ord(
max(str(bytearray()))))))))+chr(int(str(int(not()))+str(int(not()))+str(int()
)))+max(str(set()))+min(str(set()))+str(int(not()))+next(reversed(str(range(
not())))))
exec(chr(ord(max(oct(int())))+(not()))+max(str(range(
int())))+chr(sum(range(len(repr(str(set))))))+chr(max(
range(ord(max(oct(int()))))))+max(str(set))+min(str(set()
))+str(+(not()))+max(str(tuple())))
```

### Basics
Expand Down
104 changes: 26 additions & 78 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,80 +1,20 @@
<html>
<head>
<title>PyWTF - Write any Python with only built-in functions.</title>
<meta name="description" content="PyWTF is an esoteric and educational programming style based on JSFuck and inspired by this tweet. It uses only built-in functions to execute code.">
<meta name="description" content="PyWTF is an esoteric and educational programming style based on JSFuck and inspired by this tweet. It uses only built-in functions to execute code. It currently represents all characters below 0x7f in 49 characters or less.">
<meta charset="utf-8" />
<meta property="og:image" content="/preview.png" />
<meta name="viewport" content="width=device-width" />
<style>

body {
padding: 20px;
}

body, * {
font-family: monospace;
font-size: 14px;
line-height: 1.4em;
}

h1 {
font-size: 2em;
position: absolute;
top: 70px;
font-weight: normal;
left: 140px;
}

h2 {
width: 90px;
text-align: right;
padding: 50px 5px 5px;
background: #FFD43B;
color: #306998;
font-weight: bold;
font-size: 20px;
line-height: 1em;
}

h3 {
font-weight: bold;
}

p, li, textarea, .actions {
width: 100%;
max-width: 600px;
}

textarea {
display: block;
height: 200px;
margin: 1em 0;
}

ul.pre li{
white-space: pre;
}

.checkbox {
display: inline-block;
}

.actions a {
float: right;
}

.actions {
clear: both;
}

</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/vs2015.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
<style>body{padding:20px;background-color:#191919;color:white}*,body{font-family:monospace;font-size:14px;line-height:1.4em}h1{font-size:2em;position:absolute;top:70px;font-weight:normal;left:140px}h2{width:90px;text-align:right;padding:50px 5px 5px;background:#FFD43B;color:#306998;font-weight:bold;font-size:20px;line-height:1em}h3{font-weight:bold}.actions,li,p,textarea{width:100%;max-width:600px}textarea{display:block;height:200px;margin:1em 0}ul.pre li{white-space:pre}.checkbox{display:inline-block}.actions a{float:right}.actions{clear:both}code{color:#ffffff;font-family:monospace, monospace;padding:4px;border-radius:4px}textarea{background-color:#1e1e1e;color:white;font-family:'Courier New', Courier, monospace;border:1px solid #444;padding:10px;width:100%;height:200px;resize:none}pre{max-width:600px;overflow-wrap:break-word;white-space:pre-wrap;word-wrap:break-word;background-color:#1e1e1e;padding:10px;border-radius:5px}a:hover{color:#563ad2!important;border-bottom:1px solid #563ad2!important;text-decoration:none}a{color:#b18af8}</style>
</head>
<body>
<h1>PyWTF</h1>

<h2>()+<br>a-z</h2>

<p>PyWTF is an esoteric and educational programming style based on JSFuck and inspired by <a href="https://x.com/chordbug/status/1834642829919781369">this tweet</a>. It uses only built-in functions to execute code.</p>
<p>PyWTF is an esoteric and educational programming style based on JSFuck and inspired by <a href="https://x.com/chordbug/status/1834642829919781369">this tweet</a>. It uses only built-in functions to execute code. <b>It currently represents all characters below <code>0x7f</code> in 49 characters or less.</b></p>

<p>It does not depend on a browser, so you can run it with Python.</p>

Expand All @@ -86,9 +26,14 @@ <h2>()+<br>a-z</h2>
<textarea id="input" value="print('PyWTF')"></textarea>
<button id="encode" type="text">Encode</button>

<div class="checkbox">
<input id="autoencode" type="checkbox" checked/>
<label for="autoencode">Auto-encode</label>
</div>

<div class="checkbox">
<input id="eval" type="checkbox" checked />
<label for="eval">Eval Source</label>
<label for="eval">Wrap with <code>exec()</code></label>
</div>

<div class="checkbox">
Expand All @@ -98,13 +43,13 @@ <h2>()+<br>a-z</h2>

<div class="checkbox"></div>
<input id="astrix" type="checkbox" />
<label for="astrix">Allow for '*'s</label>
<label for="astrix">Allow for '*'s (currently useless)</label>
</div>

<textarea id="output"></textarea>
<pre><code id="output" class="python"></code></pre>
<div class="actions">
<span id="stats"></span>
<a id="run" href="#">Run This</a>
<!-- <a id="run" href="#">Run This</a> -->
</div>

<h3>Links</h3>
Expand Down Expand Up @@ -136,17 +81,20 @@ <h3>Basics</h3>
<script>
function encode(){
var output = replaceAndJoin($('input').value);
$("output").value = output;
$("output").innerHTML = output;
$("stats").innerHTML = output.length + " chars";
hljs.highlightAll();
}
function autoencode() {
$("input").oninput = $('autoencode').checked ? encode : "";
$("eval").onchange = $('autoencode').checked ? encode : "";
$("period").onchange = $('autoencode').checked ? encode : "";
$("astrix").onchange = $('autoencode').checked ? encode : "";
if ($('autoencode').checked) encode();
}

$("encode").onclick = encode;
$("eval").onchange = encode;
$("period").onchange = encode;
$("astrix").onchange = encode;
$("scope").onchange = encode;
$("input").onchange = encode;

$('autoencode').onclick = autoencode;
autoencode();
encode();
</script>
</body>
Expand Down
128 changes: 61 additions & 67 deletions pywtf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,133 +4,131 @@ function $(id){

const csvData = `0,chr(int())
1,chr(not())
2,chr(len(str(dict())))
2,chr((not())+(not()))
3,chr(len(hex(int())))
4,chr(len(str(not())))
5,chr(len(str(set())))
6,chr(len(str(complex(not()))))
6,chr(len(str(set()))+(not()))
7,chr(len(repr(str(set()))))
8,chr(len(bin(ord(str(int())))))
9,chr(len(repr(repr(chr(int())))))
10,min(str(credits))
11,chr(len(str(range(int()))))
12,chr(len(set(str(type(bytes())))))
13,chr(len(str(type(int()))))
14,chr(len(str(type(not()))))
15,chr(len(str(type(float()))))
16,chr(len(str(type(object()))))
17,chr(len(str(type(complex()))))
18,chr(len(str(type(reversed(str())))))
19,chr(len(repr(str(type(complex())))))
13,chr(len(str(set)))
14,chr(len(str(dict)))
15,chr(len(str(bytes)))
16,chr(len(str(object)))
17,chr(len(str(complex)))
18,chr(len(str(reversed)))
19,chr(len(str(reversed))+(not()))
20,chr(len(str(set(str(not())))))
21,chr(len(str(set(str(not()))))+int(not()))
21,chr(len(str(set(str(not()))))+(not()))
22,chr(len(str(type(iter(set())))))
23,chr(len(str(type(iter(set()))))+int(not()))
23,chr(len(str(bin)))
24,chr(len(str(type(iter(bytes())))))
25,chr(len(str(set(str(set())))))
25,chr(len(str(ascii)))
26,chr(len(str(type(iter(dict())))))
27,chr(len(str(type(iter(dict()))))+int(not()))
27,chr(len(str(type(iter(dict()))))+(not()))
28,chr(len(str(type(iter(str())))))
29,chr(max(range(len(str(zip())))))
30,chr(len(str(zip())))
31,chr(len(str(zip()))+int(not()))
29,chr(len(str(type(iter(str()))))+(not()))
30,chr(int(str(len(hex(int())))+str(int())))
31,chr(max(range(ord(min(str(range(int())))))))
32,min(str(range(int())))
33,chr(ord(min(str(range(not()))))+int(not()))
33,chr(ord(min(str(range(not()))))+(not()))
34,min(repr(repr(str())))
35,chr(len(str(reversed(str()))))
36,chr(len(str(reversed(str())))+int(not()))
37,chr(len(str(reversed(str())))+len(str(dict())))
38,chr(len(str(reversed(str())))+len(hex(int())))
36,chr(len(str(reversed(str())))+(not()))
37,chr(len(str(reversed(str())))+(not())+(not()))
38,chr(max(range(ord(max(repr(str()))))))
39,max(repr(str()))
40,min(str(set()))
41,max(str(tuple()))
42,chr(ord(max(str(tuple())))+int(not()))
43,chr(ord(max(str(tuple())))+len(str(dict())))
42,chr(ord(max(str(tuple())))+(not()))
43,chr(ord(max(str(tuple())))+(not())+(not()))
44,max(str(tuple(repr(str()))))
45,chr(sum(range(int(str(int(not()))+str(int())))))
45,chr(max(range(ord(min(str(float()))))))
46,min(str(float()))
47,chr(max(range(ord(str(int())))))
48,str(int())
49,str(int(not()))
50,str(len(str(dict())))
49,str(+(not()))
50,str((not())+(not()))
51,str(len(hex(int())))
52,str(len(str(not())))
53,str(len(str(set())))
54,str(len(str(complex(not()))))
55,max(str(ord(max(str(not())))))
56,max(str(ord(str(int()))))
57,max(str(ord(str(int(not())))))
57,max(str(ord(str(+(not())))))
58,chr(ord(str(int()))+ord(min(str(credits))))
59,chr(ord(str(int()))+len(str(range(int()))))
60,next(iter(str(object())))
60,next(iter(str(str)))
61,chr(ord(str(int()))+len(str(type(int()))))
62,next(reversed(str(object())))
62,next(reversed(str(str)))
63,chr(ord(str(int()))+len(str(type(float()))))
64,chr(ord(str(int()))+len(str(type(object()))))
65,chr(ord(str(int()))+len(str(type(complex()))))
66,chr(sum(range(len(set(str(type(bytes())))))))
67,next(iter(str(copyright)))
68,chr(ord(next(iter(str(copyright))))+int(not()))
69,chr(ord(max(repr(str())))+len(str(zip())))
70,min(str(not(not())))
71,chr(ord(next(iter(str(not(not())))))+int(not()))
72,chr(ord(min(str(not(not()))))+len(str(dict())))
68,chr(ord(next(iter(str(copyright))))+(not()))
69,chr(max(range(ord(min(str(()in()))))))
70,min(str(()in()))
71,chr(ord(min(str(()in())))+(not()))
72,chr(ord(min(str(()in())))+(not())+(not()))
73,chr(ord(str(int()))+len(str(set(str(set())))))
74,chr(ord(str(int()))+len(str(type(iter(dict())))))
75,chr(ord(min(str(not(not()))))+len(str(set())))
74,chr(ord(next(iter(str(str))))+len(str(dict)))
75,chr(ord(min(str(()in())))+len(str(set())))
76,chr(ord(str(int()))+len(str(type(iter(str())))))
77,chr(ord(str(int()))+max(range(len(str(zip())))))
78,chr(ord(str(int()))+len(str(zip())))
79,chr(ord(str(int()))+len(str(zip()))+int(not()))
77,chr(max(range(sum(range(len(str(set)))))))
78,chr(sum(range(len(str(set)))))
79,chr(sum(range(len(str(set))))+(not()))
80,chr(ord(min(str(set())))+ord(min(str(set()))))
81,chr(ord(max(str(tuple())))+ord(min(str(set()))))
82,chr(ord(str(int()))+ord(min(repr(repr(str())))))
81,chr(sum(range(len(str(set))))+len(hex(int())))
82,chr(sum(range(len(str(set))))+len(str(not())))
83,chr(max(range(ord(min(str(not()))))))
84,min(str(not()))
85,chr(ord(min(str(not())))+int(not()))
86,chr(ord(min(str(not())))+len(str(dict())))
85,chr(ord(min(str(not())))+(not()))
86,chr(ord(min(str(not())))+(not())+(not()))
87,chr(ord(min(str(not())))+len(hex(int())))
88,chr(ord(min(str(not())))+len(str(not())))
89,chr(ord(min(str(not())))+len(str(set())))
90,chr(ord(min(str(not())))+len(str(complex(not()))))
91,chr(ord(min(str(not())))+len(repr(str(set()))))
90,chr(max(range(sum(range(len(str(dict)))))))
91,chr(sum(range(len(str(dict)))))
92,max(repr(repr(repr(str()))))
93,chr(ord(max(repr(repr(repr(str())))))+int(not()))
93,chr(ord(max(repr(repr(repr(str())))))+(not()))
94,chr(ord(str(int()))+ord(min(str(float()))))
95,min(max(vars()))
96,chr(ord(min(min(locals())))+int(not()))
96,chr(ord(min(min(vars())))+(not()))
97,chr(max(range(ord(max(bin(int()))))))
98,max(bin(int()))
99,chr(ord(max(bin(int())))+int(not()))
99,chr(ord(max(bin(int())))+(not()))
100,next(reversed(hex(ord(max(str(dict()))))))
101,next(reversed(str(not())))
102,next(iter(str(frozenset())))
103,chr(ord(next(iter(str(frozenset()))))+int(not()))
104,chr(ord(max(bin(int())))+len(str(complex(not()))))
105,chr(ord(max(bin(int())))+len(repr(str(set()))))
103,chr(ord(next(iter(str(frozenset()))))+(not()))
104,chr(max(range(sum(range(len(repr(str(set))))))))
105,chr(sum(range(len(repr(str(set))))))
106,max(str(complex()))
107,chr(ord(max(str(complex())))+int(not()))
108,chr(ord(max(bin(int())))+ord(min(str(credits))))
109,chr(ord(max(bin(int())))+len(str(range(int()))))
107,chr(ord(max(str(complex())))+(not()))
108,chr(ord(max(str(complex())))+(not())+(not()))
109,chr(ord(max(str(complex())))+len(hex(int())))
110,chr(max(range(ord(max(oct(int()))))))
111,max(oct(int()))
112,chr(ord(max(oct(int())))+int(not()))
113,chr(ord(max(oct(int())))+len(str(dict())))
112,chr(ord(max(oct(int())))+(not()))
113,chr(ord(max(oct(int())))+(not())+(not()))
114,max(str(range(int())))
115,max(str(not(not())))
116,max(str(set()))
117,max(str(not()))
115,max(str(()in()))
116,max(str(set))
117,max(str(bin))
118,max(str(vars))
119,max(str(pow))
120,max(hex(int()))
121,max(str(credits))
122,max(str(zip))
123,min(str(dict()))
124,chr(ord(min(str(dict())))+int(not()))
124,chr(ord(min(str(dict())))+(not()))
125,max(str(dict()))
126,chr(ord(max(str(dict())))+int(not()))`;

const astrixData = `64,chr(ord(min(str(range(not()))))*(int(not())+int(not())))`;
126,chr(ord(max(str(dict())))+(not()))`;

const periodData = `66,max(str(bytes())).upper()
69,next(reversed(str(not()))).upper()
Expand All @@ -143,9 +141,7 @@ const periodData = `66,max(str(bytes())).upper()
87,max(str(pow)).upper()
88,max(str(object())).upper()
89,max(str(credits)).upper()
90,max(str(zip)).upper()
91,chr(ord(max(str(zip)).upper())+int(not()))
99,next(iter(str(copyright))).lower()`;
90,max(str(zip)).upper()`;

function mapCharacters(csvData) {
const charMap = {};
Expand All @@ -160,13 +156,11 @@ function mapCharacters(csvData) {
}

const charMapPeriod = mapCharacters(periodData);
const charMapAstrix = mapCharacters(astrixData);

function replaceAndJoin(input) {
const asciiValues = Array.from(input, char => char.charCodeAt(0));
let map = mapCharacters(csvData);
if($('period').checked) Object.assign(map, charMapPeriod);
if($('astrix').checked) Object.assign(map, charMapAstrix);
let out = asciiValues.map(char => map[char] || ` <COULDNT FIND ${char}> `).join('+');
return $('eval').checked ? `exec(${out})` : out;
}

0 comments on commit ec27f5d

Please sign in to comment.