1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

feat(cli): add --all option to run test command

This commit is contained in:
Divlo
2021-10-13 21:43:45 +02:00
parent aeff95e691
commit 0a27b9e1a1
47 changed files with 1657 additions and 1773 deletions

View File

@ -10,7 +10,7 @@ void character_append(char* string, char character) {
string[length + 1] = '\0';
}
void character_print(char* character, int number_of_times) {
void character_print(char* character, size_t number_of_times) {
for (size_t iteration = 0; iteration < number_of_times; iteration++) {
printf("%s", character);
}

View File

@ -1,5 +1,7 @@
#ifndef CHARACTER_H
#define CHARACTER_H
#ifndef __CHARACTER__
#define __CHARACTER__
#include <stdlib.h>
/**
* @brief Append a character to a string, assuming string points to an array
@ -10,6 +12,6 @@
*/
void character_append(char* string, char character);
void character_print(char* character, int number_of_times);
void character_print(char* character, size_t number_of_times);
#endif

View File

@ -1,5 +1,5 @@
#ifndef INPUT_H
#define INPUT_H
#ifndef __INPUT__
#define __INPUT__
/**
* @brief Read a line from stdin.

View File

@ -12,10 +12,10 @@ int main() {
int step = strcmp(type, "normal") == 0 ? 1 : height;
while ((strcmp(type, "normal") == 0 && step <= height) || (strcmp(type, "reverse") == 0 && step != 0)) {
int numberOfStars = (step * 2) - 1;
int totalNumberOfLocations = (height * 2) - 1;
int totalNumberOfSpaces = totalNumberOfLocations - numberOfStars;
int numberOfSpacesOnEachSide = totalNumberOfSpaces / 2;
size_t numberOfStars = (step * 2) - 1;
size_t totalNumberOfLocations = (height * 2) - 1;
size_t totalNumberOfSpaces = totalNumberOfLocations - numberOfStars;
size_t numberOfSpacesOnEachSide = totalNumberOfSpaces / 2;
character_print(" ", numberOfSpacesOnEachSide);
character_print("*", numberOfStars);
character_print(" ", numberOfSpacesOnEachSide);