Downward Number Race

Pyth, 38 34 bytes

j.tm+j\=jL\+C,.u+NYJ.WnsHQ+ZO2Y0J+\=QE
j.tmj\=jL\+.T,.u+NYJ.WnsHQ+ZO2Y0JE

Try it online!


Jelly, 37 36 33 bytes

,‘X
0Ç<³$пµżIFµ“+=”ṁṖ⁸żF
ÇСḊz⁶G

3 bytes thanks to Dennis.

Try it online

Explanation

,‘X                    Helper link. Argument: n. Radomly return n or n+1.

 ‘                     Increment n
,                      Pair. Yield [n, n+1]
  X                    Return a random item from the pair.

0Ç<³$пµżIFµ“+=”ṁṖ⁸żF   Monadic link. Argument: s. Generate one racer.

0                       Start with value 0.
  <³$пµ                While value is less than s:
 Ç                        Use helper link to increment current value.
                        Collect intermediate results in a list.
         I              Compute consecutive differences.
        ż               Zip intermediate results with their next increment value 0 or 1.
          Fµ            Flatten. Let's call the current list A.
                        Odd items of A are racer state and even items are random 0 or 1.
            “+=”        Yield "+=".
                 Ṗ      Yield A without its last element.
                ṁ       Mold i.e Repeat the characters of the string until it contains length(A)-1 characters.
                  ⁸ż    Zipwith. Pair the elements of A with the correponding characters
                    F   Flatten.

ÇСṫ2z” G               Main link. Arguments: s (score needed), r (#racers)

ÇС                     Call the link above r times.
                        Generate a list of r racers.
   Ḋ                    Remove first element of the list (its a garbage s value)
    z⁶                  Transpose with space as fill value.
      G                 Grid. Format the result.

TSQL, 367 345 341 bytes

Golfed

DECLARE @r int=20, -- racers
        @g char=2  -- goal

DECLARE @ varchar(99)=REPLICATE('0',@r)a:PRINT @
DECLARE @A varchar(99)='',@s varchar(99)='',@i int=0WHILE @i<@r
SELECT
@i+=1,@A+=char(43-x*11),@s+=IIF(x=1,' ',LEFT(y,1)),@=RIGHT(@,@r-1)+IIF(x=1,' ',REPLACE(LEFT(@,1)+y,@g+1,' '))FROM(SELECT
IIF(LEFT(@,1)IN('',@g),1,0)x,ROUND(RAND(),0)y)z
PRINT @A+'
'+@s+'
'+REPLACE(@A,'+','=')IF @>''goto a

Try it online

Ungolfed:

DECLARE @r int=10, -- racers
        @g char=2  -- goal

DECLARE @ varchar(99)=REPLICATE('0',@r)
a:
PRINT @
DECLARE @A varchar(99)='',@s varchar(99)='',@i int=0

WHILE @i<@r
  SELECT
    @i+=1,
    @A+=char(43-x*11),
    @s+=IIF(x=1,' ',LEFT(y,1)),
    @=RIGHT(@,@r-1)+IIF(x=1,' ',REPLACE(LEFT(@,1)+y,@g+1,' '))
  FROM(SELECT IIF(LEFT(@,1)IN('',@g),1,0)x,ROUND(RAND(),0)y)z

PRINT @A+'
'+@s+'
'+REPLACE(@A,'+','=')

IF @>''GOTO a

Note that the random seed on the test site will always be the same, giving the same result each time, in studio management it will give different results. Can use different values for racers and goal to get a different picture

Tags:

Code Golf