g | x | w | all
Bytes Lang Time Link
013Haskell + hgl250720T225122ZWheat Wi
107Nim250719T143514ZjanAkali
008Japt250716T150152ZShaggy
135C64 Basic250719T102241ZOSI8
004Uiua250717T220853Znyxbird
121Clojure250717T170818ZNikoNyrh
086Python3250716T145047ZAjax1234
00705AB1E250715T131923ZKevin Cr
017Charcoal250715T234540ZNeil
005Jelly250715T194911ZJonathan
054JavaScript ES11250715T120653ZArnauld
068JavaScript250715T095311Ztata

Haskell + hgl, 13 bytes

uef nb$df*^nb

Attempt This Online!

Explanation

21 bytes

uue$l2m(rv<<nx<rv)nbr

Attempt This Online!

Explanation

Two functions uue and nbr almost solve this task. uue is an "unfold", basically a variant of uef from the first solution. It takes a function which breaks a list apart and repeats it until the input is empty collecting the pieces.

nbr takes the first occurrence of every element of the list out, however it reorders the remaining elements. So instead of doing what we want uue nbr just sort of repeats the first lap a couple of times, eliminating cars if they don't finish a lap.

So we have to fix this ordering problem, and we end up paying quite a bit to do this. What I do is take the intersection of the remainder with the reverse of the original list. This takes the order of the reversed original list and imposes it on the fragment. Then I reverse the result.

This is done with this monstrosity: rv<<nx<rv

Reflection

I think this is a really good challenge. I'm happy enough with the first answer, but I'm pretty unhappy with the second. hgl is really close to being really short with just uue nbr, but it fumbles it. I'm even disappointed in how many bytes it takes to fix the issue in the second answer.

So I have a couple of things I think could be improved:

Nim, 112 109 107 bytes

proc(s= @[1]):auto=(var l:seq[s.type];for c in s:(var i=0;while(l.grow(i+1,@[]);c in l[i]):i+=1
l[i]&=c)
l)

Try it in Wandbox! (with added let f= header)

Ungolfed:

proc raceOrder(cars = @[1]): auto =
  var laps: seq[cars.type]
  for car in cars:
    var i=0
    while(laps.grow(i+1,@[]); car in laps[i]):
      i+=1
    laps[i] &= car
  return laps

Japt, 8 bytes

I tried this initially and it didn't work; Nyxbird's solution inspired me to try it again and it worked this time 🤷🏼‍♂️

ü@¯Y è¶X

Try it

ü@¯Y è¶X     :Implicit input of array U
ü            :Group by
 @           :Passing each X at index Y through the following function
  ¯Y         :  Slice U to index Y
     è       :  Count the elements
      ¶X     :    Equal to X

Original, 10 bytes

Was stuck on 12 for ages, with the possibility of 10 only dawning on me just before I posted. If outputting a 3D-array were allowed then the last 3 bytes could be replaced with o.

í üÎÕËñÌmÎ

Try it

í üÎÕËñÌmÎ     :Implicit input of array
í              :Interleave with indices
  ü            :Group & sort by
   Î           :  First element (car)
    Õ          :Transpose
     Ë         :Map
      ñ        :  Sort by
       Ì       :    Last element
        m      :  Map to
         Î     :    First elements

C64 Basic, 135 bytes

C64 code

The code has 135 bytes without counting the DATA lines which may be different depending on the test case.

Additional limitations:

C64 screenshot

Try in emulator

Uiua, 4 bytes

⊕□⊸⧆

Try it!

⊕ group into □ boxes ⊸ by ⧆ occurences.
⧆ occurences gives the number of times each element of an array has appeared (up to the current index), so ⧆[1 2 1 3 1 2] is [0 0 1 0 2 1].

Clojure, 121 bytes

#(map reverse(vals(second(reduce(fn[[R P]c](let[r(+(or(R c)0)1)][(assoc R c r)(update P r conj c)]))[{}(sorted-map)]%))))

TIO

Python3, 86 bytes

def f(c):
 while c:
  l=[[],[]]
  for i in c:l[i not in l[1]]+=[i]
  yield l[1];c=l[0]

Try it online!

05AB1E, 17 11 7 bytes

.¡IN£s¢

-6 bytes porting JonathanAllan's Jelly answer (but without convenient Ġ builtin).
-4 bytes thanks to @Neil

Try it online or verify all test cases.

Original 17 bytes answer:

vÐÙþkDŠõsǝ}\¯)Ù¨è

Try it online or verify all test cases.

Explanation:

.¡       # Group the values in the (implicit) input-list by:
  I      #  Push the input-list
   N     #  Push the 0-based group_by-index
    £    #  Leave that many leading items from the input-list
     s   #  Swap so the current value is at the top of the stack
      ¢  #  Count how many times it occurs in this input-list prefix
         # (after which the list of lists of values is output implicitly)
v        # Loop the (implicit) input-size amount of times:
 Ð       #  Triplicate the current list
         #  (which will be the implicit input-list in the first iteration)
  Ù      #  Uniquify the top copy
   þ     #  Remove potential empty strings by only keeping numbers
    k    #  Get all (0-based) indices of these values in the duplicated list
 D       #  Duplicate that list of indices
  Š      #  Triple-swap to make the order indices,list,indices
   õsǝ   #  Insert empty strings at those indices in the list,
         #  to mark the current lap as done
}\       # After the loop: discard the top list of empty strings
  ¯      # Push an empty list (work-around for single-lap input-lists)
   )     # Wrap all other lists of indices into a list
    Ù¨   # Uniquify and remove the last item to remove all trailing empty lists
      è  # Index each inner index into the (implicit) input-list
         # (after which the list of lists of values is output implicitly)

Charcoal, 17 bytes

IE⌈Eθ№θιΦθ⁼ι№…θμλ

Try it online! Link is to verbose version of code. Explanation:

    θ               Input array
   E                Map over elements
     №              Count of
       ι            Current element
      θ             In input array
  ⌈                 Take the maximum
 E                  Map over implicit range
         θ          Input array
        Φ           Filtered where
            №       Count of
                λ   Inner element in
              θ     Input array
             …      Truncated to length
               μ    Inner index
          ⁼         Equals
           ι        Outer value
I                   Cast to string
                    Implicitly print

Jelly, 5 bytes

ĠZṢ€ị

A monadic Link that accepts a list of car numbers in lap marker observed race order and yields a list of lists of car numbers at progressive laps, each in race order.

Try it online!

How?

ĠZṢ€ị - Link: List, Cars  e.g. [7, 1, 3, 7, 3, 7, 1, 3, 3]
Ġ     - group the indices of {Cars} by their respective values
                            -> [[2, 7], [3, 5, 8, 9], [1, 4, 6]]
 Z    - transpose           -> [[2, 3, 1], [7, 5, 4], [8, 6], [9]]
  Ṣ€  - sort each           -> [[1, 2, 3], [4, 5, 7], [6, 8], [9]]
    ị - index into {Cars}   -> [[7, 1, 3], [7, 3, 1], [7, 3], [3]]

JavaScript (ES11), 54 bytes

a=>a.map(p=n=>(o[p[n]=p[n]+1|0]||=[]).push(n),o=[])&&o

Attempt This Online!

JavaScript, 68 bytes

a=>a.map(c=>o.find(r=>!r.includes(c))?.push(c)??o.push([c]),o=[])&&o

f=

a=>a.map(c=>o.find(r=>!r.includes(c))?.push(c)??o.push([c]),o=[])&&o

console.log(JSON.stringify(f([10,20,30,10,20,30,10,20,30])))
console.log(JSON.stringify(f([10,20,30,20,10,30,20,10])))
console.log(JSON.stringify(f([10,20,30,10,20,10,30,20,30])))
console.log(JSON.stringify(f([10,20,30,10,20,30,10,20,10,30,20,10,20,30])))