text:
Generate A065825
(This is A065825.) The sequence defaults apply, so you can pick another format other than this one.
Given an input integer n, find the smallest number k so that there exists an n-item subset of {1,...,k} where no three items form an arithmetic progression.
Procedure
Here, we calculate A065825(9).
We assume you have already looped from 1 to 19, and k=20 (it's just an example).
1. Generate a range from 1 to k.
[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]

2. Pick n items from that sequence, following the original order of the sequence.
[1 2 6 7 9 14 15 18 20]

3. No 3 items form an arithmetic progression.
If a sequence has arithmetic progression, it basically means the sequence has the same step between every two consecutive items.
For example, the sequence of positive even numbers ([2 4 6 8 ...]) has a consistent step (i.e. 4-2=2, and 6-4=2, etc.), so it has arithmetic progression.
The Fibonacci sequence ([1 1 2 3 5 8 13 21 ...]) does not have arithmetic progression, since it does not have a consistent step. (3-2=1, 5-3=2, 8-5=3, etc.)
As an example, let's pick 3 items from our generated sequence.
[1 2 6 [7 9 14] 15 18 20]

The picked 3-item sequence does not have arithmetic progression, since the differences are respectively 9-7=2 and 14-9=5.
This has to apply to every 3-item pair:
[[1 2 6] 7 9 14 15 18 20] (2 -1 =1, 6 -2 =4)
[1 [2 6 7] 9 14 15 18 20] (6 -2 =4, 7 -6 =1)
[1 2 [6 7 9] 14 15 18 20] (7 -6 =1, 9 -7 =2)
[1 2 6 [7 9 14] 15 18 20] (9 -7 =2, 14-9 =5)
[1 2 6 7 [9 14 15] 18 20] (14-9 =5, 15-14=1)
[1 2 6 7 9 [14 15 18] 20] (15-14=1, 18-15=3)
[1 2 6 7 9 14 [15 18 20]] (18-15=3, 20-18=2)

Here are some examples of picking non-consecutive items from the output sequence:
[1 [2] 6 [7] 9 [14] 15 18 20] (7-2=5,14-7=7)
[[1] 2 6 [7] [9] 14 15 18 20] (7-1=6,9 -7=2)

If the above is satisfied for k, then k is a valid output for A065825(9).
Test cases
Here is a reference program I use to check my test cases.
n       a(n)
1       1
2       2
3       4
4       5
5       9
6       11
7       13
8       14
9       20

Since this sequence runs into performance issues really fast, it could be interesting to repost this question with a [fastest-code] tag. Either who beats the a(43) (highest n) currently on OEIS or who calculates a(n) fastest for a n somewhere in the n=25 to 35 range... Just a suggestion...

Jelly, 14 bytes
œcœc3IEƇƊÐḟð1#

A monadic Link accepting a non-negative integer which yields a non-negative integer.
Try it online! (Too inefficient for n=9 within 60s.) Or see the test-suite.
How?
œcœc3IEƇƊÐḟð1# - Link: integer, n
            1# - let k=n and count up to find the first k, for which this is truthy:
           ð   -   dyadic chain - i.e. f(k, n):
œc             -     combinations of length (n) of (implicit [1..k])
         Ðḟ    -     filter discard those n-tuples which are truthy under:
        Ɗ      -       last three links as a monad:
  œc3          -         combinations of length three of (the n-tuple)
     I         -         incremental differences - e.g. [3,6,8]->[6-3,8-6]->[3,2]
       Ƈ       -         filter keep those diffence-pairs which are truthy under:
      E        -           all equal?

Pyth, 17 bytes
ff!/#.OZ.cY3.cSTQ

Try it online!
.cSTQ: generate all list of numbers in the range [1,T] with length equal to the input.
.cY3: for each of those, generate all length 3 subsequences.
/#.OZ: filter for the subsequences where the average is a member of the list. These are the arithmetic progressions.
f!: filter for the original lists with no arithmetic progressions
f: find the lowest T where at least one list is found.

Python 3.8, 123 115 96 94 bytes
Another -15 -17 bytes thanks to Surcolose Sputum!
f=lambda n,k=1:len(d:=f'{k:b}')*all(k>>i&k&k<<i<1for i in range(d.count('1')//n,k))or f(n,k+1)

Try it online!

Python 2, 147 135 124 bytes
-11 bytes thanks to Surcolose Sputum!
from itertools import*
f=lambda n,k=1,C=combinations:k*any(all(a+c-b*2for a,b,c in C(w,3))for w in C(range(k),n))or f(n,k+1)

Try it online!

124 bytes as a recursive function

@SurculoseSputum thanks a lot. this looks really compact now.

Nice! Since we're already using bit masks, it'd be a shame not to take advantage of some more bit-wise operations. 100 bytes

@SurculoseSputum many thanks again. I tried to only use bitshifts and bitwise and but couldn't get there on my own.

No problem. Also I really like how you put the bit count as the start of range, using the fact that k&k<<i&k<<i*2<1 is false when i==0. Very clever!

Using k<<i&k&k>>i<1 instead saves 2 bytes. Try it online!

R, 96 83 bytes
k=n=scan();C=combn;`[`=Map;try(while(!any(all[diff[C[C(1:k,n,,F),3],1,2]]))k=k+1);k

Try it online!
Full program, returns 1-indexed member of the sequence. Very slow for n > 8.

05AB1E, 19 bytes
∞.ΔLI.Æε3.Æε¥Ë≠}P}à

Outputs the \$n^{th}\$ value \$k\$.
Try it online or verify the first 8 test cases (times out for \$\geq9\$).
Explanation:
∞.Δ                 # Find the first positive integer `k`
   L                # for which its list in the range [1,k]
    I.Æ             # with combinations of the input amount of elements
       ε         }à # contains any combination-list which is truthy for:
        3.Æ         #  When taking all 3-element combinations of the current list
           ε   }P   #  they are all truthy for:
            ¥       #   When taking the forward differences of both pairs in this triplet
             Ë≠     #   they are NOT the same
                    # (after which the resulting `k` is output implicitly)

Ruby, 109...94 91 bytes
-8 bytes thanks to @GB
->n{1.step.find{|k|[*1..k].combination(n).any?{|p|p.combination(3).all?{|a,b,c|b-a!=c-b}}}}

Try it online! Takes less than 1 s for \$n\le9\$. Times out for \$n\ge12\$.

Nice, but maybe use 1.step.find instead of relying on the exit code, this makes it shorter and you can print the result on TIO.

Also, instead of .map{...}.all? you could just use .all?{...}

JavaScript (ES6),  150  145 bytes
This is quite inefficient for \$n>8\$.
n=>(g=a=>(P=a=>a.reduce((a,x)=>[...a,...a.map(y=>[...y,x])],[[]]))(a).some(a=>a[n-1]*P(a).every(([a,b,c,d])=>d|b-a!=c-b))?k:g([...a,++k]))([k=1])

Try it online!
Commented
Helper function
Since we don't have any combinatorial function available as a built-in, we're going to define just one: \$P\$ is a helper function that computes the powerset of a given array.
P = a =>
  a.reduce((a, x) =>
    [...a, ...a.map(y => [...y, x])],
    [[]]
  )

Main function
n => (                  // n = input
  g = a =>              // g is a recursive function taking a range a[]:
    P(a).some(a =>      //   for each array a[] in the powerset of a[]:
      a[n - 1] *        //     make sure that the length of a[] is at least n
      P(a)              //     compute the powerset of a[]
      .every(           //     for each quad [a,b,c,d] in there,
      ([a, b, c, d]) => //     the test is successful if either:
        d |             //       - d is defined (meaning that this array has
                        //         more than 3 entries)
        b - a != c - b  //       - or a,b,c is not an arithmetic progression
      )                 //     end of every()
    )                   //   end of some()
    ?                   //   if truthy:
      k                 //     success: return k
    :                   //   else:
      g([...a, ++k])    //     try again with k+1 appended to a[]
)([k = 1])              // initial call to g with k = 1 and a = [1]

Wolfram Language (Mathematica), 94 bytes
(t=1;While[Select[Range@t++~(S=Subsets)~{#},!Or@@(Equal@@Differences@#&/@#~S~{3})&]=={}];t-1)&

Try it online! 1-9 takes 1 min

MATL, 22 bytes
`@:GXN!"@IXN!ddA]va~}@

Try it online! Or verify test cases 1‒8 (test case 9 times out online).
Explanation
`       % Do...while
  @:    %   Push range [1 2 ... k] where is the current iteration index
  G     %   Push input, n
  XN    %   Combinations of the elements [1 2 ... k] taken n at a time. This
        %   gives an n-column matrix where each row is a combination
  !     %   Transpose. Each combination is now a column
  "     %   For each column
    @   %     Push current column
    I   %     Push 3
    XN  %     Combinations of the elements of the current column taken n at
        %     a time. This gives a 3-column matrix
    !   %     Transpose. Each combination is now a column
    dd  %     Consecutive differences along each column, twice. This gives a
        %     row vector containing 0 for columns whose three elements form
        %     an arithmetic progression
    A   %     All. This gives true if all entries of the vector are non-zero;
        %     that is, if there were no arithmetic progressions of length 3
  ]     %   End
  v     %   Concatenate the stack into a column vector
  a~    %   Any, negate. Gives false if any entry from the above vector is
        %   non-zero. This will be used as loop condition; that is, if false
        %   the loop will end
}       % Finally (execute on loop break)
  @     %   Push latest k
        % End (implicit). The top of the stack is used as loop condiion
        % Display (implicit)

Charcoal, 40 37 bytes
≔⁰ηＷ∨⁻Σ⍘η²ＩθΦη＆η＆×ηＸ²⊕λ×ηＸ⁴⊕λ≦⊕ηＩＬ↨η²

Try it online! Link is to verbose version of code. Edit: Saved 3 byte by porting @SurculoseSputum's method. Now too slow for n>6. Explanation:
≔⁰η

Start with an empty bitmask.
Ｗ∨⁻Σ⍘η²Ｉθ

Repeat while the bitmask contains the wrong number of bits...
Φη＆η＆×ηＸ²⊕λ×ηＸ⁴⊕λ

... or it contains three terms in arithmetic progression...
≦⊕η

... increment the bitmask.
ＩＬ↨η²

Output the the length (in base 2) of the bitmask, which is necessarily equal to k.
At a cost of 2 bytes, I can replace Φη with ⊙↨η², which makes the code fast enough to compute up to n=9:
≔⁰ηＷ∨⁻Σ⍘η²Ｉθ⊙↨η²＆η＆×ηＸ²⊕λ×ηＸ⁴⊕λ≦⊕ηＩＬ↨η²

Try it online! Link is to verbose version of code. (Link only computes n=8 to avoid unnecessarily overloading TIO.)
Looping over the odd numbers is slightly faster still, but not enough to be able to compute n>9 on TIO. (It also gives the wrong answer for n=0, although that's not required by the question.)

Retina, 91 bytes
.+
*_¶
/^(_)*¶(?<-1>10*)*(?(1)$|1)|1(.)*1(?<-2>.)*(?(2)$)1/{`¶(1*)$
¶0$1
)T`10`d`01*$
r`.\G

Try it online! Uses @SurculoseSputum's method, but too slow for n>8. Explanation:
.+
*_¶

Convert n to unary, and add a working area for the bitmask.
/^(_)*¶(?<-1>10*)*(?(1)$|1)|1(.)*1(?<-2>.)*(?(2)$)1/{`
)`

Repeat while the number of bits in the bitmask is not n, or there are three bits in the bitmask with identical spacing...
¶(1*)$
¶0$1

If the bitmask contains no zeros then prefix one.
T`10`d`01*$

Increment the bitmask.
r`.\G

Output the length of the bitmask, which is necessarily equal to k.
The bitmask computations involve .NET balancing groups.
^(_)*¶

This captures the unary value of n. Since the * is outside of the (_), the group is captured n times. .NET records each capture as a stack, so $1 now has a depth of n.
(?<-1>10*)*

This attempts to match the regex 10*. Each successful match pops one of the captures from the $1 stack. This continues until the stack is empty or there are no matches.
(?(1)$|1)

A conditional expression now checks whether the stack is empty. If it is not, then we want this to be because we ran out of 1 bits to match, which will be at the end of the string. If the stack is empty, then we want this to be because there are too many 1 bits, so we should be able to match one.
Note that while Retina will try to backtrack if it fails to match, this necessarily means both that the stack is not empty and that the match is not at the end of the string, i.e. this condition will never succeed in the case where the number of bits is correct.
1(.)*1(?<-2>.)*(?(2)$)1

In a similar way, we capture a variable number of bits between two 1 bits, and then require that the same number of bits exists between the latter and another 1 bits. Here the condition for a non-empty stack is a logical impossibility ($ before a 1) thus requiring the stack to be empty at this point, indicating that the number of bits is the same.


text:
Base-phi converter time!
The Golden Ratio Bureau is obsessed with this new thing they call base-phi. You see it and decide to code-golf, as is your natural instinct.
To be specific, base-phi is a number system like base 10, except it uses the number phi, or the golden ratio, as its base. A ones digit would be x*10^y, but in base phi 10 is replaced with phi. Base phi also uses 2 digits, 0 and 1.
Your goal is to accept input that is a base 10 positive natural number, then treat it as such and convert it to base phi.
Due to base phi being able to represent all numbers in more than one way, your program should convert input to its "minimal" representation. This is the representation with the least 1 digits.
Output can have trailing characters but only if the language must output them with no circumvention.
Do not use any built-ins for base conversion. You may use a built-in for phi, but the base conversion should rely on string manipulation and other mathematical operations.
Your program must support inputs up to 2147483647, or lower, depending on your language's limit for integers.
Your program can deal with any undefined behavior as you wish.
Testing cases for accuracy can be done at this link. In case you do not wish to use the link, here are the numbers 1-15 in base phi.
1 = 1
2 = 10.01
3 = 100.01
4 = 101.01
5 = 1000.1001
6 = 1010.0001
7 = 10000.0001
8 = 10001.0001
9 = 10010.0101
10 = 10100.0101
11 = 10101.0101
12 = 100000.101001
13 = 100010.001001
14 = 100100.001001
15 = 100101.001001

The shortest program following these rules wins. Have fun.

Related

"Do not use any built-ins for base conversion" - uh, seriously?

Related PE problem.

Is the number guaranteed to be positive?

Retina, 81 80 bytes
K`0.
"$+"{+`(1(\.)|(1\.(0?1)*0?)1)(00|$)
${3}0${2}11
0\.
1.
+0`0?1(\.?)1
10${1}0

Try it online! Works by repeatedly adding \$ 1 \$. Explanation:
K`0.

Start off with \$ 0. \$.
"$+"{`

Repeat the number of times given by the input.
+`(1(\.)|(1\.(0?1)*0?)1)(00|$)
${3}0${2}11

If the \$ \phi^0 \$ bit is set, use the identity \$ \phi^0 = \phi^{-1} + \phi^{-2} \$ to move bits away until there is enough room.
0\.
1.

Add \$ 1 \$.
+0`0?1(\.?)1
10${1}0

Minimise the number of bits by reversing the above identity.

Nice method, but I don't think you're going to be able to handle numbers up to 2147483647 in practice by adding 1 repeatedly!

@MitchellSpector Given that modern computers can already do more than 2147483637 operations in a second, I don't think this will take more than a few hours. (I'm not sure how fast is C# regex though) (update: 100000 takes 20 seconds, I underestimated the slowness of C#)

@mypronounismonicareinstate  I think it would take about a week.  I don't have Retina installed on my computer to try out larger inputs, but TIO computes the value for 100,000 in about 26 seconds, and the value for 200,000 in about 54 seconds.  Assuming a linear running time (which probably gives an underestimate), computing the value for 2147483647 would take about 2147483647 / 200000 * 54 / 60 / 60 / 24 = 6.7 days.

@mypronounismonicareinstate  The algorithm makes all the difference.  The dc computation gets the answer for 2147483647 in less than a second, and I don't think dc is a particularly fast language.  On the other hand, Neil's Retina solution is 29 bytes shorter than my dc solution, and this is code golf!

@MitchellSpector It may be slow, but it is arbitrary precision, although I realise that the question itself doesn't require that.

@Neil Absolutely! This wasn't a criticism of your answer, which is a perfect codegolf solution.  I was just amused at the idea of counting to 2147483647.  My dc program, as it stands, will fail at some point (even assuming unlimited resources) because the calculations won't have enough decimal places.  To make it truly unlimited precision like yours, I'd need to figure out at the beginning how many decimal places are needed.  Here I just put in a constant number of decimal places that works for inputs up to 2147483647, which was the requirement.

@Neil I went ahead and made that change, so the dc program should now work for arbitrarily large numbers also. (And I actually shortened it by a byte in doing so.)  I added a test case -- a large Lucas number over 400 trillion which comes out neatly in base $\varphi$. I find this to be a striking example of the trade-offs that choice of an algorithm can make: the dc program can handle this input in 45 seconds in TIO, while I think the Retina program would literally take thousands of years to complete. But your Retina program wins the codegolf competition by 28 bytes!

dc, 107 106 110 109 bytes
[0sD]sZ0ddsRsK?dsXZF*dkdsN-sM[lX5v1dsD+2/lN^dsY>ZlXlDlY*-sXlDdAlN^*lR+sRlKdlN+lD*-sKlN1-dsNlM!>L]dsLxlRlKk1/p

Try it online!
Or verify the test suite: the OP's test cases, 2147483647, and a very large Lucas number (over 400 trillion) which comes out neatly in base \$\varphi\$ (see screenshot below for that last test case by itself).
The program should now work for arbitrarily large numbers, restricted only by the memory capacity of the computer.

How it works:
[0sD]sZ    Macro Z, sets D to 0 when called.
0ddsRsK    Initialize R and K to 0, leaving 0 on the stack.
?dsX       Input number, store it in X,
ZF*dkdsN       store 15 times its number of decimal digits in N,
               also set that as the number of decimal places for
               computations,
-sM            and store the negative of that in M.
               M and N are bounds on the powers of phi which
               will be needed for the representation.
               Multiplying by 15 is far more than is needed:
                  For M and N, we could have multiplied by just 5,
                  because ln(10)/ln(phi) < 5.
                  We need some additional decimal places in the
                  computations to handle possible round-off errors,
                  so we conservatively multiply by 15.
[          Start a macro (which will be used as a loop).
 lX                 Push X onto the stack.
 5v1dsD+2/lN^       Set D=1.  Compute phi^N,
 dsY                   and store it in Y.
 >Z                 If phi^N > X, use macro Z to set D=0.
 lXlDlY*-sX         If D is 1, set X = X - phi^N.
 lDdAlN^*lR+sR      R += D * 10^N.
                       This places the digit D in R in the right
                       position, treating R as a number in base 10.
 lKdlN+lD*-sK       If D is 1, set K = -N.
                       (K is used as the number of "decimal"
                       places to print.)
 lN1-dsN            Set N = N-1, leaving the new value of N
                       at the top of the stack.
 lM!>L              If M <= N, call macro L recursively (in
                       other words, start another loop iteration).
]          End the macro,
dsL          save it in register L,
x            and execute it.

       Once the loop is done:
lR         Load the result R.
lKk        Set the precision (number of decimal places) to K.
1/         Divide R by 1 to convert it to the desired precision.
p          Print it.

+1 for using macOS Preview.

Perl 5, 135 bytes
sub f{(0,1,10.01)[$_=pop]||do{$_=f($_-1);$_.=0until/\..{99}/;s/.\./$&+1/e;1while s/.?2../$&+801/e+s,0?11,100,;s,.{99}$,.$&,;/1.*1/;$&}}

Try it online!
This function is no speed monster, but it's O(n). f(1000000) returns 10100000100010010000100010001.0001000010100101000100000101 in 15 secs on my laptop.

PHP, 173 bytes
$p=.5+sqrt(5)/2;for($i=45,$a=$argn,$f=1;$a>=.01;){$i?:$a*=$f=1e6;$b=$p**$i*$f;if($i--==-1)$n.='.';if((float)number_format($a-$b,3)>=0){$a-=$b;$n.=1;}else$n.=$n?0:'';}echo$n;

Try it online!
It was a real pain mostly because of errors in comparisons and subtraction when values get really small, I had to find a way to circumvent them:
$p=(1+sqrt(5))/2;                       //ϕ
for($i=45,$a=$argn,$f=1;$a>=.1;){       //no need to go beyond ϕ^45 to go up to 2147483647. $a is the input, $f a factor
  $i?:$a*=$f=1e7;                       //small numbers fix: multiplying $a and factor $f by 1000000 for following test and exit condition to work (also shortens this condition)
  $b=$p**$i*$f;                         //current power of ϕ multiplied by the factor
  if($i--==-1)$n.='.';                  //decrement $i + if we get to power -1 add the dot '.'
  if((float)number_format($a-$b,3)>=0){ //second fix to be right when difference is very small
    $a-=$b;                             //subtract the current power when ok
    $n.=1;                              //adding a '1'
  }else $n.=$n?0:'';                    //or else a '0' (test $n to avoid leading zeroes)
}
echo$n;                                 //et voilà!

I think I can golf it more, we'll see later, I'm open to suggestions. Note that my version of 2147483647 is slightly different than what I saw here, but of course it's me who's right. Haven't tried other big values..
EDIT: saved 1 byte thanks to @mathjunkie and lowered the exit threshold to 0.01 for the 111 case as rightly noticed by @MitchellSpector.. no change to the score
EDIT2: changed the factor from 10000000 to 1000000 to handle another case found by @MitchellSpector, I guess I'll have to do automated tests to detect other cases :D

The base $\varphi$ expansion for 111 is 1010001010.0000100001, but your program outputs 101000101 (one digit too few before the "decimal" point, and it's missing the digits after the point).

111 is fixed, but it looks like there are still some problems with larger numbers.  100000 gives 101010001010100000100000.1010001010000000100000001010101010101010101 but I think the answer should be 101010001010100000100000.101000101000000010000001.  (I would guess that there's a round-off error affecting the floating-point arithmetic.)

@MitchellSpector yep it's the whole point of multiplying the values by 1000000 past a certain point. Like other languages PHP can't properly subtract (or even compare equal values)  when one of them gets really small. (float)number_format($a-$b,3)>=0 is one way I found, particularly for $a==$b. I will review some of the settings for the fix, thanks

APL (Dyalog Unicode), 94 bytes
{w←{+\∘⌽⍣⍵⊢1 0}¨⍵-⍳k←2×⍵⋄s/⍨(∨\'0'≠s)∧⌽∨\'1'=⌽s←⍵(↑,'.',↓)⊃∘⍕¨⊢/b/⍨(w+.×b←(0∘⍪,1∘⍪)⍣k⍪⍬)≡¨⊂⍵0}

Try it online!
Inefficient as hell. Basically, given n as input, generate all bit patterns with n bits above and n bits below the decimal point, symbolically evaluate it as base phi (to the form a+b*phi), extract all patterns whose value is n+0*phi, pick the one that is lexicographically highest, and then trim unnecessary zeros/decimal point from both ends.
Ungolfed with comments
f←{                    ⍝ Input: ⍵←n
  v←⍵-⍳2×⍵             ⍝ Vector of n-1, n-2, ..., -n
  w←{+\∘⌽⍣⍵⊢1 0}¨v     ⍝ Reduced base-phi values (a+b×phi) of phi^v
    {          }¨v     ⍝ For each value of v,
            1 0        ⍝ Start with 1+0×phi
     +\∘⌽              ⍝ Apply "reverse then cumulative sum"
         ⍣⍵            ⍝ v times (for negative v, inverse of it |v| times)

  b←(0∘⍪,1∘⍪)⍣(2×⍵)⍪⍬  ⍝ Matrix of all possible bit patterns for 2n bits
                   ⍪⍬  ⍝ Empty matrix of 0 row, 1 column
    (0∘⍪,1∘⍪)          ⍝ Apply "horizontally concat the matrix with
                       ⍝   a 0-row prepended with the one with a 1-row"
             ⍣(2×⍵)    ⍝ 2n times

  a←⊢/b/⍨(w+.×b)≡¨⊂⍵0  ⍝ Find target bit pattern
         (w+.×b)       ⍝ Evaluate each bit pattern as base phi
                ≡¨⊂⍵0  ⍝ Compare with n+0×phi
      b/⍨              ⍝ Filter columns of b where ^ is true
    ⊢/                 ⍝ Pick the rightmost one

  s←⍵(↑,'.',↓)⊃∘⍕¨a    ⍝ Convert to string
              ⊃∘⍕¨a    ⍝ Char-ify each digit
    ⍵(↑,'.',↓)         ⍝ Insert decimal point after n chars

  s/⍨(∨\'0'≠s)∧⌽∨\'1'=⌽s  ⍝ Filter away trailing non-ones and leading zeros
               ⌽∨\'1'=⌽s  ⍝ Boolean mask to filter away trailing non-ones
              ∧           ⍝ And
     (∨\'0'≠s)            ⍝ Boolean mask to filter away leading zeros
  s/⍨                     ⍝ Filter s using ^
}

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Counting hypercube Tetris pieces
Consider the Tetris pieces, but made out of some number of (hyper)cubes instead of four squares, where two blocks are considered the same if one is a rotation, reflection, or translation of another. The goal of this challenge is to take two positive integer input values, n and k, and count the number of \$n\$-celled polyominoes consisting of \$k\$-dimensional hypercubes.
This is a code-golf challenge, so the shortest code wins.

Example
For example, when \$n = 4\$ and \$k = 3\$ there are seven different shapes:

Notice that the first piece could be made using \$1\$-cubes (line segments) instead of cubes, the next four could be made using \$2\$-cubes (squares), and only the last two require \$3\$-cubes (ordinary cubes). Thus \$p(4,1) = 1\$, \$p(4,2) = 5\$, and \$p(4,3) = 7\$.

Test Data
 n | k | p(n,k)
---+---+--------
 1 | 0 | 1
 2 | 0 | 0
 2 | 1 | 1
 3 | 2 | 2
 4 | 1 | 1
 4 | 2 | 5
 4 | 3 | 7
 4 | 4 | 7
 4 | 5 | 7
 5 | 4 | 26
 6 | 3 | 112
 7 | 3 | 607
 8 | 2 | 369

How did you create the graphics?

@Jonah, I used Mathematica. For example, the last image was made with the command Graphics3D[{Green, Cuboid[{0, 0, 0}], Cuboid[{0, 0, 1}],    Cuboid[{0, 1, 0}], Cuboid[{1, 1, 0}]}].

What would 0-dimensions be like?

You made me look this up (and now my profile pic is a tesseract ;). Cool!

0-dimensions is just a single point, so $p(1,0) = 1$ and $p(n,0) = 0$ for $n > 0$.

Related OEIS sequences: 2D: A000105 and 3D: A038119.

@KevinCruijssen, better yet, see A330891.

Python 2, 338 335 330
Try it online!
from itertools import*
n,k=input()
O=[([0]*k,)]
R=range(k)
exec"O={min(tuple(sorted(zip(*[[x-min(p)for x in p]for p in f])))for q in permutations(zip(*(o+(r,))))for f in product(*[[p,[-x for x in p]]for p in q]))for o in O for s in o for r in[tuple(s[i]+x*(i==j)for i in R)for j in R for x in-1,1]if not r in o};"*~-n
print len(O)

Reads n,k as a list from stdin (e.g. [4,2]) and prints the number of polyominoes.
Starts with a single polyomino with a single cell at the origin.
n-1 times, replaces the polyominoes with all possible polyominoes created by adding an adjacent cell to an existing polyomino, and canonizing that polyomino by finding the minimum of all possible rotations of it.
-6 bytes thanks to math junkie, -2 bytes thanks to Surculose Sputum.

Nice work.  I'd love to see the ungolfed version with explanation.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
The "skip-pure" numbers
The skip-pure numbers are defined with this rule:
A(0) = 1
A(1) = 1
A(n) = the smallest positive number not in the sequence such that A(x) + A(x-2) for any x never appears

For example, the term A(2) is 2, because 1 has already appeared. The term A(3) is 4, as A(2) + A(0) = 3 and 3 is disallowed by the third line of the rule.
Given a number n, your program should output the nth skip-pure number, using zero-based indexing (such that A(0) is defined).
Output can be in any format (strings, ints, lists, arrays, etc.), but the number itself must be outputted in base 10.
Trailing output (newlines, etc.) is allowed but only if your language has to output it. If you can work around trailing output, solve it with the workaround.
Here are test cases, shown in the format input = output:
0 = 1
1 = 1
2 = 2
3 = 4
4 = 6
5 = 7
6 = 9
7 = 10
8 = 12
9 = 13

I created this sequence myself and am probably the first person to talk about it, so there is no OEIS link.
This is a code-golf, so the shortest program that does all of the above (measured in bytes) wins. Have fun.

Apart from the first 2 terms, this is the complement of A022433.

05AB1E, 20 17 16 13 bytes
‚Qλè∞λÐ¦¦+«Kн

-3 bytes by porting @Arnauld's JavaScript answer, so make sure to upvote him!
-6 bytes on my original 20 bytes solution thanks to @Grimmy, making it shorter than the port
Outputs the 0-based \$n^{th}\$ value, as specified in the challenge description.
Try it online.
Outputting the infinite sequence would be 12 bytes:
1‚λ∞λÐ¦¦+«Kн

Try it online.
And outputting the first \$n\$ values of the sequence would be 13 bytes again:
‚Qλ£∞λÐ¦¦+«Kн

Try it online.
Explanation:
‚              # Pair the (implicit) input with itself
 Q             # Check for each whether it's equal to the (implicit) input
               # which results in a pair of 1s: [1,1]
  λ            # Create a recursive environment
   è           # to output the 0-based n'th value, where n is the (implicit) input
               # (which will be output implicitly at the end)
               # Starting with a(0)=a(1)=1 due to the earlier [1,1]-pair
               # And for any other a(n) we'll:
    ∞          #  Push an infinite positive list: [1,2,3,...]
     λ         #  Push a list of all previous values: [a(0),a(1),...,a(n-1)]
      Ð        #  Triplicate that list
       ¦¦      #  Remove the first two values from the top copy
         +     #  Add the values in the top two lists together at the same positions,
               #  which also shortens the longer list by two:
               #  [a(0)+a(2),a(1)+a(3),...,a(n-3)+a(n-1)]
          «    #  Merge it to the remaining copy of the triplicate
           K   #  Remove all those values from the infinite positive list
            н  #  Pop and leave the first remaining positive integer

1‚             # Pair 1 with itself (only works if there is no input,
               # in which case it uses the 1 again implicitly)
  λ            # Create a recursive environment
               # to output the infinite list
   ∞λÐ¦¦+«Kн   #  The rest is the same as above

JavaScript (ES7),  59  31 bytes
Returns the \$n\$-th term, 0-indexed. This is a closed-form formula.
n=>n*1.5^Math.log2(n)&n%4==2^!n

Try it online!
Formula
The only edge case is \$a(0)=1\$. For \$n\ge1\$:
$$a(n)=\cases{\left\lfloor\dfrac{3n}{2}\right\rfloor-1,&\text{if $\lfloor log_2(n)\rfloor$ is odd and $n\equiv 2\pmod 4$} \\
\left\lfloor\dfrac{3n}{2}\right\rfloor,&\text{otherwise}
}
$$

The golfing force is strong in him!

Haskell, 68 bytes
a n|n<2=1|q<-n-1=[x|x<-[a q+1..],notElem x[a c+a(c-2)|c<-[2..q]]]!!0

Try it online!
Pretty simple answer, doesn't use the formula since that is no fun.
a n                   -- a n is ...
  |n<2=1              -- 1 if n less than 2
  |q<-n-1=            -- where q is n-1
    [...]!!0          -- the first element of ...
      x|x<-[a q+1..], -- the integers larger than a(n-1) such that ...
        notElem x[a c+a(c-2)|c<-[2..q]]
          -- it satisfies the condition in the challenge.

Husk, 16 bytes
!¡ȯ←`-NS+Sz+↓2ḋ3

Try it online!
Outputting the infinite list gives -1. Kinda sad I'm unable to get it below 16.

Python 2, 76 bytes
a=b=1
w=s={1}
exec"w|=s;c=b;b=a\nwhile w&s:a+=1;s={a,a+c}\n"*input()
print b

Try it online!

So sorry, thought that was my post - rolled back changes.

Python 2, 75 \$\cdots\$ 44 42 bytes
Using Arnauld's formula from his JavaScript answer.
Saved 2 5 8 bytes thanks to Kevin Cruijssen!!!
Saved a whopping 8 22 23 25 bytes thanks to the man himself Arnauld!!!
lambda n:0**n^3*n/2^(len(bin(n))%2|n%4==2)

Try it online!
Using the OP's formula
Python 3, 87 86 bytes
f=lambda n,r=[1,1],i=1:i*(len(r)/2>=n)or(i in r)and f(n,r,i+1)or f(n,[i]+r+[i+r[1]],i)

Try it online!

45 bytes by using a similar thing I did in my 62-byter on @Arnauld's 48-byter. (You also forgot to change the header to Python 2.)

@KevinCruijssen Awesome squeeze - thanks! :D

42 bytes

@Arnauld Clever - thanks! :-)

Japt, 17 bytes
Direct port of Arnauld's formula so be sure to +1 him.
*1½^MmU &U%4¥2^!U

Try it

C (gcc), 58 42 bytes
Using Arnauld's formula from his JavaScript answer.
Saved a whopping 16 bytes thanks to the man himself Arnauld!!!
f(n){n=3*n/2^~__builtin_clz(n)&n%4==2^!n;}

Try it online!

42 bytes

@Arnauld Very nice - thanks! :-)

Darn, so close!

Io, 75 bytes
Port of Arnauld's formula from their JS answer.
method(n,(3*n/2)floor-if((n log2 floor%2==0)and(n%2==4),-1,0)+if(n==0,1,0))

Try it online!

R, 43 42 40 bytes
Using the same formula as earlier answers (and Robin's suggestions)
n+(n/2)%/%1-(!n%%4-2&log2(n+.1)%%2>1)+!n

Try it online!


text:
Split a list evenly
You are given a list of at least two positive integers as input. The challenge is to find such a position of a cut that minimizes the absolute difference between the sums of the two parts (to the left and to the right of it). The position should be given as the index of the first element after the cut.
This is tagged code-golf, so the shortest answer wins!
Test cases
These are 0-indexed.
[1, 2, 3] -> 2
[3, 2, 1] -> 1
[1, 5, 3, 2, 4] -> 2 or 3
[1, 2, 4, 8, 16] -> 4
[1, 1, 1, 1, 1] -> 2 or 3
[1, 2, 4, 8, 14] -> 4

For example, for the first test case, if the cut is placed before the second element, the sums of the parts will be 1 and 5 and the absolute difference will be 4, and if the cut is placed before the third element, the sums will be equal and the absolute difference will be 0. Therefore, the correct output is 2 (assuming 0-indexing). If multiple correct outputs exist, you must output one of them.
Explained examples
Input: [1, 2, 3]
Cut at 0: [] vs [1, 2, 3] -> 0 vs 1+2+3=6, difference is 6
Cut at 1: [1] vs [2, 3] -> 1 vs 2+3=5, difference is 4
Cut at 2: [1, 2] vs [3] -> 1+2=3 vs 3, difference is 0 (minimum)
Cut at 3: [1, 2, 3] vs [] -> 1+2+3=6 vs 0, difference is 6

Input: [1, 2, 4, 8, 14]
Cut at 0: [] vs [1, 2, 4, 8, 14] -> 0 vs 1+2+4+8+14=29, difference is 29
Cut at 1: [1] vs [2, 4, 8, 14] -> 1 vs 2+4+8+14=28, difference is 27
Cut at 2: [1, 2] vs [4, 8, 14] -> 1+2=3 vs 4+8+14=26, difference is 23
Cut at 3: [1, 2, 4] vs [8, 14] -> 1+2+4=7 vs 8+14=22, difference is 15
Cut at 4: [1, 2, 4, 8] vs [14] -> 1+2+4+8=15 vs 14, difference is 1 (minimum)
Cut at 5: [1, 2, 4, 8, 14] vs [] -> 1+2+4+8+14=29 vs 0, difference is 29

Input: [1, 1, 1, 1, 1]
Cut at 0: [] vs [1, 1, 1, 1, 1] -> 0 vs 1+1+1+1+1=5, difference is 5
Cut at 1: [1] vs [1, 1, 1, 1] -> 1 vs 1+1+1+1=4, difference is 3
Cut at 2: [1, 1] vs [1, 1, 1] -> 1+1=2 vs 1+1+1=3, difference is 1 (minimum)
Cut at 3: [1, 1, 1] vs [1, 1] -> 1+1+1=3 vs 1+1=2, difference is 1 (minimum)
Cut at 4: [1, 1, 1, 1] vs [1] -> 1+1+1+1=4 vs 1, difference is 3
Cut at 5: [1, 1, 1, 1, 1] vs [] -> 1+1+1+1+1=5 vs 0, difference is 5

Deleted sandbox post

Can you add [1, 2, 4, 8, 14] -> 4 to the test cases

Needs a worked example or two.

Uhh, why the close votes?

Didn't vote to close but there's a lack of clarity. You say These are 0-indexed but in your explanation say the correct output for the second element is 2. Is that correct?

@Noodle9 2 is the index of the first element after the cut (i.e. the third element) (quoting: The position should be given as the index of the first element after the cut); I'll rewrite that slightly

@streetster You added a wall of text to the question without asking me. Please don't do that in the future.

sorry bud, was just trying to help - feel free to remove!

Can we assume that every element in the list will be greater than zero?

@Kaddath yes (the question also mentions that in the beginning)

Thanks, some say zero is both positive and negative, some say it's neither, the way I learnt we say "strictly positive" to avoid any confusion ;)

Might be interesting to repeat this challenge, only allowing negatives - that does increase complexity, particularly if your list is unordered.

@Kaddath If anyone does consider zero positive they are certainly in the extreme minority.  Positive is certainly a clear enough term, especially within this site where it has a solid precedent of meaning greater than zero.  The confusion usually occurs with the phrase natural number.

Python 3, 50 35 bytes
f=lambda a,*l:sum(l)>0and-~f(*l,-a)

Try it online!
Explanation
If the sum of elements on the left of a is smaller than the sum of elements right of a, then the cut must be after a - explanation by Surculose Sputum.
How I arrived here:
In each recursive call we compare abs(sum(x[:i]) - sum(x[i:])) to abs(sum(x[:i+1]) - sum(x[i+1:])). If the first distance is larger, we continue with the next recursive call, if not the program is stopped:
f=lambda x,i=0:abs(sum(x[:i])-sum(x[i:]))>abs(sum(x[:i+1])-sum(x[i+1:]))and f(x,i+1)

This can be shortened by modifying the list to make the distance calculation simpler:
f=lambda x:abs(sum(x))>abs(sum(x[1:])-x[0])and 1+f(x[1:]+[-x[0]])

Even shorter if we take the input as single arguments:
f=lambda a,*l:abs(sum(x)+a)>abs(sum(x)-a)and 1+f(*x,-a)

By rearranging the formula ...
$$ |(\sum_{k \in x}k) + a| > |(\sum_{k \in x}k) - a| \\
\iff ((\sum_{k \in x}k) + a)^2 > ((\sum_{k \in x}k) - a)^2 \\
\iff ((\sum_{k \in x}k) + a)^2 - ((\sum_{k \in x}k) - a)^2 > 0 \\
\iff 4 \cdot (\sum_{k \in x}k) \cdot a > 0 \\
\overset{a>0}\iff \sum_{k \in x}k > 0 $$
... we arrive at the final solution:
f=lambda a,*x:sum(x)>0and-~f(*x,-a)

Brilliant! Took me a while to understand this, here's my attempt at an explanation: If the sum of elements on the left of a is smaller than the sum of elements right of a, then the cut must be after a. Otherwise, stop and returns the index of a.

@SurculoseSputum that is a nice explanation, I arrived there by rearranging some inequalities.

K4 / K (oK), 22 18 14 bytes
Solution:
*&(+\x)>|+\|x:

Try it online!
Explanation:
Compare cumulative sum against reverse of the reverse cumulative sum.
*&(+\x)>|+\|x: / the solution
            x: / save input as x
           |x  / reverse
         +\    / cumulative sum
        |      / reverse
       >       / greater than?
  (+\x)        / cumulative sum x
 &             / indices where true
*              / take first

What about for [1 2 4 8 14]? It seems that your current solution returns 3 when it should return 4

Ta, reverted :)

MATL, 13 bytes
t&+gREqY*|&X<

The output is 0-indexed. Try it online! Or verify all test cases.
Explanation
Consider input [1 2 4 8 16] as an example.
t    % Implicit input. Duplicate
     % STACK: [1 2 4 8 16], [1 2 4 8 16]
&+g  % All pair-wise additions, then convert to logical. Gives square matrix of ones
     % STACK: [1 2 4 8 16], [1 1 1 1 1;
                             1 1 1 1 1;
                             1 1 1 1 1;
                             1 1 1 1 1;
                             1 1 1 1 1]
R    % Upper triangular matrix. Sets elements below the diagonal to zero
     % STACK: [1 2 4 8 16], [1 1 1 1 1;
                             0 1 1 1 1;
                             0 0 1 1 1;
                             0 0 0 1 1;
                             0 0 0 0 1]
Eq   % Times 2, minus 1, element-wise
     % STACK: [1 2 4 8 16], [ 1  1  1  1  1;
                             -1  1  1  1  1;
                             -1 -1  1  1  1;
                             -1 -1 -1  1  1;
                             -1 -1 -1 -1  1]
Y*   % Matrix multiplication
     % STACK: [-29 -25 -17  -1  31]
|    % Absolute value, element-wise
     % STACK: [29 25 17 1 31]
&X<  % Index of minimum entry
     % STACK: 4
     % Implicit display

Pyth, 14 12 11 bytes
-1 byte thanks to @isaacg
lhoaysNsQ._

Try it online!
lhoaysNsQ._
         ._  All prefixes of input list
  o           Sort, using the following function as the key:
   a          Absolute difference of
     sN        - the sum of the prefix
    y              times 2
       sQ      - the sum of the input list
 h            First such prefix
l             Take its length
(which gives the index of the element immediately after the prefix)

This is based on the following identity:
\$ \left|\sum_{b \in R} b - (\sum_{q \in Q} q - \sum_{b \in R} b) \right| = \left|2\sum_{b \in R} b - \sum_{q \in Q} q \right|\$
where \$R\$ is the current prefix and \$Q\$ is the input list.

You can save a byte by replacing .m by o and b by N. .m isn't needed if you're going to use h right afterwards.

@isaacg Awesome, thanks!

Haskell, 65 36 bytes
(0%)
a%(b:c)|a<sum c=1+(a+b)%c
a%_=0

Try it online!
This answer really just uses one trick.  Instead of caluclating
$$
\left|a-b\right|
$$
and taking the minimum, go until the left hand side is greater than the right hand side.
To see why this works we will show that:
$$
  \left|a-(b+c)\right| < \left|(a+b)-c\right| \implies a > c
$$
Here is the proof:
$$
\begin{matrix}
\left|(a-c)-b \right| < \left|(a-c)+b \right| &\implies \\
a - c > 0 &\implies \\
a > c
\end{matrix}
$$

Jelly, 6 bytes
ÄḤạSỤḢ

A monadic Link accepting a list which yields the first available cut index.
Try it online!
How?
ÄḤạSỤḢ - Link: list, X         e.g.  [ 7,  1,  1,  1,  1,  1,  1,  6]
Ä      - cumulative sums (X)         [ 7,  8,  9, 10, 11, 12, 13, 19]
 Ḥ     - double                      [14, 16, 18, 20, 22, 24, 26, 38]
   S   - sum (X)                     19
  ạ    - difference (vectorises)     [ 5,  3,  1,  1,  3,  5,  7, 19]
    Ụ  - grade                       [3, 4, 2, 5, 1, 6, 7, 8]
     Ḣ - head                        3

This is very nice, but I think you should return one cut index.

Easily accommodated with one byte, but if this is a requirement you should probably change If multiple correct outputs exist, you can output any. to something like If multiple correct outputs exist, you must output one. ('any: used to refer to one or some of a thing or number of things, no matter how much or how many.')

...and doable with 0 bytes :)

I guess I'll do that, but I have seen the exact sentence If multiple correct outputs exist, you can output any used to mean that very many times, and the test cases look like [1, 5, 3, 2, 4] -> 2 or 3, not -> [2, 3] (and the lead also asks for such a position that - I tried to word that to avoid this exact misunderstanding :( )

Fair enough. You did put "2 or 3" not "2 or 3 or [2,3]". I just read "any" and assumed it was fine.

That's now done at no cost.

Python 3, 67 bytes
lambda l:min([abs(sum(l)-2*sum(l[:i])),i]for i in range(len(l)))[1]

Try it online!
Straightforward implementation, can probably be golfed more. Output the 0-indexed cut.

J, 16 13 bytes
-3 bytes thanks to Jonah
1 i.~+/\>+/\.

Try it online!

Very nice, Galen

13 bytes: 1 i.~+/\>+/\.

@Jonah Thank you! My intention was to use suffix too, but apparently I went another direction :)

JavaScript (ES6),  64  48 bytes
Now very similar to ovs' answer, but we keep track of the left sum in \$s\$ rather than re-injecting the opposite values in the list.
f=([v,...a],s=0)=>s<=eval(a.join`+`)&&1+f(a,s+v)

Try it online!
NB: eval(a.join('+')) is undefined if \$a[\:]\$ is empty, so s<=eval(a.join('+')) is always false in that case.

Husk, 8 bytes
η◄Ṁ≠½Σ¹∫

Try it online!
Explanation
η◄Ṁ≠½Σ¹∫  Implicit input, say x = [5,2,2,3,6,2,6]
       ∫  Prefix sums: p = [5,7,9,12,18,20,26]
     Σ¹   Sum of x: 26
    ½     Halve: 13
  Ṁ≠      Absolute differences with elements of p: [8,6,4,1,5,7,13]
η◄        1-based index of minimal element: 4

Wolfram Language (Mathematica), 55 bytes
Abs@ReplaceList[#,{x__,y__}:>Plus@x-Plus@y]~Ordering~1&

Try it online!
24 bytes saved @Kyle Miller
2 byte from my @pronoun is monicareinstate

57 bytes using some pattern matching: https://tio.run/##y00syUjNTSzJTE78n277X1nNwcG/KCW1KDMv3cExqdghKLUgJzE51SezuCRaWae6Ij5epzI@vtbKLiCntNihQhdMVcaq/Q8AailRcEiPrjbUUTDSUTCujeVCiBmDxQxRxIDqTIHqwDIm6DIgMR0FC6AeM3QpBKqN/f8fAA

56 bytes by using the second argument of Ordering: Try it online!

@mypronounismonicareinstate I guess you accept this type of output since this is your challenge ;)

I have now noticed that ...~Ordering~1 works as well. (that type of output is valid because it's always a single integer, as far as I know)

APL (Dyalog Unicode), 20 SBCS bytes
(⊃∘⍸((+\⌽)≥(⌽+\))∘⌽)

Try it online! Port of streetster's answer so be sure to upvote that one as well. This one is 1-indexed and returns the first option available.
APL (Dyalog Unicode), 29 SBCS bytes
{0>+/1↓⍵:0⋄1+∇((-1∘↑),⍨1∘↓)⍵}

Try it online! This is 0-indexed and returns the second option, when available. Fairly direct port of ovs's answer so be sure to upvote that answer as well!

Hah - was just about to ask whether porting mine would be shorter :)

@streetster yup; and I'm sure if I'm clever enough I can make your port even shorter :)

How'd you learn APL?

@S.S.Anne APL Cultivations (chat-based bi-weekly lessons), asking a lot of questions over at the APL Orchard chatroom (and plenty of them answered by a very patient Adám) and tackling problems. Oh, and of course: banging my head against the wall a lot. Also, I am very much a newbie still!

Charcoal, 14 bytes
ＩΣＥθ‹Σ…θ⊕κΣ✂θκ

Try it online! Link is to verbose version of code. 0-indexed. Port of @ovs's solution, except that I include the current element in each sum as the sum of an empty list is None. Explanation:
   θ            Input aray
  Ｅ             Map over elements
         κ      Current index
        ⊕       Incremented
       θ        Input array
      …         Sliced to that index
     Σ          Take the sum
    ‹           Is less than
             κ  Current index
            θ   Input array
           ✂    Sliced starting at that index
          Σ     Take the sum
 Σ              Take the sum
Ｉ               Cast to string
                Implicitly print

APL (Dyalog), 25 24 bytes
{(⊢⍳⌊/)|⍵+.×∘.(≤->)⍨⍳⍴⍵}

or
(|⍳⌊/∘|)∘.(≤->)⍨∘⍳∘⍴+.×⊢

Try it online!
Using a variation on @LuisMendo's method.
How?
⍳⍴⍵ gives the range 1 .. n where n is the array size.
∘.(≤->)⍨⎕ performs an outer product with x≤y - x>y (1 for upper triangular, -1 for lower)
⍵+.×⎕ matrix-multiplies with the array
|⎕ does absolute value, and
⎕⍳⌊/⎕ searches the minimum index of the result

Racket, 71 bytes
(define(f a[s 0][n 0])(if(<(apply + a)s)n(f(cdr a)(+(car a)s)(+ n 1))))

Try it online!
1-indexed

05AB1E (legacy), 8 bytes
Port of Zgarb's Husk answer. The index is 0-based.
ηOsO;αWk

Try it online!
05AB1E (legacy), 12 bytes
āΣôćs˜OsOα}¬

Try it online!
Explanation
ā            Length-range with the input.
 Σ           Sort by this:
  ô          Split input into chunks of current item.
   ć         Head extract,
    s        Put head in the back,
     ˜       Flatten.
      OsO    Sum head & tail.
         α}  Absolute difference between these parts.
           ¬ Take the first item of this sorting.

I like that 8-byter. I personally had this 9-byter in mind when I read the challenge: .œ2ùOÆÄWk. :)

Here an alternative 8-byter based on the 6-byte Jelly answer (1-based indexing): .¥·IOαWk

Jelly, 10 bytes
ḣJ§ạSH$iṂ$

Try it online!
How?
ḣJ§ạSH$iṂ$ - Main link (with input l, e.g. l = [1, 2, 4, 8, 16])
       iṂ$ - Get the index of the smallest element of
   ạ         - the absolute difference between
    SH$        - sum of elements in l divided by 2 and
ḣJ§            - for n in range(1, len(l)), get sum of the first n elements of l, e.g. [1, 3, 7, 15, 31]

Nice, welcome to CGCC! It turns out that my entry, ÄḤạSİM, is a golfed version of this. ḣJ§ is Ä. Doubling the left, ÄḤ, saves the $ used when halving the right, SH$. I also return all possible indices by finding the maximal indices, M, of the inverse values, İ.

@JonathanAllan Interesting. I'm fairly new to Jelly, and there's some quirks that I didn't know, like the Ä. So thank you for your explanation!

It does take some time for most people, seems like you're off to a good start so keep going! Also note that there is a chat room for getting better with Jelly (it's not very active, but is used).

Red, 60 bytes
func[a][s: 0 i: 1
while[(s: s + take a)<= sum a][i: i + 1]i]

Try it online!
1-indexed

Perl 5 -aple, 39 bytes
my$i;@F=map{(++$i)x$_}@F;$_=$F[$#F/2-1]

Try it online!
...or 42 bytes:
sub f{my$i;@_=map{(++$i)x$_}@_;$_[@_/2-1]}

Try it online!

Haskell, 101 85 bytes
f x=snd$minimum$(`zip`[0..])$(\(a,b)->abs$sum a-sum b).(`splitAt`x)<$>[0..length x-1]

Try it online!
Less golfed:
minIndex f=snd.minimum.(`zip`[0..]).map f
f x = minIndex inner [0..length x-1]
  where
    inner = (\(a, b)->abs$ sum a - sum b) . (`splitAt` x)

Your let could be replaced with a pattern guard. Try it online!

Also I'm not sure why you map across z just to index by i.  Since z is just a range of numbers this is the same as applying the function to i directly which saves a lot of bytes and gets rid of the need for let altogether.

changed it to a zip which I think is what you were getting at but looks like you had a better idea!

C# (Visual C# Interactive Compiler), 58 49 bytes
Uses a variable declaration via is to avoid declaring a proper body and having to type the excessively long word return.
For some reason List has the method FindIndex, but other IEnumerables don't seem to.
a=>0is var s?a.FindIndex(e=>(s+=e)>a.Sum()-s+e):0

Try it online!

C (gcc), 112 bytes
l;r;f(int n,char**m){char*i=*(m+1),*j=i;while(*j++);for(j-=2,r=l=0;i<=j;)l<r?l+=*i++:(r+=*j--);return i-*(m+1);}

Try it online!
Unfortunately I did not figure out how to input hex characters as arguments into the program with the online view.
Basically the input consists of a single "argument" which is the array of numbers.

Welcome to Code Golf SE! We're glad to have you.
Looking over this answer, I'm struggling to make sense of it. Admittedly, I'm no C expert, but perhaps a brief explanation of what the arguments and return value are might be in order. If you want to provide an example of your code in action, check out Try It Online, created by our very own Dennis; it makes writing, testing, and sharing code very easy, even to the point of copying an entire well-formatted Code Golf SE submission to your clipboard automatically!

Thank you for pointing this out to me - i updated the answer accordingly.

Desmos, 69 66 bytes
f(l)=L[∑_{n=1}^Ll[n]>=∑_{k=L}^{L.max}l[k]][1]
L=[1...l.length]

Returns 1-based indices. Uses the same strategy as ovs's Python answer
Try It On Desmos!
Try It On Desmos! - Prettified

Scala, 117 bytes
def g(l:List[Int],s:Int,i:Int):Int={val h::t=l;if(t==Nil)i else if(s+h>t.sum)if(s<l.sum)i+1 else i else g(t,s+h,i+1)}

This question deserved a lengthy suboptimal PHP answer, that has to cope with the fact that the arguments array starts with the script name, forcing me to add the $i>1 test that leads to extra brackets, and such oddities..
PHP, 124 bytes
$f=array_sum;$g=array_slice;for($a=$argv;$a[++$i];$s=$r)if(($s<$r=abs($f($g($a,$i))-$f($g($a,0,$i))))&$i>1)break;echo($i-2);

Try it online!

Java (JDK), 84 bytes
a->{int i=0,j=a.length-1,l=0,r=0,t;for(;i<j;)t=l<r?l+=a[i++]:(r+=a[j--]);return-~i;}

Try it online!
Credits

-1 byte thanks to ceilingcat

82 bytes


text:
Binary Reduce a List By Addition With a Right Bias
Given a list of 2 or more strictly positive integers, sum the first and last half of the list, with the middle element being counted only in the right half if the list has an odd number of elements
Some examples of the middle element being counted in the right half:
[1, 2, 3, 4]       -> Left: [1, 2];    Right: [3, 4]
[1, 2, 3]          -> Left: [1];       Right: [2, 3]
[1, 2, 3, 4, 5]    -> Left: [1, 2];    Right: [3, 4, 5]
[1, 2, 3, 4, 5, 6] -> Left: [1, 2, 3]; Right: [4, 5, 6]

Test Cases
Input
[1, 9]
[9, 5, 5, 7]
[6, 7, 5, 1, 3, 9, 7, 1, 6]
[2, 8, 10, 9, 9, 3, 7, 8, 9, 8, 6, 1, 2, 9, 8, 3, 8, 9, 5]
[2, 3, 1, 8, 6, 2, 10, 6, 7, 6]

Output
[1, 9]
[14, 12]
[19, 26]
[65, 59]
[20, 31]

Reference Program With Two Output Methods
Rules

Input/Output can be Taken/Given in any convenient and reasonable format.
Functions and full programs are both acceptable.

So just to confirm, we're permitted to return the two sums in reverse order (right sum then left sum)?

Yes you are allowed to.

Can the output be in reverse order?

@Shaggy The question is asked and answered above

Brachylog, 3 bytes
ḍ+ᵐ

Try it online!
Brachylog's cut-a-list-in-half predicate just so happens to already make the right half larger.

Python 2, 40 bytes
Takes as input a list \$ l \$, and outputs the two sums in reverse order ([right, left]).
lambda l:[sum(l.pop()for x in l),sum(l)]

Explanation
In sum(l.pop()for x in l), we pop the last element, in each iteration, and sum the popped elements. Surprisingly, the loop only runs \$ \lceil{\frac{|l|}{2}}\rceil \$ times, since for every element we iterate from the left, we are removing an element from the right, resulting in the loop terminating somewhere in the middle. Therefore it gives us the sum of the right portion of the list. The sum of the remaining elements make up the left portion.
Try it online!

That's a clever use of .pop() to ensure that only half of the list is summed... That took me a while to figure out how it was doing it!

Python 3.8, 41 bytes
lambda l:[t:=sum(l[:len(l)//2]),sum(l)-t]

Try it online!
Straightforward solution. Takes in a list, and returns the list of left and right sum.

Interesting idea that didn't go anywhere :(
Python 3, 45 bytes
lambda l,t=1j:l>[]and l[-1]+t*f(l[-2::-1],-t)

Try it online!
Returns a+bj where a, b is the right and left sum respectively.

Haskell, 44 43 bytes
f x=[sum$y(div(length x)2)x|y<-[take,drop]]

Try it online!
Based on Steven Fontanella's answer with some non-trivial modification.

K (ngn/k) / oK / K4, 8 bytes
+/'2 0N#

Try it online!

...also works in K4 and oK if you wanted to add them to the title

@streetster Thanks! I think I tried it in oK.

J, 14 bytes
-@>.@-:@#+/\|.

Try it online!
Output is in reverse.

Pyth, 6 5 bytes
Outputs the two sums in reverse order (right sum, then left sum)
sMc2_

Try it online!
 sMc2_
     _  Reverse the input
   c2   Chop into 2 equal-sized chunks, with the first chunk
         one element longer if necessary
 sM     Sum each chunk

Rust, 71 bytes
|x:&[u8]|{let s=x[..x.len()/2].iter().sum();(s,x.iter().sum::<u8>()-s)}

A closure that takes a reference to a slice of 8-bit unsigned numbers and returns a tuple of two 8-bit unsigned numbers.
try it online on the rust playground.

Haskell, 50 bytes
f x=(\(a,b)->sum<$>[a,b])$splitAt(length x`div`2)x

Try it online!

Lambdas almost always have a shorter alternative.  In this case you save a bye with a helper

@AdHocGarfHunter Would love to see it! For some reason, it the TIO link shows up empty, though... (on my phone)

Octave, 33 bytes
@(x)x*[u=(t=find(x))<mean(t);~u]'

Try it online!
How it works
@(x)x*[u=(t=find(x))<mean(t);~u]'

@(x)                               % Define an anonynous function with input x
            find(x)                % Indices of nonzero entries of x. Gives [1 2 ... n]
                                   % where n is the length of x
         (t=       )               % Assign that to variable t
                    <mean(t)       % Test if each entry of t is less than the mean of t.
                                   % This gives [1 ... 1 0 ... 0], with floor(n/2) ones
                                   % and n-floor(n/2) zeros
       u=                          % Assign that to variable u
      [                     ;~u]   % Build a 2×n matrix containing u in the first row
                                   % and u negated in the second row
                                '  % Conjugate transpose. Gives an n×2 matrix
    x*                             % Matrix-multiply x (size 1×n) times the above n×2
                                   % matrix. Gives a 1×2 vector containing the result

APL (Dyalog Extended), 12 bytes
Anonymous tacit prefix function
+/2 ¯.5⍴⌽,0⍨

Try it online!
0⍨ zero
⌽, appended to the reverse of the argument
2 ¯.5⍴ reshape to 2 rows and as many columns as needed, chopping trailing elements if uneven
+/ sum the rows

Jelly, 4 bytes
ŻŒH§

A monadic Link accepting a list which yields the pair: first-half-sum, last-half-sum.
Try it online!
How?
ŻŒH§ - Link: list, A
Ż    - prepend a zero to A
 ŒH  - split that in half (if the length is odd the first half gets the extra element)
   § - sums

Rust macro, 480 bytes
macro_rules!f{($($r:expr)*)=>{f!(@I;[$($r),*];[];)};(@$($d:ident)*;[];[$($a:tt)*];$($b:tt)*)=>{f!(%($)0;0;[$($a)*]$($b)*)};(@$($d:ident)*;[$x:expr$(,$r:tt)*];[$($a:tt)*];$($b:tt)*)=>{f!(@I$($d)*;[$($r),*];[$($a)*;($($d)*,$x)];($($d)*,$x);$($b)*)};(%($m:tt)$s:expr;$t:expr;[;($($d:ident)+,$x:expr)$($a:tt)*]$(;)*($($e:ident)*,$y:expr)$($b:tt)*)=>{{macro_rules!i{($($d)*$m(I)+)=>{f!(%($m)$s+$x;$t+$y;[$($a)*];$($b)*)};($($d)*)=>{($s,$t+$y)};($m(I)*)=>{($s,$t)}}i!($($e)*)}};}

try it online
This is kind of insane and I kind of hate myself now. The code defines a macro that takes a sequence of whitespace-seperated numbers and expands to a tuple of 2 integers. Everything is calculated at compile-time, so the code runs in \$O(1)\$, but compile times may vary.
For an introduction to Rust macros, I recommend the Rust book, the Rust refeence and The Little Book of Rust Macros.
Explanation
So rust macros operate on token streams that are matched against patterns. For our case, the main difficulty is that you basically have to consume the token stream front-to-back.
To defeat this, I first replace the list of numbers with two numbers, where one of them is reversed. Also, to be able to find the middle, I put an index next to each number. Since yout can't evaluate integer expression like 0+1, I use a tally counter made up of I identifier tokens. That way, I can detect the midpoint by comparing the length of the tally counter. Each part is replaced with ad addition of all its components, which can be evaluated at compile time.
Example
Let's use 1 2 3 as an example. This shows the basic idea, but is still simplified a bit.
1 2 3
[1 2 3] [] []  // input forward backward
[2 3] [(I, 1)] [(I, 1)]
[3] [(I, 1); (I I, 2)] [(I I, 2); (I, 1)]
[] [(I, 1); (I I, 2); (I I I, 3)] [(I I I, 3); (I I, 2); (I, 1)]
0; 0; [(I, 1); (I I, 2); (I I I, 3)] [(I I I, 3); (I I, 2); (I, 1)]  // two accumulators
0 + 1; 0 + 3; [(I I, 2); (I I I, 3)] [(I I, 2); (I, 1)]
(0 + 1; 0 + 3 + 2)

Refer to the compiler output in the rust playground for the complete expansion.
// Define a macro called f
macro_rules! f {

    // This rule is the starting point
    // It matches any number of expressions
    ($($r:expr)*) => {
        // Use the internal rules with an at sign.
        // Provide the I as the first index.
        f!(@ I; [$($r),*]; [];)
    };

    // The rules starting with an at sign are responsible for producing a reversed version
    // of the input and counting with tallys.
    // This pattern is known as tt-muncher because it consumes a token tree recursively.

    // This is the base case. It matches when the input is an empty set of brackets.
    (@ $($d:ident)*; []; [$($a:tt)*]; $($b:tt)*) => {
        // Call the second set of internal macros (the ones starting with a percent sign).
        // We use zeros as the accumulators
        f!(% ($) 0; 0; [$($a)*] $($b)*)
    };
    // This is the recursive case.
    // It extracts one expression (called x) from the input.
    (@ $($d:ident)*; [$x:expr $(,$r:tt)*]; [$($a:tt)*]; $($b:tt)*) => {
        // Call the at-macro recursively.
        // Add one I to the current tally list.
        // append (tallys, $x) to the first "array".
        // prepend (tallys, $x) to the second "array".
        f!(@ I $($d)*; [$($r),*]; [$($a)*; ($($d)*, $x)]; ($($d)*,$x); $($b)*)
    };

    // This part of the macro is called with the original and the reversed version.
    // The first argument is a dollar sign because that it needed later.
    // It extracts the count $d and value $x of the forwards array,
    // and count $e and value $y of the backwards array.
    (% ($m:tt) $s:expr; $t:expr; [; ($($d:ident)+, $x:expr) $($a:tt)*] $(;)* ($($e:ident)*, $y:expr) $($b:tt)*) => {
        {
            // To compare the two tally counters at compile time, we use an internal macro.
            // It defined rules based on $d.
            // The argument of this macro will be $e.
            macro_rules! i {
                // This case matches when $e is larger than $d.
                // That means we haven't found the end yet.
                ($($d)* $m(I)+) => {
                    // call this part recursively, adding $x and $y to their accumulators
                    f!(% ($m) $s+$x; $t+$y; [$($a)*]; $($b)*)
                };
                // $e and $d are equal.
                // This case is reached when there is an odd number of element in the input.
                ($($d)*) => {
                    // Add the value to the right accumulator and expand to a tuple
                    ($s, $t+$y)
                };
                // $e is less than $d.
                // We have moved past the midpoint.
                ($m(I)*) => {
                    // Expand to a tuple containing the accumulators
                    ($s, $t)
                }
            }
            // call the internal macro with $e
            i!($($e)*)
        }
    };
}

brainfuck, 180 bytes
++>>>>>+>,[[<]>+[>],]<[<]>[<+>-]<[<<<<[>>+<+<-]>[<+>-]>[<+>>>-[<<<[-]>>+>-]<[>+<-]<<[>-[>>>-<<<[-]]+<-]>-]>>>+<]>[<<+>+>-]<<[>>+<<-]>[>-<[-]]>[[>]<[<+>-]<[<]>-]>>>[<<[->+<]>>>]<.<.

Try it online! (testcase [2, 8, 10, 9, 9, 3, 7, 8, 9, 8, 6, 1, 2, 9, 8, 3, 8, 9, 5])
Takes input as bytes on stdin.
Outputs the two sums as bytes on stdout in reverse order.
Compiled from this VBF 1.0 code with mapping requirement x:5 :
# set y to 2
y++

# Input is to the right of x; which is the length and the divdend
# Ensure that x is the rightmost variable
# x is the length of a length-prefixed array of numbers
x+>,[[<]>+[>],]
<[<]>
#cursor is at x
# x = x / y
# from user Calamari from esolangs wiki at https://esolangs.org/wiki/Brainfuck_algorithms
x[A+x-]
A[
 y[B+C+y-]
 C[y+C-]
 B[
  C+
  A-[C[-]D+A-]
  D[A+D-]
  C[
   B-
   [x-B[-]]+
  C-]
 B-]
 x+
A]
# After this, x = x / 2, A,B,C,D = 0, y = y
# If x, x = x - 1
# from https://esolangs.org/wiki/Brainfuck_algorithms#if_.28x.29_.7B_code_.7D
x[D+A+x-]D[x+D-]
A[
  x-
  A[-]
]

# Add up first half, cursor starts at x
# Requires that the cell to the left of x is 0
x[
  [>]<   # last input
  [<+>-] # add into left neighbor
  <[<]>- # back to x, decrement x
]

>>>
[
  <<[->+<]>>>
]<.<.

asm2bf, 157 bytes
A rather long submission. Let's take a look at the golfed code first:
@l
in r1
cner1,0
cadr2,1
cpsr1
cjn%l
movr3,r2
modr3,2
divr2,2
movr4,r2
addr2,r3
@x
popr1
addr5,r1
decr2
jnzr2,%x
@y
popr1
addr6,r1
decr4
jnzr4,%y
outr6
outr5

Try it online!
I/O format
The program takes input in form of so-called ASCII characters, and produces the output analogically. It's recommended to test the program on a 16-bit brainfuck interpreter (so that the addition doesn't overflow quickly).
asm2bf is a separate language to brainfuck, therefore the Brainfuck restrictions theoretically don't apply to it (because for instance, asm2bf specification says that registers for programmer's convience are at least 16 bits long), but as there is no asm2bf interpreter on TIO, I have to somehow cope with these limitations.
That being said, let's look at some I/O examples:
!"#$% => [33, 34, 35, 36, 37] => [33 + 34, 35 + 36 + 37] => [67, 108] => Cl
!"#$ => [33, 34, 35, 36] => [33 + 34, 35 + 36] = [67, 71] => CG

Explanation
Let's take a look at the ungolfed representation of the code.
Golfing 101
@inloop
    in r1
    cne r1, 0
    cadd r2, 1
    cpush r1
    cjn %inloop

    mov r3, r2
    mod r3, 2
    div r2, 2
    mov r4, r2
    add r2, r3

@right
    pop r1
    add r5, r1
    dec r2
    jnz r2, %right

@left
    pop r1
    add r6, r1
    dec r4
    jnz r4, %left

    out r6
    out r5

Let's answer two questions first:
=> Why does the code compile without spaces between operand and the operation?
The answer is quite simple: the assembler is a very primitive tool. It assumes instruction length of three, therefore after reading instruction name, all spaces are then consumed (but obviously there can be no spaces inbetween).
=> Why is there a space between in and r1?
in is a special instruction, because it has two character length. Under the hood, it's padded to three characters using the floor character (_). Therefore, if the space was ommited, then the assembler would interpret r as the instruction name.
=> Instructions changed. cpo took place of cpush, cad of cadd. Why?
It is perfectly legal, because if every instruction has to have a three byte name, then there must be some alias that magically swaps long instruction names into short instruction names, right?
That's the full list of aliases, as of v1.3.9 (taken from the lib-bfm.lua file):
; Don't ask questions, this is beyond explaining
?band=x00
?bor=x01
?bxor=x02
?bneg=x03
?cflip=x04
; Some common defines
?push=psh
?xchg=swp
; Conditional instructions
?cadd=cad
?csub=csu
?cmul=cmu
?cdiv=cdi
?cmod=cmd
?casl=csl
?casr=csr
?cpow=cpw
?cpush=cps
?cpsh=cps
?cpop=cpo
?cxchg=csw
?cswp=csw
?csrv=crv
?cmov=cmo
?crcl=crc
?csto=cst
?cout=cou

That being said, let's dive into the algorithm.
Algorithm
Let's dissect the code step by step for better understanding:
@inloop
    in r1
    cne r1, 0
    cadd r2, 1
    cpush r1
    cjn %inloop

Some parts are obvious (label declarations for example), some are less. A new feature introduced around v1.3.5 named conditional instructions helps us greatly to solve this task.
The conditional pipeline of this fragment follows:
; if r1 is not zero, set the flag, otherwise clear it
    cne r1, 0
; if flag is set, add 1 to r2 (we accumulate the list length)
    cadd r2, 1
; push the number on the stack if the flag is set.
    cpush r1
; jump to @inloop if the flag is set.
    cjn %inloop

As you can see, it's quite simple to notice, that this tiny block of code will is responsible for:

reading the list
accumulating it's elements on the stack
keeping track of the amount of elements read (in r2)
looping until hit EOF

Note: Yes, it's true that you have to set the stack before accessing it, otherwise stack overflow error occurs. In this case, I simply don't make memory accesses, so it's not required to set the stack (because it has nowhere to overflow to)
Between these two loops, there is a tiny block of setup code:
; r3 = r2
    mov r3, r2
; r3 = r2 mod 2
    mod r3, 2
; r2 = r2 / 2
    div r2, 2
; r4 = r2
    mov r4, r2
; r2 = r2 + r3
    add r2, r3

This means, the register values are now:
r4 = r2 / 2
r3 = r2 mod 2
r2 = (r2 / 2) + r3

r3 is used as a flag to indicate whenever the middle element is present and it has to be merged to the list on the right (if count mod 2 is 1, then the count is odd, therefore we have a middle element obviously). The flag is added to the r2 register so the following loop will slurp it from the stack.
Next, there are two very simillar loops. Let's dissect these:
@right
    pop r1
    add r5, r1
    dec r2
    jnz r2, %right

@left
    pop r1
    add r6, r1
    dec r4
    jnz r4, %left

@right will execute until r2 is not zero (id est, the amount of elements left to extract from the stack to make the right list). Everytime an element is popped, the pointer (r2) decreases and the popped value is added to r5.
This being said, @right will simply extract r2 elements from the stack and sum them up to r5.
@left works pretty much the same (it will build the list on the left) returning the result in r6.
And finally, we output both values (sum for the left and the right):
    out r6
    out r5

Appendix A
Generated brainfuck code (around 1.9 kilobyte):
+>+[>>>+<<+<<[>>->+<<<-]>>>[<<<+>>>-]<[->+<<[>>>-<<+<-]>[<+>-]>>[<->[-]]<[<<<+>>>-]<]>>[-]<<<<[>>+>+<<<-]>>[<<+>>-]>[[-]>>,>>>>>>>>>>>[-]<<<<<<<<<<<[<<<+>>>>>>>>>>>>>>+<<<<<<<<<<<-]<<<[->>>+<<<]>>>>>>>>>>>>>>[<<<<<<<<<<<<<+>>>>>>>>>>>>>-]<<<<<<<[<<<<<<->+>>>>>-]<<<<<[>>>>>+<<<<<-]<[>>>>>>>>>>>>>+<<<<<<<<<<<<<[-]]>>>>>>[-]+>>>>>>>[<<<<<<<[<<<+<<+>>>>>-]<<<<<[>>>>>+<<<<<-]>>>>>>>>>>>>[-]<+>]<[>+<-]<<<<<<[-]>>>>>>>[<<<<<<<<<<<[<+>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<-]<[>+<-]>>>>>>>>>>>>>>>>>[>>]+<<[<<]>[>[>>]<+<[<<]>-]<<<<[-]<+>]<[>+<-]<<<<<<+>>>>>>>[<<<<<<<<<<<<<<+>+>>>>>>>>>>>>>-]<<<<<<<<<<<<<<[>>>>>>>>>>>>>>+<<<<<<<<<<<<<<-]>[<<<[-]>[-]>>>>>>>>[<<<<<<<<+>+>>>>>>>-]<<<<<<<[>>>>>>>+<<<<<<<-]>[-]]>>>>>>[-]<<<<<<]<<<[>>+>+<<<-]>>[<<+>>-]>[[-]>>>>[-]<[>+<<<+>>-]<<[>>+<<-]>>>>>++[>>>>+<<<<-]<<[>>>>>+>-[<<]<[[>+<-]<<]<<<-]>>>>>[<<<<<+>>+>>>-]>[<<<<+>>>>-]<<<<[-]++<<<[<<<<+>>>>-]<<<<[>>>>>>>[<<<<<<+>+>>>>>-]<<<<<[>>>>>+<<<<<-]<[>+<<-[>>[-]>>>>>>+<<<<<<<<-]>>>>>>>>[<<<<<<<<+>>>>>>>>-]<<<<<<[<-[>>>-<<<[-]]+>-]<-]>>>+<<<<]>>>>>>>[-]<[-]<<[>>+<<<<+>>-]<<[>>+<<-]>>>[<+<<+>>>-]<<<[>>>+<<<-]<]>++<<+<<[>>->+<<<-]>>>[<<<+>>>-]<[->+<<[>>>-<<+<-]>[<+>-]>>[<->[-]]<[<<<+>>>-]<]>>[-]<<<<[>>+>+<<<-]>>[<<+>>-]>[[-]>>[-]>>>>>>>>>>>>>>>[-]>[>>]<<->[<<<[<<]>+>[>>]>-]<<<[<<]>[<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<<[>>>>>>>>>>>>+<<<<<<<<<<<<<+>-]<[>+<-]>>->>>++<<<[<<<<+>+>>>-]<<<<[>>>>+<<<<-]>[<<<[-]>[-]>>>>>>>>[<<<<<<<<+>+>>>>>>>-]<<<<<<<[>>>>>>>+<<<<<<<-]>[-]]>>>>>>[-]<<<<<<]>+++<<+<<[>>->+<<<-]>>>[<<<+>>>-]<[->+<<[>>>-<<+<-]>[<+>-]>>[<->[-]]<[<<<+>>>-]<]>>[-]<<<<[>>+>+<<<-]>>[<<+>>-]>[[-]>>[-]>>>>>>>>>>>>>>>[-]>[>>]<<->[<<<[<<]>+>[>>]>-]<<<[<<]>[<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<<[>>>>>>>>>>>>>+<<<<<<<<<<<<<<+>-]<[>+<-]>>>>->+++<[<<<<<<+>+>>>>>-]<<<<<<[>>>>>>+<<<<<<-]>[<<<[-]>[-]>>>>>>>>[<<<<<<<<+>+>>>>>>>-]<<<<<<<[>>>>>>>+<<<<<<<-]>[-]]>>>>>>[-]<<<<<<]<<<[>>+>+<<<-]>>[<<+>>-]>[[-]>>>>>>>>>>>>>>>.<.<<<<<<<<<<<<<<]<<<[>>+>+<<<-]>>[<<+>>-]>[[-]<<<[-]>[-]>>]<<]

Appendix B
The code possibly can be golfed down using constpp - the tool used to set macros on certain [A-Za-z]+ strings and alias them into other, preferably longer strings. Syntax: ?find=replace
There is a tiny chance that one could golf the code down using Lua preprocessor. If you'd like to start a multiline Lua block, use ${...) syntax; single line Lua statements can be prepended with #.
Example on both methods: lib-bfm.lua.
lib-bfm is a file included everytime an assembly program is built using bfmake tool (the one to assemble your code into a ready-to-use Brainfuck program). It's overall recommended to take advantage of it, because it contains some predefined macros (like a memory allocator or quite basic code-preprocessing capabilities).
PS: If anything is unclear, please let me know down in the comments. I'll try to clarify it when I'll have some time on my hands.

brainfuck, 45 43 bytes
>>>,[>,[[<]>[<+>-]>[>]],]<[[>[<+>-]<<]>.<<]

Shorter, but assumes ',' continues to return 0 after EOF, not just the first time after EOF.
Earlier version:
>>>>>,[>+[<<]+>>->>[>>]+>,]<[[<[<<+>>-]<]<.<]

Reads numbers as characters, outputs right sum first.

JavaScript (ES6),  47  45 bytes
Outputs in reverse order.
a=>[a.reduce(s=>s+a.pop(),0),eval(a.join`+`)]

Try it online!

05AB1E, 4 bytes
R2äO

Try it online!

Clojure, 47 bytes
#(for[x(split-at(quot(count %)2)%)](apply + x))

Try it online!

R, 46 45 bytes
sum((v=scan())[l<-1:(sum(v|1)/2)]);sum(v[-l])

Try it online!
Edit: thanks to Giuseppe: -1 byte

use l<-... instead of (l=...); it's a byte shorter :-)

Thanks again Giuseppe!  BTW: do you have any idea why <- should be designed to behave differently to = in this context (apart from sneaky code golf use)?

The docs say The operators <- and = assign into the environment in which they are evaluated. The operator <- can be used anywhere, whereas the operator = is only allowed at the top level (e.g., in the complete expression typed at the command prompt) or as one of the subexpressions in a braced list of expressions. So since l is actually an argument to the [ function, it's not at the top level. Or so I believe.

Thank you: I will try to digest what that means.  It's quite disconcerting to imagine that I might actually learn something useful while trying to just waste my time code golfing...

You're not the only one! Myself included, haha. Sometimes my golfing habits kick in when writing real R code, though...

Risky, 12 bytes
_?+_0\!?/_2_+?+_0+_0+_0

Try it online!

Thunno 2, 4 bytes
r2Ẇʂ

Try it online!
Explanation
r2Ẇʂ  # Implicit input
r     # Reverse the list
 2Ẇ   # Split it in two pieces
      # (with a left-bias)
   ʂ  # Sum each inner list
      # Implicit output

Charcoal, 12 bytes
Ｆθ⊞υ⊟θＩ⟦ΣθΣυ

Try it online! Link is to verbose version of code. Port of @dingledooper's answer. Explanation:
Ｆθ

Loop over the list.
⊞υ⊟θ

Move the last element of the list to the empty list.
Ｉ⟦ΣθΣυ

Output the sums of the lists.

C (gcc), 77 bytes
i,l;f(a,n)int*a;{l=0;for(n-=i=n/2;i--;!i?i=n,n=l=!printf("%u ",l):0)l+=*a++;}

Takes as input an array and its size.
Try it online!

APL+WIN, 18 bytes
Prompts for vector of integers:
+/(2,⌈.5×⍴s)⍴s←0,⎕

Try it online! Coutesy of Dyalog Classic

Red, 52 bytes
func[a][reduce[sum take/part a(length? a)/ 2 sum a]]

Try it online!

Husk, 4 bytes
mΣ½↔

Try it online!
Explanation
   ↔ Reverse the input
  ½  Split the input into about-equal parts of 2
m    For every item in the list:
 Σ       Sum this list

dc, 35 bytes
?[zRla+salFx]sU[lb+sbz0<U]dsFxlblaf

Try it online!
Verify the test cases online.
Input is a space-separated list of numbers on stdin.
Output is on stdout, on two lines: the sum of the left part, then the sum of the right part.
How it works:
?        Read the input and push it on the stack.
            (The last number in the list is at the top of the stack.)

[        Start a macro.
 zR        Move the bottom item on the stack to the top,
              moving the rest of the stack down one item.
 la+sa     Pop the top item on the stack and add it to register a.
              This number comes from the left part.
 lFx       Execute F recursively.
]sU      End the macro and name it U.

[        Start a macro.
 lb+sb     Pop the top item on the stack and add it to register b.
              This number comes from the right part.
              (Note that if the stack is empty so that there's
              nothing to pop, then b is left unchanged.
              This will happen the last time through when the
              original list had an even number of items.)
 z0<     If there's anything still on the stack,
 U         then execute macro U (which adds the bottom item on the
           stack to register a and then executes F recursively).
]dsFx    End the macro, name it F, and execute it.

lblaf    Print a, then print b.

C (gcc), 67 bytes
f(x,y,a,b)int*x,*y,*a,*b;{for(*a=*b=0;x<y--;*a+=x<y?*x++:0)*b+=*y;}

Try the test cases online!
This is a function with two "in" parameters (x and y) and two "out" parameters (a and b).
Input is taken as an array of ints, and is passed as a pointer x to the beginning of the array and a pointer y to (the location immediately after) the end of the array.
The function returns the left and right sums in *a and *b, respectively.

Factor, 55 54 bytes
: f ( s -- s s ) dup length 2/ floor cut [ sum ] bi@ ;

Try it online!

Julia, 41 bytes
a->[sum(a[1:(e=end÷2)]),sum(a[e+1:end])]

Scala, 42 bytes
val(a,b)=l.splitAt(l.size/2);(a.sum,b.sum)

Sorry but i'm not sure if it has to be a function if it is the case it costs 74 bytes.
val f:List[Int]=>(Int,Int)=l=>{val(a,b)=l.splitAt(l.size/2);(a.sum,b.sum)}

It should be written using a tail recursion to be more efficient but the cost in caracters would be higher.

Hello and welcome to CGCC! To answer your question, yes your code should be formatted as a function to be considered a valid submission (you could also format it as a full program by reading from STDIN, but I'm guessing that would be longer).

Thank you for joining Codegolf! We allow an anonymous function l=>..., because that is a expression that be assigned to a variable. That way, you don't need to count the type annotation. Also, you can take a look our tips for golfing in scala.

You don't need to write out the whole function like that. You can do it like this with a lambda, and it's just 4 bytes more

PHP, 60 bytes
for(;$a=$argv[++$i];)$r[$i<count($argv)/2]+=$a;var_dump($r);

Try it online!
Like often, much shorter with a straight loop.. PHP and arrays, sigh
PHP, 79 bytes
fn($l,$g=array_sum,$h=array_slice)=>[$g($h($l,0,$n=count($l)/2)),$g($h($l,$n))]

Try it online!
PHP takes care itself of the right bias.. it's long mostly because array functions have lengthy names..

MathGolf, 8 bytes
h½‼<≥αmΣ

Try it online.
Explanation:
h        # Get the length of the (implicit) input-list (without popping the list itself)
 ½       # Halve it (integer-divided by 2)
  ‼      # Apply the following two commands separately:
   <     #  Take all elements of the list smaller than the length//2
   ≥     #  Take alle elements of the list larger than or equal to the length//2
    α    # Wrap both lists into a list
     m   # Map over this list of lists:
      Σ  #  And sum each inner list
         # (after which the entire stack joined together is output implicitly as result)

JavaScript (V8), 68 bytes
(l,h=k=>k.reduce((a,e)=>a+e,0))=>([h(l.splice(0,l.length>>1)),h(l)])

Try it online!

MAWP, 17 bytes
%@[_2A{%M~}]%:1;:

Try it! (Only first line is taken as input)
Outputs sums in reverse.

Factor + math.unicode, 21 bytes
[ halves [ Σ ] bi@ ]

Try it online!
Explanation:
It's a quotation (anonymous function) that takes a sequence from the data stack as input and leaves two integers on the data stack as output.

halves Split a sequence in half. Luckily for us, it keeps the middle element with the latter sequence.
[ ... ] bi@ Apply a quotation to two objects.
Σ Sum a sequence.

Vyxal, 7 bytes
Ṙ₅½⌈ẇv∑

Try it Online!
-1 thanks to lyxal

Try it Online! for 7

Vyxal 2.7.2, 2 bytes
IṠ

Try it Online!
Yes.
Explained
IṠ
I  # Split the input list into two halves. Due to a bug in 2.7.2, this unintentionally gives the right bias required
 Ṡ # Sum of each sublist.

JavaScript (V8), 53 bytes
x=>eval(x.splice(x.length/2,0,'0,')+`[${x.join`+`}]`)

Try it online!

Arturo, 34 bytes
$->a[map split.at:/size a 2a=>sum]

Try it!

Perl 5 -a, 33 bytes
map$a[$i++>@F/2-1]+=$_,@F;say"@a"

Try it online!

Uiua SBCS, 11 bytes
∩/+⊃↘↙⌊÷2⧻.

Try it!


text:
Is the input Bl lu ur rr ry?
This is based off this challenge.
Given an input string, check whether the string is blurry.
What's a blurry string?
A blurry string is a string that's contained in the set of all blurrified pure-ASCII strings.
Take a non-blurrified pure-ASCII string abc as an example. You repeat every character of this twice:
aabbcc

And then insert spaces at every odd-even index.
a ab bc c

Then, remove the preceding 2 and succeeding 2 extra characters. If there isn't enough space left, ignore the abundant removing instructions.
ab bc

As an example, all of these strings are blurry (the empty line stands for an empty string):
Before  After
"a"   ->
"ab"  ->ab
"abc" ->ab bc
"abcd"->ab bc cd
...

(Before = the string before blurrification)
(After  = the string after blurrification,
i.e. the strings in the set of all blurry strings.)

Specification

The input string consists purely of printable ASCII characters. The only whitespace it will contain is the space character.
You don't have to remove extra characters before the check.
Your output can consist of any trailing whitespace, as long as it's possible to tell a truthy result from a falsy result.
It's noteworthy that the definition of "blurry" in this challenge is different than the previous challenge.

Test cases
Here is a program I use to check my test cases.
""          -> True
"ab"        -> True
"ab bc"     -> True
"aa aa"     -> True
"ab bc cd"  -> True
" b bc cd"  -> True
"ab bc c "  -> True
"a   c cd"  -> True
"        "  -> True

"a"         -> False
"abc"       -> False
"ab  bc  cd"-> False
"ab#bc#cd"  -> False
"abbccd"    -> False
"a ab bc cd"-> False
"a a ab b b"-> False
"ba cb dc"  -> False
"ba bc dc"  -> False
"FFaallssee"-> False
"a aa a"    -> False

I think it would be good to include some test cases where characters in the pre-blurred string repeat.

I meant truthy ones like a aa a or even just eight spaces. (Edit: Oops, I mean aa aa)

I'd argue the empty string is not blurry because one doesn't simply remove the first and last two characters from a string shorter than 4.

I don't understand how is " b bc cd" or "ab bc c " or "a c cd" or "" or " "*8 blurry. What are the strings that originated those?

Depending on the answer to my comment above, it might be good to edit the challenge to explicitly specify we are defining a blurry string in a way that is different from what was done in the challenge in which this one is inspired

@RGS " bcd", "abc" , "a cd" , "" and "    " (4 spaces) respectively

@JoKing if you are right, then "it might be good to edit the challenge to explicitly specify we are defining a blurry string in a way that is different from what was done in the challenge in which this one is inspired" (which should be done by the OP, not saying you should do it)

Perl 5 with -plF/^(.((.)\x20\3)*.|)$/, 7 bytes
$_=@F^1

Try it online!
Explanation
Continuing the theme of abusing -F, I ended up with the same expression used in the Retina answer. The -F argument splits the input string on the valid expression and will place an even number of elements in @F, if the regular expression doesn't match, @F will just contain one entry, the whole string. When numeric operators are applied to a list (@F in this case) the length is implicitly used, so we XOR with 1 to give 0 for the failing test cases and a positive integer for all others.

Retina, 14 bytes
a`.((.) \2)*.|

Try it online!
Explanation
a forces the match to be on the entire string
.((.) \2)*. just means any character (.) followed by a captured group repeated 0 to many times ((...)*) of any character saved into a second captured group ((.)) followed by a space and the same character that was matched in the second capture group (\2). The final . just matches the last character
| allows the empty string to match by having an alternative match of the empty string

Python 3, 60 54 bytes
-6 bytes thanks to Surculose Sputum!
a,*b,c=input()or'ab'
while b:x,y,z,*b=b;x[x!=z][y>' ']

Try it online! Output is via exit code.
By using different sets of errors for truthy/falsy inputs this can be 52 bytes, as suggested by Surculose Sputum.

55 bytes by throwing NameError when input is empty.

54 bytes.

-1 byte: x[x+y!=z+' ']

Python 2, 57 bytes
lambda x:x==''.join(c+' '+c for c in x[::3]+x[-1:])[2:-2]

Try it online!
Uses the same approach as my Pyth answer. The blurring portion of the code is based off of @Surculose Sputum's answer to the original "Blur a string" challenge.

Haskell, 68 bytes
_#""=1<2
p#(' ':x:y:s)|p==x=y#s
_#_=2<1
f""=1<2
f(x:y:s)=y#s
f _=2<1

Try it online!
Explanation
f is the entry point. No real tricks; loop through recursively ensuring that every third character is a space, while keeping track of the second character of the previous chunk each time and ensuring that it's equal to the first of the next chunk.

You can combine the first and last case for both (#) and f.  Try it online!

Pyth, 13 bytes
qjd.:+%3Q>1Q2

Try it online!
qjd.:+%3Q>1Q2
      %3Q      Take every 3rd character of the input string
                (eg. "ab bc cd" becomes "abc")
     +   >1Q   Append the last character of the input string
 jd.:       2  "Blur" the resulting string
                (ie. find all substrings of length 2 and join on spaces)
q              Return true if that matches the input string

For -1 byte, >1Q is the same as eQ

@ar4093 Yep, except that eQ throws an Index Out of Range error for the empty string :/

05AB1E, 16 13 12 bytes
¤º«3ô€нüJðýQ

Try it online!
Uses the blurring program here to re-blur the string. -1 byte thanks to Kevin Cruijssen!
Old Answer Explained
3ô`©)€н`®θJüJðýQ
3ô                  # Split the input into chunks of 3
  `©                # Item split the above and store the last item in the register
    )               # Wrap everything back into a list
     €н             # Get the first character from each item in then above list
       `            # Item split the list generated from the above map
        ®θJ         # Join the above with the last letter from the register
           üJðý     # Blatant port of https://codegolf.stackexchange.com/a/203906/78850 -- i.e. blur the string
               Q    # Check to see if the blurred string is the input

-1 by changing 3ô€н`IθJ to ¤º«3ô€н: verify all test cases.

Charcoal, 26 21 bytes
⁼✂θ¹±¹¦¹⭆✂θ¹±¹¦³⁺⁺ι ι

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, - for a blurry string, nothing if not. Explanation:
  θ                     Input string
 ✂ ¹±¹¦¹                Slice off the first and last characters
⁼                       Is equal to
          θ             Input string
         ✂ ¹±¹¦³        Every other third character
        ⭆               Map over characters and join
                ⁺⁺ι ι   Wrap a space in that character
                        Implicitly print

Japt, 13 bytes
The empty string being truthy cost a couple of bytes :\
¶¬ë3 pUÌ ä+ ¸

Try it (includes all test cases)
¶¬ë3 pUÌ ä+ ¸     :Implicit input of string U
¶                 :Test for equality with
 ¬                :Split to an array
  ë3              :Take every 3rd element, starting with the first
     p            :Push
      UÌ          :  Last character of U
         ä+       :Consecutive pairs, reduced by concatenation
            ¸     :Join with spaces

Red, 52 51 bytes
func[a][s:[skip]parse a[opt[s any[copy t s" "t]s]]]

Try it online!

Jelly, 8 bytes
m3żḊ$K⁼Ṗ

A monadic Link accepting a list of characters which yields 1 (blurry), or 0 (not blurry).
Try it online! Or see the test-suite.
How?
m3żḊ$K⁼Ṗ - Link: list of characters, S
m3       - modulo-3-slice (S)
    $    - last two links as a monad (f(X)):
   Ḋ     -   remove the head (X)
  ż      -   zip together (X and that)
     K   - join with spaces
       Ṗ - remove the tail (S)
      ⁼  - equal?

JavaScript (Node.js), 29 bytes
s=>/^.((.) \2)*.$|^$/.test(s)

Try it online!
Pure port


text:
Multiplication algorithm on a 4004
So I was playing around with this emulator of the Intel 4004 and decided I wanted to set a challenge for myself. The first use for the 4004 was in a calculator, so I decided  that I would try to code golf every operator on said calculator(addition, subtraction, multiplication, division, decimal points, and the square root) in hexadecimal. Now this was my first code golf challenge I ever set for myself, like ever, and I am relatively new at coding in general, but I thought it would be a fun thing to try out. This was the code for multiplication, specifically 3*4(In order to change it, simply replace the nybbles following the Ds[except for the 0] with any number you want as long as the product is below 16 and the second and third Ds have the same nybble trailing them):
 D4 B1 D3 B0 D3 B2 A0 82 B0 D0 B1 F8 F3 14 12 B1 40 06 B0 92 F3 E0

Are there any flaws in my 22-byte design, and is there a way to shorten the code?
For reference, the instruction set for the 4004 in binary is in this table: http://www.e4004.szyc.org/iset.html

PS, please do animate mode for testing. Run mode is buggy.

I think you should use the [tips] tag.

Note that hardcoding the inputs in the program is not allowed as per our site defaults. Looking at the emulator, I think a good compromise would be "assume two input values are loaded in two registers, and output to accumulator (or another register)".

Ok, some of my code is setting the inputs so thanks for the clarification!

4004 machine code, 12 bytes
This is the best code I could come up with using the same I/O as the provided code:
D4      LDM 4
B0      XCH R0
D3      LDM 3
F4      CMA
B1      XCH R1
D0      LDM 0
40 09   JUN TEST
        :LOOP
80      ADD R0
        :TEST
71 08   ISZ R1, LOOP
E0      WRM

If you omit the first 3 instructions and the last instruction then the inputs become R0 and the accumulator and the accumulator becomes the output.
Note that this does not handle overflow very well at all; you can add in a CLC to ensure that it at least calculates it correctly modulo 16, or in case the caller has left the carry set.

Incoming carry can be ignored by using CLB instead of LDM 0, but I hadn't finished reading the instruction set at the time.