Full Symmetric Square

What You'll Learn
This pattern is a full symmetric version of Program 28. First we print rows for E..A, then we mirror by printing rows for B..E. Each row is built using two halves and the condition j > i.
⭐ Pattern Output
E E E E E E E E E
E D D D D D D D E
E D C C C C C D E
E D C B B B C D E
E D C B A B C D E
E D C B B B C D E
E D C C C C C D E
E D D D D D D D E
E E E E E E E E ENode.js / console version
Print the top half (E..A) then the bottom half (B..E). Each row uses left + right halves.
const A = "A".charCodeAt(0);
const top = "E".charCodeAt(0);
function printRow(i) {
let line = "";
for (let j = top; j >= A; j--) line += (j > i ? String.fromCharCode(j) : String.fromCharCode(i)) + " ";
for (let j = A + 1; j <= top; j++) line += (j > i ? String.fromCharCode(j) : String.fromCharCode(i)) + " ";
console.log(line.trimEnd());
}
for (let i = top; i >= A; i--) printRow(i);
for (let i = A + 1; i <= top; i++) printRow(i);Browser version (document.write + div)
Reference-style output using fixed-width cells.
<!DOCTYPE html>
<html>
<head>
<style>
div.cell {
display: inline-block;
text-align: center;
width: 15px;
}
</style>
</head>
<body>
<script>
const A = 65;
const top = 69;
function printRow(i) {
for (let j = top; j >= A; j--) {
if (j > i) document.write("<div class=\\"cell\\">" + String.fromCharCode(j) + "</div>");
else document.write("<div class=\\"cell\\">" + String.fromCharCode(i) + "</div>");
}
for (let j = A + 1; j <= top; j++) {
if (j > i) document.write("<div class=\\"cell\\">" + String.fromCharCode(j) + "</div>");
else document.write("<div class=\\"cell\\">" + String.fromCharCode(i) + "</div>");
}
document.write("<br>");
}
for (let i = top; i >= A; i--) printRow(i);
for (let i = A + 1; i <= top; i++) printRow(i);
</script>
</body>
</html>🧠 How It Works
Core idea
This is Program 28 plus a mirrored bottom half. First part prints rows for i = E..A, second part prints rows for i = B..E. Each row is built from two loops (left half and right half) using the condition j > i to decide whether to print the column letter or the row letter.
Loops + condition
An outer loop picks the row, inner loop(s) decide what to print (letter / star / blank) based on comparisons.
Connect it to the output
Compare each loop boundary with the pattern output above — each row corresponds to one outer iteration.
Key Takeaways
Two parts: top (E..A) and bottom (B..E).
Two halves per row create symmetry.
j > i chooses outer letter vs row letter.
Time complexity: O(n²).
❓ Frequently Asked Questions
E..A). Program 29 adds the mirrored bottom half (B..E), so the full output becomes a symmetric square.i = A. With the condition j > i, most positions keep their outer column letter, while the center position becomes A.div cells preserve the grid and keep the square aligned.More JavaScript alphabet patterns
Browse the full list for more variations.
10 people found this page helpful
