-
Notifications
You must be signed in to change notification settings - Fork 0
/
equal.in
36 lines (36 loc) · 1.07 KB
/
equal.in
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
[+>]+>[+>] increase both strings and space in between
<[<]> to the start
include(copy.bf)
[>]>[>]< to the copy end
[[>>+<<-]<] shift the copy two cells right
>>>[>]< to the copy end
[-<]> subtract one to get initial strings
include(interleave.bf)
<<+>> set equality flag
TODO: Check the length inequality and shortcircuit to inequality case
[ equality bruteforce loop
[>-<-] subtract both first and second string characters
>[ if second string character nonzero (not equal)
[-]<<<[-]>>> kill second character and equality flag
]
>[[<<+>>-]>] shift the remaining contiguous part to the left
>[ if spreadout remains are there (cannot be equal then):
* destroy them
[>>]<<[[-]<<]
* destroy contiguous part
<<[[-]<]
* and kill equality flag
<[-]
* and get back to the "spreadout" part (now empty)
>>>>>
]
<<<<[<]> to the contiguous part
]
<<[<+>-] copy the equality flag closer
<< to the string
[ finalization loop
-[>>+<<-] subtract one from the string and copy it over the equality flag
>[<+>-] copy the equality flag closer
<< to the next char
]
> to the equality flag