Starlink Beam Planner
Reported by candidates from SpaceX's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The SpaceX Starlink Beam Planner, reported in April 2024, looks like a 3D geometry monster. It isn't. Strip the vectors and it's a bipartite assignment with a capacity cap of 32 per satellite, plus a graph coloring step with only 4 colors per satellite. If the OA lands in your inbox, expect to build a visibility check, assign users, then color. StealthCoder sits invisibly as a safety net on the live OA if the geometry makes you blank, but the structure below is the whole game.
The problem
You are given the positions of users and satellites as three-dimensional vectors relative to the center of a spherical Earth at (0, 0, 0). Construct a set of satellite beams that serves at least minimumServed distinct users. Practice Contract Implement planBeams. Return an integer matrix in which every row is [userIndex, satelliteIndex, color]: userIndex and satelliteIndex are zero-based. color is one of 1, 2, 3, or 4. The order of the returned rows does not matter. Your assignment must satisfy all of the following rules: One beam per user: a user may appear in at most one returned row. User visibility: for user vector U and satellite vector S, the angle between U and S - U must be at most 45 degrees. Satellite capacity: one satellite may serve at most 32 users. Frequency separation: consider two users assigned to the same satellite. If their beams use the same color, the angle between the vectors from that satellite to the two users must be at least 10 degrees. Coverage: the matrix must contain at least minimumServed rows. Any assignment satisfying these rules is accepted. It does not have to equal the reference output shown in an example, and it may serve more than minimumServed users. Function planBeams(users: double[][], satellites: double[][], minimumServed: int) → int[][] Examples Example 1 users = [[1,0,0],[0,1,0]] satellites = [[2,0,0],[0,2,0]] minimumServed = 2 return = [[0,0,1],[1,1,1]] User 0 is directly below satellite 0, and user 1 is directly below satellite 1. Both users are served, so the minimum of 2 is met. Example 2 users = [[1,0,0],[0.996194698,0.087155743,0]] satellites = [[2,0,0]] minimumServed = 2 return = [[0,0,1],[1,0,2]] The two beams are less than 10 degrees apart at satellite 0, so the reference plan gives them different colors. Any other feasible colors are also accepted. Example 3 users = [[1,0,0],[0,1,0]] satellites = [[2,0,0]] minimumServed = 1 return = [[0,0,1]] User 0 is visible from the satellite. Serving that user alone satisfies minimumServed = 1; user 1 may be omitted. Constraints 1 <= users.length <= 500 1 <= satellites.length <= 100 Every user and satellite entry contains exactly three finite coordinates. Every user and satellite vector is nonzero, and every coordinate has absolute value at most 10^9. 0 <= minimumServed <= users.length At least one valid assignment serves minimumServed users.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to split it into three clean stages. First, visibility: for user U and satellite S, compute the angle between U and (S - U) with a dot product and compare cos against cos(45 degrees). Skip acos, it loses precision. Second, assignment: each user picks one visible satellite, each satellite takes at most 32. That's a flow problem, but greedy often passes since any valid answer is accepted and you only need minimumServed. Use max flow if greedy fails. Third, coloring: per satellite, build conflicts between users whose beams are under 10 degrees apart, measured from the satellite, then color with 4 colors. Greedy coloring can fail on dense clusters, so try backtracking or drop a user if you have slack. The pitfall is floating point on borderline angles and forgetting the 32 cap interacts with coloring. StealthCoder is your hedge if the flow or coloring logic escapes you mid-assessment.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Starlink Beam Planner cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass SpaceX's OA.
SpaceX reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Starlink Beam Planner FAQ
What does the SpaceX Starlink Beam Planner really reduce to?+
Three stages. Filter visible user-satellite pairs with a dot-product angle test, assign users to satellites under a 32 capacity, then color each satellite's users with 4 colors so close beams differ. It's matching plus graph coloring wearing a physics costume.
Should I use greedy or max flow for the assignment?+
Max flow is the safe choice since it maximizes served users under the capacity cap. Greedy can pass when minimumServed is loose. You only need at least minimumServed, so if the guarantee is tight, go with flow. With 500 users and 100 satellites, flow is cheap.
How do I avoid floating point errors on the angle checks?+
Compare cosines instead of calling acos. Check dot(a,b) against cos(angle) times the product of norms, with a tiny epsilon. Coordinates go up to 10^9, so squared values get large. Doubles handle it, but don't normalize carelessly and watch borderline cases like exactly 45 degrees.
How do I handle the 10 degree color rule?+
Per satellite, take the vectors from the satellite to each assigned user. Two users conflict if their angle is under 10 degrees. Assign colors 1 to 4 so conflicting users never share one. Try greedy by order first, then backtrack or drop an unneeded user if stuck.
How do I prepare for this in 48 hours?+
Practice a dot-product angle helper, a simple max flow or capacity-limited greedy matching, and small graph coloring with backtracking. Write the three stages as separate functions so you can debug each. Test with the three examples, especially the two-beam case under 10 degrees.