From 14d3f040e4a10147d8744b43481572ee01db2cab Mon Sep 17 00:00:00 2001 From: Maksim Strutinskiy Date: Mon, 23 Oct 2017 10:38:00 +0200 Subject: [PATCH 1/4] Added method for getting tomorrow's date, works every time --- get_tomorrow_date/TomorrowDate.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 get_tomorrow_date/TomorrowDate.java diff --git a/get_tomorrow_date/TomorrowDate.java b/get_tomorrow_date/TomorrowDate.java new file mode 100644 index 000000000..5e70d8593 --- /dev/null +++ b/get_tomorrow_date/TomorrowDate.java @@ -0,0 +1,16 @@ +import java.util.Date; + +class TomorrowDate { + public static Date get() throws InterruptedException { + waitUntilTomorrow(); + return todayDate(); + } + + private static void waitUntilTomorrow() throws InterruptedException { + Thread.sleep(1000 * 60 * 24); // 1 day + } + + private static Date todayDate() { + return new Date(); + } +} \ No newline at end of file From 181d4ce6f514f0e84c550bc300db77033006932b Mon Sep 17 00:00:00 2001 From: Maksim Strutinskiy Date: Mon, 23 Oct 2017 10:40:17 +0200 Subject: [PATCH 2/4] Added extra empty line in the end --- get_tomorrow_date/TomorrowDate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_tomorrow_date/TomorrowDate.java b/get_tomorrow_date/TomorrowDate.java index 5e70d8593..9c5a2fc99 100644 --- a/get_tomorrow_date/TomorrowDate.java +++ b/get_tomorrow_date/TomorrowDate.java @@ -13,4 +13,4 @@ private static void waitUntilTomorrow() throws InterruptedException { private static Date todayDate() { return new Date(); } -} \ No newline at end of file +} From 8a7652e6af3c8dca93fb4ecc4fe90a291a42db73 Mon Sep 17 00:00:00 2001 From: Maksim Strutinskiy Date: Mon, 23 Oct 2017 11:19:33 +0200 Subject: [PATCH 3/4] Added a function to multiply by 10, can also multiply by almost 1 --- multiply_by_10/Multiply.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 multiply_by_10/Multiply.java diff --git a/multiply_by_10/Multiply.java b/multiply_by_10/Multiply.java new file mode 100644 index 000000000..de7d766fa --- /dev/null +++ b/multiply_by_10/Multiply.java @@ -0,0 +1,12 @@ +public class Multiply { + public static long by10(long number) { + long result = 0; + result += number << 3; + result += number << 1; + return result; + } + + public static long byAlmost1(long number) { + return number << 1 >> 2 << 3 >> 1 << 2 >> 3; + } +} \ No newline at end of file From 46c1c31e9fde972814cc0ac2df3800ee05f0d7e7 Mon Sep 17 00:00:00 2001 From: Maksim Strutinskiy Date: Mon, 23 Oct 2017 11:22:42 +0200 Subject: [PATCH 4/4] Added extra line in the end --- multiply_by_10/Multiply.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multiply_by_10/Multiply.java b/multiply_by_10/Multiply.java index de7d766fa..05d3b4acd 100644 --- a/multiply_by_10/Multiply.java +++ b/multiply_by_10/Multiply.java @@ -9,4 +9,4 @@ public static long by10(long number) { public static long byAlmost1(long number) { return number << 1 >> 2 << 3 >> 1 << 2 >> 3; } -} \ No newline at end of file +}