All files / leetCode 0401.ts

100% Statements 10/10
100% Branches 6/6
100% Functions 1/1
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  3x 1x   2x   2x 24x 1440x         11x         2x    
export default function readBinaryWatch(turnedOn: number): string[] {
  if (turnedOn > 8)
    return []
 
  const result: string[] = []
 
  for (let h = 0; h < 12; ++h) {
    for (let m = 0; m < 60; ++m) {
      if (
        h.toString(2).split('0').join('').length
        + m.toString(2).split('0').join('').length
        === turnedOn
      ) {
        result.push(`${h}:${m < 10 ? '0' : ''}${m}`)
      }
    }
  }
 
  return result
}