From 5c824b86c7b5e87d66549f00d4e3a5574b4a9306 Mon Sep 17 00:00:00 2001 From: chirag2506 Date: Sun, 7 Oct 2018 13:58:01 +0530 Subject: [PATCH] Added my profile into readme.md and added a JAVA code of all snake and ladder paths from one postion to other --- README.md | 7 +++++++ code/BoardPath.java | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 code/BoardPath.java diff --git a/README.md b/README.md index 06ba005..ed7bec7 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,13 @@ Please note that this project is released with a [Code of Conduct](CODE_OF_CONDU - Lover of programming, drums, cars, ping-pong and anime. - [![github-alt][github-img]](https://github.com/costassolla) +### Chirag Gupta +- First Year Student +- Interested in development, machine learning. +- Lover of programming, Greek mythology, Marvel. +- [![github-alt][github-img]](https://github.com/chirag2506) + [![twitter-alt][twitter-img]](https://twitter.com/chiraggupta2506) + ### CohheeTime - I built my first website in 1999 - [![github-alt][github-img]](https://github.com/CohheeTime) diff --git a/code/BoardPath.java b/code/BoardPath.java new file mode 100644 index 0000000..60a5880 --- /dev/null +++ b/code/BoardPath.java @@ -0,0 +1,37 @@ +import java.util.ArrayList; +import java.util.Scanner; + +public class getBoardPath { + + public static void main(String[] args) { + Scanner scn = new Scanner(System.in); + System.out.println("Enter Current Position:"); + int n1= scn.nextInt(); + System.out.println("Enter Destination Position:"); + int n2= scn.nextInt(); + System.out.println(GetBoardPath(n1, n2)); + + } + + public static ArrayList GetBoardPath(int curr, int end) { +// Returns all snake & ladder board paths from curr to end + if (curr == end) { + ArrayList basePositive = new ArrayList<>(); + basePositive.add("\n"); + return basePositive; + } + if (curr > end) { + ArrayList baseNegative = new ArrayList<>(); + return baseNegative; + } + ArrayList MyResult = new ArrayList<>(); + for (int dice = 1; dice <= 6; dice++) { + ArrayList RecResult = GetBoardPath(curr + dice, end); + for (String RecResultString : RecResult) { + MyResult.add(dice + RecResultString); + } + } + return MyResult; + } + +} \ No newline at end of file