-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d75c98e
commit d464578
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/com/fishercoder/solutions/fourththousand/_3280.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.fishercoder.solutions.fourththousand; | ||
|
||
public class _3280 { | ||
public static class Solution1 { | ||
public String convertDateToBinary(String date) { | ||
String[] parts = date.split("-"); | ||
StringBuilder sb = new StringBuilder(); | ||
for (String part : parts) { | ||
sb.append(Integer.toBinaryString(Integer.parseInt(part))); | ||
sb.append("-"); | ||
} | ||
sb.setLength(sb.length() - 1); | ||
return sb.toString(); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/test/java/com/fishercoder/fourththousand/_3280Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.fishercoder.fourththousand; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.fishercoder.solutions.fourththousand._3280; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class _3280Test { | ||
private _3280.Solution1 solution1; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
solution1 = new _3280.Solution1(); | ||
} | ||
|
||
@Test | ||
public void test1() { | ||
assertEquals("100000100000-10-11101", solution1.convertDateToBinary("2080-02-29")); | ||
} | ||
} |