-
Notifications
You must be signed in to change notification settings - Fork 6
Docs: add 3 new pattern programs (Hollow Square, Diamond, Hollow Pyramid) — Refs #16 #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |||||||||
| <div align="right"> | ||||||||||
|
|
||||||||||
| **🧭 Navigation** | ||||||||||
| [⬅️ Previous](20_typedef.md) | [🏠 Home](README.md) | [➡️ Next](21_pattern_examples.md) | ||||||||||
| [⬅️ Previous](20_typedef.md) | [🏠 Home](README.md) | [➡️ Next](README.md) | ||||||||||
|
|
||||||||||
| </div> | ||||||||||
|
|
||||||||||
|
|
@@ -256,6 +256,152 @@ int main() { | |||||||||
|
|
||||||||||
| --- | ||||||||||
|
|
||||||||||
| **Code:** | ||||||||||
| Runnable source: [contributions/basic_programs/pattern_hollow_square.c](../contributions/basic_programs/pattern_hollow_square.c) | ||||||||||
|
|
||||||||||
| ```c | ||||||||||
| /* | ||||||||||
| * Hollow Square Pattern | ||||||||||
| * | ||||||||||
| * Explanation: | ||||||||||
| * - The pattern prints a square of size n. | ||||||||||
| * - Only the border (first row, last row, first column, last column) | ||||||||||
| * is printed with '*'. | ||||||||||
| * - The inner cells are printed with spaces to make the square hollow. | ||||||||||
|
|
||||||||||
| */ | ||||||||||
|
|
||||||||||
| #include <stdio.h> | ||||||||||
|
|
||||||||||
| int main() { | ||||||||||
| int n = 5; | ||||||||||
|
|
||||||||||
| for (int i = 1; i <= n; i++) { | ||||||||||
| for (int j = 1; j <= n; j++) { | ||||||||||
| if (i == 1 || i == n || j == 1 || j == n) | ||||||||||
| printf("* "); | ||||||||||
| else | ||||||||||
| printf(" "); | ||||||||||
|
|
||||||||||
| } | ||||||||||
| printf("\n"); | ||||||||||
| } | ||||||||||
| return 0; | ||||||||||
| } | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| **Expected output:** | ||||||||||
| ``` | ||||||||||
| * * * * * | ||||||||||
| * * | ||||||||||
| * * | ||||||||||
| * * | ||||||||||
| * * * * * | ||||||||||
| ``` | ||||||||||
|
Comment on lines
+293
to
+300
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add language specifier to expected output block to resolve MD040. The expected output fence (line 294) is missing a language specifier. While the linter accepts an empty specifier, explicitly using **Expected output:**
-```
+```output
* * * * *
* *
* *
* *
* * * * *
-```
+```🧰 Tools🪛 markdownlint-cli2 (0.18.1)294-294: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI Agents |
||||||||||
| --- | ||||||||||
|
|
||||||||||
| **Code:** | ||||||||||
| Runnable source: [contributions/basic_programs/pattern_diamond.c](../contributions/basic_programs/pattern_diamond.c) | ||||||||||
|
Comment on lines
+303
to
+304
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove leading space before Line 303 has an unintended leading space. Remove it to match the formatting of earlier patterns and line 259. -**Code:**
+**Code:**
Runnable source: [contributions/basic_programs/pattern_diamond.c](../contributions/basic_programs/pattern_diamond.c)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| ```c | ||||||||||
| /* | ||||||||||
| * Diamond Star Pattern | ||||||||||
| * | ||||||||||
| * Explanation: | ||||||||||
| * - The diamond is created using: | ||||||||||
| * 1. Upper pyramid | ||||||||||
| * 2. Lower inverted pyramid | ||||||||||
| * - Each row is centered using spaces. | ||||||||||
| */ | ||||||||||
|
|
||||||||||
| #include <stdio.h> | ||||||||||
|
|
||||||||||
| int main() { | ||||||||||
| int n = 5; | ||||||||||
|
|
||||||||||
| // Upper half | ||||||||||
| for (int i = 1; i <= n; i++) { | ||||||||||
| for (int s = 1; s <= n - i; s++) printf(" "); | ||||||||||
| for (int j = 1; j <= 2*i - 1; j++) printf("*"); | ||||||||||
| printf("\n"); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Lower half | ||||||||||
| for (int i = n - 1; i >= 1; i--) { | ||||||||||
| for (int s = 1; s <= n - i; s++) printf(" "); | ||||||||||
| for (int j = 1; j <= 2*i - 1; j++) printf("*"); | ||||||||||
| printf("\n"); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return 0; | ||||||||||
| } | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| **Expected output:** | ||||||||||
| ``` | ||||||||||
| * | ||||||||||
| *** | ||||||||||
| ***** | ||||||||||
| ******* | ||||||||||
| ********* | ||||||||||
| ******* | ||||||||||
| ***** | ||||||||||
| *** | ||||||||||
| * | ||||||||||
| ``` | ||||||||||
|
Comment on lines
+340
to
+351
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add language specifier to expected output block to resolve MD040. Same as the Hollow Square pattern: specify **Expected output:**
-```
+```output
*
***
*****
*******
*********
*******
*****
***
*
-```
+```🧰 Tools🪛 markdownlint-cli2 (0.18.1)341-341: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| --- | ||||||||||
|
|
||||||||||
| **Code:** | ||||||||||
| Runnable source: [contributions/basic_programs/pattern_hollow_pyramid.c](../contributions/basic_programs/pattern_hollow_pyramid.c) | ||||||||||
|
Comment on lines
+355
to
+356
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove leading space before Line 355 has an unintended leading space. Remove it to match earlier patterns. -**Code:**
+**Code:**
Runnable source: [contributions/basic_programs/pattern_hollow_pyramid.c](../contributions/basic_programs/pattern_hollow_pyramid.c)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| ```c | ||||||||||
| /* | ||||||||||
| * Hollow Pyramid Pattern | ||||||||||
| * | ||||||||||
| * Explanation: | ||||||||||
| * - Spaces center the pyramid. | ||||||||||
| * - First and last positions print stars. | ||||||||||
| * - Last row prints all stars. | ||||||||||
| */ | ||||||||||
|
|
||||||||||
| #include <stdio.h> | ||||||||||
|
|
||||||||||
| int main() { | ||||||||||
| int n = 5; | ||||||||||
|
|
||||||||||
| for (int i = 1; i <= n; i++) { | ||||||||||
|
|
||||||||||
| // Leading spaces | ||||||||||
| for (int s = 1; s <= n - i; s++) printf(" "); | ||||||||||
|
|
||||||||||
| for (int j = 1; j <= 2*i - 1; j++) { | ||||||||||
| if (j == 1 || j == 2*i - 1 || i == n) | ||||||||||
| printf("*"); | ||||||||||
| else | ||||||||||
| printf(" "); | ||||||||||
|
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| printf("\n"); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return 0; | ||||||||||
| } | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| **Expected output:** | ||||||||||
| ``` | ||||||||||
| * | ||||||||||
| * * | ||||||||||
| * * | ||||||||||
| * * | ||||||||||
| ********* | ||||||||||
| ``` | ||||||||||
gpl-gowthamchand marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| --- | ||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
| ## Summary | ||||||||||
|
|
||||||||||
| - Pattern programs use nested loops for rows and columns. | ||||||||||
|
|
@@ -267,6 +413,7 @@ int main() { | |||||||||
| <div align="right"> | ||||||||||
|
|
||||||||||
| **🧭 Navigation** | ||||||||||
| [⬅️ Previous](20_typedef.md) | [🏠 Home](README.md) | [➡️ Next](21_pattern_examples.md) | ||||||||||
| [⬅️ Previous](20_typedef.md) | [🏠 Home](README.md) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| </div> | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Align comment formatting with documentation standards.
The C code examples in this section use inconsistent formatting with raw markdown comments instead of embedding comments within fenced C code blocks. This violates MD007 and MD018 linting rules.
Restructure the three new examples (gcd_lcm_functions, perfect_number_function, strong_number_function) to place C-style comments inside the fenced code blocks, consistent with the repository's existing documentation:
Apply the same restructuring to the perfect_number_function.c and strong_number_function.c comments.
📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
206-206: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
207-207: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
208-208: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
209-209: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
210-210: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
210-210: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
211-211: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
211-211: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
212-212: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
213-213: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
214-214: Unordered list indentation
Expected: 0; Actual: 1
(MD007, ul-indent)
217-217: No space after hash on atx style heading
(MD018, no-missing-space-atx)
242-242: Code block style
Expected: fenced; Actual: indented
(MD046, code-block-style)
🤖 Prompt for AI Agents