text:
Even a clock that isn't working gets the time right two or three times a day
Context
When I was a little kid, I watched a Disney movie where Goofy told his son "Boy, even a broken clock is right two or three times a day." (see this youtube clip, courtesy of @Arnauld).
Rationale
Given the previous statement, we wish to look at a clock that is stopped and answer the following question: is this clock telling the correct time?, decision-problem-style. But we will also do it Goofy style, assuming a stopped clock gets the correct time 3 times a day.
Task
Pick some time of the morning with at least minute precision. Call it \$t\$.
The function/full program/etc you submit must satisfy the following requirements:

if executed at \$t\text{ am}\$ and at \$t\text{ pm}\$, your code produces an observable output a (think Truthy in decision-problem challenges).
for every calendar day, there is a third time \$t_1\$ distinct from \$t\text{ am}\$ and \$t\text{ pm}\$ such that, if your code is ran at that time, your code also deterministically produces the observable output a. This means \$t_1\$ may be constant or it may be a function of the day the code is ran at.
if ran at any other time of the day, your code produces an observable output b that must be distinct from a (think Falsy in decision-problem challenges).

Recall that your code should be precise at least to the minute. This means that you may decide that seconds don't matter for your answer, but you might also want to decide that your answer checks up to nanoseconds in order to decide if it is that time of the day.
Input
Either your code takes no input or it takes the "current" time. For the time, acceptable formats include, but are not limited to:

Any ISO format for date/time strings where time is given at least to the minute;
An integer list with [hours, minutes] or [hours, minutes, seconds] or any similar list with further subdivisions of the second; (this order may be reversed but may not be shuffled)
Different arguments, each representing one element from the lists above.

Output
A single, well-defined, observable output a if your code is run at \$t\text{ am}\$, at \$t\text{ pm}\$, or at \$t_1\$, as specified in your answer. If ran at any other time, your code produces the observable output b, distinct from a.
Bonus imaginary internet points
Bonus imaginary internet points will be awarded to the shortest answer for which \$t_1\$ isn't constant. If this question turns out to receive enough attention, this will turn into an actual rep bounty.

This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it! If you dislike this challenge, please give me your feedback. Happy golfing!

May we take the input as [minutes, hours] instead of [hours, minutes]?

@KevinCruijssen yes, edited spec!

Note that Goofy is right that a stopped clock may get the correct time 3 times a day when Daylight Saving Time ends.

@Arnauld indeed! or if he is really really unlucky, only once in the day that DST starts :D

Or the clock could be traveling across time zones :) .  @Arnauld

@MitchellSpector Yup! Taking +30' and +45' TZ into account, if you travel fast enough and visit the countries in the correct order, you should be able to get the correct time almost 40 times a day. :)

...Goofy actually says "broken" rather than "stopped" which leaves the posibility of a fast or slow running clock too.

Must the observable output b be a single value or would, say, a is 1 and b is in {0,2,3} acceptable?

@JonathanAllan addressing the quote, I didn't exactly quote Goofy because I don't remember his exact words! For this challenge I assumed the clock was stopped. The observable output b should be fixed.

@Arnauld Far more often than that if you want to run in circles around the north or south pole all day...

JavaScript (ES6), 13 bytes
Takes input as (h)(m). Returns true for 01:00, 02:00 and 13:00, or false for anything else.
h=>m=>26%h<!m

Try it online!
How?
Testing \$26\bmod h<\delta_m\$ is equivalent to test that we have \$m=0\$ and \$26\equiv 0\pmod h\$.
For \$0<h\le23\$, we have \$26\equiv 0\pmod h\$ iff \$h\$ divides \$26\$, i.e. \$h\in\{1,2,13\}\$.
For the edge case \$h=0\$, 26%h results in NaN which is neither greater nor lower than any other value, so the test returns false as expected, no matter the value of \$m\$.
Other possible values
This program generates all possible values \$n<1000\$ for the expression \$n\bmod h\$.
for(n = 1; n < 1000; n++) {
  A = [...Array(24)].map((_, x) => x).filter(x => n % x == 0);
  if(A.length == 3 && A.some(x => A.includes(x + 12))) {
    console.log(n, A);
  }
}

Try it online!

This would also work with 85 which has factors 1AM, 5AM, 5PM, right?

Why can't we do (h,m)=>26%h<!m (12 bytes)?

@DavidCallanan That's 14 bytes.

@Arnauld Wow I'm bad at counting xD thanks for noticing

This is disturbingly brilliant.

@DavidCallanan No worries. :) There's some kind of optical illusion involved here. At first glance, (h,m)=> does look shorter than h=>m=>.

@Sparr I've added a program computing some more values.

Bash + Core utilities, 26 25 bytes + Bonus imaginary Internet points!
egrep '(.)T(11|23|0\1)00'

Try it online!
Thanks to @mypronounismonicareinstate for pointing out that the ISO 8601 allows omitting the colon in the time part, which saves a byte in the code. (ISO 8601 also allows omitting the hyphens in the date, but that doesn't affect the regex.)
This accepts input on stdin in a format like
20200319T1018-0700
which is a basic ISO 8601 format with precision to the minute.
The result is in the exit code: 0 for truthy (one of the three Goofy times), 1 for falsey (everything else).
The three times it outputs 0 are at:

11:00 am
11:00 pm
d:00 am where d is the last digit of the date.

So, today, March 19, it would output truthy (exit code 0) for  9 am (because 9 is the last digit of the date 19), 11 am, and 11 pm.

Without the bonus, I think this works for 20 bytes, outputting 0 at 9:01, 21:01 and 19:01.

Or even 17 bytes.

@RobinRyder Looks good to me.  If you want to post your 17-byte solution, go ahead.  I haven't even looked at answers without the bonus :) .

No, thanks, go ahead. I wouldn't have thought of it without your answer. :)

R, 23 bytes
function(h,m)26%%h|m|!h

Try it online!
Port of Arnauld's solution, go upvote his!
Outputs FALSE at 1:00, 13:00 and 2:00, and TRUE otherwise.

Previous version:
R, 26 bytes
function(h,m)!h|m|(h/6)%%1

Try it online!
Outputs FALSE at the three times:
\$t_{am}\$ = 6:00
\$t_{pm}\$ = 18:00
\$t_1\$ = 12:00
and TRUE at any other time.
Indeed, for the output to be FALSE, we need h≠0, m=0, and h to be a multiple of 6.

Japt -!, 8 bytes
Inspired by Kevin's choice of times. Input as 2 integers in the order h, m. Outputs true at 00:00, 01:01 and 13:01 and false otherwise.
%C*VÉ©Nx

Try it
%C*VÉ©Nx     :Implicit input of integers U=h and V=m
%C           :U modulo 12 (=1 if U=1 or U=13)
  *V         :Multiplied by V (=1 if above and V=1)
    É        :Subtract 1 (=0 if all above)
     ©       :Logical AND with
      N      :Array of inputs (i.e., [U,V])
       x     :Reduced by addition (=0 if U=V=0)
             :Implicit output of boolean negation of result

A port of Arnauld's solution would be 1 byte shorter.
26%U<!V

Try it

I thought this was the shortest... then I realized that these 05AB1E and Jelly solutions aren't upvoted that high.

C (gcc), 22 \$\cdots\$ 20 19 bytes
Saved a byte thanks to Arnauld!!!
f(h,m){h=26%~h<!m;}

Try it online!
Returns 1 for noon, midnight and 1am, 0 otherwise.
Adaptation of Arnauld's formula.

You can save another byte with 26%~h.

@Arnauld Just take the mod of the negative. Amazing - thanks! :-)

Note that in C ISO 1990, the sign of the result of the modulo is implementation-defined (oh dear...). Fortunately, it was changed to the sign of the dividend in C ISO 1999.

@Arnauld May take them some time but the standards committees tend to get it right eventually. :D

Ruby, 48 44 bytes
-4 bytes thanks to Value Ink!
Differs from other answers so far in that it (i) takes no input and (ii) has a unique \$t_1\$ for every day of the year.
p (t=*Time.now)[2]%12+t[1]<1||t[1,2]==t[3,2]

Try it online! (actual code)
Try it online! (demo version showing the three times that will return true on a given date)
Outputs true at 00:00, 12:00, and month:day (03:20 for today, 20 March); false otherwise.
*Time.now yields an array of the form [sec, min, hour, day, month, year, wday, yday, isdst, zone], of which the first 8 elements are integers (but only min, hour, day, and month are used here). Then print true if hour (mod 12) and min are both 0, or if hour = month and min = day.

Nice first answer here! Good job! You might prefer to include a TIO link for a demo version of your answer; TIO is widespread in this community and is a really nice place to test answers because users can test the answers themselves.

@RGS thanks! I can't seem to get TIO to work. I get 'Error: the server's response could not be decoded'. Maybe I'm doing it wrong?

Prob not, some hours ago I also had a problem with TIO. maybe the server is having some trouble... :/

@RGS I'm having the same issues. Yesterday evening TIO was working 1/4th of the time, but today I get that same connection error every time. Pretty annoying.. (Only positive thing about it, is that I finally decided to install 05AB1E on my local machine, which I had postponed for ages since I have TIO normally xD). And nice first answer, Dingus. Welcome to CGCC! :)

@KevinCruijssen yeah, this also means I'll probably be downloading Jelly's repo to my machine hehe

TIO links added

Save bytes by splatting Time.now instead of converting to an array: t=*Time.now. Welcome to CGCC! :)

05AB1E, 16 11 10 bytes
Taking input in the format [minutes, hours]:
`12%*ΘIO_~

Try it online.
Without input and using the current time builtins:
ža12%žb*Θžažb+_~

Try it online (not very useful right now..) or try it online with emulated hours/minutes.
Both programs use the three times:
\$t_{am}\$ = 1:01
\$t_{pm}\$ = 13:01
\$t_1\$ = 00:00
And will output 1 on any of those three times above, and 0 on any other time.
Explanation:
`           # Push the values in the (implicit) input-pair separated to the stack
 12%        # Take modulo-12 on the hours, to make the 24-hour a 12-hour clock
    *       # Multiply it with the minutes
     Θ      # And check if it's exactly 1 (1 if truhy; 0 if falsey)
I           # Push the input-pair again
 O          # Sum them together
  _         # Check if it's exactly 0 (1 if truhy; 0 if falsey)
      ~     # And then check if either of the two checks is 1
            # (after which the result is output implicitly)

ža          # Push the current hours
  12%       # Modulo 12, to make the 24-hour a 12-hour clock
     žb     # Push the current minutes
       *    # Multiply them together
        Θ   # And check if it's exactly 1 (1 if truthy; 0 if falsey)
žažb        # Push the current hours and minutes again
    +       # Add them together
     _      # Check if it's exactly 0 (1 if truthy; 0 if falsey)
         ~  # And then check if either of the two checks is 1
            # (after which the result is output implicitly)

Interesting solution :) I take it you already had it prepared? Or did you come up with all of this just now?

@RGS Came up with it just now. :) And -5 bytes by taking the hours/minutes as input. May we take the input as [minutes, hours] instead of [hours, minutes]?

05AB1E (legacy), 5 bytes
_₂I%›

Port of @Arnauld's JavaScript answer, so make sure to upvote him!!
Takes two loose inputs, in the order minutes, hours.
Will also output 1 for any of these three times below, and 0 on any other time:
\$t_{am}\$ = 01:00
\$t_{pm}\$ = 13:00
\$t_1\$ = 02:00
Try it online or verify some more test cases.
Explanation:
_     # Check if the (implicit) input-integer (minutes) is 0 (1 if truthy; 0 if falsey)
 ₂    # Push 26
  I   # Push the second input-integer (hours)
   %  # Take 26 modulo-hours (will result in 26 if the hours are 0 in the legacy version)
    › # Check if the first value is larger than the second
      # (after which it is output implicitly as result)

How in the world did Adnan think of the 26 constant already?

@a'_' Dunno. Probably because there are 26 letters in the alphabet. Although I'm wondering the same thing about some of the other single-byte constants tbh, since we also have 36,95,255,256 as single-byte builtins (and 10,100,1000 of course).

Python 3, 35 \$\cdots\$ 22 19 bytes
Saved a byte thanks to Arnauld!!!
Saved 3 bytes thanks to Surculose Sputum!!!
lambda h,m:26%~h==m

Try it online!
Returns True for noon, midnight and 1am, False otherwise.
Adaptation of Arnauld's formula.

Do you need the +(...)? I think outputting True or False would work.

Python 3, 21 bytes
lambda h,m:26%-~h<m<2

Try it online!
Input: hour and minute, as integers
Output: True if the time is 00:01,01:01,12:01, otherwise False.

Retina 0.8.2, 28 bytes
^.
$&$&$&$&
\G\d
$*
^1{8}:18

Try it online! Link includes test cases. Explanation:
^.
$&$&$&$&

Repeat the hour tens digit four times.
\G\d
$*

Convert the hour digits to unary.
^1{8}:18

They must sum to 8 and the minutes must be 18 (arbitrarily chosen to reuse the same digits).

Perl 5 -lF: , 34 bytes
say$F[0]%12&&$F[0]!=1||$F[1]>0?0:1

Try it online!
Reads current time input from stdin in hh:mm format.  Outputs 1 at 00:00, 01:00, and 12:00;  0 at all other times.

-F implies -n and -a, so you can reduce your command line options to -lF:.

That's only true since 5.20.0,  but TIO is using a later version so I'll take it - thanks :)

Charcoal, 10 bytes
⁼²№⟦↨Ｓ⁴Ｎ⟧⁹

Try it online! Link is to verbose version of code. Takes input as hour and minute separated by a space, on separate lines, or as a JSON list i.e. [22, 10], and outputs - for 09 09, 15 09 and 21 09 only. Explanation:
   ⟦    ⟧   List of
     Ｓ      Hours as a string
    ↨ ⁴     Interpreted as base 4
       Ｎ    Minutes
  №      ⁹  Count `9`s
⁼²          Must be 2 of them.

Retina, 18 17 bytes + Bonus imaginary Internet points
(.)T(11|23|0\1)00

Try it online!
Note that TIO is having technical issues at the moment, so the link that it gave me above may or may not work.

Thanks to @mypronounismonicareinstate for pointing out that the ISO 8601 allows omitting the colon in the time part, which saves a byte in the code.  (ISO 8601 also allows omitting the hyphens in the date, but that doesn't affect the regex.)

I don't really know Retina, but this port of my bash answer appears to be right :) .
The program accepts input on stdin in a format like
20200319T1018-0700
which is a basic ISO 8601 format with precision to the minute.
Like my bash answer, it outputs truthy (0) for 11:00 am, 11:00 pm, and d:00 am where d is the last digit of the current date.  It outputs falsey (1) otherwise.

Nice job getting the bonus imaginary internet points!! :D

I'm pretty sure the : and the - are not necessary in ISO 8601 (posssibly saving 1 byte).

@mypronounismonicareinstate That's interesting, thank you.  I hadn't checked out the spec -- I just went off of what GNU date printed for its ISO 8601 output.

Ruby, 19 bytes
Returns true at 6:00, 12:00, 18:00.
->h,m{h>0&&m|h%6<1}

Try it online!

Jelly,  7  6 bytes
Turns out porting Arnauld's answer is a byte shorter than my original answer (which I've kept below)
26%<¬}

A dyadic Link accepting the hour (an integer in [0,23]) on the left and the minute (an integer in [0,59]) on the right which yields 1 at three times (not varying by day), 2,0 (02:00), 1,0 (01:00), and 13,0 (13:00).
Try it online!

My 7
æle1,98

A dyadic Link accepting the hour (an integer in [0,23]) on the left and the minute (an integer in [0,59]) on the right which yields 1 at three times (not varying by day), 1,1 (01:01), 2,49 (02:49), and 14,49 (14:49).
Try it online!

perl -ple, 18 bytes
$_=/(2[01]|08):00/

Reads a time in HH:MM format from STDIN (optionally preceded by a date in YYYY-MM-DD format (or anything else which doesn't like a time)).
Print 1 followed by a newline if the time is 08:00, 20:00 or 21:00; otherwise, it prints a single newline.

Hey there, welcome to this community! Your submission looks nice but I don't really know Perl! Do you think you could include a TIO link? If you check the other answers, you will notice they all include such a link, usually with the text "Try it online" :)

W, 5 bytes
... With True and False swapped around; they're distinctive anyway.
♥─y¥•

Uncompressed:
!26bm>

Explanation
!      % Check whether the input is equal to 0
   b   % Push the second input
 26 m  % Push 26 % b
     > % Is input == 0 larger than the above value?

Io, 19 bytes
Port of @Arnauld's answer...
method(U,V,26%U>=V)

Try it online!


text:
Measure the lengths of binary patterns
Let's consider the sequence of the binary representation of positive integers (without any leading zero):
1 2  3  4   5   6   7   8    9    10   11   12   ...
1 10 11 100 101 110 111 1000 1001 1010 1011 1100 ...

If we join them together, we get:
1101110010111011110001001101010111100 ...

If we now look for the patterns /1+0+/, we can split it as follows:
110 11100 10 1110 1111000 100 110 10 10 111100 ...

We define \$s_n\$ as the length of the \$n\$-th pattern built that way. Your task is to generate this sequence.
The first few terms are:
3, 5, 2, 4, 7, 3, 3, 2, 2, 6, 3, 5, 9, 4, 4, 2, 3, 4, 3, 2, 2, 3, 3, 2, 8, 4, 4, 2, 3, 7, 4, 6, 11, 5, 5, ...

Related OEIS sequence: A056062, which includes the binary representation of \$0\$ in the initial string and counts \$0\$'s and \$1\$'s separately.
Rules
You may either:

take \$n\$ as input and return the \$n\$-th term, 1-indexed
take \$n\$ as input and return the \$n\$-th term, 0-indexed
take \$n\$ as input and return the \$n\$ first terms
take no input and print the sequence forever

This is a code-golf challenge.
Some more examples
The following terms are 1-indexed.
s(81)    = 13
s(100)   = 3
s(101)   = 2
s(200)   = 5
s(1000)  = 5
s(1025)  = 19
s(53249) = 29

Just to make sure; does an infinite list as a value fall under the fourth output category?

@JonathanFrech As long as it can be easily viewed somehow -- partially, obviously -- that's fine with me. (But that's actually a good question that should be asked on Meta if it wasn't already.)

Can the sequence be 2-indexed?

@a'_' No, sorry. Let's stick with the sequence default rules.

Husk, 7 bytes
mLġ≤ṁḋN

Try it online!
Takes no input and prints ALL the numbers!
Explanation
mLġ≤ṁḋN
      N        The list of all positive integers [1,2,3...]
    ṁḋ         Convert each to binary and concatenate the resulting digits
  ġ≤           Split them in groups where each digit is less than or equal to the previous one (basically cuts wherever there is a 0 followed by a 1)
mL             Compute the length of each group

Python, 77 67 bytes
lambda n:len(''.join(f'{i:b}'for i in range(9*n)).split('01')[n])+2

Try it online!
Returns the \$n^\text{th}\$ term, 1-indexed.

Save 1 byte by replacing +2-(n<2) with -~(n>1).

If you use range(9*n), the starting 0 helps you not getting the special case at start. 67 bytes

@SurculoseSputum Was just updating to that! :D

MATL, 15 bytes
E:"@B]v&Y'2esG)

This takes n as input and outputs the n-th term, 1-indexed.
Try it online!
Explanation
A binary pattern of the specified form ends at least as often as every even number. So for input n, considering the numbers 1, 2, ..., 2*n guarantees that at least n patterns are obtained.
E      % Implicit input: n. Push 2*n
:"     % For each k in [| 2 ... 2*n]
  @    %   Push k
  B    %   Binary expansion. Gives a row vector containing 1's and 0's
]      % End
v      % Concatenate everything into a column vector
&Y'    % Lengths of run-length encoding. Runs contain 1's and 0's alternately
2e     % Reshape as a two-column matrix, in column-major order
s      % Sum of each column. This gives the lenghts of the desired patterns
G)     % Take the n-th entry. Implicit display

Haskell, 80 bytes
([1..]>>=f)#0
f 0=[]
f x=f(div x 2)++[mod x 2]
(0:1:x)#l=l+1:x#1
(a:x)#l=x#(l+1)

Try it online!
Inspired by Leo's Husk answer, calculates an infinite list.

Octave, 62 bytes
@(n)diff(regexp([arrayfun(@dec2bin,1:4*n,'un',0){:}],'1+'))(n)

Try it online!
Explanation
@(n)                                                           % function with input n
                                   1:4*n                       % range [1, 2, ... 4*n]
                 arrayfun(@dec2bin,     ,'un',0)               % convert each to binary string
                [                               {:}]           % concat into one string
         regexp(                                    ,'1+')     % starting indices of runs of 1's
    diff(                                                 )    % consecutive differences
                                                           (n) % take n-th entry

Jelly, 12 11 bytes
ḤB€FI»0kƲẈḣ

Try it online!
A monadic link taking an integer \$n\$ and returning the first \$n\$ terms of the series.
Change from ×9 to Ḥ inspired by @JonathanAllan’s answer. Thanks!

Jelly, 11 bytes
ḤB€FŒgẈ+2/ḣ

A monadic Link accepting an integer, n, which yields a list of the first n values.
Try it online!
How?
ḤB€FŒgẈ+2/ḣ - Link: integer, n
Ḥ           - double (n)
  €         - for each v in (implicit range = [1..2n]):
 B          -   (v) to binary
   F        - flatten
    Œg      - group runs
      Ẉ     - get lengths
        2/  - 2-wise reduce by:
       +    -   addition
          ḣ - head to index (n)

Haskell, 135 128 bytes

Saved seven bytes thanks to ovs.

g$b=<<[1..]
b 0=[];b n=b(div n 2)++[mod n 2]
l(1:r)1=1+l r 1;l(0:r)0=1+l r 0;l(0:r)1=1+l r 0;l(1:r)0=0
g a=l a 1:g(drop(l a 1)a)

Try it online!

The first line can be g$b=<<[1..].

@ovs Thank you very much.

bash + GNU utilities, 76 58 57 bytes
seq -f 2o%.fn $[2*$1]|dc|sed -E "s/(1*0*){$1}.*/\1Zp/"|dc

Try it online!
Thanks to user41805 for suggestions that ended up shaving 18 bytes off!  And for 1 more byte now too.
Takes \$n\$ as an argument, and prints the \$n^\text{th}\$ entry in the sequence (with 1-based indexing).

I believe you can replace (1*0*){$1}(1*0+) with (1*0*){$1} and use \1 instead of \2 in the sed substitution, and include i=1 in the for loop and remove 0 in the dc command to save some bytes. Actually, I think using seq | xargs can be shorter than the for-loop.

Thanks -- I'll take a look at this.  I had put the 0 in the dc command precisely so I could eliminate i=0 in the loop initialization, for a savings of 2 bytes.

TIO's back in action! :D

@user41805 Thanks for the suggestions!  They shortened the code considerably.

Nice usage of seq -f instead of xargs. I believe you can use dc instead of wc -c by changing the replacement part of the sed s command to save a byte

@user41805 Great idea -- thank you!

Perl 5 -n, 73 bytes
$_=join'',map{sprintf"%b",$_}1..($n=$_)*2;say y///c for(/1+0+/g)[0..$n-1]

Try it online!
Takes input n via stdin, prints the first n numbers in the sequence.

Save 11 bytes by returning the n-th entry, 0-based: Try it online!

@Xcali++ is unnecessary keeping 1-indexeded Try it online!

05AB1E, 9 bytes
∞bSγ2ôεSg

Untested, since TIO isn't working.. >.> But it should work (unless one of those builtins used isn't lazy).
I'll try to finally install 05AB1E locally later today to verify if it indeed works.
EDIT: Installed 05AB1E locally, and apparently it didn't work due to the Join on the infinite list. So here an alternative 9-byter that does actually work.
Outputs the infinite sequence.
Try it online.
Explanation:
∞          # Push an infinite list of positive integers: [1,2,3,4,5,6,...]
 b         # Convert each to a binary string
           #  → ["1","10","11","100","101","110",...]
  S        # Convert it to a flattened list of digits
           #  → [1,1,0,1,1,1,0,0,1,0,1,1,1,0,...]
   γ       # Split them into parts of consecutive equal digits
           #  → [[1,1],[0],[1,1,1],[0,0],[1],[0],[1,1,1],[0],...]
    2ô     # Split all that into parts of size 2
           #  → [[[1,1],[0]],[[1,1,1],[0,0]],[[1],[0]],[[1,1,1],[0]],...]
      ε    # Map over each pair
       S   #  Convert it to a flattened list of digits again
           #   → [[1,1,0],[1,1,1,0,0],[1,0],[1,1,1,0],...]
        g  #  Pop and push its length
           #   → [3,5,2,4,...]
           # (after which the mapped infinite list is output implicitly as result)

Alternative 9: ∞bS.¬‹}€g

@Grimmy What does .¬ do? It's not in the wiki, and I'm a bit too lazy to dive into the code. ;) (And I've the huge golf you did on my other answer. I will update it when I have some time.)

It's in info.txt. .¬      = pop a      split a on function f, where f = [(a, b) → bool], usage: .¬<func>}

Ruby, 48 bytes
->n{("%b%b"*n%[*1..n*2]).scan(/1+0+/)[n-1].size}

Try it online!

K (ngn/k), 26 bytes
{x##'(&0>':t)_t:,/2\'!2*x}

Try it online!
Returns the first n items.
J, 35 bytes
{[:((1,2</\])#;.1])@;[:#:&.>[:i.3&*

Try it online!
Returns the nth item

Charcoal, 34 22 bytes
≔…⌕Ａ⭆⊗⊕θ⍘ι²01⊕θηＩ⁻⊟η⊟η

Try it online! Link is to verbose version of code. Based on @LuisMendo's observation that the numbers up to 2n provide sufficient digits, although I search for 01 so I actually need 0 through 2n+1. Explanation:
⭆⊗⊕θ⍘ι²

Convert all the numbers from 0 to 2n+1 to base 2 and concatenate them.
≔…⌕Ａ...01⊕θη

Find the positions of the substrings 01 but truncated after the nth entry.
Ｉ⁻⊟η⊟η

Output the difference between the last two positions.

Jelly, 15 14 bytes
×3ŻBFœṣØ.ḊẈ+2ḣ

Try it online! Thanks to @JonathanAllan and @NickKennedy for helping me out, in chat, to finish this solution. I came up with ×3RBFœṣØ.Ẉ+2ḣ but that fails for n = 1!
How it works:
×3ŻBFœṣØ.ḊẈ+2ḣ    Monadic link: takes `n` as input and returns the first `n` terms
×3                Multiply input by three and
  Ż                create the list [0, 1, ..., 3n].
   B              Get the binary representation of each number and
    F              flatten to get [0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, ...]
                  Now we find the /1+0+/ patterns by looking at occurrences of [0, 1],
                   i.e. when one pattern ends and the next begins:
     œṣ           Split the [0, 1, 1, 0, 1, 1, 1, 0 ...] list at occurrences of
       Ø.         [0, 1], so [0, 1, 1, 0, 1, 1, 1, 0 ...] -> [[], [1], [1, 1, ...], ...]
         Ḋ         and drop the first element of the resulting list (the empty one).
          Ẉ       Finally we get the length of each sublist,
           +2      add 2 (to compensate for the lost 1 and 0),
             ḣ     and take the first `n` elements of that.

Japt, 11 bytes
Outputs the nth 1-indexed term.
g°U²ô¤¬ò<)l

Try it
g°U²ô¤¬ò<)l     :Implicit input of integer U
g               :Index into
 °U             :  Increment U
   ²            :  Square it
    ô           :  Range [0,result]
     ¤          :  To binary strings
      ¬         :  Join
       ò<       :  Partition after characters that are less than the next
         )      :End indexing
          l     :Length

Red, 122 111 bytes
func[n][b: copy""repeat i 2 * n[append b find enbase/base
to#{}i 2"1"]parse b[n copy i[any"1"any"0"]]length? i]

Try it online!

PHP, 108 bytes
for($a=[$p=$i=1];;$p=$c,$o++){if(!$a)$a=str_split(decbin(++$i));if($p<$c=array_shift($a)){echo$o,',';$o=0;}}

Try it online!
Will print the sequence indefinitely.

C (gcc), 124 \$\cdots\$ 109 104 bytes
Saved 2 3 4 8 9 14 bytes thanks to Arnauld!!!
c;t;b;i;f(n){for(i=c=0,t=1;++i;){for(b=0;i>>++b;);for(;b--;++c)if(t^i>>b&1&&(t^=1)?c*=!--n:0)return c;}}

Try it online!
Goes through positive integers \$i\$ catching transitions from \$0\$ to \$1\$ as it rolls through the non-leading-zero bits of the \$i\$'s.
Returns the \$n^\text{th}\$ term, 1-indexed.

I wonder if there's something to do with __builtin_clz(), but a naive attempt is +2 bytes :-/

@Arnauld +1 byte :-/

Gaia, 13 bytes
ḣ┅b¦_ėt(2/Σ¦E

Try it online!
Port of Luis' MATL answer.

W x, 7 bytes
REALLY slow. The array is 1-indexed and it outputs all upto the input. (Glad that I tie with Husk BTW. Special bonus: it doesn't involve infinite lists!)
♫│x╤►U╟

Uncompressed:
^k2BLHkr

Explanation
^        % 10 ^ input. Make sure that enough items are calculated.
 k       % Find the length range of that.
  2B     % Convert every item to binary.
         % Since at least 1 item >= the base, this vectorizes.

         % Automatic flatten before grouping
    LH   % Grouping: Is the previous item >= current item?
      kr % Reduce by length

Flag:x  % Output all items upto the input, including input-indexed item. 1-indexed.

W x, 8 bytes
You can try this without having to wait for a long time.
☺│╪å∟↕c╟

Uncompressed:
3*k2BLHkr

Explanation
3*         % Input times 3, idea copied from RGS's answer.
  k        % Provide a length-range
   2B      % Convert all to binary
     LH    % Group by >=
           % Automatic flattening before grouping
       kr  % Reduce by length

Flag:x      % Output all less than the input index. INCLUDING the input index item.
```

APL (Dyalog Extended), 17 bytes
{⍵⊃≢¨⊆⍨1+∊⊤¨⍳+⍨⍵}

Try it online!
Gives nth term, 1-indexed.
How it works
{⍵⊃≢¨⊆⍨1+∊⊤¨⍳+⍨⍵}
{               }  ⍝ ⍵←n
             +⍨⍵   ⍝ Double of n
            ⍳      ⍝ 1 .. 2n, inclusive
         ∊⊤¨  ⍝ Convert each to binary and flatten
       1+     ⍝ Add 1
     ⊆⍨       ⍝ Partition self into non-increasing segments
              ⍝ (Without 1+, zero items are dropped)
   ≢¨  ⍝ Lengths of each segment
 ⍵⊃    ⍝ Take nth item

Vyxal, 67 bitsv2, 8.375 bytes
Þ∞bfĠ2ẇvf@

Try it Online!
Bitstring:
0010011101110110001111101100111001011111001011101000111011000011110

Factor, 92 bytes
: f ( n -- n ) dup 3 * [0,b] [ >bin ] map concat "01" " " replace " " split nth length 2 + ;

Try it online!

APL (Dyalog Classic), 29 bytes
{⍵+.=+\2</∊,(2∘⊥⍣¯1)¨⍳3+⍵}

Try it online!
Will post explanation soon!

,(2∘⊥⍣¯1)¨ can be just 2⊥⍣¯1¨

Zpr'(h, 369 bytes
s |> \

(g (foldr (op-> ++) () (map b |N)))
(e ())|>o
(e (S ()))|>z
(e (S (S .n)))|>(e n)
(h ())|>()
(h (S ()))|>()
(h (S (S .n)))|>(S (h n))
(b ())|>()
(b (S .n))|>((b (h (S n))) ++ (' (e n) ()))
(l (' z (' o .r)))|>1
(l (' z (' z .r)))|>(S (l (' z r)))
(l (' o (' o .r)))|>(S (l (' o r)))
(l (' o (' z .r)))|>(S (l (' z r)))
(g .a)|>(' (l a) (g (drop (l a) a)))
<|prelude.zpr

main |> (take 8 s)

Execution
Zpr-h-master/stdlib$ ../Zprh --de-peano above.zpr
(' 3 (' 5 (' 2 (' 4 (' 7 (' 3 (' 3 (' 2 0))))))))

Explanation
; build the sequence by splitting the bits of all natural numbers |N
sequence |> (generate (foldr (op-> ++) () (map bits |N)))

; compute if a natural number is even (parity shifted by one)
(even ())         |> one
(even (S ()))     |> zero
(even (S (S .n))) |> (even n)

; halve a natural number, rounding down
(halve ())         |> ()
(halve (S ()))     |> ()
(halve (S (S .n))) |> (S (halve n))

; compute a natural number's binary representation
(bits ())     |> ()
(bits (S .n)) |> ((bits (halve (S n))) ++ (' (even n) ()))

; compute the length of the pattern sought after at the bit stream's beginning
(len (' zero (' one .rest)))  |> 1
(len (' zero (' zero .rest))) |> (S (len (' zero rest)))
(len (' one (' one .rest)))   |> (S (len (' one rest)))
(len (' one (' zero .rest)))  |> (S (len (' zero rest)))

(generate .all-bits) |> (' (len all-bits) \
                           (generate (drop (len all-bits) all-bits)))

; include from the standard library
<| prelude.zpr

; output the first eight sequence members
main |> (take 8 sequence)

Wolfram Language (Mathematica), 70 bytes
Tr[1^Join@@Partition[Split[Join@@IntegerDigits[Range[2#],2]],2][[#]]]&

Try it online!

source: Stack Exchange

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

sort: votes


text:
Minimum Hop Count in Directed Graph based on Conditional Statement
A directed graph G is given with Vertices V and Edges E, representing train stations and unidirectional train routes respectively.
Trains of different train numbers move in between pairs of Vertices in a single direction.
Vertices of G are connected with one another through trains with allotted train numbers.
A hop is defined when a passenger needs to shift trains while moving through the graph. The passenger needs to shift trains only if the train-number changes.
Given two Vertices V1 and V2, how would one go about calculating the minimum number of hops needed to reach V2 starting from V1?

In the above example, the minimum number of hops between Vertices 0 and 3 is 1.
There are two paths from 0 to 3, these are
0 -> 1 -> 2 -> 7-> 3
Hop Count 4
Hop Count is 4 as the passenger has to shift from Train A to B then C and B again.
and
0 -> 5 -> 6 -> 8 -> 7 -> 3
Hop Count 1
Hop Count is 1 as the passenger needs only one train route, B to get from Vertices 0 to 3
Thus the minimum hop count is 1.

Input Examples
Input Graph Creation

Input To be solved

Output Example
Output - Solved with Hop Counts

0 in the Hop Count column implies that the destination can't be reached

Hi, and welcome to the site! Questions here should be in the form of challenges with a winning criterion, such as code-golf. Could you add such a criterion, and also add an example input, such as one matching the picture? Thanks!

Thanks for the suggestions. I've edited the challenge to make the winning criteria based on algorithmic efficiency. I will shorty upload an example input. Thanks again!

You also posted the same question on StackOverflow. Are you looking for programming help?

@xnor, this is a question that I failed to answer, when my friend asked me. I told him that I would ask the StackExchange community. If I have violated any rules, I apologize, and I am ready to remove it from the SO or CG community.

How large can V, E and the number of trains be?

I took the liberty to edit the picture to add the missing train IDs. But feel free to rollback or edit further if necessary.

@mypronounismonicareinstate, the maximum values of V, E, and the number of trains are 5000, 10000, and 10 respectively.

Are we only meant to handle this graph, i.e. the input is just the two nodes? Or are given the graph as well?

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


text:
Shortest total non-primitive recursive function
Natural numbers ≡ \$\mathbb{N}≡\{0,1,2,...\}\$
The submission can be either a program or a function, both cases will henceforth be referred to as "function".
The task is to golf the shortest function \$\mathbb{N}^n→\mathbb{N}\$, i.e. a function that maps \$n\$ natural numbers (with \$n>0\$ being a number of your choosing) to a natural number, such that the function is not primitive recursive, that is, a function that is not composable from only the following functions (each variable being a natural number):
(from https://en.wikipedia.org/wiki/Primitive_recursive_function)
Zero
$$Z()=0$$
Successor
$$S(x)=x+1$$
Projection
$$P_i^n(x_0,x_1,\dots,x_{n-1})=x_i$$
Composition
$$h(x_0,x_1,\dots,x_m)=f(g_1(x_0,x_1,\dots,x_m),\dots,g_k(x_0,x_1,\dots,x_m))$$
Primitive recursion
$$\begin{align}h(0,x_0,\dots,x_k)&=f(x_0,\dots,x_k)\\h(S(y),x_0,\dots,x_k)&=g(y,h(y,x_0,\dots,x_k),x_0,\dots,x_k)\end{align}$$

From the above five functions/operations, we can get many functions like the constant function, addition, multiplication, exponentiation, factorial, primality test, etc.
A (total) function that is not primitive recursive could be one that grows faster than any primitive recursive function, like the Ackermann function. Its proof of not being primitive recursive is on Wikipedia.
Or a function could be non primitive recursive due to contradictions that would arise otherwise; examples are provided in the answers to this Math Stack Exchange question as pointed out by Bubbler.

The submissions are free to use any radix as long as the same radix is used for each of the input and output numbers.
Your submission can take input as a list of numbers, a list of strings representing numbers, a string containing (constant) delimiter-separated numbers, or the like. In the case of using a string or equivalent, your submissions are free to use any character to represent each digit of the radix chosen, as long the choice is consistent throughout all inputs and output.
The function will always be called with the same number of inputs.
The submission should always terminate and return a result, that is, it cannot loop indefinitely.
The function should always give deterministic output.
The submission should theoretically work for any input, including those outside of the used numeric data types.
A proof accompanying your answer is appreciated, but not required.

This challenge was drafted thanks to the helpful commenters at its Sandbox.

I'm afraid most winning entries will just output infinite lists, or apply the same operator to the input ad infinitum...

Does the function our code computes need to be non-primitive recursive, or the simplest function which describes its behavior? For example, the fix point of the Collatz function is non-primitive recursive, however it always outputs 1 (equivalent to f(n)=1), so one could say it doesn't count...

I keep surpassing my comment edit cap, so forgive me for yet another: What about truly constant functions that print the same stream. On the one hand, the infinite list could not be calculated with primitive recursion nor print a non-terminating stream. On the other hand...

@AviF.S. 1) The submission cannot loop indefinitely, as per "it cannot loop indefinitely." 2) Isn't f(n)=1 still unproven? 3) The input is mapped to one output natural number (finite in size), so an infinite array/stream would not count as valid output.

Darn! Sounds like my BF & 05AB1E answers are out... 2) It is unproven, correct. However the question still holds; it was just the simplest example I could think of. For another example, please see my APL answer, which does return just one number and doesn't loop indefinitely. However, the output behaves like f(n) = n==1. 3) Ah, my fault, I see that now!

I think people are misinterpreting this challenge.  It's supposed to be a total function, meaning mathematically that its domain is the entire set of natural numbers -- that is, it halts for every natural number as input.  Also, you need to show that there is no primitive recursive algorithm for it, not just that the particular algorithm you have doesn't appear to match how primitive recursive functions work.

If I output x isn't that the successor to the successor, ..., to zero?

@JonathanAllan I'm not sure if I understand what you are asking, precisely, but the goal is to output a function that is NOT primitive recursive, therefore you can't output n as that is just the projection function. Similarly e.g. you cannot output a constant because that function is the zero function composed with some number of successor functions.

Ah I get it - we "output a function". Still got no idea how to compete though :(

@JonathanAllan It is a little unconventional as really the program is just there for scoring. You write a program which maps some vector $ x \in { 0, 1, 2, \dots }^{n} $ to a single number. If that total mapping cannot be replicated by a primitive recursion function, then your submission is valid. Hope that helps.

@FryAmTheEggman Thanks, the function has one output which is a variable natural number, rather than only ever outputting a single natural number :)

@FryAmTheEggman Not being familiar with the subject matter does this challenge boil down to "pick some already known function and golf it"? Or is there reasonable scope to actually write said function first?

@JonathanAllan It is not too difficult to come up with certain classes of functions which aren't primitive recursive. For example, the quickly growing functions like the Ackermann function are not too hard to modify or replicate and then "reprove." That said, it is not trivial - but I am no expert in this area, so there could be another approach that is easier.

@MitchellSpector : It's worse than that:  the domain is all nonempty lists of natural numbers.

@EricTowers The domain of the desired answer is just $\mathbb{N}^k$ for some $k>0$ of your choosing.  The domain of any particular primitive recursive function is $\mathbb{N}^k$ for some corresponding particular $k>0.$

@MitchellSpector : From your prior comment, " its domain is the entire set of natural numbers", which is $\Bbb{N}$, not $\Bbb{N}^k$ for some $k \in \Bbb{Z}_{>0}$.

@EricTowers The OP specifically allowed for functions with domain $\mathbb{N}^k$ for any $k>0$ of your choosing.  My earlier comment was directed at solutions where people had written a function whose domain was some proper subset of $\mathbb{N},$ rather than being all of $\mathbb{N}.$  At the time, I don't think anybody had chosen to use any $k$ other than $1.$  It was also directed at purported solutions where the function being computed was actually primitive recursive, even though the algorithm used didn't match the requirements for primitive recursion itself.

Haskell, 29 bytes
(+1)?(2?)
z?f=(iterate f z!!)

Try it online!
An Ackermann-like function. Starting the base numerical value at 2 makes for a simple base case. An annoying number of bytes are spent converting the arguments order for "apply f n times starting from z" from iterate f z!!n to (?) z f n which can be curried nicely.
Same thing written more explicitly for 2 bytes longer:
31 bytes
0%n=n+1
m%n=iterate((m-1)%)2!!n

Try it online!
Another alternative to the original is to flip the two arguments to ?, allowing it to be defined in a point-free way for the same byte count.
29 bytes
(?2)?(+1)
(?)=((!!).).iterate

Try it online!
29 bytes
(?2)?(+1)
(?)f=(!!).iterate f

Try it online!
31 bytes
n?0=n+1
0?m=2
n?m=(n-1)?m?(m-1)

Try it online!

Very neat how the explicit version only differs from my version by 1 byte (plus some variable renames).  Could you use a modified version of the proof I linked to prove this answer correct?

@AdHocGarfHunter I might be able to, but I think I can piggyback off existing results more easily. Something like, the Ackermann functions grows faster than any primitive recursive function, and this function grows as fast as the Ackermann function. Specifically, for both of them, f 3 grows as fast as exponentiation. So I think my function at layer m should grow at least as fast as Ackermann at later m-1, which would suffice.

C (gcc) -lm, 268 197 194 bytes
x[9];e(n,c){int w=sqrt(n/6*8+1)/2-.5,b=n/6+w*~w/2,*z=x+b;for(n%=6;c--;)n-2?n-3?n-4?n-5?x[w-b]=n?*z:b:e(w-b,*z):e(w-b,1,e(b,1)):*z&&--*z:++*z;}main(n){e(x[1]=n,scanf("%d",&n));printf("%d",1+*x);}

Try it online!
Now 3 more bytes off thanks to @ceilingcat again (saving a pointer z to x[b], and then using *z instead of x[b] throughout).
Thanks to C golfing expert @ceilingcat for reducing this by an amazing 71 bytes!

I decided to write an answer that works completely differently from the other solutions posted so far. This uses diagonalization of the primitive recursive functions (it's not a function that grows faster than any primitive recursive function, the way the Ackermann and Sudan functions do).
I don't think there's any way to golf this to be as short as the Ackermann or Sudan programs, but it has two advantages: (1) It's easy to understand the proof that it's not primitive recursive, and (2) you can actually run it on reasonably sized inputs without running out of time or getting stack overflows!

The basic idea behind this function \$F\$ is first to enumerate all programs to compute primitive recursive functions of one variable. Let \$P_0, P_1, ...\$ be this enumeration.  Then, for any input \$n,\$ here's how to compute \$F(n)\$: First supply \$n\$ as input to the program \$P_n\$ and run that.  When \$P_n\$ halts with an integer as output (as it's guaranteed to do, because it's computing a primitive recursive function), add \$1\$ to that output.  That's \$F(n).\$
\$F\$ is clearly total.
Now,

\$F\$ is not the function computed by \$P_0\$ because \$F(0)\$ is one higher than the output of \$P_0\$ on input \$0,\$
\$F\$ is not the function computed by \$P_1\$ because \$F(1)\$ is one higher than the output of \$P_1\$ on input \$1,\$
\$F\$ is not the function computed by \$P_2\$ because \$F(2)\$ is one higher than the output of \$P_2\$ on input \$2,\$

etc.  In general, \$F\$ isn't the function computed by \$P_n,\$ because \$F(n)\$ is one higher than the output of \$P_n\$ on input \$n.\$
So \$F\$ isn't the same as the function computed by any of the programs \$P_n.\$  But those are all the primitive recursive functions.  So \$F\$ isn't primitive recursive.

The way I enumerate all the primitive recursive functions is by implementing a variant of Uwe Schöning's programming language LOOP.  It is known that the functions computable by a LOOP program are precisely the primitive recursive functions.  (These programs actually cover all primitive recursive functions, not just the primitive recursive functions of one variable, even though that's ultimately all we would need.)
My variant miniLOOP is even simpler than the original language.  Just as in LOOP, there are variables \$x_0, x_1, x_2, \dots\$; each of these variables can hold a natural number (a non-negative integer).  To use a miniLOOP program to compute a function of \$k\$ variables, you store the values of the \$k\$ arguments in \$x_1, \dots, x_k,\$ and then run the program.  The output is the value of \$x_0\$ at the end.
Here are the basic programming statements available in miniLOOP (all variables are restricted to the natural numbers):

\$x_n=m,\$
\$x_n=x_m,\$
\$x_n\$++ (increment),
\$x_n\$-- (decrement except that if \$x_n\$ is equal to 0, its value is left unchanged, because we don't allow negative numbers).

Statements can also be constructed from other statements using the following two constructs:

\$P;Q\$ where \$P\$ and \$Q\$ are statements; this means to execute \$P\$ first and then \$Q.\$
\$\text{LOOP } x_n \text{ DO } P \text{ END},\$ which means to execute \$P\$ repeatedly, \$x_n\$ times in a row.  (Repeating it 0 times means not doing it at all, of course.)  Note that the number of repetitions is the value that \$x_n\$ has when the loop starts.  Even if the body of the loop changes the value of \$x_n,\$ the number of repetitions won't change.  This is the key thing that makes this an implementation of primitive recursion.

For example, the following program doubles its input:
LOOP x1 DO x1++ END
x0 = x1

(Recall that a function of one variable takes its input in \$x_1\$ and leaves its output in \$x_0.\$)

You can check that even though miniLOOP is a bit simpler than the LOOP language defined in the Wikipedia article, you can simulate all the LOOP constructs with miniLOOP programs.  So miniLOOP also computes precisely the primitive recursive functions.

Every miniLOOP program is assigned a number; that is how we enumerate them.  This enumeration uses the Cantor pairing function
$$\pi(x,y)=\frac{(x+y)(x+y+1)}{2}+y.$$
Here is the numerical assignment:

\$x_n=c\$ is assigned the number \$6 \pi(n,c).\$
\$x_n=x_m\$ is assigned the number \$6 \pi(n,m)+1.\$
\$x_m\$++ is assigned all the numbers \$6 \pi(n,m)+2\$ for any \$n\$ (it doesn't matter that one program can be included multiple times in the enumeration).
\$x_m\$-- is assigned all the numbers \$6 \pi(n,m)+3\$ for any \$n.\$
\$P;Q\$ is assigned all the numbers \$6 \pi(q,p)+4\$, where \$p\$ is assigned to \$P\$ and \$q\$ is assigned to \$Q.\$  (\$q\$ and \$p\$ are "backwards" in this formula only because this is code golf and I ended up saving a few bytes by doing it that way.)
\$\text{LOOP } x_n \text{ DO } P \text{ END}\$ is assigned the numbers \$6 \pi(p,n)+5,\$ where \$p\$ is a number assigned to \$P.\$

Note that every number is assigned to a unique program.  (A program can have more than one number assigned to it, but a number is associated with exactly one program.)  And it's easy to take a number and figure out what program it's assigned to.
For example, you can check that the program above that doubles its input is assigned 1667230.  This is computed as \$6 \pi(13,731)+4,\$ where \$13 =6\pi(0,1)+1\$ and \$731=6\pi(14,1)+5.\$  In that last formula, \$14=6\pi(0,1)+2.\$

In the C program, \$x\$ is a global array holding all the variables needed for what you're running.  I've only declared it to hold 9 variables, since that's plenty for demonstrating it, but in practice you would really want to allow that to grow using malloc as needed.
The function e takes an input n and runs the miniLOOP program assigned to n.  It assumes that x[1], ..., x[k] have already been set up as desired for the input, and it leaves the output in x[0].
The main program simply takes its input n, stores it in x[1], and calls e(n) to run the miniLOOP program assigned to n.  It then adds 1 to the output and prints that as the output of the main program.
As described in the outline at the beginning, this program halts on every input.  But it's not primitive recursive, since it disagrees with miniLOOP program number n (at input n), and those miniLOOP programs compute all the primitive recursive functions.
The TIO link shows what this program does with input 1667230.  Recall that 1667230 is assigned to a miniLOOP program that doubles its input, and you can see that the output of the main program here is 3334461 (which is not equal to double 1667230, being one higher, as intended).

You write "These programs actually cover all primitive recursive functions, not just the primitive recursive functions of one variable, even though that's ultimately all we would need."  This is surprising since the required function accepts lists of naturals as inputs, not single naturals.  What is the justification that you can restrict to single input functions?

@EricTowers One way to look at it is that for each program $P$ (in a language like LOOP or my miniLOOP) and for each $k>0,$ there's a corresponding primitive recursive function $F^P_k:\mathbb{N}^k \to \mathbb{N},$ where $F(x_1,\dots,x_k)$ is the value left in $x_0$ if you initialize $x_1, \dots, x_k$ to the right values (and set the other variables to $0$) and run $P.$  All the primitive recursive functions of any number of variables are covered by this.  The only ones actually needed for the solution are the functions of one variable $F^P_1,$ but you get the others for free.

@EricTowers In my previous comment (which it's too late to edit), I meant to write: "...where $F_k^P(x_1,\dots,x_k)$ is the value..."

You can simplify miniLOOP further into four constructs x_n = 0, x_n++, P;Q, and LOOP x_n DO P END. Conversions from miniLOOP: x_n = c -> x_n = 0 followed by c copies of x_n++; x_n = x_m -> x_n = 0; LOOP x_m DO x_n++ END; x_n-- -> x_u = 0; x_v = 0; LOOP x_n DO x_u = x_v; x_v++ END; x_n = x_u.

@Bubbler Great point. In fact, we can eliminate $x_n=0$ also because we can simply designate some otherwise unused variable whose value is always $0$ to be used instead of $0$ (if we're implementing a function of $k$ variables, all the variables but $x_1, \dots, x_k$ are initialized to $0$).  That leaves just 3 constructs, which would simplify and shorten the program in my answer, but also may be of some independent interest.

@MitchellSpector But it breaks assignment into x_0, which is required for the current formulation of a non-primitive recursive function.

@Bubbler  You're right, I was too hasty.

Haskell, (Ackermann-like) 31 bytes
Inspiration from this answer.
0%x=x+1
n%x=iterate((n-1)%)x!!x

Try it online!
Or if \$g^n\$ is \$n\$ compositions of \$g\$ then
\$
f_0(x)=x+1 \\
f_n(x)=f_{n-1}^x(x)
\$
This function appears here with a proof that it is not primitive recursive.
Haskell, (Ackermann) 39 bytes
0%n=n+1
m%0=(m-1)%1
m%n=(m-1)%(m%(n-1))

Try it online!
Haskell, (Sudan) 45 bytes
(n#x)y|n<1=x+y|y<1=x|q<-n#x$y-1=(n-1)#q$q+y+1

Try it online!

@FryAmTheEggman It is still correct (%) is $f$ with the first argument fixed at $0$.  I do think it is a bit confusing.  So I will probably include the definition used in the linked document.

This is the fast-growing hierarchy.

@user76284 Do you want me to place this function in a hierarchy?  I'm not sure the intention of the comment.

dc, 76 bytes
?sysxsn[lx+q]sp[lydln*0=ply1-sylFxdSxly1+dsy+Syln1-snlFxln1+snLxsDLysD]dsFxp

Try it online!
This implements Sudan's function, which I believe was the first computable but non-primitive-recursive function discovered.  It grows faster than any primitive recursive function.
Three space-separated arguments \$n, x,\$ and \$y\$ are read from stdin, and the output \$F(n, x, y)\$ is written to stdout.
The function grows so quickly that you need something like dc that supports arbitrarily large integers to have a chance at computing any interesting examples at all.
I'll post an explanation later (dc is a pain to document), but the TIO link shows how large its outputs get: \$F(2,11,2)\$ is 16,031 digits long!  This appears to be the largest example I can compute on TIO without overflowing the stack (due to the heavy use of recursive calls).
The Wikipedia link above has a table of sample outputs.  You can run my program at TIO and see that it matches the ones that Wikipedia shows.
There's a proof that it's not primitive recursive in Theories of Computational Complexity, by Cristian Calude.

It seems you can add another d after [ly to remove the first occurrence of ly after that part

@user41805  Yes, it's probably golfable more -- I'll check it out.  I quickly put this together, but the code to save and restore things from the stack can probably be shortened too.

Zpr'(h, 81 bytes
(a () .n)|>(S n)
(a (S .k) ())|>(a k (S ()))
(a (S .k) (S .n))|>(a k (a (S k) n))

<| constants.zpr
main |> (a 3 4)

Execution
stdlib % ../Zprh --de-peano above.zpr
125

Explanation
; implementation of the Ackermann-Peter function in Zpr'(h

; base case for k = 0
(ackermann-peter () .n)         |> (S n)

; base case for n = 0
(ackermann-peter (S .k) ())     |> (ackermann-peter k (S ()))

; general case for k, n > 0
(ackermann-peter (S .k) (S .n)) |> (ackermann-peter k (ackermann-peter (S k) n))

; include integer constants
<| constants.zpr

; test the implementation
main |> (ackermann-peter 3 4)

Upvoted for not just a neat esolang I didn't know, but one that you personally created! Plus it's Peano... Do you mind submitting to TIO.run or making an online compiler/interpreter? It'd be nice to be able to try it out without installing!

@AviF.S. I have already asked to add it to TIO, however TIO's maintainer currently has other priorities.

Awesome! I looked it up and it looks like the source is on Github. Perhaps with a pull request they'll be more timely? Looks like someone else has done the same here (requested adding a language with a pull)!

I do not want to overwhelm TIO's maintainer. If you want to use Zpr'(h yourself, building is not that cumbersome.

Haha, I already did! I only meant since this community seems to like links to verify answers online without any effort or commitment :p

I'd be interested to see an explanation of this submission.

@user41805 Added.

Python Ackermann, 78 \$\cdots\$ 59 45 bytes
Save 2 bytes (in pre production) thanks to user41805!!!
A=lambda m,n:m and A(m-1,n<1or A(m,n-1))or-~n

Try it online!
Going with FryAmTheEggman's most excellent advice and implementing the Ackermann function.

I believe you can use <1 instead of ==0

I don't know Python well. How would you set this up to show some examples which work without getting stack overflow from the recursion?

You can usually assume the recursion limit is set high enough without including it in your byte count. Also, I suggest looking into the Ackermann function, I'm pretty sure it is shorter.

You should be able to compute F(1,1,1) and other small values like that. Again, I don't really do Python programming, but I think your formulas aren't set up right.  Your formula for f(n,x,y) should involve n-1 and y-1, not n+1 and y+1.  I think that's why your recursion is never ending.  Also, for $y<1,$ be sure to return x; I'm not sure you're doing that.

@MitchellSpector Started to see major bugs in my code so switched over to the Ackermann function.

C (gcc) Ackermann, 37 36 bytes
A(m,n){m=m?A(m-1,n?A(m,n-1):1):n+1;}

Try it online!

Nicely done. I'm wondering if you did this by yourself or if you saw my solution to the Ackermann function challenge.

@S.S.Anne Golfed your solution - thanks! :D If you haven't already, you'll want to update your Ackermann function solution to this.

This is my solution. It has been since two days ago, when I posted it.

@S.S.Anne Ah, checking I see it was feersum's solution I golfed. If you look at the edit history you'll see first I simply use m= instead of return then got rid of the !.

JavaScript (Node.js),  81  76 bytes
An inefficient but non-recursive1 implementation of the Ackermann function, accepting either Numbers or BigInts.
Given enough time and memory, this should work in theory for any pair \$(m,n)\$.
Takes input as ([m])(n).
s=>n=>eval("for(;s+s;){(m=s.pop())?s.push(~-m)&&n?s.push(n--&&m):n++:n++}n")

Try it online!

1: By 'non-recursive', I mean that there's no recursive function call. Therefore, the code does not depend on the size of the call stack, which is always bounded regardless of the total amount of available memory. Instead, it's using its own stack s[].

Hmm... Is it really right to call this non-recursive?  This is only a question of nomenclature, but I would say that you're just implementing a recursive approach yourself using a stack (that's what I did in my dc implementation of Sudan's function).  Now, to be fair, something like that is presumably unavoidable, since this can't be done with bounded loops.  But I would still call it recursion.  (On the other hand, it's true that you're not literally calling a function inside itself, of course.)

Yes, the call stack is bounded (since it isn’t added to internally), but the stack in your program is unbounded since you’re storing there the things that would usually be stored in the call stack frame. Just to be clear, this isn’t a criticism — doing something like that is unavoidable.

Yes, I think that’s clearer.

Retina 0.8.2, 51 bytes
\d+
$*
{`((1*)1,1*)1$
$2,$1
1,$
,1
}`\B,(1*)$
1$1
1

Try it online! An implementation of the Ackermann function in unary arithmetic, so don't try to compute anything larger than A(4, 1) on TIO. Explanation:
\d+
$*

Convert to unary.
{`
}`

Repeat the steps until there is only one value left on the stack.
((1*)1,1*)1$
$2,$1

If the top of the stack is m+1, n+1 then decrement the latter to n and push a copy of m below m+1 so the stack is now m, m+1, n.
1,$
,1

If the top of the stack is m+1, 0 then decrement the former to m and increment the latter to 1.
\B,(1*)$
1$1

If the top of the stack is 0, n then remove the 0 and increment n.
1

Convert to decimal.

APL (Dyalog Unicode), 16 bytes
{×⍺:∇⍣⍵⍨⍺-1⋄2+⍵}

Try it online!
This function \$ f(\alpha,\omega) \$ is a variation of the commonly-known Ackermann function, which turns out as follows:
$$
\begin{align}
f(0,\omega)&= 2+\omega \\
f(1,\omega)&= 2\times\omega \\
f(2,\omega)&= 2^\omega \\
\end{align}
$$
But the pattern doesn't extend for \$ \alpha \ge 3 \$.
How it works
{×⍺:∇⍣⍵⍨⍺-1⋄2+⍵}
{×⍺:           }   ⍝ If ⍺ is nonzero,
    ∇⍣⍵⍨⍺-1        ⍝ Compute this expression, which expands to...
    (⍺-1)(∇⍣⍵)⍺-1  ⍝   Recursively call self with left arg ⍺-1, ⍵ times
                   ⍝   on the starting value of ⍺-1
           ⋄2+⍵    ⍝ Otherwise, return 2+⍵

MMIX, Ackermann, 60 bytes (15 instrs)
(jxd)
00000000: 5a000003 23000101 f8010000 5a010004  Z¡¡¤#¡¢¢ẏ¢¡¡Z¢¡¥
00000010: e3010001 27000001 f1fffffa c1040000  ẉ¢¡¢'¡¡¢ȯ””«Ḋ¥¡¡
00000020: 27050101 fe020004 f303fff6 f6040002  '¦¢¢“£¡¥ṙ¤”ẇẇ¥¡£
00000030: c1010300 27000001 f1fffff2           Ḋ¢¤¡'¡¡¢ȯ””ṗ

Disassembly and explanation:
ack PBNZ  $0,0F     // if(!m)
    ADDU  $0,$1,1
    POP   1,0       // return n + 1
0H  PBNZ  $1,0F     // if(!n)
    SETL  $1,1
    SUBU  $0,$0,1
    JMP   ack       // return ack(m - 1, 1)
0H  SET   $4,$0
    SUBU  $5,$1,1
    GET   $2,rJ
    PUSHJ $3,ack
    PUT   rJ,$2
    SET   $1,$3     // n = ack(m, n - 1)
    SUBU  $0,$0,1   // m--
    JMP   ack       // return ack(m,n)


text:
Filter an array so that duplicate items are removed
In the shortest amount of code in any programming language, filter out the duplicate items in an array of which the order is irrelevant.
Here are some test cases:
[1, 2, 2, 3, 1, 2, 4] => [1, 2, 3, 4]
['a', 'a', 'b', 'a', 'c', 'a', 'd'] => ['a', 'b', 'c', 'd']

I also should note that there currently aren't any open questions that meet these exact criteria.

Related (char input, no built-in allowed)

Preserving order of first (or last) appearance would be a different challenge that's perhaps more interesting (because Set builtins and sorting with duplicate merging won't work).  It might be good if one of the test-cases showed that you're definitely allowed to re-order the elements you do keep, like [1, 2] => [2, 1] being valid.  I'd also suggest tweaking the title to something that doesn't imply order preservation.  Perhaps involving the phrase "set of unique items"

Can answers assume that the list does not contain empty strings?

1-byte built-ins
05AB1E (legacy)
Ù

Try it online!
Alternatively:
ê

Try it online!
APL (Dyalog Unicode)
∪

Try it online!
Jelly
Q

Try it online!
W
U

Stax
u

MATL
u

Try it online!
MathGolf
▀

Try it online!
Seriously/Actually
╔

Japt
â

Try it online!
Pyth
{

Try it online!
Husk
u

Try it online!
Pyke
}

Try it online!
Canvas
Ｄ

Try it online!
Vyxal
U

Try it Online!

And once again, the most boring answer gets voted to the top. But at least you took the time to compile a collection.

@wastl Boring answers getting voted to the top is another story, but at least we have a consensus about using a community answer to group all trivial solutions.

Ah, I can't see that it's a community wiki in the app, it just says "Edited by Arnauld"

It always bothered me that this is called unique elements. Shouldn't it be distinct? To me, the unique elements in 1, 2, 2, 3, 1, 2, 4 are 3,4 since they appear exactly once.

Python 3, 15 3 bytes
Reduced to 3 bytes thanks to a'_'!!!
set

Try it online!
Without set
Python 3, 35 \$\cdots\$30 29 bytes
Saved 3 bytes thanks to a'_'!!!
Saved a byte thanks to Jitse!!!
Saved a byte thanks to  Jonathan Allan!!!
lambda l:list(dict(zip(l,l)))

Try it online!

Or just... 3 bytes

@a'_' Brilliant - thanks! :-)

Very nice way of using set +1

Anyway, 31 bytes without set.

@a'_' Sweet - thanks! :-)

lambda l:dict(zip(l,l)).keys() for 30 bytes

@Jitse Clever - thanks! :-)

...without set save a byte: lambda l:list(dict(zip(l,l))) (of course set works in place of list too :p)

@JonathanAllan Nice one - thanks! Yeah staying away from lambda l:{e for e in l} too since it's not really without set! :p

Python 3, 3 bytes
set

Try it online! It also works on Python 2
Or without set:
Python 3, 34 29 26 bytes
lambda l:[*dict(zip(l,l))]

Try it online! Thanks to Jonathan Alan and Surculose Sputum for helping me golf this one!

...that non-set answer can be lambda l:list({e:1for e in l}) saving four

The non-set answer can be lambda l:[*dict(zip(l,l))], making use of splat operator to save 3 bytes

Ruby, 8 bytes
->a{a&a}

or
->a{a|a}

Try it online!
Set intersection (&) or set union (|), both of which remove duplicates. Shorter than the built-in uniq method.

Java 8, 27 15 bytes
S->S.distinct()

Stream I/O.
Try it online.
27 22 bytes:
java.util.HashSet::new

-5 bytes thanks to @OlivierGrégoire.
List input, Set output.
Try it online.

java.util.HashSet::new for the List input, Set output.

@OlivierGrégoire Ah, of course. I always forget about ::.. Thanks!

Retina 0.8.2, 6 bytes
D`
G`.

Try it online! Doesn't work on empty strings. Explanation:
D`

Replace all duplicates with empty strings.
G`.

Remove all empty strings.

Where do the rules state that your program is allowed to assume the input does not contain empty strings?

I'm not claiming it does, but as yet none of the test cases include empty strings.

JavaScript (Node.js), 13 bytes
a=>new Set(a)

Try it online!
Unfortunately Set must be used with new, otherwise the answer will be just 3 bytes: Set, as a function.

But you are returning a set, instead of an array.

@kanine the specification does not state we must return an array, it only specifies we'll be given one and must filter out duplicates.

@kanine Even so changing the set into an array costs only 5 bytes.

@JonathanAllan, but looking as the test cases, it demands for an array.

@kanine we do not define challenges by their test cases. We also prefer loose I/O rules on this site. Note that the OP has also specified the input as "an array of which the order is irrelevant" which I would imagine means I/O is less restrictive than a list to the point of just meaning "container". If you think there is a point of contention here you should just ask OP to clarify in a comment under the question.

@JonathanAllan, good point

Batch, 182 Bytes
@Echo Off&Setlocal EnableDelayedExpansion
For %%A In (%~1)do (
Set M=F
IF "!O!"=="" (Set O=%%A) Else (
For %%B in (!O!)do If %%A==%%B Set M=T
IF !M!==F Set O=!O!,%%A))
ECHO(!O!

Builds a string starting with first element of the original string, compares each element of the new string against the next element of the original string, assigning and testing a troothy value before appending the next element to the new string.

Wolfram Language (Mathematica), 5 bytes
Union

Try it online!

Io, 18 bytes
Io doesn't allow assigning functions. It's terrible!
method(x,x unique)

Try it online!

Charcoal, 9 bytes
Ｗ⁻θυ⊞υ⊟ιυ

Try it online! Link is to verbose version of code. Works best on strings due to the way Charcoal prints numbers by default. Explanation:
Ｗ⁻θυ

Remove all occurrences of elements in the result from the input. While this temporary value is not empty...
⊞υ⊟ι

... push the last element of that value to the result.
υ

Print the result.

Erlang (escript), 41 bytes
Great thanks for the Haskell answer! (so that I can port it)
u([H|T])->[H]++u([X||X<-T,X/=H]);u(I)->I.

Try it online!
Erlang (escript), 79 72 bytes
It's a recursive definition of uniquifying. The premise is that Erlang doesn't have a set-conversion built-in.
u([H|T])->case string:find(T,[H])of nomatch->[H];_->[]end++u(T);u(I)->I.

Try it online!
Explanation
u([H|T])-> % Try to split the input into a head & tail.

case string:find(T,[H])of
           % Check whether H is a substring of T.
           % Strings are lists in Erlang, so it
           % doesn't raise a type error when applied on lists.

nomatch->[H];
           % If false, return head.
_->[]end   % Else, return empty list.
++u(T);    % Recurse down until ...

u(I)       % ... the operand is an empty list,
->I.       % where the operand is returned
```

Haskell, 29 bytes
f(a:b)=a:f[x|x<-b,x/=a]
f x=x

Try it online!
This answer gives us the list with the first occurrence of every element.
Haskell, 33 bytes
f(a:b)=[a|notElem a b]++f b
f x=x

Try it online!
This answer gives us the last occurrence of every element.

Does not import Data.List;nub do the same at 20 bytes?

@JonathanFrech Probably

Sledgehammer, 2 bytes
⠓⣻

Decompresses into this Wolfram Language function:
Union

Surprised that Sledgehammer doesn't have a 1-byte built-in...

perl -E, 23 bytes
@_{<>}=0;say for keys%_

Reads an array from STDIN, one element per line. Writes the unique elements to STDOUT, elements separated by two newlines.
(No TIO link, as it seems to not terminate the final line of the input with a newline, which leads to an incorrect output).

You can manually add an empty line at the end of input.

R, 6 bytes
unique

Try it online!

perl -MList::Util=uniq -E, 17 bytes
say for uniq@ARGV

Accepts an array as arguments, prints the unique elements to STDOUT, one element per line.
TIO

If you take the input on STDIN, you can save 3 bytes: Try it online!

IBM/Lotus Notes Formula, 10 bytes
@Unique(i)

Takes input from multi-value field i. Screenshots below.

Symja, 16 bytes
DeleteDuplicates

Try It Online!

Can't you just go with DeleteDuplicates?

@RGS I'm not sure about function rules with Symja. I'll probably ask a meta question about what I can and can't include.

I'm pretty sure you can

@RGS I was more saying I don't know if I can say DeleteDuplicates without the function declaration m:=.

Assuming you saw the code I wrote in my link, having as answer the code DeleteDuplicates is, in my opinion, the same as this R answer or this Python answer or this Sledgehammer answer or this Mathematica answer. When the function we want is a built-in, you can just use that. No need to rename it. Also similar to arrow functions (Java, JS, ...) or lambdas (Python)

We only need to include the renaming of the function when whatever we write afterwards is recursive. Either way, removing the : will save 1 byte.

@RGS I see what you mean. Thanks!

Clojure, 3 bytes
set

Try it online!
Returns a set, or preserving order:
Clojure, 8 bytes
distinct

Try it online!

MOO, 36 bytes
return #372:remove_duplicates(@args)

Extremely implementation-specific. The shortest non-implementation-specific way of doing this is return $list_utils:remove_duplicates(@args) (43 bytes).
Unfortunately, functions aren't first-class objects in this language, so #372:remove_duplicates (22 bytes) is a syntax error and thus isn't valid.
The shortest way of doing this without using a builtin is x={};for y in (args[1])x=setadd(x,y);endfor return x; (53 bytes)

T-SQL, 24 bytes
SELECT DISTINCT v FROM t

Takes input as separate rows in a table t with varchar field v, which is permitted per our IO rules.
Without an ORDER BY, SQL returns the rows in a non-prescribed order.

sh + POSIX utilities, 7 bytes
sort -u

sh + POSIX utilities, 9 bytes
sort|uniq

Notes

The TIO uses bash because it doesn't provide plain sh, but it should work fine in any shell.
I was flexible with the input (one entry of the array per line, no other markers) because sh doesn't have arrays. If you wanted to do it with, e.g., bash arrays, you could do this (TIO):

a=(1 2 2 3 1 2 4 a a b a c a d)
printf '%s\n' "${a[@]}" | sort -u

Hey there, welcome! You may want to add a TIO link to your submission so that others can try it out, if possible. Also, in the first option, why don't you go with just uniq?

@RGS if uniq’s input isn’t sorted, it will only remove consecutive dupes. I was posting from mobile so no link :)

https://www.gnu.org/software/coreutils/manual/html_node/uniq-invocation.html#uniq-invocation Based on GNU uniq documentation, you could use uniq -d, but I'm not sure if that's available in POSIX uniq.

C++ (gcc), 69 bytes
#import<set>
using s=std::set<int>;s f(int*a,int l){return s{a,a+l};}

This is what I like about C++: It has a lot of features.
Try it online!

C (gcc), 86 bytes
i,j;f(a,l)int*a;{for(i=l;i--;)for(j=l;j--;)i-j?a[i]-a[j]?:bcopy(a-~i,a+i,--l-i<<2):0;}

Hoping to roll the two loops together.
Try it online!
C (gcc), 87 bytes
i,j;f(a,l)int*a;{for(i=j=l;i-=j--==l;j=j?:l)i-j?a[i]-a[j]?:bcopy(a-~i,a+i,--l-i<<2):0;}

Turns out longer.
Try it online!

I think you should return the resulting length, like this 82-byter. Otherwise we never know where the resulting array ends.

Factor, 7 bytes
members

Try it online!


text:
Solving the water bucket riddle!
Context
The water buckets riddle or the water jugs riddle is a simple riddle that can be enunciated in a rather general form as:
Given \$n > 0\$ positive integers \$a_1, a_2, \cdots, a_n\$ representing the capacities (in units of volume) of \$n\$ buckets and a positive integer \$t \leq \max(a_1, a_2, \cdots, a_n)\$, find a sequence of "moves" that places \$t\$ units of volume of water in some bucket \$i\$.
To define the valid "moves", let \$c_1, c_2, \cdots, c_n\$ represent the units of volume of water each bucket \$i\$ contains, with \$0 \leq c_i \leq a_i\ \forall i\$. Then, at each step you can do any of the following:

fill a bucket \$i\$ entirely, setting \$c_i = a_i\$
empty a bucket \$i\$ entirely, setting \$c_i = 0\$
pour a bucket \$i\$ over a bucket \$j\$, setting

$$\begin{cases}
c_i = \max(0, c_i - (a_j - c_j)) \\
c_j = \min(a_j, c_j + c_i)
\end{cases}$$
i.e you pour bucket \$i\$ over bucket \$j\$ until bucket \$i\$ becomes empty or bucket \$j\$ becomes full, whatever happens first (or both if both things happen at the same time).
Task
Given the bucket capacities and the target measurement, your task is to output a minimal sequence of movements that places \$t\$ units of volume of water in one of the buckets.
Input
The capacities of the buckets are positive integers. You can assume these capacities are unique and ordered. You can take them in a number of reasonable formats, including but not limited to:

a list of integers
arguments to a function

Additionally, you will take a positive integer t that is not larger than the maximum number present in the input capacity list.
You can assume the input parameters specify a solvable instance of the water buckets problem.
Output
Your program/function/etc should output the shortest sequence of moves that places t units of volume of water in one of the buckets. If several such sequences exist you can output any one sequence. Please note that some moves commute and that also introduces multiple solutions to some problems.
Your program can print the sequence or return it as a list of moves or any other sensible thing.
To identify the moves and the buckets, you can choose any encoding suitable for your needs, as long as it is consistent across test cases and completely unambiguous. A suggestion is, use three letters to identify the three moves, like "E" for emptying a bucket, "F" for filling and "P" for pouring and use numbers to identify the buckets (0-index or 1-indexed or using its total capacity, for example).
With this encoding, to identify a move you always need one letter and a number. In case of a "pouring" move, a second integer is also needed. It is up to you to consistently use "P" n m as n was poured over m or m was poured over n.
Test cases
We use the encoding above and "P" n m means "pour bucket n over bucket m".
[1, 2, 3, 4], 1 -> ['F 1']
[1, 2, 3, 4], 2 -> ['F 2']
[1, 2, 3, 4], 3 -> ['F 3']
[1, 2, 3, 4], 4 -> ['F 4']
[13, 17], 1 -> ['F 13', 'P 13 17', 'F 13', 'P 13 17', 'E 17', 'P 13 17', 'F 13', 'P 13 17', 'E 17', 'P 13 17', 'F 13', 'P 13 17']
[4, 6], 2 -> ['F 6', 'P 6 4']
[1, 4, 6], 2 -> ['F 6', 'P 6 4']
[3, 4, 6], 2 -> ['F 6', 'P 6 4']
[4, 5, 6], 2 -> ['F 6', 'P 6 4']
[4, 6, 7], 2 -> ['F 6', 'P 6 4']
[1, 3, 5], 2 -> ['F 3', 'P 3 1']
[7, 9], 4 -> ['F 9', 'P 9 7', 'E 7', 'P 9 7', 'F 9', 'P 9 7']
[8, 9, 13], 6 -> ['F 9', 'P 9 8', 'P 8 13', 'P 9 8', 'F 13', 'P 13 8']
[8, 9, 13], 7 -> ['F 8', 'P 8 9', 'F 8', 'P 8 9']
[8, 9, 11], 10 -> ['F 8', 'P 8 9', 'F 11', 'P 11 9']
[8, 9, 12], 6 -> ['F 9', 'P 9 12', 'F 9', 'P 9 12']
[8, 9, 12], 5 -> ['F 8', 'P 8 12', 'F 9', 'P 9 12']
[23, 37, 41], 7 -> ['F 41', 'P 41 23', 'P 41 37', 'P 23 41', 'F 41', 'P 41 23', 'P 41 37', 'F 41', 'P 41 37', 'E 37', 'P 41 37', 'E 37', 'P 41 37', 'F 41', 'P 41 37']
[23, 31, 37, 41], 7 -> ['F 23', 'P 23 37', 'F 31', 'P 31 37', 'P 31 41', 'P 37 31', 'P 31 41']

You can check a vanilla Python reference implementation here

Can I take n as input?

@SurculoseSputum in languages such as C and related ones, where you need such a parameter to know when the array ends, yes. If you are coding in python, then I'm afraid not.

Python 3, 243 239 bytes
-4 bytes thanks to @JonathanFrech!
def f(a,t,k=1):
 while g(a,t,[0]*len(a),[],k):k+=1
def g(a,t,c,p,k):n=len(a);k,i=k//n,k%n;k,j=k//n,k%n;exec(["c[i]=0","c[i]=a[i]","x=min(a[j]-c[j],c[i]);c[i]-=x;c[j]+=x"][k%3]);p+=k%3,i,j;return g(a,t,c,p,k//3)if k>2else{t}-{*c}or print(p)

Try it online!
Input: a list of bucket capacities a, and the target t.
Output: to stdout, a list of integers, where each triplet m,i,j denotes a move: m is the move type (0,1,2 corresponds to empty, fill, pour), and i,j are the bucket indices (0-index). For move types empty and fill, the 2nd bucket is ignored.
How: Each sequence of moves p can be encoded by an integer k using modular arithmetic. g is a recursive function that checks if the sequence p encoded by k will result in the target t. If so, that sequence is printed to stdout, and a Falsy value is returned.

Old solution using itertools.product
Python 3.8 (pre-release), 279 249 bytes
Whopping -30 thanks to @ovs's double product trick!
from itertools import*
P=product
a,t=eval(input())
for r in count():
 for p in P(*tee(P((0,1,2),R:=range(n:=len(a)),R),r)):
  c=[0]*n;[exec(["c[i]=0","c[i]=a[i]","x=min(a[j]-c[j],c[i]);c[i]-=x;c[j]+=x"][m])for m,i,j in p]
  if t in c:print(p);exit()

Try it online!
Slow, ugly and can probably be golfed more.
Input: from stdin, a,t where a is the list of bucket capacities, and t is the goal.
Output: to stdout, the optimal list of moves, each move has the form (m, i, j) where:

m is the move type 0,1,2 (empty, fill, pour)
i and j are the target buckets' indices (0-index).
The moves empty and fill only affects the 1st bucket i, and thus the irrelevant 2nd bucket j is set to an arbitrary value.
The move (2,i,j) pours the water from bucket i to bucket j.

How:
This program simply tries all possible sequence of move, in order of length.
To generate all sequence of r moves:

product((0,1,2), range(n), range(n)) generates a list of all possible moves by performing the Cartesian product between all move types 0,1,2, all values of i and all values of j.
tee(product(...), r) clones the move list into r lists.
product(*tee(...)) takes the Cartesian product ofrmove lists, which results in all possible sequence ofr` moves.

To perform a sequence of move p:

c[i]=0,c[i]=a[i], and x=min(a[j]-c[j],c[i]);c[i]-=x;c[j]+=x respectively handles emptying, filling, and pouring between bucket i and j. Note that pouring can handle i==j, which results in a no-op.
exec(["handle E", "handle F", "handle P"][m]) selects the correct handler for move type m.

The inner for-loop is a little shorter with another product: for p in product([x for x in product((0,1,2),R,R)if x[1]^x[2]],repeat=r):

And you don't really need to check if i and j are distinct: for p in product(product((0,1,2),R,R),repeat=r) (this is even slower than before)

@ovs Nice observation! Took me a while to realize why distinct i and j is not needed, as I was working with the challenge's formula instead of the one in my solution. :)

TIO times up your code with the test case [7, 9], 4 which is the shortest test case I could come up with (yet) that uses the empty operation (6 steps). Can you confirm that your code runs locally with this test case?

I found by hand that the correct k was 2358833, which when reached produces the correct sequence.

Ok, thanks for taking your time to verify this! Cool solution :D

p+=[(k%3,i,j)]; ~> p+=(k%3,i,j),;.

@JonathanFrech thanks! I shortened it to p+=k%3,i,j which changes the output format a bit but saves 4 byte.

JavaScript (ES6),  197 191  188 bytes
Takes input as (a)(t).
Returns a string of concatenated operations Fx, Ex or Px>y, with 0-indexed buckets.
a=>F=(t,N)=>(g=(b,n,o)=>[...b,0].some((V,i,x)=>(x=a[i])-V^t?n&&b.some((v,j,[...B])=>(s='F',B[j]=i-j?x?(v+=V)-(B[s=`P${i}>`,i]=x<v?x:v):a[s='E',j]:0,g(B,n-1,[o]+s+j))):O=o))(a,N)?O:F(t,-~N)

Try it online!
The above test link inserts spaces between operations for readability. Some longer test cases have been removed.

Javascript, 364 bytes
I'm sure this can be golfed much better pretty easily.
S=t=>G=>{L=t.length;r=(f,n,a,i,e=0)=>{if(0==n)return f.indexOf(G)>=0&&[];a=(A,B,C,D)=>(X=f.slice(),X[A]=B,X[C]=D,X);for(;e<L;++e){for(K of[0,t[e]])if(F=r(a(e,K),n-1))return[[+!K,e]].concat(F);for(i=0;i<L;++i)if(i!=e&&(O=r(a(e,Math.max(0,f[e]-t[i]+f[i]),i,Math.min(t[i],f[e]+f[i])),n-1)))return[[2,e,i]].concat(O)}};for(T=1;!(E=r(Array(L).fill(0),T));++T);return E}

Returns an array of arrays. Each array is in the format [n, i] if n=0 (fill) or n=1 (empty), or [2, i, j] for "pour bucket i into bucket j". The buckets are always given as indices, starting from 0.
Uses the same basic search method as the other answers.
Unminified version:
var S = (capacities, target) => {
    let n = capacities.length;
    var waterBuckets = (levels, maxSteps) => {
      if (maxSteps == 0) return levels.indexOf(target) >= 0 ? [] : false;
      let getCopy = () => levels.slice();
      for (let i = 0; i < n; ++i) {
        for (let level of [0, capacities[i]]) {
          let levelsCopy = getCopy();
          levelsCopy[i] = level;
          let res = waterBuckets(levelsCopy, maxSteps - 1);
          if (res) return [[+!level, i]].concat(res);
        }
        for (let j = 0; j < n; ++j) {
          if (i === j) continue;
          let levelsCopy = getCopy();
          levelsCopy[i] = Math.max(0, levels[i] - capacities[j] + levels[j]);
          levelsCopy[j] = Math.min(capacities[j], levels[i] + levels[j]);
          let res = waterBuckets(levelsCopy, maxSteps - 1);
          if (res) return [[2, i, j]].concat(res);
        }
      }
    };
    for (let s = 1;; ++s) {
      let r = waterBuckets(Array(n).fill(0), s);
      if (r) return r;
    }
};

Charcoal, 112 104 bytes
⊞υＥθ⁰Ｆυ¿¬ⅈ¿№…ιＬθη⪫✂ιＬθＬι¹ «ＦＬθＦ²⊞υ⁺Ｅι⎇⁼κν∧λ§θκμ⟦§EFλκ⟧ＦＬθＦＬθ¿⁻λκ«≔⌊⟦§ιλ⁻§θκ§ικ⟧ε⊞υ⁺Ｅι⎇⁼κν⁺με⎇⁼λν⁻μεμ⟦Pλκ

Try it online! Link is to verbose version of code. Could save 6 bytes by including the final bucket state in the output. The code spends most of its time emptying or pouring empty buckets, so don't try it on the harder problems. Explanation:
⊞υＥθ⁰

Start off with all buckets empty and no operations so far. (Each entry comprises n buckets plus an unspecified number of operations.)
Ｆυ¿¬ⅈ

Perform a breadth-first search until a solution has been printed. (This relies on t being positive, as that means that at least one step is necessary.)
¿№…ιＬθη⪫✂ιＬθＬι¹ «

If one of the first n buckets contains t then this is a solution in which case output it, otherwise:
ＦＬθＦ²

Loop over each bucket and whether it's being emptied or filled.
⊞υ⁺Ｅι⎇⁼κν∧λ§θκμ⟦§EFλκ⟧

Calculate the new bucket values and append the result with the additional operation.
ＦＬθＦＬθ¿⁻λκ«

Loop over each pair of distinct buckets.
≔⌊⟦§ιλ⁻§θκ§ικ⟧ε

Calculate the amount that can be poured from one bucket to the other.
⊞υ⁺Ｅι⎇⁼κν⁺με⎇⁼λν⁻μεμ⟦Pλκ

Calculate the new bucket values and append the result with the additional operation. Adding an extra ¿ε to the beginning of this block does make the code a bit faster but it wasn't significant enough to be able to solve the harder problems on TIO.


text:
Counting valid Binary Sudoku boards
Sequel of Counting valid Binary Sudoku rows.
Background
Binary Sudoku, also known as Takuzu, Binario, and Tic-Tac-Logic, is a puzzle where the objective is to fill a rectangular grid with two symbols (0s and 1s for this challenge) under the following constraints:

Each row/column cannot have a substring of 000 or 111, i.e. one symbol cannot appear three times in a row, horizontally or vertically.

A row/column of 1 0 0 0 1 1 violates this rule since it contains three copies of 0 in a row.

Each row/column should contain exactly as many 0s as 1s, i.e. the counts of two symbols must be the same.

A row/column of 1 0 1 1 0 1 violates this rule since it has four 1s but only two 0s.
Some examples of rows that meet the first two requirements include:
[1 0 0 1]
[1 1 0 0]
[1 1 0 1 0 0]
[1 1 0 0 1 0 0 1]

The entire grid cannot have two identical rows or columns.

Note that the constraint 2 enforces the grid size to be even in both dimensions.
Here are some examples of completed Binary Sudoku:
(4x4)
1 1 0 0
0 1 1 0
1 0 0 1
0 0 1 1

(6x8)
1 1 0 1 0 1 0 0
0 0 1 0 1 0 1 1
0 1 0 1 0 0 1 1
1 1 0 0 1 1 0 0
0 0 1 0 1 1 0 1
1 0 1 1 0 0 1 0

Challenge
Given two positive integer m and n, calculate the number of distinct valid Binary Sudoku boards of width 2m and height 2n. (You may take the values of 2m and 2n as input instead of m and n.)
A253316 is the sequence for square boards.
Test cases
m,n => answer
-------------
1,1 => 2
1,2 => 0
2,2 => 72
2,3 => 96
2,4 => 0
3,3 => 4140
3,4 => 51744
3,5 => 392208
4,4 => 4111116

For the input 1,2, it counts 2-by-4 boards, i.e. boards with four rows of length 2. But we can't have four distinct rows of length 2 to fill the grid (we have only 01 and 10). Therefore, by rule 3, the answer to the input 1,2 is zero. The same argument applies to the input 2,4 (4-by-8 boards).
Reference implementation in Python. This can handle up to 3,5 in a minute. Note that putting r > c takes much more time than the same pair swapped, though the results are the same.
Scoring and winning criterion
Standard code-golf rules apply. The shortest submission in bytes wins.

Can we take 2n and 2m as input instead of n and m?

@RGS Yes. I'll edit the post to allow it.

4,5 => 201005480

Python 3.8 (pre-release), 265 250 198 bytes
lambda n,m:sum(not(n>len({*s})or m>len(set(z:=[*zip(*s)]))or any(p*3in"".join(v)or v.count("1")*2-len(v)for p in'01'for v in[*s]+z))for s in P(*[[*P(*['01']*m)]]*n))
from itertools import*;P=product

Try it online! Takes as input 2n and 2m. Thanks to Bubbler for finding a bug in my original answer and for golfing a massive 52 bytes off.
How it works:
The anonymous function we define will be taking 2n and 2m as input, generate all binary boards with the specified dimensions and then count how many of those satisfy the restrictions.
Generating all boards
... for s in P(*[[*P(*['01']*m)]]*n))
from itertools import*;P=product

is generating all the boards. The product function from the library itertools can be used to generate the cartesian product of all the arguments it is given. Breaking the nested Ps down, P(*['01']*m) creates a list of length m with '01': ['01', '01', ..., '01'] and then the splat operator * is used to turn each element of the list into an argument to P, so P(*['01']*m) generates all valid rows of length m. Call it P1.
Then we have P(*[[*P1]]*n) which takes all valid rows and turns it into a list of all valid rows, with [*P1]. We then enclose such a list in another list and multiply by n, so that we get a list of length n where each value is a list of all valid rows. Then the splat operator * is used to provide such a list as a series of arguments to the itertools.product function, thus getting all the correct-sized binary sudoku boards. We iterate over those with s.
Checking restrictions on the board
Now we are left with checking the conditions imposed on the board s with
not(n>len({*s})or m>len(set(z:=[*zip(*s)]))or any(p*3in"".join(v)or v.count("1")*2-len(v)for p in'01'for v in[*s]+z))

Instead of verifying if the board satisfies everything, we check if the board doesn't violate any restriction:

n>len({*s})or m>len(set(z:=[*zip(*s)])) checks if there are n unique rows, by converting the list of rows into a set; similarly we transpose s into z and check if there are m unique columns;
then any(B1 or B2 for v in[*s]+z) goes over all rows and all columns:

B2 = v.count("1")*2-len(v) gives 0 when the amount of 1s is exactly half of the size of the row/column and other non-zero integers when it is not. Regardless of giving a positive or negative result, Python will treat it as a Truthy value.
B1 = p*3in"".join(v) for p in'01' builds the substrings "000" and "111" and checks if those are in the row/column

Wrapping it up
In the end, we just sum all the Truthy values that correspond to all the boards that did not violate any restrictions.

I think v.count("1")==m/2 must be v.count("1")==len(v)/2 because the length of v can be either 2n or 2m.

@Bubbler I think you are right!

198 bytes by logic negation, ('0','1')->'01', and abusing itertools.product.

Wolfram Language (Mathematica), 144 bytes
Input (2n,2m)
(l=Length)@Select[Tuples[{0,1},g=#],And@@Flatten[{#~Count~1==#~Count~0,Max[l/@Split@#]<3}&/@Flatten[c={#,Transpose@#},1],1]&&l/@(Union/@c)==g&]&

Try it online!

Jelly, 26 bytes
IIP;S¬$PȧQƑ
×Ø-ṗ$s€ÇƇZ€$⁺L

A dyadic Link accepting 2n on the left and 2m on the right (or vice-versa as it's symmetric) which yields the count.
Try it online! This will time out even for (6,4) (i.e. m=2 and n=3)*
How?
I imagine that if one worked out a combinatorial formula it would be much shorter (and quicker and more memory efficient!), but this entry is pure brute-force...
IIP;S¬$PȧQƑ - Link 1, (    no row has a run of 3 or more
                       AND no column contains differing type counts
                       AND all the rows are different
                      ): a single board, B
I           - incremental differences (vectorises) - e.g. [-1,1,1,1] -> [2,0,0]
 I          - incremental differences (vectorises)
  P         - product - this will give a list which will contain a zero for any row
                        containing a run of at least three equal items
     $      - last two links as a monad:
    S       -   sum (vectorises) - since we use -1 and 1: zero if the counts are equal
     ¬      -   logical NOT
   ;        - concatenate
       P    - product - this will be non-zero if (no row has a run of 3 or more
                                  AND no column contains differing type counts)
          Ƒ - is (B) invariant under:
         Q  -   de-duplication - i.e are all the rows different?
        ȧ   - logical AND

×Ø-ṗ$s€ÇƇZ€$⁺L - Link: 2n, 2m
×              - multiply -> 2n×2m (size of board)
    $          - last two links as a monad:
 Ø-            -   signs = [-1,1]
   ṗ           - Cartesian power (all lists of length 2n×2m of items -1 and 1)
      €        - for each:
     s         -   split into slices of length 2m (i.e. into rows)
           $   - last two links as a monad:
        Ƈ      -   filter keep those for which:
       Ç       -     call last Link (1) as a monad
          €    -   for each:
         Z     -     transpose
            ⁺  - repeat the last link - i.e. check the results with rows<->columns
             L - length

* I ran m=2, n=3 locally and it yielded 96 as expected (after over an hour in which it hit 100% memory (16GB Ram) and slowed to a snail's pace while using disk).

Charcoal, 102 81 64 bytes
Ｎθ≔×θＮη≔ＥＸ²η⪪⭆◧⍘ι²ηΣλθζＦ²≔ＥΦζ⬤κ›⁼№μ0№μ1⁺⊖№κμΣＥ²№μ×³ＩξＥθ⭆κ§ξμζＩＬζ

Try it online! Link is to verbose version of code. Takes the actual size as input. Explanation:
Ｎθ≔×θＮη

Input the width and area.
≔ＥＸ²η⪪⭆◧⍘ι²ηΣλθζ

Generate all possible grids of 0s and 1s of the given width and area.
Ｆ²

Loop over rows and columns.
Φζ⬤κ›⁼№μ0№μ1⁺⊖№κμΣＥ²№μ×³Ｉξ

Keep only those grids where each row has an equal number of 0s and 1s, is unique, and contains neither 000 nor 111.
≔Ｅ...Ｅθ⭆κ§ξμζ

Transpose the rows and columns so that the columns can be checked on the next pass.
ＩＬζ

Output the number of remaining grids.
Previous much faster 102-byte version:
ＮθＮη≔ΦＥＸ²θ⭆◧⍘ι²θΣλ›⁼№ι0№ι1ΣＥ²№ι×³Ｉλζ⊞υ⟦⟧ＦυＦ‹ＬιηＦζＦ¬№ιλ⊞υ⁺ι⟦λ⟧ＩＬΦＥΦυ⁼ＬιηＥθ⭆ι§νλ⬤ι›⁼№λ0№λ1⁺⊖№ιλΣＥ²№λ×³Ｉν

Try it online! Link is to verbose version of code. Takes the actual size as input.