« first day (488 days earlier)      last day (754 days later) » 

8:04 PM
@DJMcMayhem What was subtraction again?
(Brain-Flak)
 
There isn't any subtraction, but [...] negates ..., so you can implement subtraction pretty easily
 
Ok, let me do subtraction first.
 
Because everything inside of (...) is implicitly summed, so (a[b]) pushes a-b
 
... why:
3
8
5
@DJMcMayhem (()[])?
 
8:06 PM
I remember <> -> height, () -> one, {} -> pop what was [] again?
 
that's for pushing length of stack including itself
 
[] == stack height
 
ohh
wait what is <> then, 0?
 
<> == switch stack
 
wait right facekeyboard
 
8:07 PM
@Mr.Xcoder That's three seperate atoms (...) == push (...), () == 1, [] == stack height
 
@DJMcMayhem Why does (()[]) subtract but return the values on the stack too?
 
So that pushes stack-height + 1
@Mr.Xcoder Parentheses have different meanings depending on whether there is anything inside of them. [] by itself is a nilad
So you're pushing stack height + 1 (3). You got (un)lucky with your input choices lol
 
@Dj Please suggest me two inputs.
 
@Mr.Xcoder 5, 8 is fine, it's just the wrong program accidentally gave the right result.
Do you want me to tell you how to subtract, or do you want to figure it out with hints?
Also, this might be a better conversation in the third stack...
26 messages moved from The Nineteenth Byte
 
Ok... o/
 
8:11 PM
o/
 
(I'm curious, forgive me for lurking)
 
That's fine
 
Ok teach me how to negate a number...
Nvm...
 
So [...] evaluates to the negative of ... So [()()()] for example would evaluate to -3, but nothing is done with that value. ([()()()]) would push -3
 
@DJMcMayhem ([{}]) would negate the top of the stack, wouldn't it?
 
8:15 PM
Yep!
 
yes
though it doesn't always make sense to pop, negate, the push if you want to do something with the negated value
(but we can golf it after you've made a solution first :P)
 
But then how to add that to the other input?
 
@HyperNeutrino Yes, Push-Pop-Redundancy is hard to figure out (even for me still)
 
yup
@Mr.Xcoder things next to each other are implicitly summed
 
^
Which is why ()()() == 3
So {}{} evaluates to the sum of the top two elements, ({}{}) pushes that
 
8:18 PM
wait (({}){}) is the shortest way to double the top value right?
 
Yeah
 
I thought (([{}]){}) would work, but it does not...
 
@Mr.Xcoder That's really close, it just has a redundant push in it
 
see the problem is you're popping, negating, then pushing, and then popping that element off and adding it
 
You should pop two values and push one, that's popping two and pushing two
 
8:20 PM
so you're getting x => (x[-1] = -x[-1]) + x[-1]
 
([{}]){} doesn't do it either... Trying to comply to those advices
 
that's the wrong push to remove lol ;)
you want to pop and negate and then add that to the next element without pushing the first value back
 
Hooray!
([{}]{})
 
Yep!
 
yay
now you have the problem that two values were popped
 
8:22 PM
Actually that should be ({}[{}]), shouldn't it?
 
@Mr.Xcoder no because then you're subtracting the second element from the first but it's the other way around
 
ik.
 
@Mr.Xcoder One is a-b the other is b-a
 
@DJMcMayhem Ik.
> confusing-languages
lol
 
room topic changed to The Third Stack: A chat room for discussing the Brain-Flak programming language. Try it online: tio.run/#brain-flak Github link: github.com/DJMcMayhem/Brain-Flak [brain-flak] [confusing-languages] [scary-pencils] [what-does-my-code-do?]
 
8:23 PM
what is a scary pencil
 
@DJMcMayhem What should I do next?
 
So like HN said, you're losing the second value (b), so you won't be able to use it in the next loop
So you need a way to compute a-b while leaving b on the stack
 
So I should duplicate it?
 
(or b-a, I don't remember)
That's one way
So you could move 'a' over to the other stack so you can duplicate 'b', then move 'a' back over
That's the easiest way to understand, but it's not the shortest
 
Woah woah woah, take it easy.
 
8:25 PM
I found that harder to understand :I lol
 
Oh, haha
@Mr.Xcoder The other way is realizing that (...) evaluates to the same thing as ... So ((...)) pushes something twice
So how would you write a peek snippet? (evaluates to the top element without removing it)
 
Well I got it: ([{}]({}))
 
Exactly
 
Gives me:
-3
5
 
8:27 PM
you now need to loop it
 
Now you just need to wrap that in a loop
ninja'd
 
But first, @Mr.Xcoder Do you understand stack switching?
 
@DJMcMayhem Not really, no. I guess it's <> that just reverses the stack?
 
No, it switches
 
8:29 PM
What does that mean?
 
There are two stacks, and every operation does something to the active stack. <> toggles between the two
 
oh, I see. Can you give me an example?
 
So all input is loaded to the active stack at first, and then the alternate is empty. So something like <>(()()) will print 2 no matter what the input is
Because you're pushing 2 onto the (empty) alternate, so the input is irrelevant
 
cool.
 
And since (...) pushes to the active always, then ({}<>) will pull the top value off the active, and move it over to the alternate
 
8:31 PM
Ok. How should I go about looping?
 
It's also worth noting that <> evaluates to 0 so it doesn't affect chains of nilads.
 
@Mr.Xcoder {...} will run the code inside it until the top of the active stack is 0 (or empty)
It also evaluates all the code inside it, but that's a little more advanced and not needed for this task. But it's a really cool second approach to things
 
SO {([{}]({}))} wouldn't work.
... but why?...
 
well first of all, you need to move the deltas to the other stack because otherwise they interfere with your current calculations
 
@HyperNeutrino Ok, I switched to {<([{}]({}))>}. Next
 
8:34 PM
that doesn't work.
<...> evaluates ... and returns 0
 
No, that's the monad. <...> != <>
 
what you need to do is (...<>)<>, which evaluates stuff, switches, pushes, and switches back
 
oh
sweet. {(([{}]({}))<>)<>} still won't work though
 
so is the shortest way of pushing 0 just (<><>)
@Mr.Xcoder that doesn't work because it will stop whenever there's a 0 in the input
 
Or (<()>)
 
8:35 PM
ah cool
 
@Mr.Xcoder Since you're a beginner, you could assume the input doesn't contain 0's
That makes it much harder
@HyperNeutrino Sometimes (<>) works
 
(requires all sorts of stack-height weirdness lol)
@DJMcMayhem huh interesting. I guess that's only when you want to switch stacks right?
 
@DJMcMayhem Regardless of that, it still does not work.
 
What do you have?
What's it doing?
 
{(([{}]({}))<>)<>}
 
8:36 PM
oh right. that's pushing twice
 
let's see. {...} Loops right?
 
{([{}]({})<>)<>}
that was pushing to first stack, then swapping and pushing to second stack, then swapping back, so pushing to both stacks
 
Ok so now {([{}]({})<>)<>} gives me 0.
 
Your deltas are on the alternate. Toggle again
 
I know. Wait
Haha, {([{}]({})<>)<>}<>
 
8:38 PM
does that work?
 
Yes.
 
Well, technically you'll want a {} after that to get rid of the last difference
 
I'm wondering if this causes troubles with it exhausting the end of the stack which would give an extra value
 
Oh no sorry
 
And also, it reverses the deltas too
 
8:38 PM
(ninja'd :P)
@DJMcMayhem well my 36-byter does too :P
which I guess I could fix by just moving everything back to the other stack
 
Which is fortunately pretty easy, other than handling '0'
 
yup :P
 
@DJMcMayhem So I need to reverse the result of {([{}]({})<>)<>}<>{}?
 
Yeah. So another loop that toggles elements over
Which is either trivial (if you don't handle deltas of 0) or slightly difficult (if you do)
 
i'll pick the easy way, gtg in 2'
 
8:41 PM
I have 62 bytes as my final answer @DJMcMayhem
 
@HyperNeutrino For handling 0s?
 
Challenge accepted
 
handling 0s, and in the correct order
^^ :P
anyway gtg o/
 
@DJMcMayhem I thought {{([{}]({})<>)<>}<>{}{}} would work for reversing. Apparently I was wrong
 
So first off simplify
How do you move one item over?
 
8:44 PM
<>.
 
No, that toggles
 
I think I figured.
 
But it doesn't move anything
 
What did I do this time: {({([{}]({})<>)<>}<>{}<>)<>}<>?
@DJMcMayhem (...<>)<>.
 
@Mr.Xcoder Yes, and what you're trying to move is the top item on the stack {}
So ({}<>)<>
@HyperNeutrino I got it 58 (54 if we can assume there's always at least two inputs)
 
8:48 PM
@DJMcMayhem Is ({([{}]({})<>)<>}<>{}<>)<> correct?
 
For reversing or for the whole thing?
 
no it actually is identity with {([{}]({})<>)<>}<>{}
@DJMcMayhem reversing. but it ain't valid.
 
You only want one loop
 
huh
 
And the [{}] inside will mess it up because it removes multiple items
 
8:50 PM
ahh, I'd like to continue learning but I gtg now. Bye o/
 
See you
 
nvm back now
 
@HyperNeutrino Wanna see my solution?
I'm pretty sure it's optimal
 
sure!
 
8:52 PM
The trick is pushing should I keep looping values over in the first loop, not in the middle of the second
 
oh hm smart
 
9:09 PM
@DJMcMayhem I've never seen that trick before. It's genius.
 
:D
@Riley I'm glad to hear that, and that means a lot coming from you :)
 
I bet I have a bunch of answers that I could improve with that.
 
Brain-flak just passed 50 stars on github for the first time! \o/ \o/
4
@Riley I think I've used it before, but I can't remember where
 
9:28 PM
It only saved 2 bytes on one answer. I thought it would have been a lot more than that. It's too bad you can't search for brain-flak code.
 
0
A: Tips for Golfing in Brain-Flak

DJMcMayhemPush extra loop counters Frequently, you'll want to do something like Perform X operation on every element in the stack or Perform X operation on every pair of adjacent elements in the stack When the input may contain '0's, or the result of operation X may give a 0, this is really in...

@Riley Could you maybe save 2 more by combining the (()) with an existing ()? (No idea if that'll work, I haven't seen the answer in question)
 
This one. No, and I reverse the stack 4 times, but there is too much other stuff going on to do this more than once.
 

« first day (488 days earlier)      last day (754 days later) »