From b580d1f6442f223f455e04f32a586659c7ff0dee Mon Sep 17 00:00:00 2001 From: Kagura Date: Wed, 6 Nov 2024 12:43:56 +0800 Subject: [PATCH] + --- .gitignore | 5 ++++- src/JavaDoubao/XtoY.java | 43 ---------------------------------------- 2 files changed, 4 insertions(+), 44 deletions(-) delete mode 100644 src/JavaDoubao/XtoY.java diff --git a/.gitignore b/.gitignore index f68d109..72e2aef 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,7 @@ bin/ .vscode/ ### Mac OS ### -.DS_Store \ No newline at end of file +.DS_Store + +Main.kt +.idea/ \ No newline at end of file diff --git a/src/JavaDoubao/XtoY.java b/src/JavaDoubao/XtoY.java deleted file mode 100644 index 63490db..0000000 --- a/src/JavaDoubao/XtoY.java +++ /dev/null @@ -1,43 +0,0 @@ -package JavaDoubao; -import java.util.ArrayList; - -public class XtoY { - - - public static class Main { - public static int solution(int xPosition, int yPosition) { - // Please write your code here - int diff = Math.abs(yPosition -xPosition); - int gone = 1; - ArrayList steps = new ArrayList<>(); - steps.add(1); - int lastStep = 1; - - while (gone < diff/2) { - lastStep += 1; - gone += lastStep; - steps.add(lastStep); - } - - if (gone*2 == diff){ - - } - - - - for (Integer steps2 : steps) { - System.out.printf("%d,",steps2); - } - System.out.println("Result"); - - return steps.size(); - } - - public static void main(String[] args) { - // You can add more test cases here -// System.out.println(solution(12, 6)); - System.out.println(solution(34, 45)); - System.out.println(solution(50, 30)); - } - } -}