401.binary-watch.go 243 B

12345678910
  1. func readBinaryWatch(num int) (res []string) {
  2. for h := uint8(0); h < 12; h++ {
  3. for m := uint8(0); m < 60; m++ {
  4. if bits.OnesCount8(h)+bits.OnesCount8(m) == num {
  5. res = append(res, fmt.Sprintf("%d:%02d", h, m))
  6. }
  7. }
  8. }
  9. return
  10. }