From 4bab14b63ea833c62fad55803e88ce8be1973bab Mon Sep 17 00:00:00 2001 From: Amaan Sayyed <73849668+AmaanSayyed@users.noreply.github.com> Date: Sun, 8 Oct 2023 14:22:31 +0530 Subject: [PATCH 1/4] Happy Hacktoberfest 2023. Added Hollow Rectangle inscribed in Rectangle Pattern <3 --- .../HollowDiamondRectangle.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/HollowDiamondPattern/HollowDiamondRectangle.java diff --git a/src/HollowDiamondPattern/HollowDiamondRectangle.java b/src/HollowDiamondPattern/HollowDiamondRectangle.java new file mode 100644 index 0000000..57d60a5 --- /dev/null +++ b/src/HollowDiamondPattern/HollowDiamondRectangle.java @@ -0,0 +1,43 @@ +import java.util.Scanner; + + +public class HollowDiamondRectangle { + public static void main(String[] args) + { + Scanner sc = new Scanner(System.in); + int i=0, j=0; + int n = sc.nextInt(); + // upper half of the pattern + for(i = 0; i < n; i++) + { + for(j = 0; j < (2 * n); j++) + { + if(i + j <= n - 1) // upper left triangle + System.out.print("*"); + else + System.out.print(" "); + if((i + n) <= j) // upper right triangle + System.out.print("*"); + else + System.out.print(" "); + } + System.out.println(); + } + // bottom half of the pattern + for(i = 0; i < n; i++) + { + for(j = 0; j < (2 * n); j++) + { + if(i >= j) // bottom left triangle + System.out.print("*"); + else + System.out.print(" "); + if(i >= (2 * n - 1) - j) // bottom right triangle + System.out.print("*"); + else + System.out.print(" "); + } + System.out.println(); + } + } +} From 8bf61d7c9041de5aaaee0eccf6b24c92c9b288b1 Mon Sep 17 00:00:00 2001 From: Amaan Sayyed <73849668+AmaanSayyed@users.noreply.github.com> Date: Sun, 8 Oct 2023 14:23:48 +0530 Subject: [PATCH 2/4] Delete src/HollowDiamondPattern directory --- .../HollowDiamondRectangle.java | 43 ------------------- 1 file changed, 43 deletions(-) delete mode 100644 src/HollowDiamondPattern/HollowDiamondRectangle.java diff --git a/src/HollowDiamondPattern/HollowDiamondRectangle.java b/src/HollowDiamondPattern/HollowDiamondRectangle.java deleted file mode 100644 index 57d60a5..0000000 --- a/src/HollowDiamondPattern/HollowDiamondRectangle.java +++ /dev/null @@ -1,43 +0,0 @@ -import java.util.Scanner; - - -public class HollowDiamondRectangle { - public static void main(String[] args) - { - Scanner sc = new Scanner(System.in); - int i=0, j=0; - int n = sc.nextInt(); - // upper half of the pattern - for(i = 0; i < n; i++) - { - for(j = 0; j < (2 * n); j++) - { - if(i + j <= n - 1) // upper left triangle - System.out.print("*"); - else - System.out.print(" "); - if((i + n) <= j) // upper right triangle - System.out.print("*"); - else - System.out.print(" "); - } - System.out.println(); - } - // bottom half of the pattern - for(i = 0; i < n; i++) - { - for(j = 0; j < (2 * n); j++) - { - if(i >= j) // bottom left triangle - System.out.print("*"); - else - System.out.print(" "); - if(i >= (2 * n - 1) - j) // bottom right triangle - System.out.print("*"); - else - System.out.print(" "); - } - System.out.println(); - } - } -} From 5f68da77b1a41e924ac48b95c3c8801073560c98 Mon Sep 17 00:00:00 2001 From: Amaan Sayyed <73849668+AmaanSayyed@users.noreply.github.com> Date: Sun, 8 Oct 2023 14:25:28 +0530 Subject: [PATCH 3/4] Hollow Diamond Pattern Added hollow diamond Pattern Inscribe in Rectangle --- .../HollowDiamondRectangle.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/HollowDiamondPattern/HollowDiamondRectangle.java diff --git a/src/HollowDiamondPattern/HollowDiamondRectangle.java b/src/HollowDiamondPattern/HollowDiamondRectangle.java new file mode 100644 index 0000000..57d60a5 --- /dev/null +++ b/src/HollowDiamondPattern/HollowDiamondRectangle.java @@ -0,0 +1,43 @@ +import java.util.Scanner; + + +public class HollowDiamondRectangle { + public static void main(String[] args) + { + Scanner sc = new Scanner(System.in); + int i=0, j=0; + int n = sc.nextInt(); + // upper half of the pattern + for(i = 0; i < n; i++) + { + for(j = 0; j < (2 * n); j++) + { + if(i + j <= n - 1) // upper left triangle + System.out.print("*"); + else + System.out.print(" "); + if((i + n) <= j) // upper right triangle + System.out.print("*"); + else + System.out.print(" "); + } + System.out.println(); + } + // bottom half of the pattern + for(i = 0; i < n; i++) + { + for(j = 0; j < (2 * n); j++) + { + if(i >= j) // bottom left triangle + System.out.print("*"); + else + System.out.print(" "); + if(i >= (2 * n - 1) - j) // bottom right triangle + System.out.print("*"); + else + System.out.print(" "); + } + System.out.println(); + } + } +} From 32a80aa466c4c5f6444d34f649f22cacbde9d290 Mon Sep 17 00:00:00 2001 From: Amaan Sayyed <73849668+AmaanSayyed@users.noreply.github.com> Date: Sun, 8 Oct 2023 14:29:40 +0530 Subject: [PATCH 4/4] Update README.md --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1283738..1955f71 100644 --- a/README.md +++ b/README.md @@ -153,4 +153,17 @@ * * * * ***************** -``` \ No newline at end of file +``` +15.Hollow Diamond Pattern +``` +* * * * * * * * * * +* * * * * * * * +* * * * * * +* * * * +* * +* * +* * * * +* * * * * * +* * * * * * * * +* * * * * * * * * * +```