1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 | use std::fmt;
use std::fmt::{Display, Formatter};
#[derive(Debug, Default)]
struct One;
#[derive(Debug, Default)]
struct OneNotFlip;
#[derive(Debug, Default)]
struct Two;
#[derive(Debug, Default)]
struct List<T, U>(T, U);
#[derive(Debug, Default)]
struct State<T,U>(T, U);
impl Display for One {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "1")
}
}
impl Display for Two {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "2")
}
}
impl<T: Display, U: Display> Display for List<T, U> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}, {}", self.0, self.1)
}
}
trait Flip {
type O;
}
impl Flip for Two {
type O = One;
}
impl Flip for One {
type O = Two;
}
trait First {
type O;
}
impl<T, U> First for State<T, U> {
type O = T;
}
trait Prepend<T> {
type O;
}
impl<T> Prepend<T> for One {
type O = List<T, One>;
}
impl<T> Prepend<T> for Two {
type O = List<T, Two>;
}
impl<T, U: Prepend<T>, V> Prepend<T> for List<U, V> {
type O = List<<U as Prepend<T>>::O, V>;
}
trait Compute {
type O;
}
impl<T, U: Flip, V> Compute for State<List<T, U>, List<V, Two>>
where List<V, OneNotFlip>: Prepend<<U as Flip>::O> {
type O = State<List<List<T, U>, <U as Flip>::O>, <List<V, OneNotFlip> as Prepend<<U as Flip>::O>>::O>;
}
impl<T, U: Flip, V> Compute for State<List<T, U>, List<V, One>>
where V: Prepend<<U as Flip>::O> {
type O = State<List<List<T, U>, <U as Flip>::O>, <V as Prepend<<U as Flip>::O>>::O>;
}
impl<T, U: Flip, V> Compute for State<List<T, U>, List<V, OneNotFlip>>
where V: Prepend<U> {
type O = State<List<List<T, U>, U>, <V as Prepend<U>>::O>;
}
trait Do<N> {
type O;
}
impl<T> Do<()> for T {
type O = T;
}
impl<T, N> Do<(N,)> for T
where T: Do<N>,
<T as Do<N>>::O: Compute {
type O = <<T as Do<N>>::O as Compute>::O;
}
type Init = State<List<List<List<List<One, Two>, Two>, One>, One>, List<One, One>>;
type NinetyFive = ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),),);
type FinalState = <Init as Do<NinetyFive>>::O;
type Output = <FinalState as First>::O;
fn main() {
let x = <Output as Default>::default();
println!("{}", x)
}
|
i hate this. wow
post a comment