Skip to main content
fixed link
Source Link
Edgex42
  • 1.4k
  • 1
  • 10
  • 12

Brain-Flak, 36 10 4242 30 bytes

(<>)<>{({}<>)<>({}<>)({}[{}]]<>){{}{}}{}<>}<> 

Outputs 0 if it is double speak, and nothing if it isn't

-12 bytes thanks to Nitrodon

How it works

(<>)  PushPushes 0 to the second stack <> Go Swaps back to the first stack { Begin Begins a loop that will run for everyuntil twothe charactersstack inis inputempty ({}<>)<>([{}<>]<>) PopPops the top two elementsitems fromoff of the first stack, and pushpushes themtheir difference to the second stack ({{}[{}])}{} Pop themIf the difference is zero, it gets popped and pushnothing theirhappens. difference {{}{}}{}If there difference is Popsone, everythe elementzero ofthat thewas stackput ifon itat isn'tthe zero.beginning Elsegets popped, onlyso popnothing will get outputted at the differenceend  <>} SwapSwaps back to the first stack } and restart the End loop <>  Swap to the second stack for output 

Try it Online!Try it Online!

Brain-Flak, 36 10 42 bytes

(<>)<>{({}<>)<>({}<>)({}[{}]){{}{}}{}<>}<> 

Outputs 0 if it is double speak, and nothing if it isn't

How it works

(<>)  Push 0 to the second stack <> Go back to the first stack { Begin a loop that will run for every two characters in input ({}<>)<>({}<>) Pop the top two elements from the first stack, and push them to the second ({}[{}]) Pop them and push their difference {{}{}}{} Pops every element of the stack if it isn't zero. Else, only pop the difference <>} Swap back to the first stack and restart the loop <>  Swap to the second stack for output 

Try it Online!

Brain-Flak, 36 10 42 30 bytes

(<>)<>{({}[{}]<>){{}{}}{}<>}<> 

Outputs 0 if it is double speak, and nothing if it isn't

-12 bytes thanks to Nitrodon

How it works

(<>) Pushes 0 to the second stack <> Swaps back to the first stack { Begins a loop that will run until the stack is empty ({}[{}]<>) Pops the top two items off of the first stack and pushes their difference to the second stack {{}{}}{} If the difference is zero, it gets popped and nothing happens. If there difference is one, the zero that was put on at the beginning gets popped, so nothing will get outputted at the end  <> Swaps back to the first stack }  End loop <> Swap to the second stack for output 

Try it Online!

Fixed rule violation and fixed link
Source Link
Edgex42
  • 1.4k
  • 1
  • 10
  • 12

Brain-Flak, 36 1010 42 bytes

(<>)<>{({}<>)<>({}<>)({}[{}]}){{}{}}{}<>}<> 

Outputs 0 if it is double speak, and a different numbernothing if it isn't

Turns out there is a much shorter solution that I missed, but this one is a lot harder to explain.

How it works

Basically the outermost brackets pushes the sum of all the elements inside of it to the stack. Inside of it, there is only one element, which is a loop. In Brain-Flak, loops evaluate to the sum of all of their runs, and inside that loops, it gets the difference of the top two elements of the stack and pops them. If it is double speak, the loop will always evaluate to zero, so it pushes 0 to the stack, but if it isn't double speak, it won't evaluate to zero at least once, making it falsey.

(<>) Push 0 to the second stack <> Go back to the first stack { Begin a loop that will run for every two characters in input ({}<>)<>({}<>) Pop the top two elements from the first stack, and push them to the second ({}[{}]) Pop them and push their difference {{}{}}{} Pops every element of the stack if it isn't zero. Else, only pop the difference <>} Swap back to the first stack and restart the loop <> Swap to the second stack for output 

Try it Online!Try it Online!

Brain-Flak, 36 10 bytes

({{}[{}]}) 

Outputs 0 if it is double speak, and a different number if it isn't

Turns out there is a much shorter solution that I missed, but this one is a lot harder to explain.

Basically the outermost brackets pushes the sum of all the elements inside of it to the stack. Inside of it, there is only one element, which is a loop. In Brain-Flak, loops evaluate to the sum of all of their runs, and inside that loops, it gets the difference of the top two elements of the stack and pops them. If it is double speak, the loop will always evaluate to zero, so it pushes 0 to the stack, but if it isn't double speak, it won't evaluate to zero at least once, making it falsey.

Try it Online!

Brain-Flak, 36 10 42 bytes

(<>)<>{({}<>)<>({}<>)({}[{}]){{}{}}{}<>}<> 

Outputs 0 if it is double speak, and nothing if it isn't

How it works

(<>) Push 0 to the second stack <> Go back to the first stack { Begin a loop that will run for every two characters in input ({}<>)<>({}<>) Pop the top two elements from the first stack, and push them to the second ({}[{}]) Pop them and push their difference {{}{}}{} Pops every element of the stack if it isn't zero. Else, only pop the difference <>} Swap back to the first stack and restart the loop <> Swap to the second stack for output 

Try it Online!

another typo
Source Link
Edgex42
  • 1.4k
  • 1
  • 10
  • 12

Brain-FlakBrain-Flak, 3636 10 bytes

(<>)<>{({}<>)<>({}<>)({}[{}]{})<>}<> 

Outputs 0 if it is double speak, and a different number if it isn't

Explanation

Turns out there is a much shorter solution that I missed, but this one is a lot harder to explain.

(<>)<> Pushes 0 to the second stack, then swaps back to the first { Begins a loop ({}<>)<>({}<>) Pop the top two stack values, and push them onto the second stack ({}[{}]{}) Adds the difference of the top two values of the stack to the 0 we pushed earlier. If any of the them aren't the same two letters, that 0 value will change and it won't be truthy anymore. <> Swaps back to first stack } End loop <> Swap to second stack to get output 

Basically the outermost brackets pushes the sum of all the elements inside of it to the stack. Inside of it, there is only one element, which is a loop. In Brain-Flak, loops evaluate to the sum of all of their runs, and inside that loops, it gets the difference of the top two elements of the stack and pops them. If it is double speak, the loop will always evaluate to zero, so it pushes 0 to the stack, but if it isn't double speak, it won't evaluate to zero at least once, making it falsey.

Try it Online!

Brain-Flak, 36 bytes

(<>)<>{({}<>)<>({}<>)({}[{}]{})<>}<> 

Outputs 0 if it is double speak, and a different number if it isn't

Explanation

(<>)<> Pushes 0 to the second stack, then swaps back to the first { Begins a loop ({}<>)<>({}<>) Pop the top two stack values, and push them onto the second stack ({}[{}]{}) Adds the difference of the top two values of the stack to the 0 we pushed earlier. If any of the them aren't the same two letters, that 0 value will change and it won't be truthy anymore. <> Swaps back to first stack } End loop <> Swap to second stack to get output 

Try it Online!

Brain-Flak, 36 10 bytes

({{}[{}]}) 

Outputs 0 if it is double speak, and a different number if it isn't

Turns out there is a much shorter solution that I missed, but this one is a lot harder to explain.

Basically the outermost brackets pushes the sum of all the elements inside of it to the stack. Inside of it, there is only one element, which is a loop. In Brain-Flak, loops evaluate to the sum of all of their runs, and inside that loops, it gets the difference of the top two elements of the stack and pops them. If it is double speak, the loop will always evaluate to zero, so it pushes 0 to the stack, but if it isn't double speak, it won't evaluate to zero at least once, making it falsey.

Try it Online!

Source Link
Edgex42
  • 1.4k
  • 1
  • 10
  • 12
Loading