-
-
Notifications
You must be signed in to change notification settings - Fork 359
Added brainfuck code and explanation for Euclidean Algorithm #463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
ok umm not quite sure how to fix the conflicts tbh ill try again maybe like tmr? |
I'll fix the conflicts once the code is reviewed. These are easy ones to fix on my end. I am still trying to wrap my head around BF, though. I want to do these reviews soon! |
0c91e8f
to
e8fdf02
Compare
I think @Trashtalk217 did a decent BF review last time. Can he also do this review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this review is going to take a while, I'm not done, I just wanted to give you something so there is no complete radio silence.
book.json
Outdated
}, | ||
{ | ||
"lang": "bf", | ||
"name": "brainfuck" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we already have brainfuck in book.jason
, put that can easily be fixed by resolving the conflict later.
book.json
Outdated
}, | ||
{ | ||
"lang": "bf", | ||
"name": "Brainfuck" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we already have brainfuck in book.jason
, but a conflict like this can easily be resolved.
book.json
Outdated
}, | ||
{ | ||
"lang": "bf", | ||
"name": "Brainfuck" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we already have brainfuck in book.jason
, but a conflict like this can easily be resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore this, Its double
@@ -0,0 +1,2 @@ | |||
,>,>>>+[[-]<<<<[->>>+<<<]>[->>>+<<<]>>[-<+<<+>>>]>[-<+<<+>>>]<<[->->[-]+<[>-]>[->>]<<<]>[>]<[<<[-]>>[-<<+>>>+<]]<[<<[-]>>[-<<+>>>>+<<]]>>>[-]+>[-]<<[>-]>[<<<<.>>>>->>]<<] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd first like to note it's really hard commenting on a onliner but I'll do my best: the second [-]
is unnecessary, I've never seen it called.
@@ -0,0 +1,2 @@ | |||
,>,>>>+[[-]<<<<[->>>+<<<]>[->>>+<<<]>>[-<+<<+>>>]>[-<+<<+>>>]<<[->->[-]+<[>-]>[->>]<<<]>[>]<[<<[-]>>[-<<+>>>+<]]<[<<[-]>>[-<<+>>>>+<<]]>>>[-]+>[-]<<[>-]>[<<<<.>>>>->>]<<] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just going to leave a nice indented version down below, so I can accuratly point some things out.
,>,
>>>+
[
[-]
<<<<
[->>>+<<<]
>
[->>>+<<<]
>>
[-<+<<+>>>]
>
[-<+<<+>>>]
<<
[
->->
**[-]**
+<
[>-]
>
[->>]
<<<
]
>
[>]
<
[
<<
[-]
>>
[-<<+>>>+<]
]
<
[
<<
[-]
>>
[-<<+>>>>+<<]
]
>>>
**[-]**
+
**>[-]<**
<
[>-]
>
[<<<<.>>>>->>]
<<
]
The parts I surrounded with ** I found to be unneeded. And I have been able to leave them away without much issue.
@@ -0,0 +1 @@ | |||
>,>,[<[>->+<[>]>[<+>-]<<[<]>-]>[-<+>]>[-<+<+>>]<]<. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3cf8c21
to
7372cd9
Compare
oh yes hi, updated the code&updated this branch |
@@ -209,6 +213,114 @@ and modulo method: | |||
[import, lang="LOLCODE"](code/lolcode/euclid.lol) | |||
{% sample lang="bash" %} | |||
[import, lang="bash"](code/bash/euclid.bash) | |||
{% sample lang="bf" %} | |||
#### Subtraction varient | |||
##### Code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with the code at this point. The code is as slim as it can be without having to redo the fundemantals. This leaves me with one final question, and that one is of style: What is your justification for writing your code as a one-liner and then a explanation in the md-file? We already have a brainfuck bubble sort and it is quiet different -> here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc there was a discussion in the discord chat about if to combine the explanation and code, and we agreed on removing all comments in the code to make it more 'brainfuck', i see if i can find that chat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#407 (comment)
So basically there was a discussion, also on discord iirc? and was like agreed to have the brainfuck code to have comments striped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the "source code" then commented version with my whitespace submission. I think it's best this way. Brainfuck is a joke language and the joke is more effective without comments, but then after you see the source code you want to know more and that's when the comments are nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just find the format we already have for the bubble sort bf more easy to read and review and it also keeps documentation and code in the same place, which I prefer. And when this PR is added we'll lose some concistency between chapters. Still, having a style guide for brainfuck code seams a bit ridiculous and if this is the way some other people already agreed on, I'm fine with that. In that case I will start reviewing the explanation part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait so do we want like
Brainfuck is a joke language and the joke is more effective without comments
& reformat prev code
or like same as previous pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jiegillet prefers the first and I prefer the latter. I've asked Leios what he thinks of it, he'll look at it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that the in-text code should be more BF-like; however, a commented version is also necessary (if possible). Both this chapter and bubble sort provide an adequate solution; however, I would argue that the bubble sort seems much easier to read when the two chapters are put side-by-side.
I think this ultimately boils down to a number of factors:
- a single line of BF code does not actually fit on the page when rendering online
- the explanation provided for this chapter is a bit hard to follow. Somehow the commented Bubble sort implementation is easier, even though it has less detail.
With other esoteric languages (like whitespace), the code was displayed as it would be seen in actually whitespace code, and then a heavily commented / modified version was put underneath. I think this is also a fine solution, but if we do that we need to make sure that the BF code actually fits into the AAA codebox.
I think the best solution is just to provide a heavily commented BF code sample with the explanation in-built. If that's not possible, the explanation at the end of the chapter is still useful, but should be rewritten (which I can help with). Sorry for all the extra work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I just rmbed why the commented code wasnt in the file
All the .,[]+- was screwing up the code
was kinda busy with like music and school so was afk the whole of nov:/ Not quite sure how well this explanation is but at least its slightly better
was kinda busy with like music and school so was afk the whole of nov:/ |
**Here, we subtract 1 from cell 2 from 3 until one of them hits 0, the other cell would be |a-b|** | ||
``` | ||
<< | ||
[->- subtracts a from b, assuming a>b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't a>b
actually affect the code execution here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that’s one of the reasons why I didn’t comment in the actual bf code, cuz .,<> are all affecting execution
Just so that multiple algos and langs dont get merged, there's another PR