Skip to content
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

Double spaces on svg format #117

Open
krowter opened this issue Jun 25, 2022 · 0 comments
Open

Double spaces on svg format #117

krowter opened this issue Jun 25, 2022 · 0 comments

Comments

@krowter
Copy link
Contributor

krowter commented Jun 25, 2022

Choosing svg as the output format results in double spaces

Comparison
Screenshot from 2022-06-25 17-47-24

PS I used the web version, havent tried sending a POST request

Edited (1 Oct 2023):
Not reproducible anymore :/

My code at the time

function pascalsTriangle(size) {
  const result = [[1]];

  for (let i = 0; i < size; i++) {
    const row = [];

    for (let j = 0; j <= i + 1; j++) {
      row.push((result[i][j] ?? 0) + (result[i][j - 1] ?? 0));
    }

    result.push(row);
  }

  return result;
}

function formatTriangle(triangle) {
  const SPACE = '  ';
  const size = triangle.length;

  for (let rowIndex = 0; rowIndex < size; rowIndex++) {
    let row = '';
    const leftPadding = size - rowIndex;

    row += SPACE.repeat(leftPadding);
    row += triangle[rowIndex].map(num => num.toString().padStart(SPACE.length * 2)).join('');

    console.log(row);
  }
}

formatTriangle(pascalsTriangle(10));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

3 participants