Hi! First of all, thank you for sharing your repository. It has been very helpful while studying for rank 05. π€©
I noticed something about the life project output formatting and wanted to ask about it.
In your implementation, the board is printed directly with all spaces:
void print_board(t_game* game)
{
for(int i = 0; i < game->height; i++)
{
for(int j = 0; j < game->width; j++)
{
putchar(game->board[i][j]);
}
putchar('\n');
}
}
However, the subject example seems to compress/remove extra spaces in the output. For example, the subject shows:
$> echo 'sdxssdswdxddddsxaadwxwdxwaa' | ./a.out 10 6 0 | cat -e
$
O OOO $
O O $
OOO O $
O OOO $
$
Because of that, I ended up using a different printing function to match the subject formatting more closely.
like that;
void print_res(t_game *game)
{
for (int i = 0; i < game->height; i++)
{
int j = 0;
while (j < game->width && game->grid[i][j] == ' ')
j++;
while (j < game->width)
{
if (game->grid[i][j] == ' ' && j + 1 < game->width && game->grid[i][j + 1] == ' ')
j++;
else
putchar(game->grid[i][j++]);
}
putchar('\n');
}
}
So I was wondering:
- did the exam accept the full-width output with spaces???
- or did you change the printing logic during the actual exam???
Thanks again for sharing your work! π
Hi! First of all, thank you for sharing your repository. It has been very helpful while studying for rank 05. π€©
I noticed something about the
lifeproject output formatting and wanted to ask about it.In your implementation, the board is printed directly with all spaces:
However, the subject example seems to compress/remove extra spaces in the output. For example, the subject shows:
Because of that, I ended up using a different printing function to match the subject formatting more closely.
like that;
void print_res(t_game *game)
{
for (int i = 0; i < game->height; i++)
{
int j = 0;
while (j < game->width && game->grid[i][j] == ' ')
j++;
while (j < game->width)
{
if (game->grid[i][j] == ' ' && j + 1 < game->width && game->grid[i][j + 1] == ' ')
j++;
else
putchar(game->grid[i][j++]);
}
putchar('\n');
}
}
So I was wondering:
Thanks again for sharing your work! π