FastPrepPainted Cube: Count and Roll
Problems/Painted Cube: Count and Roll

Painted Cube: Count and Roll

Jane Street logoJane Street● EasyNEW GRADFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in five Jane Street interview reports from 2022 to 2026, for trading desk operations roles, in phone screens and first interviews. All five use a painted 3 by 3 by 3 cube cut into 27 unit cubes. Three reports ask how many unit cubes have paint on at most one face. Three ask about picking a unit cube at random and rolling it: one asks for the chance that you can see paint, one for the chance that none of the five visible faces is painted, and one does not make clear which of the two it means. One report asks both parts.

We turned it into one function that takes the cube size and returns both answers. Any size n, asking for the chance of seeing paint (the other version is one minus this), giving the probability as a reduced fraction, the limits and every example except the first are our own choices.

Our version is about 90% the same as the reported question.

A large n x n x n cube is built from n3 unit cubes. The six outside faces of the large cube are painted, and then it is taken apart. A face of a unit cube is painted exactly when it was on the outside of the large cube.

Return an array [count, num, den] where:

  • count is the number of unit cubes with at most one painted face.
  • num / den is the probability that you can see paint after this experiment: pick one unit cube uniformly at random and roll it like a fair die. When it stops, the face on the table is hidden and the other five faces are visible. Write the probability as a fraction in lowest terms.

Function

paintedCube(n: int) → long[]

Examples

Example 1

n = 3return = [7,25,27]

The cube in the very middle has no paint and the 6 cubes in the middle of the big faces have one painted face, so 7 cubes have at most one. The other 20 cubes (12 on the edges, 8 corners) have at least two painted faces and only one face is hidden, so they always show paint. A face-middle cube hides its paint only when it lands on that face, a chance of 1/6. The chance of seeing no paint is (1 + 6 * 1/6) / 27 = 2/27, so the chance of seeing paint is 25/27.

Example 2

n = 1return = [0,1,1]

The only cube is painted on all six faces. No cube has at most one painted face, and paint always shows, so the probability is 1/1.

Example 3

n = 4return = [32,13,16]

The inside is a 2 x 2 x 2 block of 8 unpainted cubes, and each big face has a 2 x 2 middle, giving 24 cubes with one painted face. That is 32 cubes. The chance of seeing no paint is (8 + 24 / 6) / 64 = 12/64 = 3/16, so the answer is 13/16.

Example 4

n = 5return = [81,89,125]

27 inside cubes and 6 * 9 = 54 face-middle cubes give 81. The chance of seeing no paint is (27 + 54 / 6) / 125 = 36/125, so the answer is 89/125.

Example 5

n = 10return = [896,53,125]

8^3 = 512 inside cubes and 6 * 64 = 384 face-middle cubes give 896. The chance of seeing no paint is (512 + 64) / 1000 = 72/125, so the answer is 53/125.

Constraints

  • 1 <= n <= 105

More Jane Street Phone Screen questions

  • Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
  • Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
  • Load/Store Arithmetic InterpreterPHONE SCREEN · Seen Oct 2026
  • Instrument Stack Language JumpsPHONE SCREEN · Seen Oct 2026
  • Run a Stack Language InterpreterPHONE SCREEN · Seen Oct 2026
  • Positive-Integer Expression EvaluationPHONE SCREEN · Seen Oct 2026
  • Add Two Integers Given as StringsPHONE SCREEN · Seen Sep 2026
  • Angle Between Clock HandsPHONE SCREEN · Seen Jul 2026
  • Route Length From Two CyclistsPHONE SCREEN · Seen Jul 2026
  • Sort TradesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Random Points Inside One ArcSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Range of a Third CorrelationTower Research Capital · PHONE SCREEN
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Expected Fake-Name CollisionsMercor · PHONE SCREENMercor interview questions
  • Union Area of Two RectanglesDocuSign · PHONE SCREENDocuSign interview questions
  • Count Routes Through a City GridIMC Trading · PHONE SCREENIMC Trading interview questions
  • Intersection of Two RectanglesFigma · PHONE SCREENFigma interview questions
  • Extra Coin Win ProbabilityMicrosoft · PHONE SCREENMicrosoft interview questions
  • Light Source Hits: Sample, Compare, and FitOpenAI · PHONE SCREENOpenAI interview questions

Interview reports that mention this question

  • Jane Street TDOE UK Phone Screen: 15 Experiences (Part 4 of 10)
  • Jane Street TDOE Interviews: 165 Experiences (Part 1 of 10)
  • Jane Street TDOE US Phone Screen: 20 Experiences (Part 6 of 10)
  • Jane Street TDOE New Grad Interview Questions: 11 Experiences

Jane Street interview experiences

  • Jane Street TDO UK and Hong Kong: 22 Experiences (Part 10 of 10)
  • Jane Street TDOE US Final Round: 11 Experiences (Part 5 of 10)
All Jane Street interview questionsSee Jane Street hiring insights
Saved
class Solution {
    public long[] paintedCube(int n) {
      // Write your code here.
    }
}
Checking account…