diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-10-11 22:19:00 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-10-11 22:19:00 +0200 |
| commit | 73c2b00a10c5786ddeeacc915e233fd4df1c9321 (patch) | |
| tree | e299ea4e8ac161b2b21170172ff8f182c1c3fe1a /rushs/evalexpr | |
| parent | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (diff) | |
fix: evalexpr & tinyprintf contenaient toute la piscine
Diffstat (limited to 'rushs/evalexpr')
192 files changed, 0 insertions, 5421 deletions
diff --git a/rushs/evalexpr/80cols/80cols.sh b/rushs/evalexpr/80cols/80cols.sh deleted file mode 100755 index d66cf9b..0000000 --- a/rushs/evalexpr/80cols/80cols.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -[ $# -ne 1 ] && exit 1 -[ -f $1 ] || exit 1 - -while IFS='' read -r line; do - var=$(printf '%s' "$line" | wc -m) - [ "$var" -ge 80 ] && printf '%s\n' "$line" -done < "$1" - -exit 0 diff --git a/rushs/evalexpr/80cols_grep/80cols.grep b/rushs/evalexpr/80cols_grep/80cols.grep deleted file mode 100644 index 1fe0c1f..0000000 --- a/rushs/evalexpr/80cols_grep/80cols.grep +++ /dev/null @@ -1 +0,0 @@ -.\{80,\} diff --git a/rushs/evalexpr/evalexpr/Makefile b/rushs/evalexpr/Makefile index 280f19c..280f19c 100644 --- a/rushs/evalexpr/evalexpr/Makefile +++ b/rushs/evalexpr/Makefile diff --git a/rushs/evalexpr/a.out b/rushs/evalexpr/a.out Binary files differdeleted file mode 100755 index 33e84ed..0000000 --- a/rushs/evalexpr/a.out +++ /dev/null diff --git a/rushs/evalexpr/add_int_ptr/add_int_ptr.c b/rushs/evalexpr/add_int_ptr/add_int_ptr.c deleted file mode 100644 index ad48639..0000000 --- a/rushs/evalexpr/add_int_ptr/add_int_ptr.c +++ /dev/null @@ -1,7 +0,0 @@ -int *add_int_ptr(int *a, int *b) -{ - if (!a || !b) - return a; - *a += *b; - return a; -} diff --git a/rushs/evalexpr/alphabet/alphabet.c b/rushs/evalexpr/alphabet/alphabet.c deleted file mode 100644 index 9496c66..0000000 --- a/rushs/evalexpr/alphabet/alphabet.c +++ /dev/null @@ -1,13 +0,0 @@ -#include <stdio.h> - -int main(void) -{ - for (char i = 'a'; i < 'z'; i++) - { - putchar(i); - putchar(' '); - } - putchar('z'); - putchar('\n'); - return 0; -} diff --git a/rushs/evalexpr/alphanum/alphanum.sh b/rushs/evalexpr/alphanum/alphanum.sh deleted file mode 100755 index e4c5aee..0000000 --- a/rushs/evalexpr/alphanum/alphanum.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -letters() -{ - grepped=$(echo "$1" | grep -E "^[a-zA-Z]+$") - [ "$1" = "$grepped" ] && return 0 || return 1 -} - -empty() -{ - if echo "$1" | grep -qE '^[[:space:]]+$'; then - return 0 - fi - return 1 -} - -digit() -{ - grepped=$(echo "$1" | grep -E "^[0-9]$") - [ "$1" = "$grepped" ] && return 0 || return 1 -} - -number() -{ - grepped=$(echo "$1" | grep -E "^[1-9][0-9]+$") - [ "$1" = "$grepped" ] && return 0 || return 1 -} - -alph() -{ - grepped=$(echo "$1" | grep -E "^[a-zA-Z0-9]+$") - [ "$1" = "$grepped" ] && return 0 || return 1 -} - -while IFS='' read -r str; do - if [ -z "$str" ]; then - echo it is empty - continue - elif letters "$str"; then - echo "it is a word" - elif number "$str"; then - echo "it is a number" - elif digit "$str"; then - echo "it is a digit" - elif empty "$str"; then - echo "it is empty" - elif alph "$str"; then - echo "it is an alphanum" - else - echo "it is too complicated" - exit - fi -done diff --git a/rushs/evalexpr/array_max_min/array_max_min.c b/rushs/evalexpr/array_max_min/array_max_min.c deleted file mode 100644 index 8b2d3a5..0000000 --- a/rushs/evalexpr/array_max_min/array_max_min.c +++ /dev/null @@ -1,23 +0,0 @@ -#include <stddef.h> -#include <stdio.h> - -void array_max_min(int tab[], size_t len, int *max, int *min) -{ - if (tab && len) - { - *min = tab[0]; - *max = tab[0]; - - for (size_t i = 0; i < len; i++) - { - if (tab[i] > *max) - { - *max = tab[i]; - } - else if (tab[i] < *min) - { - *min = tab[i]; - } - } - } -} diff --git a/rushs/evalexpr/ascii_carousel/rot_x.c b/rushs/evalexpr/ascii_carousel/rot_x.c deleted file mode 100644 index 667106d..0000000 --- a/rushs/evalexpr/ascii_carousel/rot_x.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <stddef.h> - -void rot_x(char *s, int x) -{ - if (s == NULL) - { - return; - } - - if (x < 0) - { - x = 26 + x; - } - - for (size_t i = 0; s[i]; i++) - { - if (s[i] >= 'a' && s[i] <= 'z') - { - s[i] = ((s[i] - 'a') + x) % 26 + 'a'; - } - else if (s[i] >= 'A' && s[i] <= 'Z') - { - s[i] = ((s[i] - 'A') + x) % 26 + 'A'; - } - } -} diff --git a/rushs/evalexpr/ascii_house/ascii_house.sh b/rushs/evalexpr/ascii_house/ascii_house.sh deleted file mode 100755 index 83d907e..0000000 --- a/rushs/evalexpr/ascii_house/ascii_house.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - - -echo ' /\' -echo ' / \' -echo -n "/____\\ \`" && echo "'\`" -echo -n "| | \`" && echo "'''\`" -echo "| | \`|\`" -echo '|_/\_|___|__' diff --git a/rushs/evalexpr/assignment_operator/assignment_operator.c b/rushs/evalexpr/assignment_operator/assignment_operator.c deleted file mode 100644 index cae560f..0000000 --- a/rushs/evalexpr/assignment_operator/assignment_operator.c +++ /dev/null @@ -1,37 +0,0 @@ -void plus_equal(int *a, int *b) -{ - if (!a || !b) - { - return; - } - *a = *a + *b; -} - -void minus_equal(int *a, int *b) -{ - if (!a || !b) - { - return; - } - *a = *a - *b; -} - -void mult_equal(int *a, int *b) -{ - if (!a || !b) - { - return; - } - *a = *a * *b; -} - -int div_equal(int *a, int *b) -{ - if (!a || !b || *b == 0) - { - return 0; - } - int res = *a % *b; - *a = *a / *b; - return res; -} diff --git a/rushs/evalexpr/binary_search_ptr/bsearch.c b/rushs/evalexpr/binary_search_ptr/bsearch.c deleted file mode 100644 index bdc189c..0000000 --- a/rushs/evalexpr/binary_search_ptr/bsearch.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "bsearch.h" - -#include <stddef.h> - -int *binary_search(int *begin, int *end, int elt) -{ - if (begin == end) - { - return begin; - } - if (begin > end) - { - if (elt > *begin) - { - return begin + 1; - } - return begin; - } - - size_t m = (end - begin) / 2; - - if (begin[m] == elt) - { - return begin + m; - } - - if (begin[m] > elt) - { - return binary_search(begin, begin + m, elt); - } - - if (m == 0) - { - m++; - } - - return binary_search(begin + m, end, elt); -} diff --git a/rushs/evalexpr/binary_search_ptr/bsearch.h b/rushs/evalexpr/binary_search_ptr/bsearch.h deleted file mode 100644 index e011744..0000000 --- a/rushs/evalexpr/binary_search_ptr/bsearch.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef BSEARCH_H_ -#define BSEARCH_H_ - -/* -** Search `elt` in the memory range of [`begin` - `end`[. -** `begin` is a pointer to the first element. -** `end` is a pointer **AFTER** the last element. -** The elements in the range [`begin` - `end`[ are sorted in ascending order. -** If the range is empty, `begin` == `end`. -** `begin` and `end` can't be `NULL`. -** Returns a pointer to the element if found, or a pointer to the memory -** location where the element could be inserted to keep the array sorted. -*/ -int *binary_search(int *begin, int *end, int elt); - -#endif /* !BSEARCH_H_ */ diff --git a/rushs/evalexpr/binary_tree_dynamic/Makefile b/rushs/evalexpr/binary_tree_dynamic/Makefile deleted file mode 100644 index 7fa9879..0000000 --- a/rushs/evalexpr/binary_tree_dynamic/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -CC = gcc -CFLAGS = -Wall -Werror -Wvla -Wextra -std=c99 -pedantic - -SRC = binary_tree.c binary_tree_print.c -OBJ = $(SRC:.c=.o) - -.PHONY: library clean - -library: $(OBJ) - ar csr libbinary_tree.a $(OBJ) - -$(OBJ): $(SRC) - -clean: - $(RM) libbinary_tree.a $(OBJ) diff --git a/rushs/evalexpr/binary_tree_dynamic/binary_tree.c b/rushs/evalexpr/binary_tree_dynamic/binary_tree.c deleted file mode 100644 index 6d99e99..0000000 --- a/rushs/evalexpr/binary_tree_dynamic/binary_tree.c +++ /dev/null @@ -1,95 +0,0 @@ -#include "binary_tree.h" - -#include <stddef.h> -#include <stdio.h> - -int size(const struct binary_tree *tree) -{ - if (tree == NULL) - return 0; - - return 1 + size(tree->left) + size(tree->right); -} - -static int max(int a, int b) -{ - if (a > b) - return a; - return b; -} - -int height(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return -1; - } - - return 1 + max(height(tree->left), height(tree->right)); -} - -int is_perfect(const struct binary_tree *tree) -{ - if (tree == NULL) - return 1; - return height(tree->left) == height(tree->right) && is_perfect(tree->right) - && is_perfect(tree->right); -} - -int is_complete(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return 1; - } - - int hg = height(tree->left); - int hd = height(tree->right); - - if (hg - hd != 0 && hg - hd != 1) - { - return 0; - } - - return is_complete(tree->left) && is_complete(tree->right); -} - -int is_degenerate(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return 1; - } - - if (tree->left && tree->right) - { - return 0; - } - return is_degenerate(tree->left) && is_degenerate(tree->right); -} - -int is_full(const struct binary_tree *tree) -{ - if (tree == NULL) - return 1; - if ((tree->left && !tree->right) || (!tree->left && tree->right)) - return 0; - return is_full(tree->right) && is_full(tree->left); -} - -static int is_bzt(const struct binary_tree *tree, int min, int max) -{ - if (tree == NULL) - return 1; - if (tree->data > max || tree->data <= min) - return 0; - return is_bzt(tree->left, min, tree->data) - && is_bzt(tree->right, tree->data, max); -} - -int is_bst(const struct binary_tree *tree) -{ - if (tree == NULL) - return 1; - return is_bzt(tree, -2147483647, 2147483647); -} diff --git a/rushs/evalexpr/binary_tree_dynamic/binary_tree.h b/rushs/evalexpr/binary_tree_dynamic/binary_tree.h deleted file mode 100644 index a08e4ef..0000000 --- a/rushs/evalexpr/binary_tree_dynamic/binary_tree.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef BINARY_TREE_H -#define BINARY_TREE_H - -struct binary_tree -{ - int data; - struct binary_tree *left; - struct binary_tree *right; -}; - -int size(const struct binary_tree *tree); -int height(const struct binary_tree *tree); -void dfs_print_prefix(const struct binary_tree *tree); -void dfs_print_infix(const struct binary_tree *tree); -void dfs_print_postfix(const struct binary_tree *tree); -int is_perfect(const struct binary_tree *tree); -int is_complete(const struct binary_tree *tree); -int is_degenerate(const struct binary_tree *tree); -int is_full(const struct binary_tree *tree); -int is_bst(const struct binary_tree *tree); - -#endif /* !BINARY_TREE_H */ diff --git a/rushs/evalexpr/binary_tree_dynamic/binary_tree_print.c b/rushs/evalexpr/binary_tree_dynamic/binary_tree_print.c deleted file mode 100644 index bce0f77..0000000 --- a/rushs/evalexpr/binary_tree_dynamic/binary_tree_print.c +++ /dev/null @@ -1,40 +0,0 @@ -#include <stddef.h> -#include <stdio.h> - -#include "binary_tree.h" - -void dfs_print_prefix(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return; - } - - printf("%d ", tree->data); - dfs_print_prefix(tree->left); - dfs_print_prefix(tree->right); -} - -void dfs_print_infix(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return; - } - - dfs_print_infix(tree->left); - printf("%d ", tree->data); - dfs_print_infix(tree->right); -} - -void dfs_print_postfix(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return; - } - - dfs_print_postfix(tree->left); - dfs_print_postfix(tree->right); - printf("%d ", tree->data); -} diff --git a/rushs/evalexpr/bit_rotation/rol.c b/rushs/evalexpr/bit_rotation/rol.c deleted file mode 100644 index 151ebb5..0000000 --- a/rushs/evalexpr/bit_rotation/rol.c +++ /dev/null @@ -1,5 +0,0 @@ -unsigned char rol(unsigned char value, unsigned char roll) -{ - roll %= sizeof(unsigned char) * 8; - return (value << roll) | (value >> (8 * sizeof(unsigned char) - roll)); -} diff --git a/rushs/evalexpr/bubble_sort/bubble_sort.c b/rushs/evalexpr/bubble_sort/bubble_sort.c deleted file mode 100644 index 13d2ba3..0000000 --- a/rushs/evalexpr/bubble_sort/bubble_sort.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "bubble_sort.h" - -void bubble_sort(int array[], size_t size) -{ - if (!array || size == 0) - { - return; - } - - int mod; - do - { - mod = 0; - for (size_t i = 0; i < size - 1; i++) - { - if (array[i] > array[i + 1]) - { - mod = 1; - int tmp = array[i]; - array[i] = array[i + 1]; - array[i + 1] = tmp; - } - } - } while (mod); -} diff --git a/rushs/evalexpr/bubble_sort/bubble_sort.h b/rushs/evalexpr/bubble_sort/bubble_sort.h deleted file mode 100644 index a33d531..0000000 --- a/rushs/evalexpr/bubble_sort/bubble_sort.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef BUBBLE_SORT_H -#define BUBBLE_SORT_H - -#include <stddef.h> - -void bubble_sort(int array[], size_t size); - -#endif /* !BUBBLE_SORT_H */ diff --git a/rushs/evalexpr/check_alphabet/check_alphabet.c b/rushs/evalexpr/check_alphabet/check_alphabet.c deleted file mode 100644 index fc540b4..0000000 --- a/rushs/evalexpr/check_alphabet/check_alphabet.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "check_alphabet.h" - -#include <stddef.h> - -int check_alphabet(const char *str, const char *alphabet) -{ - if (alphabet == NULL || *alphabet == '\0') - { - return 1; - } - - for (int i = 0; alphabet[i]; i++) - { - int j; - for (j = 0; str[j] && str[j] != alphabet[i]; j++) - { - continue; - } - if (str[j] == '\0') - { - return 0; - } - } - return 1; -} diff --git a/rushs/evalexpr/check_alphabet/check_alphabet.h b/rushs/evalexpr/check_alphabet/check_alphabet.h deleted file mode 100644 index 667a20f..0000000 --- a/rushs/evalexpr/check_alphabet/check_alphabet.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CHECK_ALPHABET_H -#define CHECK_ALPHABET_H - -int check_alphabet(const char *str, const char *alphabet); - -#endif /* !CHECK_ALPHABET_H */ diff --git a/rushs/evalexpr/clang-format/.clang-format b/rushs/evalexpr/clang-format/.clang-format deleted file mode 100644 index 7ed8115..0000000 --- a/rushs/evalexpr/clang-format/.clang-format +++ /dev/null @@ -1,79 +0,0 @@ -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Right -AlignOperands: false -AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: true -BinPackParameters: true -BreakBeforeBraces: Custom -BraceWrapping: - AfterEnum: true - AfterClass: true - AfterControlStatement: true - AfterFunction: true - AfterNamespace: true - AfterStruct: true - AfterUnion: true - AfterExternBlock: true - BeforeCatch: true - BeforeElse: true - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: false -BreakBeforeBinaryOperators: NonAssignment -BreakBeforeTernaryOperators: true -BreakConstructorInitializers: BeforeComma -BreakInheritanceList: BeforeComma -BreakStringLiterals: true -ColumnLimit: 80 -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -Cpp11BracedListStyle: false -DerivePointerAlignment: false -FixNamespaceComments: true -ForEachMacros: ['ILIST_FOREACH', 'ILIST_FOREACH_ENTRY'] -IncludeBlocks: Regroup -IncludeCategories: - - Regex: '<.*>' - Priority: 1 - - Regex: '.*' - Priority: 2 -IndentCaseLabels: false -IndentPPDirectives: AfterHash -IndentWidth: 4 -IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: false -Language: Cpp -NamespaceIndentation: All -PointerAlignment: Right -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: false -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -TabWidth: 4 -UseTab: Never diff --git a/rushs/evalexpr/clang-format/zaza.c b/rushs/evalexpr/clang-format/zaza.c deleted file mode 100644 index a6eec9a..0000000 --- a/rushs/evalexpr/clang-format/zaza.c +++ /dev/null @@ -1,78 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#define ZAZA_SIZE 4 - -static char get_zaza_char(size_t id) -{ - const int zaza[ZAZA_SIZE] = { - 10 * 10 + 2 * 10 + 2 * 10 / 10, - 10 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - + 10 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - + 10 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - + 10 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - - * 1 - + 10 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - + 10 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - + 10 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - + 10 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - + 10 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - + 10 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - - (1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - + 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 - + 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1), - 122, - (38943 * 43 - 84393 / 34583 - - ) % 10 - + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - + 1 + 1 + 1 + 1 + 1 - }; - switch (id * 2 + 4 - 2 + id * 4 - 2 + -5 * id) - - { - case (0): - return (zaza[0]); - case (1000 - 100 - 4 * 100 + 10 * 100 - 14 * 100 - (10 * 10 - 1)): - return (zaza[1]); - case (1 << 11 >> 3 << 5 >> 2 << 1 << 1 << 1 >> 1 >> 1 >> 1 << 5 >> 4 << 1 - >> 1 >> 2 >> 9): - return zaza[2]; - case (3 ^ 100) - (100 ^ 100) - (99 - 99) - (98 - 98) - (97 - 97) - (96 - 96) - - (95 - 95) - (94 - 94) - (93 - 93) - (92 - 92) - (91 - 91) - (90 - 90) - - (89 - 89) - (88 - 88) - (87 - 87) - (86 - 86) - (85 - 85) - (84 - 84) - - (83 - 83) - (82 - 82) - (81 - 81) - (80 - 80) - (79 - 79) - (78 - 78) - - (77 - 77) - (76 - 76) - (75 - 75) - (74 - 74) - (73 - 73) - (72 - 72) - - (71 - 71) - (70 - 70) - - - (69 - 69) - (68 - 68) - (67 - 67) - (66 - 66) - (65 - 65) - (64 - 64) - - (63 - 63) - (62 - 62) - (61 - 61) - (60 - 60) - (59 - 59) - (58 - 58) - - (57 - 57) - (56 - 56) - (55 - 55) - (54 - 54) - (53 - 53) - (52 - 52) - - (51 - 51) - 100 - (50 - 50) - (49 - 49) - (48 - 48) - (47 - 47) - - (46 - 46) - (45 - 45) - (44 - 44) - (43 - 43) - (42 - 42) - (41 - 41) - - (40 - 40) - (39 - 39) - (38 - 38) - (37 - 37) - - - (36 - 36) - (35 - 35) - (34 - 34) - (33 - 33) - (32 - 32) - (31 - 31) - - (30 - 30) - (29 - 29) - (28 - 28) - (27 - 27) - (26 - 26) - (25 - 25) - - (24 - 24) - (23 - 23) - (22 - 22) - (21 - 21) - (20 - 20) - (19 - 19) - - (18 - 18) - (17 - 17) - (16 - 16) - (15 - 15) - (14 - 14) - (13 - 13) - - (12 - 12) - (11 - 11) - (10 - 10) - (9 - 9) - (8 - 8) - (7 - 7) - - (6 - 6) - (5 - 5) - (4 - 4) - (3 - 3) - (2 - 2) - (1 - 1): - return (zaza[3]); - default: - return (0); - } -} -int main(void) -{ - for (size_t i = 0; i < ZAZA_SIZE; i += (i % 2 == 2 - 2) ? 1 % 2 : 1 % 2) - { - putchar(get_zaza_char(i)); - } - putchar('\n'); - return (0); -} diff --git a/rushs/evalexpr/create_files/create_files.sh b/rushs/evalexpr/create_files/create_files.sh deleted file mode 100755 index 28dba00..0000000 --- a/rushs/evalexpr/create_files/create_files.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -touch ' ' -chmod 644 ' ' - -touch '\' -chmod 644 '\' - -touch -- -- -chmod 644 -- -- - -touch '|' -chmod 644 '|' - -touch '"' -chmod 644 '"' - -touch "'" -chmod 644 "'" - -touch -- --\$i*\'\"\\ -chmod 644 -- --\$i*\'\"\\ - -touch '# Exams are fun!' -chmod 644 '# Exams are fun!' - -touch ";\`kill -9 0\`" -chmod 644 ";\`kill -9 0\`" - -path="1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/41/42/43/44/45/46/47/48/49/50" - -mkdir -p "$path" -touch $path/farfaraway -chmod 644 $path/farfaraway diff --git a/rushs/evalexpr/cut_csv/test.csv b/rushs/evalexpr/cut_csv/test.csv deleted file mode 100644 index d88282b..0000000 --- a/rushs/evalexpr/cut_csv/test.csv +++ /dev/null @@ -1,15 +0,0 @@ -James;Lebron;LABron;Lakers; -Davis;Anthony;Unibrow;Pelicans; -Mitchell;Donovan;Spida;Jazz; -Harden;James;TheBeard;Rockets; -Cousins;DeMarcus;Boogie;Wariors; -Embiid;Joel;TheProcess;76Sixers; -Bryant;Kobe;BlackMamba;Lakers; -Jordan;Michael;AirJordan;Bulls; -Johnson;Earvin;Magic;Lakers; -Howard;Dwight;Superman;Wizards; -Westbrook;Russel;MrTripleDouble;Thunder; -Durant;Kevin;KD;Wariors; -George;Paul;PG-13;Thunder; -Leonard;Kawhi;TheKlaw;Raptors; -Irving;Kyrie;UncleDrew;Celtics; diff --git a/rushs/evalexpr/cut_csv/with_cut.sh b/rushs/evalexpr/cut_csv/with_cut.sh deleted file mode 100755 index 9618f00..0000000 --- a/rushs/evalexpr/cut_csv/with_cut.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -[ $# -ne 2 ] && exit 1 - -if ! [ -f "$1" ]; then - exit 1 -fi - -if ! [ "$2" -eq "$2" ] 2> /dev/null; then - exit 1 -fi - -[ "$2" -lt 0 ] && exit 1 - -if [ "$2" -gt "$(wc -l < "$1")" ]; then - exit 1 -fi - -line=$(head --lines="$2" "$1" 2> /dev/null | tail -n 1 | cut -d ';' -f 2-3 || exit 1) -c1=$(echo "$line" | cut -d ';' -f 1) -c2=$(echo "$line" | cut -d ';' -f 2) - -echo "$c1 is $c2" diff --git a/rushs/evalexpr/cut_csv/with_sed.sh b/rushs/evalexpr/cut_csv/with_sed.sh deleted file mode 100755 index fb5e1f8..0000000 --- a/rushs/evalexpr/cut_csv/with_sed.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -[ $# -ne 2 ] && exit 1 - -if ! [ -f "$1" ]; then - exit 1 -fi - -if ! [ "$2" -eq "$2" ] 2>/dev/null; then - exit 1 -fi - -[ "$2" -lt 0 ] && exit 1 - -if [ "$2" -gt $(wc -l < "$1") ]; then - exit 1 -fi - -i=1 - -while IFS= read -r line; do - [ "$i" -eq "$2" ] && echo "$line" | sed 's/^.*;\(.*\);\(.*\);.*;$/\1 is \2/' - i=$(($i + 1)) -done < "$1" diff --git a/rushs/evalexpr/digit/digit.c b/rushs/evalexpr/digit/digit.c deleted file mode 100644 index 5646b13..0000000 --- a/rushs/evalexpr/digit/digit.c +++ /dev/null @@ -1,13 +0,0 @@ -unsigned int digit(int n, int k) -{ - if (n <= 0 || k <= 0) - { - return 0; - } - - for (int i = 0; i < k - 1; i++) - { - n /= 10; - } - return n % 10; -} diff --git a/rushs/evalexpr/display_square/display_square.c b/rushs/evalexpr/display_square/display_square.c deleted file mode 100644 index 9e834d7..0000000 --- a/rushs/evalexpr/display_square/display_square.c +++ /dev/null @@ -1,44 +0,0 @@ -#include <stdio.h> - -void display_square(int width) -{ - if (width <= 0) - { - return; - } - - if (width % 2 == 0) - { - width++; - } - - if (width == 1) - { - putchar('*'); - putchar('\n'); - return; - } - - for (int i = 0; i < width; i++) - { - putchar('*'); - } - putchar('\n'); - - for (int i = 0; i < ((width - 3) / 2); i++) - { - putchar('*'); - for (int j = 0; j < width - 2; j++) - { - putchar(' '); - } - putchar('*'); - putchar('\n'); - } - - for (int i = 0; i < width; i++) - { - putchar('*'); - } - putchar('\n'); -} diff --git a/rushs/evalexpr/dlist/Makefile b/rushs/evalexpr/dlist/Makefile deleted file mode 100644 index 1251967..0000000 --- a/rushs/evalexpr/dlist/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -CC = gcc -CFLAGS = -std=c99 -pedantic -Werror -Wall -Wextra -Wvla - -SRC = dlist-1.c dlist-2.c dlist-3.c dlist-4.c -OBJ = $(SRC:.c=.o) - -.PHONY: library clean - -library: $(OBJ) - ar csr libdlist.a $(OBJ) - -clean: $(OBJ) - $(RM) *.a $(OBJ) - -$(OBJ): $(SRC) diff --git a/rushs/evalexpr/dlist/dlist-1.c b/rushs/evalexpr/dlist/dlist-1.c deleted file mode 100644 index 443ebca..0000000 --- a/rushs/evalexpr/dlist/dlist-1.c +++ /dev/null @@ -1,78 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include "dlist.h" - -struct dlist *dlist_init(void) -{ - struct dlist *res = malloc(sizeof(struct dlist)); - if (res == NULL) - return NULL; - - res->size = 0; - res->head = NULL; - res->tail = NULL; - return res; -} - -int dlist_push_front(struct dlist *list, int element) -{ - if (element < 0) - return 0; - struct dlist_item *new = malloc(sizeof(struct dlist_item)); - if (new == NULL) - return 0; - - new->data = element; - new->next = list->head; - new->prev = NULL; - - if (list->size == 0) - list->tail = new; - else - list->head->prev = new; - - list->head = new; - list->size++; - - return 1; -} - -void dlist_print(const struct dlist *list) -{ - if (list->size == 0) - return; - - for (struct dlist_item *i = list->head; i != list->tail; i = i->next) - { - printf("%d\n", i->data); - } - printf("%d\n", list->tail->data); -} - -int dlist_push_back(struct dlist *list, int element) -{ - if (element < 0) - return 0; - struct dlist_item *new = malloc(sizeof(struct dlist_item)); - if (new == NULL) - return 0; - - new->data = element; - new->prev = list->tail; - new->next = NULL; - - if (list->size == 0) - list->head = new; - else - list->tail->next = new; - list->tail = new; - list->size++; - - return 1; -} - -size_t dlist_size(const struct dlist *list) -{ - return list->size; -} diff --git a/rushs/evalexpr/dlist/dlist-2.c b/rushs/evalexpr/dlist/dlist-2.c deleted file mode 100644 index 5ccdaa3..0000000 --- a/rushs/evalexpr/dlist/dlist-2.c +++ /dev/null @@ -1,113 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include "dlist.h" - -int dlist_get(const struct dlist *list, size_t index) -{ - if (index >= list->size) - return -1; - - struct dlist_item *i; - for (i = list->head; index; index--, i = i->next) - { - continue; - } - - return i->data; -} - -int dlist_insert_at(struct dlist *list, int element, size_t index) -{ - if (index > list->size || element < 0) - return 0; - else if (index == list->size) - dlist_push_back(list, element); - else if (index == 0) - dlist_push_front(list, element); - else - { - struct dlist_item *new = malloc(sizeof(struct dlist_item)); - if (new == NULL) - return 0; - new->data = element; - - struct dlist_item *i; - for (i = list->head; index - 1; index--, i = i->next) - continue; - new->next = i->next; - i->next->prev = new; - i->next = new; - new->prev = i; - list->size++; - } - return 1; -} - -int dlist_find(const struct dlist *list, int element) -{ - int index = 0; - struct dlist_item *i; - for (i = list->head; i && i->data != element; index++, i = i->next) - continue; - if (!i) - return -1; - return index; -} - -int dlist_remove_at(struct dlist *list, size_t index) -{ - if (index >= list->size) - return -1; - int res; - struct dlist_item *item; - if (list->size == 1) - { - item = list->head; - res = list->head->data; - list->head = NULL; - list->tail = NULL; - } - else if (index == 0) - { - item = list->head; - res = item->data; - item->next->prev = NULL; - list->head = item->next; - } - else if (index == list->size - 1) - { - item = list->tail; - res = item->data; - item->prev->next = NULL; - list->tail = item->prev; - } - else - { - for (item = list->head; index; index--, item = item->next) - continue; - - res = item->data; - item->prev->next = item->next; - item->next->prev = item->prev; - } - - free(item); - list->size--; - return res; -} - -void dlist_clear(struct dlist *list) -{ - if (list->size == 0) - return; - for (struct dlist_item *i = list->head; i;) - { - struct dlist_item *tmp = i->next; - free(i); - i = tmp; - } - list->size = 0; - list->head = NULL; - list->tail = NULL; -} diff --git a/rushs/evalexpr/dlist/dlist-3.c b/rushs/evalexpr/dlist/dlist-3.c deleted file mode 100644 index 22b4b52..0000000 --- a/rushs/evalexpr/dlist/dlist-3.c +++ /dev/null @@ -1,83 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include "dlist.h" - -void dlist_map_square(struct dlist *list) -{ - for (struct dlist_item *i = list->head; i; i = i->next) - { - i->data *= i->data; - } -} - -void dlist_reverse(struct dlist *list) -{ - struct dlist_item *tmp; - for (struct dlist_item *i = list->head; i; i = i->prev) - { - tmp = i->next; - i->next = i->prev; - i->prev = tmp; - } - tmp = list->tail; - list->tail = list->head; - list->head = tmp; -} - -struct dlist *dlist_split_at(struct dlist *list, size_t index) -{ - if (list->size == 0) - return dlist_init(); - if (index >= list->size) - { - return NULL; - } - - struct dlist *new = dlist_init(); - if (new == NULL) - return NULL; - new->size = list->size - index; - list->size = index; - - struct dlist_item *i; - for (i = list->head; index; index--, i = i->next) - { - continue; - } - - new->head = i; - new->tail = list->tail; - list->tail = i->prev; - if (i->prev) - { - i->prev->next = NULL; - } - else - { - list->head = NULL; - } - i->prev = NULL; - return new; -} - -void dlist_concat(struct dlist *list1, struct dlist *list2) -{ - if (list2->head == NULL) - return; - if (list1->tail == NULL) - { - list1->head = list2->head; - list1->tail = list2->tail; - list1->size = list2->size; - return; - } - - list1->tail->next = list2->head; - list2->head->prev = list1->tail; - list1->tail = list2->tail; - list1->size += list2->size; - list2->size = 0; - list2->head = NULL; - list2->tail = NULL; -} diff --git a/rushs/evalexpr/dlist/dlist-4.c b/rushs/evalexpr/dlist/dlist-4.c deleted file mode 100644 index 9ed7aaa..0000000 --- a/rushs/evalexpr/dlist/dlist-4.c +++ /dev/null @@ -1,97 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include "dlist.h" - -size_t max(size_t a, size_t b) -{ - if (a >= b) - { - return a; - } - return b; -} - -size_t min(size_t a, size_t b) -{ - if (a <= b) - { - return a; - } - return b; -} - -size_t min_3(size_t a, size_t b, size_t c) -{ - if (a <= b) - { - if (a <= c) - { - return a; - } - return c; - } - else - { - if (b <= c) - { - return b; - } - return c; - } -} - -size_t my_strlen(const int *s) -{ - size_t i; - for (i = 0; s[i] != -1; i++) - { - continue; - } - return i; -} - -size_t levenshtein(const int *s1, const int *s2) -{ - size_t l1 = my_strlen(s1); - size_t l2 = my_strlen(s2); - if (min(l1, l2) == 0) - { - return max(l1, l2); - } - - if (s1[0] == s2[0]) - { - return levenshtein(s1 + 1, s2 + 1); - } - - size_t lev1 = levenshtein(s1 + 1, s2); - size_t lev2 = levenshtein(s1, s2 + 1); - size_t lev3 = levenshtein(s1 + 1, s2 + 1); - - return 1 + min_3(lev1, lev2, lev3); -} - -int *to_str(const struct dlist *l) -{ - int *res = malloc((l->size + 1) * sizeof(int)); - res[l->size] = -1; - size_t j = 0; - for (struct dlist_item *i = l->head; i; i = i->next, j++) - { - res[j] = i->data; - } - return res; -} - -unsigned int dlist_levenshtein(const struct dlist *list1, - const struct dlist *list2) -{ - int *l1 = to_str(list1); - int *l2 = to_str(list2); - - unsigned int res = levenshtein(l1, l2); - free(l1); - free(l2); - return res; -} diff --git a/rushs/evalexpr/dlist/dlist.h b/rushs/evalexpr/dlist/dlist.h deleted file mode 100644 index 97cde1a..0000000 --- a/rushs/evalexpr/dlist/dlist.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef DLIST_H -#define DLIST_H - -#include <stddef.h> - -struct dlist_item -{ - int data; - struct dlist_item *next; - struct dlist_item *prev; -}; - -struct dlist -{ - size_t size; - struct dlist_item *head; - struct dlist_item *tail; -}; - -// Threshold 1 -struct dlist *dlist_init(void); -int dlist_push_front(struct dlist *list, int element); -void dlist_print(const struct dlist *list); -int dlist_push_back(struct dlist *list, int element); -size_t dlist_size(const struct dlist *list); - -// Threshold 2 -int dlist_get(const struct dlist *list, size_t index); -int dlist_insert_at(struct dlist *list, int element, size_t index); -int dlist_find(const struct dlist *list, int element); -int dlist_remove_at(struct dlist *list, size_t index); -void dlist_clear(struct dlist *list); - -// Threshold 3 -void dlist_map_square(struct dlist *list); -void dlist_reverse(struct dlist *list); -struct dlist *dlist_split_at(struct dlist *list, size_t index); -void dlist_concat(struct dlist *list1, struct dlist *list2); - -// Threshold 4 -unsigned int dlist_levenshtein(const struct dlist *list1, - const struct dlist *list2); - -#endif /* !DLIST_H */ diff --git a/rushs/evalexpr/element_count/element_count.c b/rushs/evalexpr/element_count/element_count.c deleted file mode 100644 index cec47ae..0000000 --- a/rushs/evalexpr/element_count/element_count.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "element_count.h" - -size_t element_count(int *begin, int *end) -{ - if (!begin || !end || begin >= end) - { - return 0; - } - return end - begin; -} diff --git a/rushs/evalexpr/element_count/element_count.h b/rushs/evalexpr/element_count/element_count.h deleted file mode 100644 index 57412ed..0000000 --- a/rushs/evalexpr/element_count/element_count.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef ELEMENT_COUNT_H -#define ELEMENT_COUNT_H - -#include <stddef.h> - -size_t element_count(int *begin, int *end); - -#endif /* !ELEMENT_COUNT_H */ diff --git a/rushs/evalexpr/fact/fact.c b/rushs/evalexpr/fact/fact.c deleted file mode 100644 index 1440c94..0000000 --- a/rushs/evalexpr/fact/fact.c +++ /dev/null @@ -1,8 +0,0 @@ -unsigned long fact(unsigned n) -{ - if (n == 0) - { - return 1; - } - return n * fact(n - 1); -} diff --git a/rushs/evalexpr/facto/facto.sh b/rushs/evalexpr/facto/facto.sh deleted file mode 100755 index 350973a..0000000 --- a/rushs/evalexpr/facto/facto.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -[ $# -ne 1 ] && exit 1 -i=$1 -res=1 -while [ "$i" -gt 0 ]; do - res=$(($res * $i)) - i=$(($i - 1)) -done -echo "$res" diff --git a/rushs/evalexpr/fibo/fibo.c b/rushs/evalexpr/fibo/fibo.c deleted file mode 100644 index 99c0d79..0000000 --- a/rushs/evalexpr/fibo/fibo.c +++ /dev/null @@ -1,8 +0,0 @@ -unsigned long fibonacci(unsigned long n) -{ - if (n == 0 || n == 1) - { - return n; - } - return fibonacci(n - 1) + fibonacci(n - 2); -} diff --git a/rushs/evalexpr/fibo_iter/fibo_iter.c b/rushs/evalexpr/fibo_iter/fibo_iter.c deleted file mode 100644 index 36ebf46..0000000 --- a/rushs/evalexpr/fibo_iter/fibo_iter.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <stdio.h> - -unsigned long fibo_iter(unsigned long n) -{ - if (n == 0) - { - return 0; - } - unsigned long prev = 1; - unsigned long pprev = 0; - unsigned long i; - - for (i = 1; i < n; i++) - { - unsigned long next = pprev + prev; - pprev = prev; - prev = next; - } - - return prev; -} diff --git a/rushs/evalexpr/fifo/Makefile b/rushs/evalexpr/fifo/Makefile deleted file mode 100644 index e5c9374..0000000 --- a/rushs/evalexpr/fifo/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CC=gcc -CFLAGS=-std=c99 -Wall -Wextra -Wvla -Werror -pedantic - -.PHONY: library clean - -library: fifo_access.o fifo_setup_destroy.o - ar csr libfifo.a $^ - -fifo_access.o: fifo_access.c - $(CC) $(CFLAGS) -c -o fifo_access.o fifo_access.c - -fifo_setup_destroy.o: fifo_setup_destroy.c - $(CC) $(CFLAGS) -c -o fifo_setup_destroy.o fifo_setup_destroy.c - -clean: - rm *.o libfifo.a diff --git a/rushs/evalexpr/fifo/fifo.h b/rushs/evalexpr/fifo/fifo.h deleted file mode 100644 index c4b0a6f..0000000 --- a/rushs/evalexpr/fifo/fifo.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef FIFO_H -#define FIFO_H - -#include <stddef.h> - -struct list -{ - int data; - struct list *next; -}; - -struct fifo -{ - struct list *head; - struct list *tail; - size_t size; -}; - -struct fifo *fifo_init(void); -size_t fifo_size(struct fifo *fifo); -void fifo_push(struct fifo *fifo, int elt); -int fifo_head(struct fifo *fifo); -void fifo_pop(struct fifo *fifo); -void fifo_clear(struct fifo *fifo); -void fifo_destroy(struct fifo *fifo); -void fifo_print(const struct fifo *fifo); - -#endif /* !FIFO_H */ diff --git a/rushs/evalexpr/fifo/fifo_access.c b/rushs/evalexpr/fifo/fifo_access.c deleted file mode 100644 index 5d31586..0000000 --- a/rushs/evalexpr/fifo/fifo_access.c +++ /dev/null @@ -1,66 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include "fifo.h" - -size_t fifo_size(struct fifo *fifo) -{ - return fifo->size; -} - -void fifo_push(struct fifo *fifo, int elt) -{ - struct list *new = malloc(sizeof(struct list)); - if (new == NULL) - { - return; - } - new->data = elt; - - if (fifo_size(fifo) == 0) - { - fifo->head = new; - } - new->next = NULL; - if (fifo_size(fifo) != 0) - { - fifo->tail->next = new; - } - fifo->tail = new; - - fifo->size++; -} - -int fifo_head(struct fifo *fifo) -{ - return fifo->head->data; -} - -void fifo_pop(struct fifo *fifo) -{ - if (fifo_size(fifo) == 0) - { - return; - } - if (fifo_size(fifo) == 1) - { - free(fifo->head); - fifo->head = NULL; - fifo->tail = NULL; - return; - } - - struct list *tmp = fifo->head->next; - free(fifo->head); - fifo->head = tmp; - - fifo->size--; -} - -void fifo_print(const struct fifo *fifo) -{ - for (struct list *l = fifo->head; l; l = l->next) - { - printf("%d\n", l->data); - } -} diff --git a/rushs/evalexpr/fifo/fifo_setup_destroy.c b/rushs/evalexpr/fifo/fifo_setup_destroy.c deleted file mode 100644 index 80820e1..0000000 --- a/rushs/evalexpr/fifo/fifo_setup_destroy.c +++ /dev/null @@ -1,39 +0,0 @@ -#include <stdlib.h> - -#include "fifo.h" - -struct fifo *fifo_init(void) -{ - struct fifo *f = malloc(sizeof(struct fifo)); - if (f == NULL) - { - return NULL; - } - - f->size = 0; - f->head = NULL; - f->tail = NULL; - - return f; -} - -void fifo_clear(struct fifo *fifo) -{ - for (struct list *l = fifo->head; l != fifo->tail;) - { - struct list *tmp = l->next; - free(l); - l = tmp; - } - free(fifo->tail); - - fifo->head = NULL; - fifo->tail = NULL; - fifo->size = 0; -} - -void fifo_destroy(struct fifo *fifo) -{ - fifo_clear(fifo); - free(fifo); -} diff --git a/rushs/evalexpr/find_ascii/find_ascii.sh b/rushs/evalexpr/find_ascii/find_ascii.sh deleted file mode 100755 index db31722..0000000 --- a/rushs/evalexpr/find_ascii/find_ascii.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -for filename in $(ls "$1"); do - echo $1/$filename | file -f - | grep ASCII -done diff --git a/rushs/evalexpr/freq_analysis/freq_analysis.c b/rushs/evalexpr/freq_analysis/freq_analysis.c deleted file mode 100644 index c60d7a6..0000000 --- a/rushs/evalexpr/freq_analysis/freq_analysis.c +++ /dev/null @@ -1,28 +0,0 @@ -#include <stdio.h> - -int find_rank(int h[26], int min) -{ - int res = 0; - for (int i = 0; i < 26; i++) - { - res += h[i] > h[min] || (h[i] == h[min] && i < min); - } - return res; -} - -void freq_analysis(const char text[], const char table[]) -{ - int h[26] = { 0 }; - for (int i = 0; text[i]; i++) - { - h[text[i] - 'A']++; - } - - for (int j = 0; j < 26; j++) - { - if (h[j] != 0) - { - printf("%c %c\n", j + 'A', table[find_rank(h, j)]); - } - } -} diff --git a/rushs/evalexpr/functional_programming/foldl.c b/rushs/evalexpr/functional_programming/foldl.c deleted file mode 100644 index ac222a7..0000000 --- a/rushs/evalexpr/functional_programming/foldl.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "functional_programming.h" - -int foldl(int *array, size_t len, int (*func)(int, int)) -{ - int acc = 0; - for (size_t i = 0; i < len; i++) - { - acc = (*func)(acc, array[i]); - } - return acc; -} diff --git a/rushs/evalexpr/functional_programming/foldr.c b/rushs/evalexpr/functional_programming/foldr.c deleted file mode 100644 index c232410..0000000 --- a/rushs/evalexpr/functional_programming/foldr.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "functional_programming.h" - -int foldr(int *array, size_t len, int (*func)(int, int)) -{ - if (len == 1) - { - return (*func)(array[0], 0); - } - return (*func)(array[0], foldr(array + 1, len - 1, func)); -} diff --git a/rushs/evalexpr/functional_programming/functional_programming.h b/rushs/evalexpr/functional_programming/functional_programming.h deleted file mode 100644 index 429b13c..0000000 --- a/rushs/evalexpr/functional_programming/functional_programming.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef FUNCTIONAL_PROGRAMMING_H -#define FUNCTIONAL_PROGRAMMING_H - -#include <stddef.h> - -void map(int *array, size_t len, void (*func)(int *)); -int foldr(int *array, size_t len, int (*func)(int, int)); -int foldl(int *array, size_t len, int (*func)(int, int)); - -#endif /* !FUNCTIONAL_PROGRAMMING_H */ diff --git a/rushs/evalexpr/functional_programming/map.c b/rushs/evalexpr/functional_programming/map.c deleted file mode 100644 index 311c39c..0000000 --- a/rushs/evalexpr/functional_programming/map.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "functional_programming.h" - -void map(int *array, size_t len, void (*func)(int *)) -{ - for (size_t i = 0; i < len; i++) - { - (*func)(array + i); - } -} diff --git a/rushs/evalexpr/generate_files/generate_files.sh b/rushs/evalexpr/generate_files/generate_files.sh deleted file mode 100755 index cf2ba0a..0000000 --- a/rushs/evalexpr/generate_files/generate_files.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -FILENAME="default" -NUMBER="1" -EXTENSION="txt" - -while [ $# -gt 0 ]; do - case "$1" in - '-f' | '--filename') - shift - FILENAME="$1" - shift - ;; - '-n' | '--number') - shift - NUMBER="$1" - shift - ;; - '-e' | '--extension') - shift - EXTENSION="$1" - shift - ;; - *) - exit 1 - ;; - esac -done - -for i in $(seq 1 $NUMBER); do - touch -- "$FILENAME-$i.$EXTENSION" -done diff --git a/rushs/evalexpr/generic_void_list/list.c b/rushs/evalexpr/generic_void_list/list.c deleted file mode 100644 index 20ecfa8..0000000 --- a/rushs/evalexpr/generic_void_list/list.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "list.h" - -#include <stdlib.h> -#include <string.h> - -struct list *list_prepend(struct list *list, const void *value, - size_t data_size) -{ - struct list *new = malloc(sizeof(struct list)); - new->next = list; - new->data = malloc(sizeof(void *)); - memcpy(new->data, value, data_size); - return new; -} - -size_t list_length(struct list *list) -{ - size_t res = 0; - while (list) - { - res++; - list = list->next; - } - return res; -} - -void list_destroy(struct list *list) -{ - while (list) - { - struct list *tmp = list->next; - free(list->data); - free(list); - list = tmp; - } -} diff --git a/rushs/evalexpr/generic_void_list/list.h b/rushs/evalexpr/generic_void_list/list.h deleted file mode 100644 index a1bc035..0000000 --- a/rushs/evalexpr/generic_void_list/list.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef LIST_H -#define LIST_H - -#include <stddef.h> - -struct list -{ - void *data; - struct list *next; -}; - -/* -** Insert a node containing `value` at the beginning of the list. -** Return `NULL` if an error occurred. -*/ -struct list *list_prepend(struct list *list, const void *value, - size_t data_size); - -/* -** Return the length of the list. -** Return `0` if the list is empty. -*/ -size_t list_length(struct list *list); - -/* -** Release the memory used by the list. -** Does nothing if `list` is `NULL`. -*/ -void list_destroy(struct list *list); - -#endif /* !LIST_H */ diff --git a/rushs/evalexpr/glob_easy/glob_easy.sh b/rushs/evalexpr/glob_easy/glob_easy.sh deleted file mode 100755 index b6ae028..0000000 --- a/rushs/evalexpr/glob_easy/glob_easy.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo $1/*.[A-Za-z][A-Za-z] diff --git a/rushs/evalexpr/glob_remove_shell/glob_remove_shell.sh b/rushs/evalexpr/glob_remove_shell/glob_remove_shell.sh deleted file mode 100755 index c2e7ff7..0000000 --- a/rushs/evalexpr/glob_remove_shell/glob_remove_shell.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -fmt=*.${1:-"txt"} - -for file in $(echo "$fmt"); do - [ -e "$file" ] && rm "$file" || exit 1 -done diff --git a/rushs/evalexpr/grade/grade.c b/rushs/evalexpr/grade/grade.c deleted file mode 100644 index caecc82..0000000 --- a/rushs/evalexpr/grade/grade.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <stdio.h> - -void grade(char g) -{ - switch (g) - { - case 'A': - puts("Excellent"); - break; - case 'B': - puts("Good"); - break; - case 'C': - puts("Not so bad"); - break; - case 'D': - puts("Could be worse"); - break; - case 'E': - puts("Maybe next time"); - break; - case 'F': - puts("No comment"); - break; - default: - puts("Call a wild ACU"); - break; - } -} diff --git a/rushs/evalexpr/greatest_divisor/greatest_divisor.c b/rushs/evalexpr/greatest_divisor/greatest_divisor.c deleted file mode 100644 index 4c8efef..0000000 --- a/rushs/evalexpr/greatest_divisor/greatest_divisor.c +++ /dev/null @@ -1,15 +0,0 @@ -unsigned int greatest_divisor(unsigned int n) -{ - if (n == 0 || n == 1) - { - return 1; - } - - int i; - for (i = n / 2; i > 0 && n % i; i--) - { - continue; - } - - return i; -} diff --git a/rushs/evalexpr/hacker_news/input.html b/rushs/evalexpr/hacker_news/input.html deleted file mode 100644 index 54d338d..0000000 --- a/rushs/evalexpr/hacker_news/input.html +++ /dev/null @@ -1,147 +0,0 @@ -<html op="news" class=" lddwcbt idc0_332" lang="en"><head> -<meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta name="referrer" content="origin"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" type="text/css" href="02_files/news.css"> - <link rel="shortcut icon" href="https://news.ycombinator.com/favicon.ico"> - <link rel="alternate" type="application/rss+xml" title="RSS" href="https://news.ycombinator.com/rss"> - <title>Hacker News</title></head><body><center><table id="hnmain" width="85%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f6ef"> - <tbody><tr><td bgcolor="#ff6600"><table style="padding:2px" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td style="width:18px;padding-right:4px"><a href="https://news.ycombinator.com/"><img src="02_files/y18.gif" style="border:1px white solid;" width="18" height="18"></a></td> - <td style="line-height:12pt; height:10px;"><span class="pagetop"><b class="hnname"><a href="https://news.ycombinator.com/news">Hacker News</a></b> - <a href="https://news.ycombinator.com/newest">new</a> | <a href="https://news.ycombinator.com/front">past</a> | <a href="https://news.ycombinator.com/newcomments">comments</a> | <a href="https://news.ycombinator.com/ask">ask</a> | <a href="https://news.ycombinator.com/show">show</a> | <a href="https://news.ycombinator.com/jobs">jobs</a> | <a href="https://news.ycombinator.com/submit">submit</a> </span></td><td style="text-align:right;padding-right:4px;"><span class="pagetop"> - <a href="https://news.ycombinator.com/login?goto=news%3Fp%3D2">login</a> - </span></td> - </tr></tbody></table></td></tr> -<tr id="pagespace" title="" style="height:10px"></tr><tr><td><table class="itemlist" cellspacing="0" cellpadding="0" border="0"> - <tbody><tr class="athing" id="28943869"> - <td class="title" valign="top" align="right"><span class="rank">31.</span></td> <td class="votelinks" valign="top"><center><a id="up_28943869" href="https://news.ycombinator.com/vote?id=28943869&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://apnews.com/article/technology-business-arts-and-entertainment-be48d7582fdd5604664fff33ed81ca80" class="titlelink">Sinclair Broadcast Group identifies data breach</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=apnews.com"><span class="sitestr">apnews.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28943869">8 points</span> by <a href="https://news.ycombinator.com/user?id=xojoc" class="hnuser">xojoc</a> <span class="age" title="2021-10-21T13:12:05"><a href="https://news.ycombinator.com/item?id=28943869">1 hour ago</a></span> <span id="unv_28943869"></span> | <a href="https://news.ycombinator.com/hide?id=28943869&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28943869">1 comment</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28926775"> - <td class="title" valign="top" align="right"><span class="rank">32.</span></td> <td class="votelinks" valign="top"><center><a id="up_28926775" href="https://news.ycombinator.com/vote?id=28926775&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.earlevel.com/main/2002/08/31/a-gentle-introduction-to-the-fft/" class="titlelink">A gentle introduction to the FFT (2002)</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=earlevel.com"><span class="sitestr">earlevel.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28926775">71 points</span> by <a href="https://news.ycombinator.com/user?id=tigerlily" class="hnuser">tigerlily</a> <span class="age" title="2021-10-20T04:31:20"><a href="https://news.ycombinator.com/item?id=28926775">12 hours ago</a></span> <span id="unv_28926775"></span> | <a href="https://news.ycombinator.com/hide?id=28926775&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28926775">14 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28930157"> - <td class="title" valign="top" align="right"><span class="rank">33.</span></td> <td class="votelinks" valign="top"><center><a id="up_28930157" href="https://news.ycombinator.com/vote?id=28930157&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://thebrowser.com/notes/jon-ingold/" class="titlelink">Jon Ingold on translating archeology into video games</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=thebrowser.com"><span class="sitestr">thebrowser.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28930157">36 points</span> by <a href="https://news.ycombinator.com/user?id=nupitalnumber" class="hnuser">nupitalnumber</a> <span class="age" title="2021-10-20T13:04:53"><a href="https://news.ycombinator.com/item?id=28930157">9 hours ago</a></span> <span id="unv_28930157"></span> | <a href="https://news.ycombinator.com/hide?id=28930157&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28930157">4 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28943611"> - <td class="title" valign="top" align="right"><span class="rank">34.</span></td> <td class="votelinks" valign="top"><center><a id="up_28943611" href="https://news.ycombinator.com/vote?id=28943611&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://news.ycombinator.com/item?id=28943611" class="titlelink">Ask HN: How to Sell a Website</a></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28943611">7 points</span> by <a href="https://news.ycombinator.com/user?id=legrisch" class="hnuser">legrisch</a> <span class="age" title="2021-10-21T12:45:35"><a href="https://news.ycombinator.com/item?id=28943611">1 hour ago</a></span> <span id="unv_28943611"></span> | <a href="https://news.ycombinator.com/hide?id=28943611&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28943611">3 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28933391"> - <td class="title" valign="top" align="right"><span class="rank">35.</span></td> <td class="votelinks" valign="top"><center><a id="up_28933391" href="https://news.ycombinator.com/vote?id=28933391&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://iconmap.io/blog" class="titlelink">We analyzed 425k favicons</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=iconmap.io"><span class="sitestr">iconmap.io</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28933391">493 points</span> by <a href="https://news.ycombinator.com/user?id=gurgeous" class="hnuser">gurgeous</a> <span class="age" title="2021-10-20T17:29:03"><a href="https://news.ycombinator.com/item?id=28933391">20 hours ago</a></span> <span id="unv_28933391"></span> | <a href="https://news.ycombinator.com/hide?id=28933391&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28933391">119 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28938551"> - <td class="title" valign="top" align="right"><span class="rank">36.</span></td> <td class="votelinks" valign="top"><center><a id="up_28938551" href="https://news.ycombinator.com/vote?id=28938551&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.science.org/content/article/machu-picchu-was-built-over-major-fault-zones-now-researchers-think-they-know-why" class="titlelink">Machu Picchu was built over major fault zones (2019)</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=science.org"><span class="sitestr">science.org</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28938551">98 points</span> by <a href="https://news.ycombinator.com/user?id=Anon84" class="hnuser">Anon84</a> <span class="age" title="2021-10-21T00:07:54"><a href="https://news.ycombinator.com/item?id=28938551">14 hours ago</a></span> <span id="unv_28938551"></span> | <a href="https://news.ycombinator.com/hide?id=28938551&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28938551">41 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28940507"> - <td class="title" valign="top" align="right"><span class="rank">37.</span></td> <td class="votelinks" valign="top"><center><a id="up_28940507" href="https://news.ycombinator.com/vote?id=28940507&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://brave.com/wp-content/uploads/2021/03/goggles.pdf" class="titlelink">Goggles: Democracy dies in darkness, and so does the Web [pdf]</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=brave.com"><span class="sitestr">brave.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28940507">114 points</span> by <a href="https://news.ycombinator.com/user?id=InvaderFizz" class="hnuser">InvaderFizz</a> <span class="age" title="2021-10-21T05:03:56"><a href="https://news.ycombinator.com/item?id=28940507">9 hours ago</a></span> <span id="unv_28940507"></span> | <a href="https://news.ycombinator.com/hide?id=28940507&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28940507">119 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28933663"> - <td class="title" valign="top" align="right"><span class="rank">38.</span></td> <td class="votelinks" valign="top"><center><a id="up_28933663" href="https://news.ycombinator.com/vote?id=28933663&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://browser.geekbench.com/v5/cpu/10496766" class="titlelink">Apple M1 Max Geekbench Score</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=geekbench.com"><span class="sitestr">geekbench.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28933663">467 points</span> by <a href="https://news.ycombinator.com/user?id=mv9" class="hnuser">mv9</a> <span class="age" title="2021-10-20T17:50:17"><a href="https://news.ycombinator.com/item?id=28933663">20 hours ago</a></span> <span id="unv_28933663"></span> | <a href="https://news.ycombinator.com/hide?id=28933663&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28933663">771 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28933981"> - <td class="title" valign="top" align="right"><span class="rank">39.</span></td> <td class="votelinks" valign="top"><center><a id="up_28933981" href="https://news.ycombinator.com/vote?id=28933981&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.commerce.gov/news/press-releases/2021/10/commerce-tightens-export-controls-items-used-surveillance-private" class="titlelink">U.S. tightens export controls on items used in surveillance of private citizens</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=commerce.gov"><span class="sitestr">commerce.gov</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28933981">275 points</span> by <a href="https://news.ycombinator.com/user?id=transpute" class="hnuser">transpute</a> <span class="age" title="2021-10-20T18:14:33"><a href="https://news.ycombinator.com/item?id=28933981">20 hours ago</a></span> <span id="unv_28933981"></span> | <a href="https://news.ycombinator.com/hide?id=28933981&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28933981">161 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28943645"> - <td class="title" valign="top" align="right"><span class="rank">40.</span></td> <td class="votelinks" valign="top"><center><a id="up_28943645" href="https://news.ycombinator.com/vote?id=28943645&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.wsj.com/articles/wework-set-to-go-public-via-spac-deal-two-years-after-failed-ipo-11634808600" class="titlelink" rel="nofollow">WeWork is trying to go public – again</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=wsj.com"><span class="sitestr">wsj.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28943645">8 points</span> by <a href="https://news.ycombinator.com/user?id=collegeburner" class="hnuser">collegeburner</a> <span class="age" title="2021-10-21T12:49:02"><a href="https://news.ycombinator.com/item?id=28943645">1 hour ago</a></span> <span id="unv_28943645"></span> | <a href="https://news.ycombinator.com/hide?id=28943645&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28943645">2 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28934624"> - <td class="title" valign="top" align="right"><span class="rank">41.</span></td> <td class="votelinks" valign="top"><center><a id="up_28934624" href="https://news.ycombinator.com/vote?id=28934624&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.copetti.org/writings/consoles/playstation-3/" class="titlelink">Playstation 3 Architecture</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=copetti.org"><span class="sitestr">copetti.org</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28934624">362 points</span> by <a href="https://news.ycombinator.com/user?id=bangonkeyboard" class="hnuser">bangonkeyboard</a> <span class="age" title="2021-10-20T18:56:53"><a href="https://news.ycombinator.com/item?id=28934624">19 hours ago</a></span> <span id="unv_28934624"></span> | <a href="https://news.ycombinator.com/hide?id=28934624&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28934624">81 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28929639"> - <td class="title" valign="top" align="right"><span class="rank">42.</span></td> <td class="votelinks" valign="top"><center><a id="up_28929639" href="https://news.ycombinator.com/vote?id=28929639&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://owlpal.substack.com/p/about-that-time-i-had-an-outburst" class="titlelink">About that time I had an outburst during the Y Combinator Interview</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=owlpal.substack.com"><span class="sitestr">owlpal.substack.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28929639">498 points</span> by <a href="https://news.ycombinator.com/user?id=curiousowl" class="hnuser">curiousowl</a> <span class="age" title="2021-10-20T12:03:25"><a href="https://news.ycombinator.com/item?id=28929639">1 day ago</a></span> <span id="unv_28929639"></span> | <a href="https://news.ycombinator.com/hide?id=28929639&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28929639">242 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28938378"> - <td class="title" valign="top" align="right"><span class="rank">43.</span></td> <td class="votelinks" valign="top"><center><a id="up_28938378" href="https://news.ycombinator.com/vote?id=28938378&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.guernicamag.com/one-mans-pest/" class="titlelink" rel="nofollow">One Man's Pest</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=guernicamag.com"><span class="sitestr">guernicamag.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28938378">8 points</span> by <a href="https://news.ycombinator.com/user?id=yimby" class="hnuser">yimby</a> <span class="age" title="2021-10-20T23:47:13"><a href="https://news.ycombinator.com/item?id=28938378">6 hours ago</a></span> <span id="unv_28938378"></span> | <a href="https://news.ycombinator.com/hide?id=28938378&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28938378">discuss</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28926582"> - <td class="title" valign="top" align="right"><span class="rank">44.</span></td> <td class="votelinks" valign="top"><center><a id="up_28926582" href="https://news.ycombinator.com/vote?id=28926582&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://brave.com/search-and-web-discovery/" class="titlelink">Brave Search replaces Google as default search engine in the Brave browser</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=brave.com"><span class="sitestr">brave.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28926582">723 points</span> by <a href="https://news.ycombinator.com/user?id=skellertor" class="hnuser">skellertor</a> <span class="age" title="2021-10-20T03:56:51"><a href="https://news.ycombinator.com/item?id=28926582">1 day ago</a></span> <span id="unv_28926582"></span> | <a href="https://news.ycombinator.com/hide?id=28926582&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28926582">528 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28943866"> - <td class="title" valign="top" align="right"><span class="rank">45.</span></td> <td class="votelinks" valign="top"><center><a id="up_28943866" href="https://news.ycombinator.com/vote?id=28943866&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://twitter.com//rashiq/status/1319346264992026624" class="titlelink" rel="nofollow">I reverse engineered mcdonald's internal API</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=twitter.com/rashiq"><span class="sitestr">twitter.com/rashiq</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28943866">3 points</span> by <a href="https://news.ycombinator.com/user?id=graderjs" class="hnuser">graderjs</a> <span class="age" title="2021-10-21T13:11:46"><a href="https://news.ycombinator.com/item?id=28943866">1 hour ago</a></span> <span id="unv_28943866"></span> | <a href="https://news.ycombinator.com/hide?id=28943866&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28943866">discuss</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28936324"> - <td class="title" valign="top" align="right"><span class="rank">46.</span></td> <td class="votelinks" valign="top"><center><a id="up_28936324" href="https://news.ycombinator.com/vote?id=28936324&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.science.org/doi/10.1126/scisignal.abc4764" class="titlelink">Injury response to DNA damage in live tumor cells promotes antitumor immunity</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=science.org"><span class="sitestr">science.org</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28936324">109 points</span> by <a href="https://news.ycombinator.com/user?id=bcaulfield" class="hnuser">bcaulfield</a> <span class="age" title="2021-10-20T20:48:40"><a href="https://news.ycombinator.com/item?id=28936324">17 hours ago</a></span> <span id="unv_28936324"></span> | <a href="https://news.ycombinator.com/hide?id=28936324&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28936324">5 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28940197"> - <td class="title" valign="top" align="right"><span class="rank">47.</span></td> <td class="votelinks" valign="top"><center><a id="up_28940197" href="https://news.ycombinator.com/vote?id=28940197&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.cowin.gov.in/" class="titlelink">India Counting Down to 1B Doses</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=cowin.gov.in"><span class="sitestr">cowin.gov.in</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28940197">105 points</span> by <a href="https://news.ycombinator.com/user?id=neelkadia" class="hnuser">neelkadia</a> <span class="age" title="2021-10-21T04:17:41"><a href="https://news.ycombinator.com/item?id=28940197">10 hours ago</a></span> <span id="unv_28940197"></span> | <a href="https://news.ycombinator.com/hide?id=28940197&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28940197">78 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28943066"> - <td class="title" valign="top" align="right"><span class="rank">48.</span></td> <td class="votelinks" valign="top"><center><a id="up_28943066" href="https://news.ycombinator.com/vote?id=28943066&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://slate.com/technology/2021/10/tether-crypto-danger-ben-mckenzie.html" class="titlelink" rel="nofollow">Time to get worried about Tether, the “stablecoin” at center of cryptocurrency</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=slate.com"><span class="sitestr">slate.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28943066">6 points</span> by <a href="https://news.ycombinator.com/user?id=RickJWagner" class="hnuser">RickJWagner</a> <span class="age" title="2021-10-21T11:45:09"><a href="https://news.ycombinator.com/item?id=28943066">2 hours ago</a></span> <span id="unv_28943066"></span> | <a href="https://news.ycombinator.com/hide?id=28943066&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28943066">5 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28940258"> - <td class="title" valign="top" align="right"><span class="rank">49.</span></td> <td class="votelinks" valign="top"><center><a id="up_28940258" href="https://news.ycombinator.com/vote?id=28940258&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.alifewithoutlimits.com.au/the-history-of-surveying/" class="titlelink">The History of Surveying</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=alifewithoutlimits.com.au"><span class="sitestr">alifewithoutlimits.com.au</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28940258">20 points</span> by <a href="https://news.ycombinator.com/user?id=barbazoo" class="hnuser">barbazoo</a> <span class="age" title="2021-10-21T04:27:11"><a href="https://news.ycombinator.com/item?id=28940258">9 hours ago</a></span> <span id="unv_28940258"></span> | <a href="https://news.ycombinator.com/hide?id=28940258&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28940258">9 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28921244"> - <td class="title" valign="top" align="right"><span class="rank">50.</span></td> <td class="votelinks" valign="top"><center><a id="up_28921244" href="https://news.ycombinator.com/vote?id=28921244&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.npr.org/2021/10/19/1047303559/fda-hearing-aid-prescription-over-the-counter" class="titlelink">The FDA wants you to be able to buy a hearing aid without a prescription</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=npr.org"><span class="sitestr">npr.org</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28921244">722 points</span> by <a href="https://news.ycombinator.com/user?id=cf100clunk" class="hnuser">cf100clunk</a> <span class="age" title="2021-10-19T17:58:42"><a href="https://news.ycombinator.com/item?id=28921244">1 day ago</a></span> <span id="unv_28921244"></span> | <a href="https://news.ycombinator.com/hide?id=28921244&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28921244">441 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28942594"> - <td class="title" valign="top" align="right"><span class="rank">51.</span></td> <td class="votelinks" valign="top"><center><a id="up_28942594" href="https://news.ycombinator.com/vote?id=28942594&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.pcgamer.com/windows-11-pcs-can-hobble-gaming-performance/" class="titlelink">Windows 11 will hobble gaming performance by default on some prebuilt PCs</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=pcgamer.com"><span class="sitestr">pcgamer.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28942594">13 points</span> by <a href="https://news.ycombinator.com/user?id=DeathArrow" class="hnuser">DeathArrow</a> <span class="age" title="2021-10-21T10:33:39"><a href="https://news.ycombinator.com/item?id=28942594">3 hours ago</a></span> <span id="unv_28942594"></span> | <a href="https://news.ycombinator.com/hide?id=28942594&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28942594">3 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28940705"> - <td class="title" valign="top" align="right"><span class="rank">52.</span></td> <td class="votelinks" valign="top"><center><a id="up_28940705" href="https://news.ycombinator.com/vote?id=28940705&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.gimp.org/news/2021/10/20/gimp-2-99-8-released/" class="titlelink">Development version: GIMP 2.99.8 Released</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=gimp.org"><span class="sitestr">gimp.org</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28940705">19 points</span> by <a href="https://news.ycombinator.com/user?id=pauloxnet" class="hnuser">pauloxnet</a> <span class="age" title="2021-10-21T05:33:20"><a href="https://news.ycombinator.com/item?id=28940705">8 hours ago</a></span> <span id="unv_28940705"></span> | <a href="https://news.ycombinator.com/hide?id=28940705&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28940705">2 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28903383"> - <td class="title" valign="top" align="right"><span class="rank">53.</span></td> <td class="votelinks" valign="top"><center><a id="up_28903383" href="https://news.ycombinator.com/vote?id=28903383&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://mikolaj-kaminski.com/jetbrains-rider-docker-compose-unicodedecodeerror-issue-fix/" class="titlelink">I couldn't debug the code because of my name</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=mikolaj-kaminski.com"><span class="sitestr">mikolaj-kaminski.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28903383">247 points</span> by <a href="https://news.ycombinator.com/user?id=mikasjp" class="hnuser">mikasjp</a> <span class="age" title="2021-10-18T08:40:39"><a href="https://news.ycombinator.com/item?id=28903383">23 hours ago</a></span> <span id="unv_28903383"></span> | <a href="https://news.ycombinator.com/hide?id=28903383&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28903383">268 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28937484"> - <td class="title" valign="top" align="right"><span class="rank">54.</span></td> <td class="votelinks" valign="top"><center><a id="up_28937484" href="https://news.ycombinator.com/vote?id=28937484&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://calbryant.uk/blog/10-ways-to-get-the-best-out-of-openscad/" class="titlelink">Getting the best out of OpenSCAD</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=calbryant.uk"><span class="sitestr">calbryant.uk</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28937484">109 points</span> by <a href="https://news.ycombinator.com/user?id=naggie" class="hnuser">naggie</a> <span class="age" title="2021-10-20T22:13:20"><a href="https://news.ycombinator.com/item?id=28937484">16 hours ago</a></span> <span id="unv_28937484"></span> | <a href="https://news.ycombinator.com/hide?id=28937484&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28937484">52 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28921083"> - <td class="title" valign="top" align="right"><span class="rank">55.</span></td> <td class="votelinks" valign="top"><center><a id="up_28921083" href="https://news.ycombinator.com/vote?id=28921083&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://spectrum.ieee.org/recycled-batteries-good-as-newly-mined" class="titlelink">Study: Recycled Lithium Batteries as Good as Newly Mined</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=ieee.org"><span class="sitestr">ieee.org</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28921083">623 points</span> by <a href="https://news.ycombinator.com/user?id=mpweiher" class="hnuser">mpweiher</a> <span class="age" title="2021-10-19T17:45:07"><a href="https://news.ycombinator.com/item?id=28921083">1 day ago</a></span> <span id="unv_28921083"></span> | <a href="https://news.ycombinator.com/hide?id=28921083&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28921083">179 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28934715"> - <td class="title" valign="top" align="right"><span class="rank">56.</span></td> <td class="votelinks" valign="top"><center><a id="up_28934715" href="https://news.ycombinator.com/vote?id=28934715&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://americasfuture.org/eliminating-gifted-programs-wont-make-education-fair/" class="titlelink">Eliminating gifted programs won’t make education fair</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=americasfuture.org"><span class="sitestr">americasfuture.org</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28934715">180 points</span> by <a href="https://news.ycombinator.com/user?id=paulpauper" class="hnuser">paulpauper</a> <span class="age" title="2021-10-20T19:03:44"><a href="https://news.ycombinator.com/item?id=28934715">19 hours ago</a></span> <span id="unv_28934715"></span> | <a href="https://news.ycombinator.com/hide?id=28934715&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28934715">400 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28939407"> - <td class="title" valign="top" align="right"><span class="rank">57.</span></td> <td class="votelinks" valign="top"><center><a id="up_28939407" href="https://news.ycombinator.com/vote?id=28939407&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://github.com/ToshioCP/Gtk4-tutorial/blob/main/Readme.md" class="titlelink">Gtk4 Tutorial</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=github.com/toshiocp"><span class="sitestr">github.com/toshiocp</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28939407">53 points</span> by <a href="https://news.ycombinator.com/user?id=marcodiego" class="hnuser">marcodiego</a> <span class="age" title="2021-10-21T01:59:18"><a href="https://news.ycombinator.com/item?id=28939407">12 hours ago</a></span> <span id="unv_28939407"></span> | <a href="https://news.ycombinator.com/hide?id=28939407&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28939407">73 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28940334"> - <td class="title" valign="top" align="right"><span class="rank">58.</span></td> <td class="votelinks" valign="top"><center><a id="up_28940334" href="https://news.ycombinator.com/vote?id=28940334&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://obua.com/publications/cosmo-id/3/" class="titlelink" rel="nofollow">Cosmopolitan Identifiers</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=obua.com"><span class="sitestr">obua.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28940334">10 points</span> by <a href="https://news.ycombinator.com/user?id=BeefySwain" class="hnuser">BeefySwain</a> <span class="age" title="2021-10-21T04:39:41"><a href="https://news.ycombinator.com/item?id=28940334">9 hours ago</a></span> <span id="unv_28940334"></span> | <a href="https://news.ycombinator.com/hide?id=28940334&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28940334">2 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28929840"> - <td class="title" valign="top" align="right"><span class="rank">59.</span></td> <td class="votelinks" valign="top"><center><a id="up_28929840" href="https://news.ycombinator.com/vote?id=28929840&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://madned.substack.com/p/a-talk-with-computer-gaming-pioneer" class="titlelink">A talk with Walter Bright about Empire</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=madned.substack.com"><span class="sitestr">madned.substack.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28929840">218 points</span> by <a href="https://news.ycombinator.com/user?id=mad_ned" class="hnuser">mad_ned</a> <span class="age" title="2021-10-20T12:29:16"><a href="https://news.ycombinator.com/item?id=28929840">1 day ago</a></span> <span id="unv_28929840"></span> | <a href="https://news.ycombinator.com/hide?id=28929840&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28929840">86 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="athing" id="28934833"> - <td class="title" valign="top" align="right"><span class="rank">60.</span></td> <td class="votelinks" valign="top"><center><a id="up_28934833" href="https://news.ycombinator.com/vote?id=28934833&how=up&goto=news%3Fp%3D2"><div class="votearrow" title="upvote"></div></a></center></td><td class="title"><a href="https://www.youtube.com/watch?v=NjrYk546uBA" class="titlelink">Bioelektryczność – Polish Robotics (1968) [video]</a><span class="sitebit comhead"> (<a href="https://news.ycombinator.com/from?site=youtube.com"><span class="sitestr">youtube.com</span></a>)</span></td></tr><tr><td colspan="2"></td><td class="subtext"> - <span class="score" id="score_28934833">123 points</span> by <a href="https://news.ycombinator.com/user?id=danielEM" class="hnuser">danielEM</a> <span class="age" title="2021-10-20T19:11:59"><a href="https://news.ycombinator.com/item?id=28934833">19 hours ago</a></span> <span id="unv_28934833"></span> | <a href="https://news.ycombinator.com/hide?id=28934833&goto=news%3Fp%3D2">hide</a> | <a href="https://news.ycombinator.com/item?id=28934833">27 comments</a> </td></tr> - <tr class="spacer" style="height:5px"></tr> - <tr class="morespace" style="height:10px"></tr><tr><td colspan="2"></td><td class="title"><a href="https://news.ycombinator.com/news?p=3" class="morelink" rel="next">More</a></td></tr> - </tbody></table> -</td></tr> -<tr><td><img src="02_files/s.gif" width="0" height="10"><table width="100%" cellspacing="0" cellpadding="1"><tbody><tr><td bgcolor="#ff6600"></td></tr></tbody></table><br><center><span class="yclinks"><a href="https://news.ycombinator.com/newsguidelines.html">Guidelines</a> - | <a href="https://news.ycombinator.com/newsfaq.html">FAQ</a> - | <a href="https://news.ycombinator.com/lists">Lists</a> - | <a href="https://github.com/HackerNews/API">API</a> - | <a href="https://news.ycombinator.com/security.html">Security</a> - | <a href="http://www.ycombinator.com/legal/">Legal</a> - | <a href="http://www.ycombinator.com/apply/">Apply to YC</a> - | <a href="mailto:hn@ycombinator.com">Contact</a></span><br><br><form method="get" action="//hn.algolia.com/">Search: - <input type="text" name="q" size="17" autocorrect="off" spellcheck="false" autocapitalize="none" autocomplete="false"></form> - </center></td></tr> - </tbody></table></center><script type="text/javascript" src="02_files/hn.js"></script> -</body></html>
\ No newline at end of file diff --git a/rushs/evalexpr/hacker_news/news.sed b/rushs/evalexpr/hacker_news/news.sed deleted file mode 100644 index 91b76d6..0000000 --- a/rushs/evalexpr/hacker_news/news.sed +++ /dev/null @@ -1 +0,0 @@ -s/^.*"\(https\?:\/\/.*\)" class="titlelink"\( rel="nofollow"\)\?>\([^<]*\).*$/**\3**\n\1\n/p diff --git a/rushs/evalexpr/hacker_news/output.txt b/rushs/evalexpr/hacker_news/output.txt deleted file mode 100644 index 68cc714..0000000 --- a/rushs/evalexpr/hacker_news/output.txt +++ /dev/null @@ -1,90 +0,0 @@ -**Sinclair Broadcast Group identifies data breach** -https://apnews.com/article/technology-business-arts-and-entertainment-be48d7582fdd5604664fff33ed81ca80 - -**A gentle introduction to the FFT (2002)** -https://www.earlevel.com/main/2002/08/31/a-gentle-introduction-to-the-fft/ - -**Jon Ingold on translating archeology into video games** -https://thebrowser.com/notes/jon-ingold/ - -**Ask HN: How to Sell a Website** -https://news.ycombinator.com/item?id=28943611 - -**We analyzed 425k favicons** -https://iconmap.io/blog - -**Machu Picchu was built over major fault zones (2019)** -https://www.science.org/content/article/machu-picchu-was-built-over-major-fault-zones-now-researchers-think-they-know-why - -**Goggles: Democracy dies in darkness, and so does the Web [pdf]** -https://brave.com/wp-content/uploads/2021/03/goggles.pdf - -**Apple M1 Max Geekbench Score** -https://browser.geekbench.com/v5/cpu/10496766 - -**U.S. tightens export controls on items used in surveillance of private citizens** -https://www.commerce.gov/news/press-releases/2021/10/commerce-tightens-export-controls-items-used-surveillance-private - -**WeWork is trying to go public – again** -https://www.wsj.com/articles/wework-set-to-go-public-via-spac-deal-two-years-after-failed-ipo-11634808600 - -**Playstation 3 Architecture** -https://www.copetti.org/writings/consoles/playstation-3/ - -**About that time I had an outburst during the Y Combinator Interview** -https://owlpal.substack.com/p/about-that-time-i-had-an-outburst - -**One Man's Pest** -https://www.guernicamag.com/one-mans-pest/ - -**Brave Search replaces Google as default search engine in the Brave browser** -https://brave.com/search-and-web-discovery/ - -**I reverse engineered mcdonald's internal API** -https://twitter.com//rashiq/status/1319346264992026624 - -**Injury response to DNA damage in live tumor cells promotes antitumor immunity** -https://www.science.org/doi/10.1126/scisignal.abc4764 - -**India Counting Down to 1B Doses** -https://www.cowin.gov.in/ - -**Time to get worried about Tether, the “stablecoin” at center of cryptocurrency** -https://slate.com/technology/2021/10/tether-crypto-danger-ben-mckenzie.html - -**The History of Surveying** -https://www.alifewithoutlimits.com.au/the-history-of-surveying/ - -**The FDA wants you to be able to buy a hearing aid without a prescription** -https://www.npr.org/2021/10/19/1047303559/fda-hearing-aid-prescription-over-the-counter - -**Windows 11 will hobble gaming performance by default on some prebuilt PCs** -https://www.pcgamer.com/windows-11-pcs-can-hobble-gaming-performance/ - -**Development version: GIMP 2.99.8 Released** -https://www.gimp.org/news/2021/10/20/gimp-2-99-8-released/ - -**I couldn't debug the code because of my name** -https://mikolaj-kaminski.com/jetbrains-rider-docker-compose-unicodedecodeerror-issue-fix/ - -**Getting the best out of OpenSCAD** -https://calbryant.uk/blog/10-ways-to-get-the-best-out-of-openscad/ - -**Study: Recycled Lithium Batteries as Good as Newly Mined** -https://spectrum.ieee.org/recycled-batteries-good-as-newly-mined - -**Eliminating gifted programs won’t make education fair** -https://americasfuture.org/eliminating-gifted-programs-wont-make-education-fair/ - -**Gtk4 Tutorial** -https://github.com/ToshioCP/Gtk4-tutorial/blob/main/Readme.md - -**Cosmopolitan Identifiers** -https://obua.com/publications/cosmo-id/3/ - -**A talk with Walter Bright about Empire** -https://madned.substack.com/p/a-talk-with-computer-gaming-pioneer - -**Bioelektryczność – Polish Robotics (1968) [video]** -https://www.youtube.com/watch?v=NjrYk546uBA - diff --git a/rushs/evalexpr/handling_complex/complex.c b/rushs/evalexpr/handling_complex/complex.c deleted file mode 100644 index 79a10be..0000000 --- a/rushs/evalexpr/handling_complex/complex.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "complex.h" - -#include <stdio.h> - -void print_complex(struct complex a) -{ - printf("complex(%.2f ", a.real); - - if (a.img < 0) - { - printf("- %.2fi", -a.img); - } - else - { - printf("+ %.2fi", a.img); - } - printf(")\n"); -} - -struct complex neg_complex(struct complex a) -{ - struct complex z = { -a.real, -a.img }; - return z; -} - -struct complex add_complex(struct complex a, struct complex b) -{ - struct complex z = { a.real + b.real, a.img + b.img }; - return z; -} - -struct complex sub_complex(struct complex a, struct complex b) -{ - return add_complex(a, neg_complex(b)); -} - -struct complex mul_complex(struct complex a, struct complex b) -{ - struct complex z = { a.real * b.real - a.img * b.img, - a.real * b.img + a.img * b.real }; - return z; -} - -struct complex div_complex(struct complex a, struct complex b) -{ - struct complex z = { - (a.real * b.real + a.img * b.img) / (b.real * b.real + b.img * b.img), - (a.img * b.real - a.real * b.img) / (b.real * b.real + b.img * b.img) - }; - return z; -} diff --git a/rushs/evalexpr/handling_complex/complex.h b/rushs/evalexpr/handling_complex/complex.h deleted file mode 100644 index c562810..0000000 --- a/rushs/evalexpr/handling_complex/complex.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef COMPLEX_H -#define COMPLEX_H - -struct complex -{ - float real; - float img; -}; - -// Print -void print_complex(struct complex a); - -// Operations -struct complex neg_complex(struct complex a); -struct complex add_complex(struct complex a, struct complex b); -struct complex sub_complex(struct complex a, struct complex b); -struct complex mul_complex(struct complex a, struct complex b); -struct complex div_complex(struct complex a, struct complex b); - -#endif /* !COMPLEX_H */ diff --git a/rushs/evalexpr/hanoi/hanoi.c b/rushs/evalexpr/hanoi/hanoi.c deleted file mode 100644 index 6ac2b71..0000000 --- a/rushs/evalexpr/hanoi/hanoi.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <stdio.h> - -void move(unsigned src, unsigned spare, unsigned dst, unsigned n) -{ - if (n == 0) - { - return; - } - - move(src, dst, spare, n - 1); - - printf("%u->%u\n", src, dst); - - move(spare, src, dst, n - 1); -} - -void hanoi(unsigned n) -{ - if (n == 0) - { - return; - } - - move(1, 2, 3, n); -} - -int main(void) -{ - hanoi(3); - return 0; -} diff --git a/rushs/evalexpr/hash_map/hash.c b/rushs/evalexpr/hash_map/hash.c deleted file mode 100644 index 434616f..0000000 --- a/rushs/evalexpr/hash_map/hash.c +++ /dev/null @@ -1,13 +0,0 @@ -#include <stddef.h> - -size_t hash(const char *key) -{ - size_t i = 0; - size_t hash = 0; - - for (i = 0; key[i] != '\0'; ++i) - hash += key[i]; - hash += i; - - return hash; -} diff --git a/rushs/evalexpr/hash_map/hash_map.c b/rushs/evalexpr/hash_map/hash_map.c deleted file mode 100644 index 4690e8b..0000000 --- a/rushs/evalexpr/hash_map/hash_map.c +++ /dev/null @@ -1,177 +0,0 @@ -#include "hash_map.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -struct hash_map *hash_map_init(size_t size) -{ - struct hash_map *new; - if ((new = malloc(sizeof(struct hash_map))) == NULL) - { - return NULL; - } - if ((new->data = malloc(size * sizeof(struct pair_list *))) == NULL) - { - return NULL; - } - new->size = size; - - for (size_t i = 0; i < size; i++) - { - new->data[i] = NULL; - } - - return new; -} - -bool hash_map_insert(struct hash_map *hash_map, const char *key, char *value, - bool *updated) -{ - if (hash_map == NULL || updated == NULL || hash_map->size == 0) - { - return false; - } - *updated = false; - - size_t h = hash(key); - if (h >= hash_map->size) - { - h %= hash_map->size; - } - - struct pair_list *new = malloc(sizeof(struct pair_list)); - if (new == NULL) - { - return false; - } - - for (struct pair_list *p = hash_map->data[h]; p; p = p->next) - { - if (strcmp(p->key, key) == 0) - { - p->value = value; - *updated = true; - free(new); - return true; - } - } - - new->next = hash_map->data[h]; - new->key = key; - new->value = value; - hash_map->data[h] = new; - return true; -} - -void hash_map_free(struct hash_map *hash_map) -{ - if (hash_map == NULL) - { - return; - } - - if (hash_map->data == NULL) - { - free(hash_map); - return; - } - - for (size_t i = 0; i < hash_map->size; i++) - { - while (hash_map->data[i]) - { - struct pair_list *tmp = hash_map->data[i]->next; - free(hash_map->data[i]); - hash_map->data[i] = tmp; - } - } - - free(hash_map->data); - free(hash_map); -} - -void hash_map_dump(struct hash_map *hash_map) -{ - if (hash_map == NULL || hash_map->data == NULL) - { - return; - } - - for (size_t i = 0; i < hash_map->size; i++) - { - if (hash_map->data[i] != NULL) - { - printf("%s: %s", hash_map->data[i]->key, hash_map->data[i]->value); - for (struct pair_list *p = hash_map->data[i]->next; p; p = p->next) - { - printf(", %s: %s", p->key, p->value); - } - printf("\n"); - } - } -} - -const char *hash_map_get(const struct hash_map *hash_map, const char *key) -{ - if (hash_map == NULL || hash_map->data == NULL || hash_map->size == 0) - { - return NULL; - } - - size_t h = hash(key); - if (h >= hash_map->size) - { - h %= hash_map->size; - } - struct pair_list *p; - for (p = hash_map->data[h]; p && strcmp(p->key, key) != 0; p = p->next) - { - continue; - } - - if (p) - { - return p->value; - } - return NULL; -} - -bool hash_map_remove(struct hash_map *hash_map, const char *key) -{ - if (hash_map == NULL || hash_map->data == NULL || hash_map->size == 0) - { - return false; - } - - size_t h = hash(key); - if (h >= hash_map->size) - { - h %= hash_map->size; - } - if (hash_map->data[h] == NULL) - { - return false; - } - - if (strcmp(hash_map->data[h]->key, key) == 0) - { - struct pair_list *tmp = hash_map->data[h]->next; - free(hash_map->data[h]); - hash_map->data[h] = tmp; - return true; - } - - struct pair_list *p; - for (p = hash_map->data[h]; p->next; p = p->next) - { - if (strcmp(p->next->key, key) == 0) - { - struct pair_list *tmp = p->next->next; - free(p->next); - p->next = tmp; - return true; - } - } - return false; -} diff --git a/rushs/evalexpr/hash_map/hash_map.h b/rushs/evalexpr/hash_map/hash_map.h deleted file mode 100644 index c731eab..0000000 --- a/rushs/evalexpr/hash_map/hash_map.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef HASH_MAP_H -#define HASH_MAP_H - -#include <stdbool.h> -#include <stddef.h> - -struct pair_list -{ - const char *key; - char *value; - struct pair_list *next; -}; - -struct hash_map -{ - struct pair_list **data; - size_t size; -}; - -size_t hash(const char *str); -struct hash_map *hash_map_init(size_t size); -bool hash_map_insert(struct hash_map *hash_map, const char *key, char *value, - bool *updated); -void hash_map_free(struct hash_map *hash_map); -void hash_map_dump(struct hash_map *hash_map); -const char *hash_map_get(const struct hash_map *hash_map, const char *key); -bool hash_map_remove(struct hash_map *hash_map, const char *key); - -#endif /* ! HASH_MAP_H */ diff --git a/rushs/evalexpr/heap/Makefile b/rushs/evalexpr/heap/Makefile deleted file mode 100644 index 2ed972b..0000000 --- a/rushs/evalexpr/heap/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -CC = gcc -CFLAGS = -Wall -Werror -Wvla -Wextra -std=c99 -pedantic -SRC = add.c del.c print.c pop.c create.c -OBJ = $(SRC:.c=.o) - -.PHONY: library clean - -library: $(OBJ) - ar csr libheap.a $(OBJ) - -$(OBJ): $(SRC) - -clean: - $(RM) libheap.a $(OBJ) diff --git a/rushs/evalexpr/heap/add.c b/rushs/evalexpr/heap/add.c deleted file mode 100644 index 78a4db8..0000000 --- a/rushs/evalexpr/heap/add.c +++ /dev/null @@ -1,39 +0,0 @@ -#include <stdlib.h> - -#include "heap.h" - -void heapify(int arr[], int n, int i) -{ - if (i == 0) - return; - int parent = (i - 1) / 2; - if (parent >= 0) - { - if (arr[i] > arr[parent]) - { - int tmp = arr[i]; - arr[i] = arr[parent]; - arr[parent] = tmp; - heapify(arr, n, parent); - } - } -} - -void add(struct heap *heap, int val) -{ - if (heap->size == heap->capacity) - { - heap->array = realloc(heap->array, heap->capacity * 2 * sizeof(int)); - if (heap->array == NULL) - { - free(heap); - return; - } - heap->capacity *= 2; - } - - heap->array[heap->size] = val; - heap->size++; - - heapify(heap->array, heap->size, heap->size - 1); -} diff --git a/rushs/evalexpr/heap/create.c b/rushs/evalexpr/heap/create.c deleted file mode 100644 index f0675ad..0000000 --- a/rushs/evalexpr/heap/create.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <stdlib.h> - -#include "heap.h" - -struct heap *create_heap(void) -{ - struct heap *res = malloc(sizeof(struct heap)); - if (res == NULL) - return NULL; - res->size = 0; - res->capacity = 8; - res->array = malloc(8 * sizeof(int)); - if (res->array == NULL) - { - free(res); - return NULL; - } - return res; -} diff --git a/rushs/evalexpr/heap/del.c b/rushs/evalexpr/heap/del.c deleted file mode 100644 index 4d2ae35..0000000 --- a/rushs/evalexpr/heap/del.c +++ /dev/null @@ -1,9 +0,0 @@ -#include <stdlib.h> - -#include "heap.h" - -void delete_heap(struct heap *heap) -{ - free(heap->array); - free(heap); -} diff --git a/rushs/evalexpr/heap/heap.h b/rushs/evalexpr/heap/heap.h deleted file mode 100644 index 085f436..0000000 --- a/rushs/evalexpr/heap/heap.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef HEAP_H -#define HEAP_H - -// size_t -#include <stddef.h> - -struct heap -{ - size_t size; - size_t capacity; - int *array; -}; - -struct heap *create_heap(void); -void add(struct heap *heap, int val); -int pop(struct heap *heap); -void delete_heap(struct heap *heap); -void print_heap(const struct heap *heap); - -#endif /* !HEAP_H */ diff --git a/rushs/evalexpr/heap/pop.c b/rushs/evalexpr/heap/pop.c deleted file mode 100644 index 55e063f..0000000 --- a/rushs/evalexpr/heap/pop.c +++ /dev/null @@ -1,49 +0,0 @@ -#include <assert.h> -#include <stdlib.h> - -#include "heap.h" - -void heapify2(struct heap *h, size_t i) -{ - size_t max = i; - if (2 * i + 1 < h->size && h->array[2 * i + 1] > h->array[max]) - max = 2 * i + 1; - if (2 * i + 2 < h->size && h->array[2 * i + 2] > h->array[max]) - max = 2 * i + 2; - if (max != i) - { - int tmp = h->array[i]; - h->array[i] = h->array[max]; - h->array[max] = tmp; - heapify2(h, max); - } -} - -int pop(struct heap *heap) -{ - assert(heap->size != 0); - if (heap->size == 1) - { - heap->size--; - return heap->array[0]; - } - else - { - int res = heap->array[0]; - heap->array[0] = heap->array[heap->size - 1]; - heap->size--; - heapify2(heap, 0); - if (heap->size < heap->capacity / 2 && heap->capacity > 8) - { - heap->array = - realloc(heap->array, (heap->capacity / 2) * sizeof(int)); - if (heap->array == NULL) - { - free(heap); - return -1; - } - heap->capacity /= 2; - } - return res; - } -} diff --git a/rushs/evalexpr/heap/print.c b/rushs/evalexpr/heap/print.c deleted file mode 100644 index f5bbe95..0000000 --- a/rushs/evalexpr/heap/print.c +++ /dev/null @@ -1,27 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include "heap.h" - -void print_rec(const struct heap *h, size_t i, int root) -{ - if (i >= h->size) - return; - if (!root) - printf(" "); - else - root = 0; - printf("%d", h->array[i]); - if (i == h->size - 1) - { - return; - } - print_rec(h, i * 2 + 1, root); - print_rec(h, i * 2 + 2, root); -} - -void print_heap(const struct heap *heap) -{ - print_rec(heap, 0, 1); - printf("\n"); -} diff --git a/rushs/evalexpr/hello_friends/hello.c b/rushs/evalexpr/hello_friends/hello.c deleted file mode 100644 index 63df2f1..0000000 --- a/rushs/evalexpr/hello_friends/hello.c +++ /dev/null @@ -1,13 +0,0 @@ -#include <stdio.h> - -int main(int argc, char **argv) -{ - if (argc == 1) - printf("Hello World!\n"); - else - for (int i = 1; i < argc; i++) - { - printf("Hello %s!\n", argv[i]); - } - return 0; -} diff --git a/rushs/evalexpr/hello_world/hello.c b/rushs/evalexpr/hello_world/hello.c deleted file mode 100644 index 0681c18..0000000 --- a/rushs/evalexpr/hello_world/hello.c +++ /dev/null @@ -1,7 +0,0 @@ -#include <stdio.h> - -int main(void) -{ - puts("Hello World!"); - return 0; -} diff --git a/rushs/evalexpr/hello_world_shebang/hello.sh b/rushs/evalexpr/hello_world_shebang/hello.sh deleted file mode 100755 index 8dc4f64..0000000 --- a/rushs/evalexpr/hello_world_shebang/hello.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo "Hello World!" diff --git a/rushs/evalexpr/hill_array/hill_array.c b/rushs/evalexpr/hill_array/hill_array.c deleted file mode 100644 index 14d3a85..0000000 --- a/rushs/evalexpr/hill_array/hill_array.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "hill_array.h" - -int top_of_the_hill(int tab[], size_t len) -{ - if (len == 0) - { - return -1; - } - - int top = 0; - size_t i = 0; - - while (i + 1 < len && tab[i] <= tab[i + 1]) - { - if (tab[i] < 0 || tab[i + 1] < 0) - { - return -1; - } - if (tab[i] != tab[i + 1]) - { - top = i + 1; - } - i++; - } - - while (i + 1 < len && tab[i] >= tab[i + 1]) - { - if (tab[i] < 0 || tab[i + 1] < 0) - { - return -1; - } - i++; - } - - if (i + 1 == len) - { - return top; - } - else - { - return -1; - } -} diff --git a/rushs/evalexpr/hill_array/hill_array.h b/rushs/evalexpr/hill_array/hill_array.h deleted file mode 100644 index 3152c19..0000000 --- a/rushs/evalexpr/hill_array/hill_array.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef HILL_ARRAY_H -#define HILL_ARRAY_H - -#include <stddef.h> - -int top_of_the_hill(int tab[], size_t len); - -#endif /* !HILL_ARRAY_H */ diff --git a/rushs/evalexpr/insertion_sort/insertion_sort.c b/rushs/evalexpr/insertion_sort/insertion_sort.c deleted file mode 100644 index 2edd195..0000000 --- a/rushs/evalexpr/insertion_sort/insertion_sort.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "insertion_sort.h" - -#include <stddef.h> - -void insertion_sort(void **array, f_cmp comp) -{ - if (array == NULL || *array == NULL) - { - return; - } - for (int i = 1; array[i]; i++) - { - for (int j = i; j > 0 && comp(array[j - 1], array[j]) > 0; j--) - { - void *tmp = array[j]; - array[j] = array[j - 1]; - array[j - 1] = tmp; - } - } -} diff --git a/rushs/evalexpr/insertion_sort/insertion_sort.h b/rushs/evalexpr/insertion_sort/insertion_sort.h deleted file mode 100644 index a7ba674..0000000 --- a/rushs/evalexpr/insertion_sort/insertion_sort.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef INSERTION_SORT_H -#define INSERTION_SORT_H - -typedef int (*f_cmp)(const void *, const void *); - -void insertion_sort(void **array, f_cmp comp); - -#endif /* ! INSERTION_SORT_H */ diff --git a/rushs/evalexpr/inside/inside.sh b/rushs/evalexpr/inside/inside.sh deleted file mode 100755 index c6872fa..0000000 --- a/rushs/evalexpr/inside/inside.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -if [ $# -ne 1 ]; then - echo Sorry, expected 1 argument but $# were passed - exit 1 -fi - -if [ -f $1 ]; then - cat $1 - exit 0 -else - echo "$1: - is not a valid file" - exit 2 -fi diff --git a/rushs/evalexpr/inside_noif/inside_noif.sh b/rushs/evalexpr/inside_noif/inside_noif.sh deleted file mode 100755 index d4ed8c9..0000000 --- a/rushs/evalexpr/inside_noif/inside_noif.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -[ $# -ne 1 ] && echo Sorry, expected 1 argument but $# were passed && exit 1 - -[ -f $1 ] && cat $1 && exit 0 || echo "$1: - is not a valid file" && exit 2 diff --git a/rushs/evalexpr/int_palindrome/int_palindrome.c b/rushs/evalexpr/int_palindrome/int_palindrome.c deleted file mode 100644 index 6d6847f..0000000 --- a/rushs/evalexpr/int_palindrome/int_palindrome.c +++ /dev/null @@ -1,18 +0,0 @@ -int int_palindrome(int n) -{ - if (n < 0) - { - return 0; - } - - int reversed = 0; - int m = n; - - while (m > 0) - { - reversed = reversed * 10 + m % 10; - m /= 10; - } - - return n == reversed; -} diff --git a/rushs/evalexpr/int_sqrt/int_sqrt.c b/rushs/evalexpr/int_sqrt/int_sqrt.c deleted file mode 100644 index 4b2e5db..0000000 --- a/rushs/evalexpr/int_sqrt/int_sqrt.c +++ /dev/null @@ -1,20 +0,0 @@ -int int_sqrt(int n) -{ - if (n < 0) - { - return -1; - } - - if (n == 0 || n == 1) - { - return n; - } - - int i; - for (i = 1; i * i < n; i++) - { - continue; - } - - return i - (i * i != n); -} diff --git a/rushs/evalexpr/io_count_words/count_words.c b/rushs/evalexpr/io_count_words/count_words.c deleted file mode 100644 index 8b8c9a5..0000000 --- a/rushs/evalexpr/io_count_words/count_words.c +++ /dev/null @@ -1,33 +0,0 @@ -#include <stdio.h> - -int count_words(const char *file_in) -{ - if (file_in == NULL) - { - return -1; - } - - FILE *f = fopen(file_in, "r"); - if (f == NULL) - { - return -1; - } - - int word = 0; - int count = 0; - int c; - while ((c = fgetc(f)) != EOF) - { - if ((c == ' ' || c == '\n' || c == '\t') && word == 1) - { - word = 0; - } - if (c != ' ' && c != '\n' && c != '\t' && word == 0) - { - word = 1; - count++; - } - } - - return count; -} diff --git a/rushs/evalexpr/io_merge_files/merge_files.c b/rushs/evalexpr/io_merge_files/merge_files.c deleted file mode 100644 index 26ac9cf..0000000 --- a/rushs/evalexpr/io_merge_files/merge_files.c +++ /dev/null @@ -1,31 +0,0 @@ -#define _POSIX_C_SOURCE 200809L - -#include <stdio.h> - -int merge_files(const char *file_1, const char *file_2) -{ - FILE *a = fopen(file_1, "a"); - if (a == NULL) - { - return -1; - } - FILE *r = fopen(file_2, "r"); - if (r == NULL) - { - return -1; - } - - int c; - while ((c = fgetc(r)) != EOF) - { - if (fputc(c, a) == EOF) - { - return -1; - } - } - - fclose(a); - fclose(r); - - return 0; -} diff --git a/rushs/evalexpr/io_replace_line/replace_line.c b/rushs/evalexpr/io_replace_line/replace_line.c deleted file mode 100644 index 7fd0e2a..0000000 --- a/rushs/evalexpr/io_replace_line/replace_line.c +++ /dev/null @@ -1,50 +0,0 @@ -#define _POSIX_C_SOURCE 200809L - -#include <stdio.h> -#include <stdlib.h> - -int replace_line(const char *file_in, const char *file_out, const char *content, - int n) -{ - FILE *a = fopen(file_out, "w"); - if (a == NULL) - { - return -1; - } - FILE *r = fopen(file_in, "r"); - if (r == NULL) - { - return -1; - } - - char *buf = NULL; - ssize_t e; - int l = 0; - size_t count = 0; - while ((e = getline(&buf, &count, r)) != 0 && e != -1) - { - if (l == n) - { - if (fputs(content, a) == EOF) - { - free(buf); - return -1; - } - } - else - { - if (fputs(buf, a) == EOF) - { - free(buf); - return -1; - } - } - l++; - } - - fclose(a); - fclose(r); - free(buf); - - return 0; -} diff --git a/rushs/evalexpr/levenshtein/levenshtein.c b/rushs/evalexpr/levenshtein/levenshtein.c deleted file mode 100644 index 4da9397..0000000 --- a/rushs/evalexpr/levenshtein/levenshtein.c +++ /dev/null @@ -1,72 +0,0 @@ -#include "levenshtein.h" - -#include <stdio.h> - -size_t max(size_t a, size_t b) -{ - if (a >= b) - { - return a; - } - return b; -} - -size_t min(size_t a, size_t b) -{ - if (a <= b) - { - return a; - } - return b; -} - -size_t min_3(size_t a, size_t b, size_t c) -{ - if (a <= b) - { - if (a <= c) - { - return a; - } - return c; - } - else - { - if (b <= c) - { - return b; - } - return c; - } -} - -size_t my_strlen(const char *s) -{ - size_t i; - for (i = 0; s[i]; i++) - { - continue; - } - return i; -} - -size_t levenshtein(const char *s1, const char *s2) -{ - size_t l1 = my_strlen(s1); - size_t l2 = my_strlen(s2); - if (min(l1, l2) == 0) - { - return max(l1, l2); - } - - if (s1[0] == s2[0]) - { - return levenshtein(s1 + 1, s2 + 1); - } - - size_t lev1 = levenshtein(s1 + 1, s2); - size_t lev2 = levenshtein(s1, s2 + 1); - size_t lev3 = levenshtein(s1 + 1, s2 + 1); - - return 1 + min_3(lev1, lev2, lev3); -} diff --git a/rushs/evalexpr/levenshtein/levenshtein.h b/rushs/evalexpr/levenshtein/levenshtein.h deleted file mode 100644 index 70a5a7b..0000000 --- a/rushs/evalexpr/levenshtein/levenshtein.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef LEVENSHTEIN_H -#define LEVENSHTEIN_H - -#include <stddef.h> - -size_t levenshtein(const char *s1, const char *s2); - -#endif /* !LEVENSHTEIN_H */ diff --git a/rushs/evalexpr/main.c b/rushs/evalexpr/main.c deleted file mode 100644 index 4062426..0000000 --- a/rushs/evalexpr/main.c +++ /dev/null @@ -1,15 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -//#include "traffic_lights/traffic_lights.h" -unsigned char rol(unsigned char value, unsigned char roll); - -int main(void) -{ - unsigned char l1 = 0b01010101; - unsigned char l2 = 3; - - printf("l1: %b", rol(l1, l2)); - - return 0; -} diff --git a/rushs/evalexpr/my_abs/my_abs.c b/rushs/evalexpr/my_abs/my_abs.c deleted file mode 100644 index fc89d2f..0000000 --- a/rushs/evalexpr/my_abs/my_abs.c +++ /dev/null @@ -1,11 +0,0 @@ -int my_abs(int n) -{ - if (n < 0) - { - return -n; - } - else - { - return n; - } -} diff --git a/rushs/evalexpr/my_atoi/my_atoi.c b/rushs/evalexpr/my_atoi/my_atoi.c deleted file mode 100644 index ca185a5..0000000 --- a/rushs/evalexpr/my_atoi/my_atoi.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "my_atoi.h" - -int my_atoi(const char *str) -{ - int res = 0; - - // str error check - if (str == NULL || *str == '0') - { - return 0; - } - - // trim whitespaces - for (; *str && *str == ' '; str++) - { - continue; - } - - // move to end of str - size_t l; - for (l = 0; str[l]; l++) - { - continue; - } - l--; - - // prepare for calculations - int factor = 1; - - // actual conversion of up to the second element of str (potential sign) - for (; l > 0; l--) - { - char val = str[l]; - if (val < '0' || val > '9') - { - return 0; - } - val -= '0'; - res += val * factor; - - factor *= 10; - } - - // l should be 0 by now - if (str[l] == '-') - { - return -res; - } - else if (str[l] != '+') - { - int val = str[l]; - if (val < '0' || val > '9') - { - return 0; - } - val -= '0'; - return res + val * factor; - } - - return res; -} diff --git a/rushs/evalexpr/my_atoi/my_atoi.h b/rushs/evalexpr/my_atoi/my_atoi.h deleted file mode 100644 index b520d09..0000000 --- a/rushs/evalexpr/my_atoi/my_atoi.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MY_ATOI_H -#define MY_ATOI_H - -#include <stddef.h> - -int my_atoi(const char *str); - -#endif /* ! MY_ATOI_H */ diff --git a/rushs/evalexpr/my_atoi_base/my_atoi_base.c b/rushs/evalexpr/my_atoi_base/my_atoi_base.c deleted file mode 100644 index 46b4560..0000000 --- a/rushs/evalexpr/my_atoi_base/my_atoi_base.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "my_atoi_base.h" - -int val_in_base(char c, const char *base) -{ - size_t i; - for (i = 0; base[i] && base[i] != c; i++) - { - continue; - } - - if (base[i]) - { - return i; - } - - return -1; -} - -int base_size(const char *base) -{ - int res; - for (res = 0; base[res]; res++) - { - continue; - } - return res; -} - -int my_atoi_base(const char *str, const char *base) -{ - int res = 0; - - // str error check - if (str == NULL || *str == '0') - { - return 0; - } - - // trim whitespaces - for (; *str && *str == ' '; str++) - { - continue; - } - - // move to end of str - size_t l; - for (l = 0; str[l]; l++) - { - continue; - } - l--; - - // prepare for calculations - int b = base_size(base); - int factor = 1; - - // actual conversion of up to the second element of str (potential sign) - for (; l > 0; l--) - { - int val = val_in_base(str[l], base); - if (val == -1) - { - return 0; - } - res += val * factor; - - factor *= b; - } - - // l should be 0 by now - if (str[l] == '-') - { - return -res; - } - else if (str[l] != '+') - { - int val = val_in_base(str[l], base); - if (val == -1) - { - return 0; - } - return res + val * factor; - } - - return res; -} diff --git a/rushs/evalexpr/my_atoi_base/my_atoi_base.h b/rushs/evalexpr/my_atoi_base/my_atoi_base.h deleted file mode 100644 index 296ae23..0000000 --- a/rushs/evalexpr/my_atoi_base/my_atoi_base.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MY_ATOI_BASE_H -#define MY_ATOI_BASE_H - -#include <stddef.h> - -int my_atoi_base(const char *str, const char *base); - -#endif /* ! MY_ATOI_BASE_H */ diff --git a/rushs/evalexpr/my_bc/my_bc.sh b/rushs/evalexpr/my_bc/my_bc.sh deleted file mode 100755 index f675838..0000000 --- a/rushs/evalexpr/my_bc/my_bc.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -[ -n "$1" ] && echo "$(($1))" && exit 0 - -while IFS='' read -r line; do - [ -z "$line" ] && exit 0 || echo "$(($line))" -done diff --git a/rushs/evalexpr/my_c_tail/main.c b/rushs/evalexpr/my_c_tail/main.c deleted file mode 100644 index ba33337..0000000 --- a/rushs/evalexpr/my_c_tail/main.c +++ /dev/null @@ -1,10 +0,0 @@ -#include <stdlib.h> - -#include "my_c_tail.h" - -int main(int argc, char *argv[]) -{ - if (argc > 1) - stdintail(atoi(argv[1])); - return 0; -} diff --git a/rushs/evalexpr/my_c_tail/my_c_tail.c b/rushs/evalexpr/my_c_tail/my_c_tail.c deleted file mode 100644 index 790240c..0000000 --- a/rushs/evalexpr/my_c_tail/my_c_tail.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "my_c_tail.h"
-
-#include <stdlib.h>
-#include <unistd.h>
-
-void stdintail(unsigned int n)
-{
- char **lines = calloc(2000, sizeof(char *));
- lines[0] = malloc(350 * sizeof(char));
- size_t m = 0;
- char c;
- size_t i = 0;
- while (read(STDIN_FILENO, &c, 1))
- {
- if (c == '\n')
- {
- lines[m][i] = '\0';
- lines[++m] = malloc(350 * sizeof(char));
- i = 0;
- }
- else
- {
- lines[m][i++] = c;
- }
- }
-
- size_t j;
- if (m > n)
- {
- for (size_t i = 0; i < m - n; i++)
- free(lines[i]);
- j = m - n;
- }
- else
- j = 0;
-
- for (; j < m; j++)
- {
- for (size_t i = 0; lines[j][i]; i++)
- write(STDOUT_FILENO, &(lines[j][i]), 1);
- write(STDOUT_FILENO, "\n", 1);
- free(lines[j]);
- }
- free(lines[m]);
- free(lines);
-}
diff --git a/rushs/evalexpr/my_c_tail/my_c_tail.h b/rushs/evalexpr/my_c_tail/my_c_tail.h deleted file mode 100644 index 172c844..0000000 --- a/rushs/evalexpr/my_c_tail/my_c_tail.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MY_C_TAIL_H -#define MY_C_TAIL_H - -void stdintail(unsigned int n); - -#endif // MY_C_TAIL_H diff --git a/rushs/evalexpr/my_calloc/my_calloc.c b/rushs/evalexpr/my_calloc/my_calloc.c deleted file mode 100644 index 5a2f7f2..0000000 --- a/rushs/evalexpr/my_calloc/my_calloc.c +++ /dev/null @@ -1,11 +0,0 @@ -#include <stdlib.h> - -void *my_calloc(size_t n, size_t size) -{ - char *res = malloc(n * size); - for (size_t i = 0; i < n * size; i++) - { - res[i] = 0; - } - return res; -} diff --git a/rushs/evalexpr/my_calloc/my_calloc.h b/rushs/evalexpr/my_calloc/my_calloc.h deleted file mode 100644 index 44bf9a2..0000000 --- a/rushs/evalexpr/my_calloc/my_calloc.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MY_CALLOC_H -#define MY_CALLOC_H - -#include <stdlib.h> - -void *my_calloc(size_t n, size_t size); - -#endif /* ! MY_CALLOC_H */ diff --git a/rushs/evalexpr/my_file/my_file.sh b/rushs/evalexpr/my_file/my_file.sh deleted file mode 100755 index 93c0c20..0000000 --- a/rushs/evalexpr/my_file/my_file.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -for arg; do - if [ -f "$arg" ]; then - echo $arg: file - elif [ -d "$arg" ]; then - echo $arg: directory - else - echo $arg: unknown - fi -done diff --git a/rushs/evalexpr/my_first_variable/create.sh b/rushs/evalexpr/my_first_variable/create.sh deleted file mode 100755 index d9264db..0000000 --- a/rushs/evalexpr/my_first_variable/create.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -my_local_frais="Javotte" - -echo My frais is $my_local_frais diff --git a/rushs/evalexpr/my_first_variable/edit.sh b/rushs/evalexpr/my_first_variable/edit.sh deleted file mode 100755 index e47e0c3..0000000 --- a/rushs/evalexpr/my_first_variable/edit.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -my_local_frais="Javotte" - -echo My frais is $my_local_frais - -my_local_frais="Pulpa" - -echo My frais is now $my_local_frais diff --git a/rushs/evalexpr/my_first_variable/use.sh b/rushs/evalexpr/my_first_variable/use.sh deleted file mode 100755 index f9d462e..0000000 --- a/rushs/evalexpr/my_first_variable/use.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo "My frais is $MY_ENV_FRAIS" diff --git a/rushs/evalexpr/my_itoa/my_itoa.c b/rushs/evalexpr/my_itoa/my_itoa.c deleted file mode 100644 index cbb6f73..0000000 --- a/rushs/evalexpr/my_itoa/my_itoa.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "my_itoa.h" - -char *my_itoa(int value, char *s) -{ - if (value == 0) - { - s[0] = '0'; - s[1] = '\0'; - return s; - } - char *head = s; - if (value < 0) - { - s[0] = '-'; - s++; - value = -value; - } - - // count numbers - int t = value; - int n = 0; - while (t > 0) - { - t /= 10; - n++; - } - - // n = number count - s[n] = '\0'; - n--; - for (; n >= 0; n--) - { - s[n] = value % 10 + '0'; - value /= 10; - } - - return head; -} diff --git a/rushs/evalexpr/my_itoa/my_itoa.h b/rushs/evalexpr/my_itoa/my_itoa.h deleted file mode 100644 index 8e84c72..0000000 --- a/rushs/evalexpr/my_itoa/my_itoa.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MY_ITOA_H -#define MY_ITOA_H - -char *my_itoa(int value, char *s); - -#endif /* ! MY_ITOA_H */ diff --git a/rushs/evalexpr/my_itoa_base/my_itoa_base.c b/rushs/evalexpr/my_itoa_base/my_itoa_base.c deleted file mode 100644 index 29b3042..0000000 --- a/rushs/evalexpr/my_itoa_base/my_itoa_base.c +++ /dev/null @@ -1,49 +0,0 @@ -#include "my_itoa_base.h" - -int base_count(const char *base) -{ - int i; - for (i = 0; base[i]; i++) - { - continue; - } - return i; -} - -char *my_itoa_base(int n, char *s, const char *base) -{ - if (n == 0) - { - s[0] = base[0]; - s[1] = '\0'; - return s; - } - char *head = s; - if (n < 0) - { - s[0] = '-'; - s++; - n = -n; - } - - // count numbers - int t = n; - int m = 0; - int b = base_count(base); - while (t > 0) - { - t /= b; - m++; - } - - // n = number count - s[m] = '\0'; - m--; - for (; m >= 0; m--) - { - s[m] = base[n % b]; - n /= b; - } - - return head; -} diff --git a/rushs/evalexpr/my_itoa_base/my_itoa_base.h b/rushs/evalexpr/my_itoa_base/my_itoa_base.h deleted file mode 100644 index 0be6314..0000000 --- a/rushs/evalexpr/my_itoa_base/my_itoa_base.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MY_ITOA_BASE_H -#define MY_ITOA_BASE_H - -char *my_itoa_base(int n, char *s, const char *base); - -#endif /* ! MY_ITOA_BASE_H */ diff --git a/rushs/evalexpr/my_memcmp/my_memcmp.c b/rushs/evalexpr/my_memcmp/my_memcmp.c deleted file mode 100644 index d498360..0000000 --- a/rushs/evalexpr/my_memcmp/my_memcmp.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "my_memcmp.h" - -int my_memcmp(const void *s1, const void *s2, size_t num) -{ - if (num == 0) - { - return 0; - } - const unsigned char *a = s1; - const unsigned char *b = s2; - - for (; num - 1 && *a == *b; a++, b++, num--) - { - continue; - } - - return *a - *b; -} diff --git a/rushs/evalexpr/my_memcmp/my_memcmp.h b/rushs/evalexpr/my_memcmp/my_memcmp.h deleted file mode 100644 index d17cbe6..0000000 --- a/rushs/evalexpr/my_memcmp/my_memcmp.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MY_MEMCMP_H -#define MY_MEMCMP_H - -#include <stddef.h> - -int my_memcmp(const void *s1, const void *s2, size_t num); - -#endif /* !MY_MEMCMP_H */ diff --git a/rushs/evalexpr/my_memcpy/my_memcpy.c b/rushs/evalexpr/my_memcpy/my_memcpy.c deleted file mode 100644 index a6a48d4..0000000 --- a/rushs/evalexpr/my_memcpy/my_memcpy.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "my_memcpy.h" - -void *my_memcpy(void *dest, const void *source, size_t num) -{ - char *d = dest; - const char *s = source; - if (dest > source) // reverse array - { - size_t l = num; - for (; l > 0; l--) - { - d[l - 1] = s[l - 1]; - } - } - else - { - for (size_t i = 0; i < num; i++) - { - d[i] = s[i]; - } - } - return dest; -} - -int main(void) -{ - return 0; -} diff --git a/rushs/evalexpr/my_memcpy/my_memcpy.h b/rushs/evalexpr/my_memcpy/my_memcpy.h deleted file mode 100644 index bc1b926..0000000 --- a/rushs/evalexpr/my_memcpy/my_memcpy.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MY_MEMCPY_H -#define MY_MEMCPY_H - -#include <stddef.h> - -void *my_memcpy(void *dest, const void *source, size_t num); - -#endif /* ! MY_MEMCPY_H */ diff --git a/rushs/evalexpr/my_memmove/my_memmove.c b/rushs/evalexpr/my_memmove/my_memmove.c deleted file mode 100644 index bb360a5..0000000 --- a/rushs/evalexpr/my_memmove/my_memmove.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "my_memmove.h" - -void *my_memmove(void *dest, const void *src, size_t n) -{ - char *d = dest; - const char *s = src; - if (dest > src) // reverse array - { - size_t l = n; - for (; l > 0; l--) - { - d[l - 1] = s[l - 1]; - } - } - else - { - for (size_t i = 0; i < n; i++) - { - d[i] = s[i]; - } - } - return dest; -} diff --git a/rushs/evalexpr/my_memmove/my_memmove.h b/rushs/evalexpr/my_memmove/my_memmove.h deleted file mode 100644 index cb253b7..0000000 --- a/rushs/evalexpr/my_memmove/my_memmove.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MY_MEMMOVE_H -#define MY_MEMMOVE_H - -#include <stddef.h> - -void *my_memmove(void *dest, const void *src, size_t n); - -#endif /* ! MY_MEMMOVE_H */ diff --git a/rushs/evalexpr/my_memset/my_memset.c b/rushs/evalexpr/my_memset/my_memset.c deleted file mode 100644 index 243a5ac..0000000 --- a/rushs/evalexpr/my_memset/my_memset.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "my_memset.h" - -void *my_memset(void *s, int c, size_t n) -{ - unsigned char *t = s; - for (size_t i = 0; i < n; i++) - { - t[i] = c; - } - - return t; -} diff --git a/rushs/evalexpr/my_memset/my_memset.h b/rushs/evalexpr/my_memset/my_memset.h deleted file mode 100644 index e5ed0f0..0000000 --- a/rushs/evalexpr/my_memset/my_memset.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MY_MEMSET_H -#define MY_MEMSET_H - -#include <stddef.h> - -#endif /* ! MY_MEMSET_H */ diff --git a/rushs/evalexpr/my_pow/my_pow.c b/rushs/evalexpr/my_pow/my_pow.c deleted file mode 100644 index f529d87..0000000 --- a/rushs/evalexpr/my_pow/my_pow.c +++ /dev/null @@ -1,13 +0,0 @@ -int my_pow(int a, int b) -{ - if (!a) - return b == 0; - int res = 1; - for (int i = 0; i < b / 2; i++) - { - res *= a * a; - } - if (b % 2) - res *= a; - return res; -} diff --git a/rushs/evalexpr/my_round/my_round.c b/rushs/evalexpr/my_round/my_round.c deleted file mode 100644 index 324bc1d..0000000 --- a/rushs/evalexpr/my_round/my_round.c +++ /dev/null @@ -1,6 +0,0 @@ -int my_round(float n) -{ - if (n < 0) - return n - 0.5; - return n + 0.5; -} diff --git a/rushs/evalexpr/my_strcmp/my_strcmp.c b/rushs/evalexpr/my_strcmp/my_strcmp.c deleted file mode 100644 index d3ef3e3..0000000 --- a/rushs/evalexpr/my_strcmp/my_strcmp.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "my_strcmp.h" - -int my_strcmp(const char *s1, const char *s2) -{ - for (; *s1 && *s1 == *s2; s1++, s2++) - { - continue; - } - - return *s1 - *s2; -} diff --git a/rushs/evalexpr/my_strcmp/my_strcmp.h b/rushs/evalexpr/my_strcmp/my_strcmp.h deleted file mode 100644 index d89a00b..0000000 --- a/rushs/evalexpr/my_strcmp/my_strcmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MY_STRCMP_H -#define MY_STRCMP_H - -#include <stddef.h> - -#endif /* ! MY_STRCMP_H */ diff --git a/rushs/evalexpr/my_strcpy/my_strcpy.c b/rushs/evalexpr/my_strcpy/my_strcpy.c deleted file mode 100644 index 69ad5ee..0000000 --- a/rushs/evalexpr/my_strcpy/my_strcpy.c +++ /dev/null @@ -1,13 +0,0 @@ -#include <stdlib.h> - -char *my_strcpy(char *dest, const char *source) -{ - size_t i; - for (i = 0; source[i]; i++) - { - dest[i] = source[i]; - } - dest[i] = '\0'; - - return dest; -} diff --git a/rushs/evalexpr/my_strlen/my_strlen.c b/rushs/evalexpr/my_strlen/my_strlen.c deleted file mode 100644 index ec80d0b..0000000 --- a/rushs/evalexpr/my_strlen/my_strlen.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "my_strlen.h" - -size_t my_strlen(const char *s) -{ - size_t i; - for (i = 0; s[i]; i++) - { - continue; - } - - return i; -} diff --git a/rushs/evalexpr/my_strlen/my_strlen.h b/rushs/evalexpr/my_strlen/my_strlen.h deleted file mode 100644 index 02806cc..0000000 --- a/rushs/evalexpr/my_strlen/my_strlen.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MY_STRLEN_H -#define MY_STRLEN_H - -#include <stddef.h> - -#endif /* ! MY_STRLEN_H */ diff --git a/rushs/evalexpr/my_strlowcase/my_strlowcase.c b/rushs/evalexpr/my_strlowcase/my_strlowcase.c deleted file mode 100644 index e52ea32..0000000 --- a/rushs/evalexpr/my_strlowcase/my_strlowcase.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "my_strlowcase.h" - -void my_strlowcase(char *s) -{ - size_t i; - for (i = 0; s[i]; i++) - { - if (s[i] >= 'A' && s[i] <= 'Z') - { - s[i] += ('a' - 'A'); - } - } -} diff --git a/rushs/evalexpr/my_strlowcase/my_strlowcase.h b/rushs/evalexpr/my_strlowcase/my_strlowcase.h deleted file mode 100644 index d4996b8..0000000 --- a/rushs/evalexpr/my_strlowcase/my_strlowcase.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MY_STRLOWCASE_H -#define MY_STRLOWCASE_H - -#include <stddef.h> - -void my_strlowcase(char *str); - -#endif /* ! MY_STRLOWCASE_H */ diff --git a/rushs/evalexpr/my_strspn/my_strspn.c b/rushs/evalexpr/my_strspn/my_strspn.c deleted file mode 100644 index 18bba0f..0000000 --- a/rushs/evalexpr/my_strspn/my_strspn.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "my_strspn.h" - -int is_in(char c, const char *accept) -{ - for (; *accept && *accept != c; accept++) - { - continue; - } - return *accept != '\0'; -} - -size_t my_strspn(const char *s, const char *accept) -{ - if (s == NULL || *s == '\0') - { - return 0; - } - - size_t res; - for (res = 0; *s && is_in(*s, accept) != 0; res++, s++) - { - continue; - } - - return res; -} diff --git a/rushs/evalexpr/my_strspn/my_strspn.h b/rushs/evalexpr/my_strspn/my_strspn.h deleted file mode 100644 index f2d7759..0000000 --- a/rushs/evalexpr/my_strspn/my_strspn.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MY_STRSPN_H -#define MY_STRSPN_H - -#include <stddef.h> - -size_t my_strspn(const char *s, const char *accept); - -#endif /* ! MY_STRSPN_H */ diff --git a/rushs/evalexpr/my_strstr/my_strstr.c b/rushs/evalexpr/my_strstr/my_strstr.c deleted file mode 100644 index 36ac439..0000000 --- a/rushs/evalexpr/my_strstr/my_strstr.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "my_strstr.h" - -#include <stddef.h> - -int my_strstr(const char *haystack, const char *needle) -{ - if (needle == NULL || *needle == '\0') - { - return 0; - } - - for (int i = 0; haystack[i]; i++) - { - if (haystack[i] == needle[0]) - { - int j; - for (j = 0; - haystack[i + j] && needle[j] && needle[j] == haystack[i + j]; - j++) - { - continue; - } - if (needle[j] == '\0') - { - return i; - } - if (haystack[i + j] == '\0') - { - return -1; - } - } - } - return -1; -} diff --git a/rushs/evalexpr/my_strstr/my_strstr.h b/rushs/evalexpr/my_strstr/my_strstr.h deleted file mode 100644 index 1b734b2..0000000 --- a/rushs/evalexpr/my_strstr/my_strstr.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MY_STRSTR_H -#define MY_STRSTR_H - -int my_strstr(const char *haystack, const char *needle); - -#endif /* ! MY_STRSTR_H */ diff --git a/rushs/evalexpr/my_strtok_r/my_strtok_r.c b/rushs/evalexpr/my_strtok_r/my_strtok_r.c deleted file mode 100644 index ec052b7..0000000 --- a/rushs/evalexpr/my_strtok_r/my_strtok_r.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "my_strtok_r.h" - -#include <stddef.h> - -static int is_delim(char c, const char *delims) -{ - for (const char *d = delims; *d; d++) - { - if (*d == c) - return 1; - } - return 0; -} - -char *my_strtok_r(char *str, const char *delim, char **saveptr) -{ - if (str == NULL) - { - if (*saveptr == NULL) - { - return NULL; - } - str = *saveptr; - } - - size_t i = 0; - while (str[i] != '\0' && is_delim(str[i], delim)) - { - i++; - } - if (str[i] == '\0') - { - *saveptr = NULL; - return NULL; - } - - char *res = str + i; - - while (str[i] != '\0' && !is_delim(str[i], delim)) - { - i++; - } - if (str[i] == '\0') - { - *saveptr = NULL; - return res; - } - *saveptr = str + i + 1; - str[i] = '\0'; - return res; -} diff --git a/rushs/evalexpr/my_strtok_r/my_strtok_r.h b/rushs/evalexpr/my_strtok_r/my_strtok_r.h deleted file mode 100644 index 5603729..0000000 --- a/rushs/evalexpr/my_strtok_r/my_strtok_r.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MY_STRTOK_R_H -#define MY_STRTOK_R_H - -char *my_strtok_r(char *str, const char *delim, char **saveptr); - -#endif /* ! MY_STRTOK_R_H */ diff --git a/rushs/evalexpr/null_terminated_arrays/null_terminated_arrays.c b/rushs/evalexpr/null_terminated_arrays/null_terminated_arrays.c deleted file mode 100644 index 32d2a17..0000000 --- a/rushs/evalexpr/null_terminated_arrays/null_terminated_arrays.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "null_terminated_arrays.h" - -#include <assert.h> -#include <stddef.h> -#include <stdio.h> - -void reverse_array(const char **arr) -{ - const char **p; - for (p = arr; *p; p++) - { - continue; - } - p--; - - while (p > arr) - { - const char *tmp = *p; - *p = *arr; - *arr = tmp; - arr++; - p--; - } -} - -void reverse_matrix(const char ***matrix) -{ - const char ***p; - for (p = matrix; *p; p++) - { - continue; - } - p--; - - while (p > matrix) - { - reverse_array(*p); - reverse_array(*matrix); - const char **tmp = *p; - *p = *matrix; - *matrix = tmp; - matrix++; - p--; - } - - if (p == matrix) - { - reverse_array(*matrix); - } -} diff --git a/rushs/evalexpr/null_terminated_arrays/null_terminated_arrays.h b/rushs/evalexpr/null_terminated_arrays/null_terminated_arrays.h deleted file mode 100644 index 31fccc5..0000000 --- a/rushs/evalexpr/null_terminated_arrays/null_terminated_arrays.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef NULL_TERMINATED_ARRAYS_H_ -#define NULL_TERMINATED_ARRAYS_H_ - -void reverse_matrix(const char ***matrix); - -#endif /* !NULL_TERMINATED_ARRAYS_H_ */ diff --git a/rushs/evalexpr/number_digits_rec/number_digits_rec.c b/rushs/evalexpr/number_digits_rec/number_digits_rec.c deleted file mode 100644 index 94de296..0000000 --- a/rushs/evalexpr/number_digits_rec/number_digits_rec.c +++ /dev/null @@ -1,8 +0,0 @@ -unsigned int number_digits_rec(unsigned int n) -{ - if (n / 10 == 0) - { - return 1; - } - return 1 + number_digits_rec(n / 10); -} diff --git a/rushs/evalexpr/palindrome/palindrome.c b/rushs/evalexpr/palindrome/palindrome.c deleted file mode 100644 index 2ecacfd..0000000 --- a/rushs/evalexpr/palindrome/palindrome.c +++ /dev/null @@ -1,47 +0,0 @@ -#include "palindrome.h" - -#include <stddef.h> - -int palindrome(const char *s) -{ - if (s == NULL) - { - return 0; - } - - if (*s == '\0') - { - return 1; - } - - const char *p = s; - while (*p) - { - p++; - } - p--; - - while (p > s) - { - while ((*p < '0' || (*p > '9' && *p < 'A') || (*p > 'Z' && *p < 'a') - || *p > 'z') - && p > s) - { - p--; - } - while ((*s < '0' || (*s > '9' && *s < 'A') || (*s > 'Z' && *s < 'a') - || *s > 'z') - && p > s) - { - s++; - } - if (*p != *s) - { - return 0; - } - p--; - s++; - } - - return 1; -} diff --git a/rushs/evalexpr/palindrome/palindrome.h b/rushs/evalexpr/palindrome/palindrome.h deleted file mode 100644 index 8595911..0000000 --- a/rushs/evalexpr/palindrome/palindrome.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef PALINDROME_H -#define PALINDROME_H - -int palindrome(const char *s); - -#endif /* !PALINDROME_H */ diff --git a/rushs/evalexpr/pine/pine.c b/rushs/evalexpr/pine/pine.c deleted file mode 100644 index 9d48761..0000000 --- a/rushs/evalexpr/pine/pine.c +++ /dev/null @@ -1,36 +0,0 @@ -#include <stdio.h> - -int pine(unsigned n) -{ - if (n < 3) - { - return 1; - } - - for (unsigned i = 0; i < n; i++) - { - for (unsigned j = 0; j < n - i - 1; j++) - { - putchar(' '); - } - - for (unsigned j = 0; j < 2 * i + 1; j++) - { - putchar('*'); - } - - putchar('\n'); - } - - for (unsigned i = 0; i < n / 2; i++) - { - for (unsigned j = 0; j < n - 1; j++) - { - putchar(' '); - } - putchar('*'); - putchar('\n'); - } - - return 0; -} diff --git a/rushs/evalexpr/pointer_swap/pointer_swap.c b/rushs/evalexpr/pointer_swap/pointer_swap.c deleted file mode 100644 index 32ceb84..0000000 --- a/rushs/evalexpr/pointer_swap/pointer_swap.c +++ /dev/null @@ -1,6 +0,0 @@ -void pointer_swap(int **a, int **b) -{ - int *tmp = *a; - *a = *b; - *b = tmp; -} diff --git a/rushs/evalexpr/prototypes/prototypes.sh b/rushs/evalexpr/prototypes/prototypes.sh deleted file mode 100755 index 3c80468..0000000 --- a/rushs/evalexpr/prototypes/prototypes.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -sed -En 's/^(([a-zA-Z]* ){0,2}([a-zA-Z]*) *\**([a-z][a-z0-9_]*)\((([a-zA-Z]* )?([a-zA-Z]* )?([a-z][a-z0-9_]* *)(\**[a-z][a-z0-9_]*|[a-z][a-z0-9_]*\[([0-9][0-9]*)?\])(, ([a-zA-Z]* )?([a-zA-Z]* )?([a-z][a-z0-9_]* *)(\**[a-z][a-z0-9_]*|[a-z][a-z0-9_]*\[([0-9][0-9]*)?\])){0,3}|void)\))$/\1;/p' "$1" diff --git a/rushs/evalexpr/quick_sort/quick_sort.c b/rushs/evalexpr/quick_sort/quick_sort.c deleted file mode 100644 index 6c61fc3..0000000 --- a/rushs/evalexpr/quick_sort/quick_sort.c +++ /dev/null @@ -1,18 +0,0 @@ -#include <stddef.h> - -void quicksort(int *tab, size_t len) -{ - if (tab == NULL) - { - return; - } - for (size_t i = 1; i < len; i++) - { - for (size_t j = i; j > 0 && tab[j - 1] > tab[j]; j--) - { - int tmp = tab[j]; - tab[j] = tab[j - 1]; - tab[j - 1] = tmp; - } - } -} diff --git a/rushs/evalexpr/quick_sort/quick_sort_example.c b/rushs/evalexpr/quick_sort/quick_sort_example.c deleted file mode 100644 index 2a5228f..0000000 --- a/rushs/evalexpr/quick_sort/quick_sort_example.c +++ /dev/null @@ -1,19 +0,0 @@ -#include <stdio.h> - -void quicksort(int *tab, int len); - -int main(void) -{ - unsigned i = 0; - int tab[] = { 10, 11, 2, 3, 8, 5, 7, 6, 26, 30, 2, 1, 17, 13, 14 }; - - unsigned size = sizeof(tab) / sizeof(int); - - quicksort(tab, size); - - for (; i < size - 1; ++i) - printf("%d ", tab[i]); - printf("%d\n", tab[i]); - - return 0; -} diff --git a/rushs/evalexpr/repeat/repeat.c b/rushs/evalexpr/repeat/repeat.c deleted file mode 100644 index 06d0b43..0000000 --- a/rushs/evalexpr/repeat/repeat.c +++ /dev/null @@ -1,11 +0,0 @@ -#include <stdio.h> - -int main(int argc, char **argv) -{ - if (argc != 3) - return 1; - - for (int i = 0; i < argv[2][0] - '0'; i++) - puts(argv[1]); - return 0; -} diff --git a/rushs/evalexpr/right_tarball/my_tarball.tar.gz b/rushs/evalexpr/right_tarball/my_tarball.tar.gz Binary files differdeleted file mode 100644 index eb6acfc..0000000 --- a/rushs/evalexpr/right_tarball/my_tarball.tar.gz +++ /dev/null diff --git a/rushs/evalexpr/rotx/rotx.c b/rushs/evalexpr/rotx/rotx.c deleted file mode 100644 index a2cb820..0000000 --- a/rushs/evalexpr/rotx/rotx.c +++ /dev/null @@ -1,59 +0,0 @@ -#include <stdlib.h> -#include <unistd.h> - -#define BUFFER_SIZE 10 - -int main(int argc, char **argv) -{ - if (argc != 2) - { - return 0; - } - - int rot = atoi(argv[1]); - int rod = rot; - if (rot < 0) - { - rot = (rot % 26) + 26; - rod = (rod % 10) + 10; - } - - char buf[BUFFER_SIZE]; - ssize_t r; - - while ((r = read(STDIN_FILENO, buf, BUFFER_SIZE))) - { - if (r == -1) - { - return 1; - } - - for (ssize_t i = 0; i < r; i++) - { - if (buf[i] >= 'a' && buf[i] <= 'z') - { - buf[i] = ((buf[i] - 'a') + rot) % 26 + 'a'; - } - else if (buf[i] >= 'A' && buf[i] <= 'Z') - { - buf[i] = ((buf[i] - 'A') + rot) % 26 + 'A'; - } - else if (buf[i] >= '0' && buf[i] <= '9') - { - buf[i] = ((buf[i] - '0') + rod) % 10 + '0'; - } - } - - ssize_t w = write(STDOUT_FILENO, buf, r); - while (w != r) - { - w += write(STDOUT_FILENO, buf, r); - if (w == -1) - { - return 1; - } - } - } - - return 0; -} diff --git a/rushs/evalexpr/sed_trailing_whitespaces/whitespaces.sed b/rushs/evalexpr/sed_trailing_whitespaces/whitespaces.sed deleted file mode 100644 index 46b7017..0000000 --- a/rushs/evalexpr/sed_trailing_whitespaces/whitespaces.sed +++ /dev/null @@ -1 +0,0 @@ -s/[ \t]*$// diff --git a/rushs/evalexpr/selection_sort/selection_sort.c b/rushs/evalexpr/selection_sort/selection_sort.c deleted file mode 100644 index 98adc7e..0000000 --- a/rushs/evalexpr/selection_sort/selection_sort.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <stddef.h> - -void swap(int *a, int *b) -{ - int tmp = *a; - *a = *b; - *b = tmp; -} - -unsigned array_min(const int arr[], unsigned start, unsigned size) -{ - unsigned min = start; - for (; start < size; start++) - { - if (arr[min] > arr[start]) - { - min = start; - } - } - return min; -} - -void selection_sort(int arr[], unsigned size) -{ - for (size_t i = 0; i < size; i++) - { - unsigned j = array_min(arr, i, size); - swap(&(arr[i]), &(arr[j])); - } -} diff --git a/rushs/evalexpr/seq/seq.sh b/rushs/evalexpr/seq/seq.sh deleted file mode 100755 index 9721432..0000000 --- a/rushs/evalexpr/seq/seq.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -if [ $# -ne 3 ]; then - echo "Usage: ./seq.sh FIRST INCREMENT LAST" 1>&2 - exit 1 -fi - -if [ "$2" -eq 0 ]; then - exit 1 -fi - -if [ "$1" -eq "$3" ]; then - echo "$1" - exit 0 -fi - -if [ "$1" -lt "$3" ]; then - [ 0 -gt "$2" ] && exit 1 - i="$1" - while [ "$3" -ge "$i" ]; do - echo "$i" - i=$(($i + $2)) - done - exit 0 -fi - -[ "$2" -gt 0 ] && exit 1 -i="$1" -while [ "$i" -ge "$3" ]; do - echo "$i" - i=$(($i + $2)) -done -exit 0 diff --git a/rushs/evalexpr/sieve_eratosthenes_advanced/Makefile b/rushs/evalexpr/sieve_eratosthenes_advanced/Makefile deleted file mode 100644 index c7e35f9..0000000 --- a/rushs/evalexpr/sieve_eratosthenes_advanced/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -CC=gcc -CFLAGS=-std=c99 -Wall -Wextra -Werror -Wvla -pedantic -LDLIBS= - -all: sieve.o - -sieve.o: sieve.c - $(CC) $(CFLAGS) -c -o sieve.o sieve.c - -.PHONY: clean - -clean: - rm sieve.o diff --git a/rushs/evalexpr/sieve_eratosthenes_advanced/sieve.c b/rushs/evalexpr/sieve_eratosthenes_advanced/sieve.c deleted file mode 100644 index 7dd4816..0000000 --- a/rushs/evalexpr/sieve_eratosthenes_advanced/sieve.c +++ /dev/null @@ -1,39 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -void sieve(int n) -{ - if (n <= 2) - { - return; - } - - // Generate array - int *a = calloc(n, sizeof(int)); - int count = 0; - - // Actual sieve and count - for (int i = 2; i < n; i++) - { - if (a[i] == 0) - { - for (int k = 2 * i; k < n; k += i) - { - a[k] = 1; - } - } - } - - for (int i = 2; i < n; i++) - { - if (a[i] == 0) - { - count++; - } - } - - // Print the count - printf("%d\n", count); - - free(a); -} diff --git a/rushs/evalexpr/simple_fnmatch/simple_fnmatch.c b/rushs/evalexpr/simple_fnmatch/simple_fnmatch.c deleted file mode 100644 index d40353f..0000000 --- a/rushs/evalexpr/simple_fnmatch/simple_fnmatch.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "simple_fnmatch.h" - -int simple_fnmatch(const char *pattern, const char *string) -{ - if (!pattern || !string) - return FNM_NOMATCH; - if (*pattern == '*' && pattern[1] == '\0') - return 0; - while (*pattern && *string) - { - if (*pattern == '?') - { - pattern++; - string++; - } - else if (*pattern == '\\') - { - pattern++; - if (!pattern || *pattern != *string) - return FNM_NOMATCH; - string++; - pattern++; - } - else if (*pattern == '*') - { - pattern++; - while (*string && simple_fnmatch(pattern, string)) - string++; - if (*string) - return 0; - } - else if (*pattern != *string) - return FNM_NOMATCH; - else - { - string++; - pattern++; - } - } - - if (*pattern == '*' && pattern[1] == '\0') - return 0; - if (*string || *pattern) - return FNM_NOMATCH; - return 0; -} diff --git a/rushs/evalexpr/simple_fnmatch/simple_fnmatch.h b/rushs/evalexpr/simple_fnmatch/simple_fnmatch.h deleted file mode 100644 index e1ae166..0000000 --- a/rushs/evalexpr/simple_fnmatch/simple_fnmatch.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef SIMPLE_FNMATCH_H -#define SIMPLE_FNMATCH_H - -#define FNM_NOMATCH 1 - -int simple_fnmatch(const char *pattern, const char *string); - -#endif /* !SIMPLE_FNMATCH_H */ diff --git a/rushs/evalexpr/evalexpr/src/evalexpr.c b/rushs/evalexpr/src/evalexpr.c index 5012355..5012355 100644 --- a/rushs/evalexpr/evalexpr/src/evalexpr.c +++ b/rushs/evalexpr/src/evalexpr.c diff --git a/rushs/evalexpr/evalexpr/src/evalexpr.h b/rushs/evalexpr/src/evalexpr.h index d440ae1..d440ae1 100644 --- a/rushs/evalexpr/evalexpr/src/evalexpr.h +++ b/rushs/evalexpr/src/evalexpr.h diff --git a/rushs/evalexpr/evalexpr/src/evalrpn.c b/rushs/evalexpr/src/evalrpn.c index db493eb..db493eb 100644 --- a/rushs/evalexpr/evalexpr/src/evalrpn.c +++ b/rushs/evalexpr/src/evalrpn.c diff --git a/rushs/evalexpr/evalexpr/src/fifo.h b/rushs/evalexpr/src/fifo.h index b330eac..b330eac 100644 --- a/rushs/evalexpr/evalexpr/src/fifo.h +++ b/rushs/evalexpr/src/fifo.h diff --git a/rushs/evalexpr/evalexpr/src/fifo_access.c b/rushs/evalexpr/src/fifo_access.c index 1986a09..1986a09 100644 --- a/rushs/evalexpr/evalexpr/src/fifo_access.c +++ b/rushs/evalexpr/src/fifo_access.c diff --git a/rushs/evalexpr/evalexpr/src/fifo_setup_destroy.c b/rushs/evalexpr/src/fifo_setup_destroy.c index 0f99ad0..0f99ad0 100644 --- a/rushs/evalexpr/evalexpr/src/fifo_setup_destroy.c +++ b/rushs/evalexpr/src/fifo_setup_destroy.c diff --git a/rushs/evalexpr/evalexpr/src/shunting_yard.c b/rushs/evalexpr/src/shunting_yard.c index 2db5fc8..2db5fc8 100644 --- a/rushs/evalexpr/evalexpr/src/shunting_yard.c +++ b/rushs/evalexpr/src/shunting_yard.c diff --git a/rushs/evalexpr/evalexpr/src/stack.c b/rushs/evalexpr/src/stack.c index 14f659e..14f659e 100644 --- a/rushs/evalexpr/evalexpr/src/stack.c +++ b/rushs/evalexpr/src/stack.c diff --git a/rushs/evalexpr/evalexpr/src/stack.h b/rushs/evalexpr/src/stack.h index d08e465..d08e465 100644 --- a/rushs/evalexpr/evalexpr/src/stack.h +++ b/rushs/evalexpr/src/stack.h diff --git a/rushs/evalexpr/evalexpr/src/stack_struct.h b/rushs/evalexpr/src/stack_struct.h index 105cd5d..105cd5d 100644 --- a/rushs/evalexpr/evalexpr/src/stack_struct.h +++ b/rushs/evalexpr/src/stack_struct.h diff --git a/rushs/evalexpr/stack/stack.c b/rushs/evalexpr/stack/stack.c deleted file mode 100644 index 0498abc..0000000 --- a/rushs/evalexpr/stack/stack.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "stack.h" - -#include <stdlib.h> - -struct stack *stack_push(struct stack *s, int e) -{ - struct stack *new = malloc(sizeof(struct stack)); - new->data = e; - new->next = NULL; - - new->next = s; - return new; -} - -struct stack *stack_pop(struct stack *s) -{ - if (s == NULL) - { - return NULL; - } - - struct stack *res = s->next; - free(s); - return res; -} - -int stack_peek(struct stack *s) -{ - return s->data; -} diff --git a/rushs/evalexpr/stack/stack.h b/rushs/evalexpr/stack/stack.h deleted file mode 100644 index bd5dd24..0000000 --- a/rushs/evalexpr/stack/stack.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef STACK_H -#define STACK_H - -struct stack -{ - int data; - struct stack *next; -}; - -struct stack *stack_push(struct stack *s, int e); -struct stack *stack_pop(struct stack *s); -int stack_peek(struct stack *s); - -#endif /* !STACK_H */ diff --git a/rushs/evalexpr/str_revert/str_revert.c b/rushs/evalexpr/str_revert/str_revert.c deleted file mode 100644 index 31f7f3d..0000000 --- a/rushs/evalexpr/str_revert/str_revert.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "str_revert.h" - -#include <stddef.h> - -void str_revert(char str[]) -{ - if (*str == '\0') - { - return; - } - - size_t len = 0; - for (; str[len]; len++) - { - continue; - } - len--; - - for (size_t i = 0; i <= len / 2; i++) - { - char tmp = str[i]; - str[i] = str[len - i]; - str[len - i] = tmp; - } -} diff --git a/rushs/evalexpr/str_revert/str_revert.h b/rushs/evalexpr/str_revert/str_revert.h deleted file mode 100644 index daa23d4..0000000 --- a/rushs/evalexpr/str_revert/str_revert.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef STR_REVERT_H -#define STR_REVERT_H - -void str_revert(char str[]); - -#endif /* ! STR_REVERT_H */ diff --git a/rushs/evalexpr/test.txt b/rushs/evalexpr/test.txt deleted file mode 100644 index 958cdbc..0000000 --- a/rushs/evalexpr/test.txt +++ /dev/null @@ -1,3 +0,0 @@ -This is a short line. -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -This is another short line. diff --git a/rushs/evalexpr/test_a_bit/is_set.c b/rushs/evalexpr/test_a_bit/is_set.c deleted file mode 100644 index 38fccf8..0000000 --- a/rushs/evalexpr/test_a_bit/is_set.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "is_set.h" - -unsigned int is_set(unsigned int value, unsigned char n) -{ - return (value & (1 << (n - 1))) != 0; -} diff --git a/rushs/evalexpr/test_a_bit/is_set.h b/rushs/evalexpr/test_a_bit/is_set.h deleted file mode 100644 index 8f2fd9a..0000000 --- a/rushs/evalexpr/test_a_bit/is_set.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef IS_SET_H -#define IS_SET_H - -unsigned int is_set(unsigned int value, unsigned char n); - -#endif /* ! IS_SET_H */ diff --git a/rushs/evalexpr/test_a_bit/test.c b/rushs/evalexpr/test_a_bit/test.c deleted file mode 100644 index e3403e4..0000000 --- a/rushs/evalexpr/test_a_bit/test.c +++ /dev/null @@ -1,11 +0,0 @@ -#include <stdio.h> - -#include "is_set.h" - -int main(void) -{ - printf("%d\n", is_set(24, 4)); - printf("%d\n", is_set(24, 3)); - - return 0; -} diff --git a/rushs/evalexpr/evalexpr/tests/tests.sh b/rushs/evalexpr/tests/tests.sh index 920f09b..920f09b 100755 --- a/rushs/evalexpr/evalexpr/tests/tests.sh +++ b/rushs/evalexpr/tests/tests.sh diff --git a/rushs/evalexpr/evalexpr/tests/unit_tests.c b/rushs/evalexpr/tests/unit_tests.c index ed445a0..ed445a0 100644 --- a/rushs/evalexpr/evalexpr/tests/unit_tests.c +++ b/rushs/evalexpr/tests/unit_tests.c diff --git a/rushs/evalexpr/tinylibstream/Makefile b/rushs/evalexpr/tinylibstream/Makefile deleted file mode 100644 index b060495..0000000 --- a/rushs/evalexpr/tinylibstream/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -CC = gcc -CFLAGS = -std=c99 -pedantic -Werror -Wall -Wextra -Wvla - -.PHONY: library clean - -library: src/tinylibstream.o - ar csr libstream.a src/tinylibstream.o - -clean: - rm libstream.a src/tinylibstream.o - -check: - $(CC) $(CFLAGS) -lcriterion src/tinylibstream.c tests/tests.c diff --git a/rushs/evalexpr/tinylibstream/include/libstream.h b/rushs/evalexpr/tinylibstream/include/libstream.h deleted file mode 100644 index 459432d..0000000 --- a/rushs/evalexpr/tinylibstream/include/libstream.h +++ /dev/null @@ -1,167 +0,0 @@ -#ifndef LIBSTREAM_H -#define LIBSTREAM_H - -#include <fcntl.h> -#include <stdbool.h> -#include <stddef.h> -#include <unistd.h> - -/* -** /!\ DO NOT MODIFY THIS FILE, AS IT WILL BE OVERRIDDEN DURING CORRECTION. /!\ -** -** You can add your own functions declarations to OTHER HEADER FILES. -*/ - -/* the value returned when end of file is reached */ -#define LBS_EOF (-1) - -/* the size of the buffer */ -#define LBS_BUFFER_SIZE 32 - -/* -** Describes the current operation: -** - if reading, the buffer contains read-buffered data -** - if writing, the buffer contains write-buffered data -*/ -enum stream_io_operation -{ - STREAM_READING = 0, - STREAM_WRITING, -}; - -/* -** Controls when to flush the buffer: -** - when unbuffered, flush every time a character is written -** - when buffered, flush when the buffer is full -** - when line buffered, flush when the buffer is full or when a \n -** character is written -*/ -enum stream_buffering -{ - STREAM_UNBUFFERED = 0, - STREAM_LINE_BUFFERED, - STREAM_BUFFERED, -}; - -struct stream -{ - /* the flags passed to open */ - int flags; - - /* - ** Initially, this variable is 0. - ** When a function such as fgetc fails, it is set to 1 to indicate - ** something went wrong. This is useful to make the difference between - ** reaching the end of file and read errors while using fgetc and - ** some others. - ** It is often referred to as the error indicator. - */ - int error; - - /* the file descriptor, as returned by open(2) */ - int fd; - - /* - ** the kind of data stored by the buffer. - ** The default value shouldn't matter. - */ - enum stream_io_operation io_operation; - - /* - ** defines when to flush **output**. - ** This field does not control input buffering (which is always fully - ** buffered). - ** - ** The default value is LINE_BUFFERED if isatty(fd), BUFFERED otherwise. - */ - enum stream_buffering buffering_mode; - - /* the amount of used bytes in the buffer */ - size_t buffered_size; - - /* - ** /!\ This field only makes sense when io_operation is STREAM_READING /!\ - ** the amount of data already read from the buffer by the user. - */ - size_t already_read; - - /* - ** buffer - ** --------------> - ** +==============+====================+---------------------+ - ** | already_read | remaining_buffered | unused_buffer_space | - ** +==============+====================+---------------------+ - ** \_______________________________/ - ** buffered_size - ** - ** /!\ The buffer can contain either read-buffered or write-buffered data, - ** depending on the value of io_operation /!\ - */ - char buffer[LBS_BUFFER_SIZE]; -}; - -/* -** These functions are defined in a header for optimization reasons: -** each .c file that includes this header will get its own copy of the -** function's code, thus easily make optimizations. -** -** ``static`` means each compilation unit (.c file) will have its own copy -** of the function without them clashing. -** -** ``inline`` means the content of the function should be "copy pasted" -** where it's called. It also tells the compiler not to complain when the -** function isn't used. -** -** They're just like a macro, except the type of arguments is checked. -*/ - -static inline size_t stream_remaining_buffered(struct stream *stream) -{ - return stream->buffered_size - stream->already_read; -} - -static inline size_t stream_unused_buffer_space(struct stream *stream) -{ - return sizeof(stream->buffer) - stream->buffered_size; -} - -static inline bool stream_readable(struct stream *stream) -{ - int access_mode = stream->flags & O_ACCMODE; - if (access_mode == O_RDWR) - return true; - return access_mode == O_RDONLY; -} - -static inline bool stream_writable(struct stream *stream) -{ - int access_mode = stream->flags & O_ACCMODE; - if (access_mode == O_RDWR) - return true; - return access_mode == O_WRONLY; -} - -static inline int lbs_ferror(struct stream *stream) -{ - return stream->error; -} - -static inline void lbs_clearerr(struct stream *stream) -{ - stream->error = 0; -} - -static inline void lbs_setbufmode(struct stream *stream, - enum stream_buffering mode) -{ - stream->buffering_mode = mode; -} - -struct stream *lbs_fopen(const char *path, const char *mode); -struct stream *lbs_fdopen(int fd, const char *mode); -int lbs_fflush(struct stream *stream); -int lbs_fclose(struct stream *stream); -int lbs_fputc(int c, struct stream *stream); -int lbs_fgetc(struct stream *stream); - -#endif /* !LIBSTREAM_H */ diff --git a/rushs/evalexpr/tinylibstream/src/tinylibstream.c b/rushs/evalexpr/tinylibstream/src/tinylibstream.c deleted file mode 100644 index dca1c01..0000000 --- a/rushs/evalexpr/tinylibstream/src/tinylibstream.c +++ /dev/null @@ -1,221 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -#include "../include/libstream.h" - -int get_flags(const char *mode) -{ - int flags; - if (strcmp(mode, "r") == 0) - { - flags = O_RDONLY; - } - else if (strcmp(mode, "r+") == 0) - { - flags = O_RDWR; - } - else if (strcmp(mode, "w") == 0) - { - flags = O_WRONLY | O_TRUNC | O_CREAT; - } - else - { - flags = O_RDWR | O_TRUNC | O_CREAT; - } - - return flags; -} - -struct stream *lbs_fopen(const char *path, const char *mode) -{ - int fd = open(path, get_flags(mode)); - - return lbs_fdopen(fd, mode); -} - -struct stream *lbs_fdopen(int fd, const char *mode) -{ - if (fd == -1) - { - return NULL; - } - - struct stream *s = malloc(sizeof(struct stream)); - if (s == NULL) - { - return NULL; - } - - s->flags = get_flags(mode); - s->error = 0; - s->fd = fd; - if (isatty(fd)) - { - s->buffering_mode = STREAM_LINE_BUFFERED; - } - else - { - s->buffering_mode = STREAM_BUFFERED; - } - s->buffered_size = 0; - s->already_read = 0; - - return s; -} - -int lbs_fflush(struct stream *stream) -{ - if (stream == NULL || stream->buffered_size == 0) - { - return 0; - } - - if (stream->io_operation == STREAM_READING) - { - if (!stream_readable(stream)) - { - stream->error = 1; - return LBS_EOF; - } - if (stream_remaining_buffered(stream) != 0 - && lseek(stream->fd, -stream_remaining_buffered(stream), SEEK_CUR) - == -1) - { - stream->error = 1; - return LBS_EOF; - } - stream->buffered_size = 0; - stream->already_read = 0; - } - else - { - if (!stream_writable(stream)) - { - stream->error = 1; - return LBS_EOF; - } - ssize_t w; - if ((w = write(stream->fd, stream->buffer, stream->buffered_size)) - == -1) - { - stream->error = 1; - return LBS_EOF; - } - stream->buffered_size = 0; - stream->already_read = 0; - } - return 0; -} - -int lbs_fclose(struct stream *stream) -{ - if (stream == NULL) - { - return 1; - } - - lbs_fflush(stream); - if (close(stream->fd) == -1) - { - return 1; - } - - free(stream); - - return 0; -} - -int lbs_fputc(int c, struct stream *stream) -{ - if (!stream_writable(stream)) - { - stream->error = 1; - return -1; - } - - if (stream->io_operation == STREAM_READING) - { - if (lbs_fflush(stream) != 0) - { - return -1; - } - stream->buffered_size = 0; - stream->already_read = 0; - } - stream->io_operation = STREAM_WRITING; - - if (stream_unused_buffer_space(stream) == 0 - || stream->buffering_mode == STREAM_UNBUFFERED) - { - if (lbs_fflush(stream) != 0) - { - return -1; - } - } - - stream->buffer[stream->buffered_size] = c; - stream->buffered_size++; - if (stream_unused_buffer_space(stream) == 0 - || stream->buffering_mode == STREAM_UNBUFFERED - || (stream->buffering_mode == STREAM_LINE_BUFFERED && c == '\n')) - { - if (lbs_fflush(stream) != 0) - { - return -1; - } - } - - return c; -} - -int refill_buffer(struct stream *stream) -{ - stream->already_read = 0; - ssize_t r; - if ((r = read(stream->fd, stream->buffer, LBS_BUFFER_SIZE)) == -1) - { - stream->error = 1; - return -1; - } - if (r == 0) - { - return -1; - } - stream->buffered_size = r; - return r; -} - -int lbs_fgetc(struct stream *stream) -{ - if (!stream_readable(stream)) - { - stream->error = 1; - return -1; - } - if (stream->io_operation == STREAM_WRITING) - { - if (lbs_fflush(stream) != 0) - { - stream->error = 1; - return -1; - } - stream->already_read = 0; - } - stream->io_operation = STREAM_READING; - - if (stream_remaining_buffered(stream) == 0) - { - int r; - if ((r = refill_buffer(stream)) == -1) - { - stream->error = 1; - return -1; - } - } - - int res = stream->buffer[stream->already_read++]; - - unsigned char c = res; - - return c; -} diff --git a/rushs/evalexpr/tinylibstream/stdin_buffering_test.c b/rushs/evalexpr/tinylibstream/stdin_buffering_test.c deleted file mode 100644 index 6d3361b..0000000 --- a/rushs/evalexpr/tinylibstream/stdin_buffering_test.c +++ /dev/null @@ -1,70 +0,0 @@ -#define _GNU_SOURCE -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -struct slow_cookie -{ - int fd; -}; - -static ssize_t slow_read(void *vcookie, char *buf, size_t count) -{ - struct slow_cookie *cookie = vcookie; - usleep(500000); // sleep for half of a second - - ssize_t res; - - while ((res = read(cookie->fd, buf, count)) < 0) - if (errno != EINTR && errno != EAGAIN) - break; - - return res; -} - -static int slow_close(void *vcookie) -{ - struct slow_cookie *cookie = vcookie; - return close(cookie->fd); -} - -cookie_io_functions_t slow_stdio = { - .read = slow_read, - .close = slow_close, -}; - -int main(void) -{ - /* setup a custom stdin stream with a slow read function */ - struct slow_cookie cookie = { - .fd = STDIN_FILENO, - }; - - FILE *input_stream = fopencookie(&cookie, "r", slow_stdio); - - /* change the buffer size to the one given by stdbuf. - ** it doesn't work out of the box as stdbuf only does - ** this for the already existing stdin stream. - */ - char *buffer = NULL; - char *buffer_size = getenv("_STDBUF_I"); - if (buffer_size) - { - size_t size = atoi(buffer_size); - buffer = malloc(size); - setvbuf(input_stream, buffer, _IOFBF, size); - } - - /* forward all characters from stdin to stdout */ - int c; - while ((c = fgetc(input_stream)) != EOF) - { - fputc(c, stdout); - fflush(stdout); - } - - fclose(input_stream); - free(buffer); - return 0; -} diff --git a/rushs/evalexpr/tinylibstream/stdout_buffering_test.c b/rushs/evalexpr/tinylibstream/stdout_buffering_test.c deleted file mode 100644 index 45c0a83..0000000 --- a/rushs/evalexpr/tinylibstream/stdout_buffering_test.c +++ /dev/null @@ -1,13 +0,0 @@ -#define _XOPEN_SOURCE 500 -#include <stdio.h> -#include <unistd.h> - -int main(void) -{ - const char test_string[] = "Robin\nloves\nBatman\n"; - for (size_t i = 0; test_string[i]; i++) - { - usleep(100000); // wait a tenth of a second - putchar(test_string[i]); - } -} diff --git a/rushs/evalexpr/tinyprintf/Makefile b/rushs/evalexpr/tinyprintf/Makefile deleted file mode 100644 index 6a07d90..0000000 --- a/rushs/evalexpr/tinyprintf/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -CC=gcc -CFLAGS=-std=c99 -Wall -Wextra -Werror -Wvla -pedantic -LDLIBS=-lcriterion - -all: src/tinyprintf.o - -check: src/tinyprintf.o - $(CC) $(CFLAGS) -o tinytests src/tinyprintf.o tests/tests.c $(LDLIBS) - ./tinytests - -src/tinyprintf.o: src/tinyprintf.c - $(CC) $(CFLAGS) -c -o src/tinyprintf.o src/tinyprintf.c - -.PHONY: clean - -clean: - rm src/tinyprintf.o tinytests diff --git a/rushs/evalexpr/tinyprintf/src/tinyprintf.c b/rushs/evalexpr/tinyprintf/src/tinyprintf.c deleted file mode 100644 index d005db7..0000000 --- a/rushs/evalexpr/tinyprintf/src/tinyprintf.c +++ /dev/null @@ -1,251 +0,0 @@ -#include "tinyprintf.h" - -#include <stdio.h> -#include <stdlib.h> - -int tinyprintf(const char *format, ...) -{ - if (format == NULL || *format == '\0') - { - return 0; - } - - va_list ap; - va_start(ap, format); - int res = 0; - - size_t i = 0; - while (format[i]) - { - if (format[i] != '%') - { - putchar(format[i]); - res++; - } - else - { - dispatch(format[i + 1], ap, &res); - format++; - } - format++; - } - va_end(ap); - return res; -} - -void dispatch(char c, va_list ap, int *res) -{ - switch (c) - { - case '%': - putchar('%'); - (*res)++; - break; - case 'd': - handle_d(va_arg(ap, int), res); - break; - case 'u': - handle_u(va_arg(ap, unsigned int), res); - break; - case 'x': - handle_x(va_arg(ap, unsigned int), res); - break; - case 'o': - handle_o(va_arg(ap, unsigned int), res); - break; - case 'c': - putchar(va_arg(ap, int)); - (*res)++; - break; - case 's': - handle_s(va_arg(ap, char *), res); - break; - default: - putchar('%'); - putchar(c); - *res += 2; - break; - } -} - -void handle_d(int val, int *res) -{ - if (val < 0) - { - putchar('-'); - (*res)++; - val = -val; - } - - if (val == 0) - { - putchar('0'); - (*res)++; - } - - int t = val; - int n = 0; - while (t > 0) - { - t /= 10; - n++; - } - - char *s = malloc(n * sizeof(char)); - int m = n; - if (s == NULL) - { - return; - } - n--; - for (; n >= 0; n--) - { - s[n] = val % 10 + '0'; - val /= 10; - } - - // actual printing - for (int i = 0; i < m; i++) - { - putchar(s[i]); - (*res)++; - } - free(s); -} - -void handle_s(char *s, int *res) -{ - if (s == NULL) - { - char *text = "(null)"; - for (; *text; text++) - { - putchar(*text); - (*res)++; - } - return; - } - for (; *s; s++) - { - putchar(*s); - (*res)++; - } -} - -void handle_u(unsigned int val, int *res) -{ - if (val == 0) - { - putchar('0'); - (*res)++; - } - - unsigned int t = val; - int n = 0; - while (t > 0) - { - t /= 10; - n++; - } - - char *s = malloc(n * sizeof(char)); - int m = n; - if (s == NULL) - { - return; - } - n--; - for (; n >= 0; n--) - { - s[n] = val % 10 + '0'; - val /= 10; - } - - // actual printing - for (int i = 0; i < m; i++) - { - putchar(s[i]); - (*res)++; - } - free(s); -} - -void handle_x(unsigned int val, int *res) -{ - if (val == 0) - { - putchar('0'); - (*res)++; - } - - unsigned int t = val; - int n = 0; - while (t > 0) - { - t /= 16; - n++; - } - - char *s = malloc(n * sizeof(char)); - int m = n; - if (s == NULL) - { - return; - } - n--; - for (; n >= 0; n--) - { - s[n] = val % 16 + '0'; - if (s[n] > '9') - { - s[n] = (s[n] - '0') % 10 + 'a'; - } - val /= 16; - } - - // actual printing - for (int i = 0; i < m; i++) - { - putchar(s[i]); - (*res)++; - } - free(s); -} - -void handle_o(unsigned int val, int *res) -{ - if (val == 0) - { - putchar('0'); - (*res)++; - } - - unsigned int t = val; - int n = 0; - while (t > 0) - { - t /= 8; - n++; - } - - char *s = malloc(n * sizeof(char)); - int m = n; - if (s == NULL) - { - return; - } - n--; - for (; n >= 0; n--) - { - s[n] = val % 8 + '0'; - val /= 8; - } - - // actual printing - for (int i = 0; i < m; i++) - { - putchar(s[i]); - (*res)++; - } - free(s); -} diff --git a/rushs/evalexpr/tinyprintf/src/tinyprintf.h b/rushs/evalexpr/tinyprintf/src/tinyprintf.h deleted file mode 100644 index fd1f0b4..0000000 --- a/rushs/evalexpr/tinyprintf/src/tinyprintf.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef TINYPRINTF_H -#define TINYPRINTF_H - -#include <stdarg.h> -#include <stddef.h> - -int tinyprintf(const char *format, ...); -void handle_d(int val, int *res); -void handle_u(unsigned int val, int *res); -void handle_x(unsigned int val, int *res); -void handle_o(unsigned int val, int *res); -void handle_s(char *s, int *res); -void dispatch(char c, va_list ap, int *res); - -#endif /* ! TINYPRINTF_H */ diff --git a/rushs/evalexpr/tinyprintf/tests/tests.c b/rushs/evalexpr/tinyprintf/tests/tests.c deleted file mode 100644 index 4235203..0000000 --- a/rushs/evalexpr/tinyprintf/tests/tests.c +++ /dev/null @@ -1,213 +0,0 @@ -#include <criterion/criterion.h> -#include <criterion/assert.h> -#include <criterion/redirect.h> -#include <stdio.h> - -#include "../src/tinyprintf.h" - -TestSuite(TestHandleD); - -Test(TestHandleD, handle_d42, .init = cr_redirect_stdout) -{ - int res = 0; - handle_d(42, &res); - fflush(stdout); - cr_assert_stdout_eq_str("42"); - cr_expect(res == 2, "Expected: %d. Got: %d", 2, res); -} - -Test(TestHandleD, handle_d0, .init = cr_redirect_stdout) -{ - int res = 0; - handle_d(0, &res); - fflush(stdout); - cr_assert_stdout_eq_str("0"); - cr_expect(res == 1, "Expected: %d. Got: %d", 1, res); -} - -Test(TestHandleD, handle_dminus42, .init = cr_redirect_stdout) -{ - int res = 0; - handle_d(-42, &res); - fflush(stdout); - cr_assert_stdout_eq_str("-42"); - cr_expect(res == 3, "Expected: %d. Got: %d", 3, res); -} - -Test(TestHandleD, simple_print, .init = cr_redirect_stdout) -{ - int retval = tinyprintf("%s [%d] %s", "Hello", 42, "world!"); - fflush(stdout); - cr_assert_stdout_eq_str("Hello [42] world!"); - cr_expect(retval == 17, "Expected: %d. Got: %d", 17, retval); -} - -TestSuite(TestHandleX); - -Test(TestHandleX, handle_x42, .init = cr_redirect_stdout) -{ - int res = 0; - handle_x(42, &res); - fflush(stdout); - cr_assert_stdout_eq_str("2a"); - cr_expect(res == 2, "Expected: %d. Got: %d", 2, res); -} - -Test(TestHandleX, handle_x0, .init = cr_redirect_stdout) -{ - int res = 0; - handle_x(0, &res); - fflush(stdout); - cr_assert_stdout_eq_str("0"); - cr_expect(res == 1, "Expected: %d. Got: %d", 1, res); -} - -Test(TestHandleX, handle_x15, .init = cr_redirect_stdout) -{ - int res = 0; - handle_x(15, &res); - fflush(stdout); - cr_assert_stdout_eq_str("f"); - cr_expect(res == 1, "Expected: %d. Got: %d", 1, res); -} - -Test(TestHandleX, handle_0xdeadc0de, .init = cr_redirect_stdout) -{ - int res = 0; - handle_x(0xdeadc0de, &res); - fflush(stdout); - cr_assert_stdout_eq_str("deadc0de"); - cr_expect(res == 8, "Expected: %d. Got: %d", 8, res); -} - -Test(TestHandleX, simple_print_hexa, .init = cr_redirect_stdout) -{ - int retval = tinyprintf("%s [%x] %s", "Hello", 42, "world!"); - fflush(stdout); - cr_assert_stdout_eq_str("Hello [2a] world!"); - cr_expect(retval == 17, "Expected: %d. Got: %d", 17, retval); -} - -TestSuite(TestHandleU); - -Test(TestHandleU, handle_u42, .init = cr_redirect_stdout) -{ - int res = 0; - handle_u(42, &res); - fflush(stdout); - cr_assert_stdout_eq_str("42"); - cr_expect(res == 2, "Expected: %d. Got: %d", 2, res); -} - -Test(TestHandleU, handle_u0, .init = cr_redirect_stdout) -{ - int res = 0; - handle_u(0, &res); - fflush(stdout); - cr_assert_stdout_eq_str("0"); - cr_expect(res == 1, "Expected: %d. Got: %d", 1, res); -} - -Test(TestHandleU, handle_u15, .init = cr_redirect_stdout) -{ - int res = 0; - handle_u(15, &res); - fflush(stdout); - cr_assert_stdout_eq_str("15"); - cr_expect(res == 2, "Expected: %d. Got: %d", 2, res); -} - -Test(TestHandleU, simple_print_unsigned, .init = cr_redirect_stdout) -{ - int retval = tinyprintf("%s [%u] %s", "Hello", 42, "world!"); - fflush(stdout); - cr_assert_stdout_eq_str("Hello [42] world!"); - cr_expect(retval == 17, "Expected: %d. Got: %d", 17, retval); -} - -TestSuite(TestHandleO); - -Test(TestHandleO, handle_o42, .init = cr_redirect_stdout) -{ - int res = 0; - handle_o(42, &res); - fflush(stdout); - cr_assert_stdout_eq_str("52"); - cr_expect(res == 2, "Expected: %d. Got: %d", 2, res); -} - -Test(TestHandleO, handle_o0, .init = cr_redirect_stdout) -{ - int res = 0; - handle_o(0, &res); - fflush(stdout); - cr_assert_stdout_eq_str("0"); - cr_expect(res == 1, "Expected: %d. Got: %d", 1, res); -} - -Test(TestHandleO, handle_o7, .init = cr_redirect_stdout) -{ - int res = 0; - handle_o(7, &res); - fflush(stdout); - cr_assert_stdout_eq_str("7"); - cr_expect(res == 1, "Expected: %d. Got: %d", 1, res); -} - -Test(TestHandleO, simple_print_octal, .init = cr_redirect_stdout) -{ - int retval = tinyprintf("%s [%o] %s", "Hello", 42, "world!"); - fflush(stdout); - cr_assert_stdout_eq_str("Hello [52] world!"); - cr_expect(retval == 17, "Expected: %d. Got: %d", 17, retval); -} - -TestSuite(TestPrint); - -Test(TestPrint, print_percent, .init = cr_redirect_stdout) -{ - int retval = tinyprintf("%%s", "in your head"); - fflush(stdout); - cr_assert_stdout_eq_str("%s"); - cr_expect(retval == 2, "Expected: %d. Got: %d", 2, retval); -} - -Test(TestPrint, print_unknown_option, .init = cr_redirect_stdout) -{ - int retval = tinyprintf("Good morning ACU! %t Tinyprintf is cool", 12); - fflush(stdout); - cr_assert_stdout_eq_str("Good morning ACU! %t Tinyprintf is cool"); - cr_expect(retval == 39, "Expected: %d. Got: %d", 39, retval); -} - -Test(TestPrint, print_tricky, .init = cr_redirect_stdout) -{ - int retval = tinyprintf("%c%c is %s... %d too.", '4', '2', "the answer", '*'); - fflush(stdout); - cr_assert_stdout_eq_str("42 is the answer... 42 too."); - cr_expect(retval == 27, "Expected: %d. Got: %d", 27, retval); -} - -Test(TestPrint, print_null, .init = cr_redirect_stdout) -{ - int retval = tinyprintf("%c%c is %s... %d too.", '4', '2', NULL, '*'); - fflush(stdout); - cr_assert_stdout_eq_str("42 is (null)... 42 too."); - cr_expect(retval == 23, "Expected: %d. Got: %d", 23, retval); -} - -Test(TestPrint, print_null_fmt, .init = cr_redirect_stdout) -{ - int retval = tinyprintf(NULL, '4', '2', NULL, '*'); - fflush(stdout); - cr_assert_stdout_eq_str(""); - cr_expect(retval == 0, "Expected: %d. Got: %d", 0, retval); -} - -Test(TestPrint, print_empty_fmt, .init = cr_redirect_stdout) -{ - int retval = tinyprintf("", '4', '2', NULL, '*'); - fflush(stdout); - cr_assert_stdout_eq_str(""); - cr_expect(retval == 0, "Expected: %d. Got: %d", 0, retval); -} diff --git a/rushs/evalexpr/traffic_lights/traffic_lights.c b/rushs/evalexpr/traffic_lights/traffic_lights.c deleted file mode 100644 index 76ea94f..0000000 --- a/rushs/evalexpr/traffic_lights/traffic_lights.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "traffic_lights.h" - -void init(unsigned char *lights) -{ - *lights <<= 4; -} - -void turn_on(unsigned char *lights, unsigned char light_num) -{ - *lights |= 1 << (light_num - 1); -} - -void turn_off(unsigned char *lights, unsigned char light_num) -{ - *lights &= ~(1 << (light_num - 1)); -} - -void next_step(unsigned char *lights) -{ - *lights <<= 1; - *lights += *lights >> 4; -} - -void reverse(unsigned char *lights) -{ - *lights = ~*lights; -} - -void swap(unsigned char *lights_1, unsigned char *lights_2) -{ - if (lights_1 == lights_2) - { - return; - } - *lights_1 = *lights_2 ^ *lights_1; - *lights_2 = *lights_1 ^ *lights_2; - *lights_1 = *lights_2 ^ *lights_1; -} diff --git a/rushs/evalexpr/traffic_lights/traffic_lights.h b/rushs/evalexpr/traffic_lights/traffic_lights.h deleted file mode 100644 index 7c803ea..0000000 --- a/rushs/evalexpr/traffic_lights/traffic_lights.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef TRAFFIC_LIGHTS_H -#define TRAFFIC_LIGHTS_H - -void init(unsigned char *lights); -void turn_on(unsigned char *lights, unsigned char light_num); -void turn_off(unsigned char *lights, unsigned char light_num); -void next_step(unsigned char *lights); -void reverse(unsigned char *lights); -void swap(unsigned char *lights_1, unsigned char *lights_2); - -#endif /* !TRAFFIC_LIGHTS_H */ diff --git a/rushs/evalexpr/user_ids/get_ids.sh b/rushs/evalexpr/user_ids/get_ids.sh deleted file mode 100644 index 2a1668b..0000000 --- a/rushs/evalexpr/user_ids/get_ids.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -cut --delimiter=: --fields=3 -s /etc/passwd | sort -rgu diff --git a/rushs/evalexpr/using_special_variables/print.sh b/rushs/evalexpr/using_special_variables/print.sh deleted file mode 100755 index c24bebd..0000000 --- a/rushs/evalexpr/using_special_variables/print.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -echo $# -echo $* -echo $1 -echo $2 -echo $3 -echo ${13} -echo $0 diff --git a/rushs/evalexpr/variant/variant.c b/rushs/evalexpr/variant/variant.c deleted file mode 100644 index eb2f8a8..0000000 --- a/rushs/evalexpr/variant/variant.c +++ /dev/null @@ -1,96 +0,0 @@ -#include "variant.h" - -#include <stdio.h> -#include <string.h> - -void variant_display(const struct variant *e) -{ - switch (e->type) - { - case (TYPE_INT): - printf("%d\n", e->value.int_v); - break; - case (TYPE_FLOAT): - printf("%f\n", e->value.float_v); - break; - case (TYPE_CHAR): - printf("%c\n", e->value.char_v); - break; - default: - printf("%s\n", e->value.str_v); - break; - } -} - -bool variant_equal(const struct variant *left, const struct variant *right) -{ - if (left == NULL || right == NULL) - { - return true; - } - switch (left->type) - { - case (TYPE_INT): - if (right->type != TYPE_INT) - { - return false; - } - return left->value.int_v == right->value.int_v; - case (TYPE_FLOAT): - if (right->type != TYPE_FLOAT) - { - return false; - } - return left->value.float_v == right->value.float_v; - case (TYPE_CHAR): - if (right->type != TYPE_CHAR) - { - return false; - } - return left->value.char_v == right->value.char_v; - default: - if (right->type != TYPE_STRING) - { - return false; - } - return strcmp(left->value.str_v, right->value.str_v) == 0; - } -} - -int variant_find(const struct variant *array, size_t len, enum type type, - union type_any value) -{ - size_t i; - struct variant cmp = { type, value }; - for (i = 0; i < len && variant_equal(array + i, &cmp) == false; i++) - { - continue; - } - - if (i == len) - { - return -1; - } - return i; -} - -float variant_sum(const struct variant *array, size_t len) -{ - if (array == NULL) - { - return 0; - } - float sum = 0; - for (size_t i = 0; i < len; i++) - { - if (array[i].type == TYPE_FLOAT) - { - sum += array[i].value.float_v; - } - else if (array[i].type == TYPE_INT) - { - sum += array[i].value.int_v; - } - } - return sum; -} diff --git a/rushs/evalexpr/variant/variant.h b/rushs/evalexpr/variant/variant.h deleted file mode 100644 index 9983bc1..0000000 --- a/rushs/evalexpr/variant/variant.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef VARIANT_H -#define VARIANT_H - -#include <stdbool.h> -#include <stddef.h> - -enum type -{ - TYPE_INT, - TYPE_FLOAT, - TYPE_CHAR, - TYPE_STRING -}; - -union type_any -{ - int int_v; - float float_v; - char char_v; - const char *str_v; -}; - -struct variant -{ - enum type type; - union type_any value; -}; - -void variant_display(const struct variant *e); -bool variant_equal(const struct variant *left, const struct variant *right); -int variant_find(const struct variant *array, size_t len, enum type type, - union type_any value); -float variant_sum(const struct variant *array, size_t len); - -#endif /* !VARIANT_H */ diff --git a/rushs/evalexpr/vector/Makefile b/rushs/evalexpr/vector/Makefile deleted file mode 100644 index 744241f..0000000 --- a/rushs/evalexpr/vector/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -CC = gcc -CFLAGS = -Wall -Werror -Wvla -Wextra -std=c99 -pedantic - -.PHONY: library clean - -library: vector.o - ar csr libvector.a vector.o - -vector.o: vector.c - $(CC) $(CFLAGS) -c -o vector.o vector.c - -clean: - $(RM) libvector.a vector.o diff --git a/rushs/evalexpr/vector/vector.c b/rushs/evalexpr/vector/vector.c deleted file mode 100644 index cbd19aa..0000000 --- a/rushs/evalexpr/vector/vector.c +++ /dev/null @@ -1,152 +0,0 @@ -#include "vector.h" - -#include <stdio.h> -#include <stdlib.h> - -struct vector *vector_init(size_t n) -{ - struct vector *res = malloc(sizeof(struct vector)); - if (res == NULL) - { - return NULL; - } - - res->size = 0; - res->capacity = n; - res->data = malloc(n * sizeof(int)); - if (res->data == NULL) - { - return NULL; - } - return res; -} - -void vector_destroy(struct vector *v) -{ - if (v) - { - free(v->data); - free(v); - } -} - -struct vector *vector_resize(struct vector *v, size_t n) -{ - if (!v) - { - return NULL; - } - if (n == v->capacity) - { - return v; - } - if (v) - { - int *tmp = realloc(v->data, n * sizeof(int)); - if (tmp == NULL) - { - return NULL; - } - v->data = tmp; - - if (n < v->size) - { - v->size = n; - } - v->capacity = n; - return v; - } - return NULL; -} - -struct vector *vector_append(struct vector *v, int elt) -{ - if (v == NULL) - { - return NULL; - } - - if (v->size == v->capacity) - { - if (vector_resize(v, v->capacity * 2) == NULL) - { - return NULL; - } - } - v->data[v->size] = elt; - v->size++; - return v; -} - -void vector_print(const struct vector *v) -{ - if (v == NULL || v->size == 0) - { - printf("\n"); - return; - } - for (size_t i = 0; i < v->size - 1; i++) - { - printf("%d,", v->data[i]); - } - printf("%d\n", v->data[v->size - 1]); -} - -struct vector *vector_reset(struct vector *v, size_t n) -{ - if (vector_resize(v, n) == NULL) - { - return NULL; - } - - v->size = 0; - return v; -} - -struct vector *vector_insert(struct vector *v, size_t i, int elt) -{ - if (v == NULL || i > v->size) - return NULL; - if (i == v->size) - { - return vector_append(v, elt); - } - if (v->size == v->capacity) - { - if (vector_resize(v, v->capacity * 2) == NULL) - { - return NULL; - } - } - for (size_t j = v->size; j > i; j--) - { - v->data[j] = v->data[j - 1]; - } - v->size++; - - v->data[i] = elt; - return v; -} - -struct vector *vector_remove(struct vector *v, size_t i) -{ - if (v == NULL || v->size == 0 || i >= v->size) - { - return NULL; - } - for (size_t j = i; j < v->size - 1; j++) - { - v->data[j] = v->data[j + 1]; - } - - v->size--; - - if (v->size < v->capacity / 2) - { - if (vector_resize(v, v->capacity / 2) == NULL) - { - return NULL; - } - } - return v; -} diff --git a/rushs/evalexpr/vector/vector.h b/rushs/evalexpr/vector/vector.h deleted file mode 100644 index 5afada7..0000000 --- a/rushs/evalexpr/vector/vector.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef VECTOR_H -#define VECTOR_H - -#include <stddef.h> - -struct vector -{ - // The number of elements in the vector - size_t size; - // The maximum number of elements in the vector - size_t capacity; - // The elements themselves - int *data; -}; - -/* -** Initialize the vector with `n` capacity. -** Returns `NULL` if an error occured. -*/ -struct vector *vector_init(size_t n); - -/* -** Release the memory used by the vector. -** Does nothing if `v` is `NULL`. -*/ -void vector_destroy(struct vector *v); - -/* -** Resize the vector to `n` capacity. -** Returns `NULL` if an error occured. -*/ -struct vector *vector_resize(struct vector *v, size_t n); - -/* -** Append an element to the end of the vector. Expand the vector if needed. -** Returns `NULL` if an error occured. -*/ -struct vector *vector_append(struct vector *v, int elt); - -/* -** Display the vector contents on `stdout`. -** Displays `\n` if `v` is `NULL`. -*/ -void vector_print(const struct vector *v); - -/* -** Remove all the elements of the vector, and resize it to `n` capacity. -** Returns `NULL` if an error occured. -*/ -struct vector *vector_reset(struct vector *v, size_t n); - -/* -** Insert `n` at the index `i`. Expand the vector if needed. -** Returns `NULL` if an error occured. -*/ -struct vector *vector_insert(struct vector *v, size_t i, int elt); - -/* -** Remove the element at the index `i`. -** Returns `NULL` if an error occured. -*/ -struct vector *vector_remove(struct vector *v, size_t i); - -#endif /* !VECTOR_H */ |
