Skip to content

Commit 708fe3e

Browse files
refactor 401
1 parent c50f1ee commit 708fe3e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/main/java/com/fishercoder/solutions/_401.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public List<String> readBinaryWatch(int num) {
2929
List<String> times = new ArrayList<>();
3030
for (int h = 0; h < 12; h++) {
3131
for (int m = 0; m < 60; m++) {
32-
if (Integer.bitCount(h * 60 + m) == num) {
32+
if (Integer.bitCount(h * 64 + m) == num) {
3333
times.add(String.format("%d:%02d", h,
3434
m));//%02 means to pad this two-digit decimal number on the left with zeroes
3535
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.fishercoder;
2+
3+
import com.fishercoder.solutions._401;
4+
import java.util.Arrays;
5+
import org.junit.BeforeClass;
6+
import org.junit.Test;
7+
8+
import static junit.framework.TestCase.assertEquals;
9+
10+
public class _401Test {
11+
private static _401.Solution1 solution1;
12+
13+
@BeforeClass
14+
public static void setup() {
15+
solution1 = new _401.Solution1();
16+
}
17+
18+
@Test
19+
public void test1() {
20+
assertEquals(
21+
Arrays.asList("0:01", "0:02", "0:04", "0:08", "0:16", "0:32", "1:00", "2:00", "4:00",
22+
"8:00"), solution1.readBinaryWatch(1));
23+
}
24+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy