Skip to content

Commit

Permalink
Merge pull request #14 from Ram-Amoncar/fixed-solution
Browse files Browse the repository at this point in the history
fixed solution for christmas-tree
  • Loading branch information
cesalberca authored Jul 10, 2024
2 parents 11bad72 + 5caba6f commit 1e8cdfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/christmas-tree/solutions/christmas-tree.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest'
import { ChristmasTree } from './christmas-tree'

describe.skip('ChristmasTree', () => {
describe('ChristmasTree', () => {
it('should render a tree with 3 rows', () => {
const christmasTree = new ChristmasTree()

Expand Down
3 changes: 2 additions & 1 deletion src/christmas-tree/solutions/christmas-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ChristmasTree {
const finalTree = treeArr
.map((x, i) => {
const paddedSpaces = Math.floor(maxStarsPerRow / 2) + i * -1
return x.padStart(paddedSpaces).padEnd(paddedSpaces)
return x.padStart(maxStarsPerRow - paddedSpaces)
})
.join('\n')

Expand All @@ -30,6 +30,7 @@ export class ChristmasTree {
const isHalf = i === half
if (isHalf) {
lastRow += '|'
break
} else {
lastRow += ' '
}
Expand Down

0 comments on commit 1e8cdfa

Please sign in to comment.