Simulate D Flip-Flop Objective

Simulate an edge-triggered D Flip-Flop.

What is D Flip-Flop?

A D flip-flop is an electronic digital device that outputs an inputted data (abbr. D) with synchronization to a clock (abbr. CLK). Usually CLK is a uniform pulse, but in this challenge, CLK may be not uniform.

Input

A bitstring with length \$n\$ will be given as CLK and another bitstring with length \$n-1\$ will be given as D. A bit represents the state of an input during a unit time (tick). CLK leads D by half a tick.

Output

The output (abbr. Q) is a bitstring with same length and starting timepoint as D. If CLK doesn't start with 01, the starting bit of Q is implementation-defined. Q is updated upon a rising moment of CLK to the bit of D at the time. On the other times, Q retains its state.

Examples

The red line indicates a rising moment of CLK.


Example 1:





Example 2:




Rules


If CLK isn't a tick longer than D, the entire challenge falls into don't care situation.
Though defined as bitstrings, the actual elements of CLK, D, and Q doesn't matter. In this case, if a string is not binary (that is, contains a third character), the entire challenge falls into don't care situation.
J, 27 23 bytes

-4 bytes thanks to Bubbler!

;@(&lt;@({.\);.1~1,2&lt;/\}.)


Try it online!

CLK is the left argument; D is the right one. When CLK doesn't start with 01, the starting bits are the same as the first bit of D.

                       ;.1  - cut 
                          ] - the right argument (D)
   (          )             - where
         2 /\               - the previous element 
             [              - of the left argument (CLK)
          &lt;                 - is smaller than the next one 
       }.                   - drop
      1                     - the first item
    1,                      - prepend with 1 (for cutting)
               (     )      - for each cut group
                   $        - make a list   
                #           - of the same length as the group
                    {.      - with elements same as the first one  
                 &lt;@         - and box the list
  ;                         - unbox the sublists and flatten them
[:                          - function composition


K (oK), 27  23bytes

-4 bytes thanks to ngn!

{,/&amp;\'|\'(0,&amp;1_&gt;':x)_y}


Try it online!