Add main.py solver
This commit is contained in:
parent
64dcb8fed4
commit
88ac4ce7dc
3 changed files with 2108 additions and 1766 deletions
3786
index.html
3786
index.html
File diff suppressed because it is too large
Load diff
18
main.py
Normal file
18
main.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import matplotlib.pyplot as plt
|
||||
|
||||
fig, axs = plt.subplots(5, 5)
|
||||
cnt = 0
|
||||
x = []
|
||||
y = []
|
||||
with open('index.html') as f:
|
||||
for l in f.readlines():
|
||||
if l.startswith('<div'):
|
||||
s = l.split(':')
|
||||
y.append(10 - int(float(s[3].split('px')[0]) / 50))
|
||||
x.append(int(float(s[4].split('px')[0]) / 50))
|
||||
cnt += 1
|
||||
if cnt % 80 == 0:
|
||||
axs[((cnt - 1) // 80) // 5, ((cnt - 1) // 80) % 5].scatter(x, y)
|
||||
x = []
|
||||
y = []
|
||||
plt.show()
|
70
main.rs
70
main.rs
|
@ -6,6 +6,34 @@ use std::fs::File;
|
|||
use std::io::Write;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
// From https://ascii.co.uk/art/anime
|
||||
let header = r#"
|
||||
db db
|
||||
dpqb dp8b
|
||||
8b qb_____dp_88
|
||||
88/ . `p
|
||||
q'. \
|
||||
.'. .-. ,-. `--.
|
||||
|. / 0 \ / 0 \ | \
|
||||
|: `.__ ___.' | \\/
|
||||
|. " | (
|
||||
\. `-'-' ,' |
|
||||
_/`------------'. .|
|
||||
/. \\::(::[];)||:. \
|
||||
/. ' \.`:;;;;'''/`. .|
|
||||
|. |/ `;--._.__/ |..|
|
||||
|: _/_,'''',,`. `:.'
|
||||
|. ` / , ',`. |/
|
||||
\. -'/\/ ',\ |\
|
||||
/\__-' /\ / ,: |.\
|
||||
/. .| ' /-. ,: |..\
|
||||
:. .| /| | , ,||: ..:
|
||||
|. .` | '//` ,:|: :|
|
||||
|.. .\ //\/ ,|: ..|
|
||||
\. .\ <./ ,'. ../
|
||||
\_ ,..`.__ _,..,._/
|
||||
`\|||/ `--'\|||/'"#;
|
||||
|
||||
let letters = HashMap::from([
|
||||
(
|
||||
'A',
|
||||
|
@ -129,8 +157,8 @@ fn main() -> std::io::Result<()> {
|
|||
"0000000000
|
||||
0001111000
|
||||
0010000100
|
||||
0100000000
|
||||
0111000000
|
||||
0010000000
|
||||
0011100000
|
||||
0000111000
|
||||
0000000100
|
||||
0010000100
|
||||
|
@ -161,6 +189,19 @@ fn main() -> std::io::Result<()> {
|
|||
0100000010
|
||||
0010000100
|
||||
0001111000
|
||||
0000000000",
|
||||
),
|
||||
(
|
||||
'1',
|
||||
"0000000000
|
||||
0000110000
|
||||
0001110000
|
||||
0010110000
|
||||
0000110000
|
||||
0000110000
|
||||
0000110000
|
||||
0000110000
|
||||
0001111000
|
||||
0000000000",
|
||||
),
|
||||
(
|
||||
|
@ -187,12 +228,26 @@ fn main() -> std::io::Result<()> {
|
|||
0111111110
|
||||
0000001000
|
||||
0000001000
|
||||
0000000000",
|
||||
),
|
||||
(
|
||||
'🙂',
|
||||
"0000000000
|
||||
0000000000
|
||||
0011001100
|
||||
0011001100
|
||||
0000000000
|
||||
0100000010
|
||||
0100000010
|
||||
0011001100
|
||||
0001111000
|
||||
0000000000",
|
||||
),
|
||||
]);
|
||||
let ans = "HAPPYAPRILFOOLSDAY2024";
|
||||
let mut file = File::create("index.html")?;
|
||||
let ans = "HAPPYAPRILFOOLSDAY202441🙂";
|
||||
let mut rng = thread_rng();
|
||||
let mut file = File::create("index.html")?;
|
||||
writeln!(file, "<!DOCTYPE html><!--{}-->", header)?;
|
||||
for c in ans.chars() {
|
||||
let letter = letters[&c].chars();
|
||||
let mut zeros = letter
|
||||
|
@ -201,12 +256,15 @@ fn main() -> std::io::Result<()> {
|
|||
.map(|(i, _)| i)
|
||||
.collect::<Vec<_>>();
|
||||
zeros.shuffle(&mut rng);
|
||||
let mut cnt = 0;
|
||||
for i in zeros {
|
||||
cnt += 1;
|
||||
writeln!(
|
||||
file,
|
||||
"<div style='color:white;position:absolute;top:{}px;left:{}px'>0</div>",
|
||||
"<div style='color:white;position:absolute;top:{}px;left:{}px'>{}</div>",
|
||||
((i / 11) as f32 + rng.gen_range(0.1..0.9)) * 50.0,
|
||||
((i % 11) as f32 + rng.gen_range(0.1..0.9)) * 50.0
|
||||
((i % 11) as f32 + rng.gen_range(0.1..0.9)) * 50.0,
|
||||
if cnt % 2 == 0 { "|" } else { "." }
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue