M

@mattar

schema validation

TypeScript
1 year ago
class ValidationError extends Error { constructor(message: string) { super(message); this.name = 'ValidationError'; } } type PrimitiveType = 'string' | 'boolean' | 'number' | 'any'; type Validator<T> = (value: T) => boolean | string;

Quick Sort

C
2 years ago
#include <stdio.h> #include <stdlib.h> #define MAX 10 void swap(int array[MAX], int index1, int index2) { int temporary = array[index1]; array[index1] = array[index2]; array[index2] = temporary; }

Shell Sort

C
2 years ago
#include <stdio.h> #define MAX 10 void shellSort(int array[MAX]) { for (int interval = MAX / 2; interval > 0; interval /= 2) { for (int index = interval; index < MAX; index++) { for (int prevIndex = index - interval, currentIndex

Bubble Sort

C
2 years ago
#include <stdio.h> #define MAX 10 void bubbleSort(int array[MAX]) { for (int maxIndex = MAX; maxIndex > 0; maxIndex--) { for (int prevIndex = 0, currentIndex = 1; currentIndex < maxIndex; prevIndex++, currentIndex++) { if (array[p

Insertion Sort

C
2 years ago
#include <stdio.h> #define MAX 10 void insertionSort(int data[MAX]) { for (int index = 1; index < MAX; index++) { for (int previousIndex = index - 1, currentIndex = index; previousIndex >= 0; previousIndex--, currentIndex--)

Selection Sort

C
2 years ago
#include <stdio.h> #define MAX 10 void selectionSort(int data[MAX]) { int lowestIndex = 0; int lastPointer = 0; int selectorPointer = 0; while (lastPointer < (MAX - 1))

reverse string with recursion

C
2 years ago
#include <stdio.h> #include <string.h> char *reverse(char str[], int index) { printf("%c", str[index]); if (index != 0) reverse(str, index - 1); }

counting with recursion

C
2 years ago
#include <stdio.h> void counter(int i, int ii) { printf("%d\n", i); if (i != ii) counter(i + 1, ii); }

Stack: infix to postfix converter and evaluation

C
2 years ago
#include <stdio.h> #include <string.h> #include <ctype.h> #define MAX 20 typedef struct Stack { int top; int item[MAX]; } Stack;

double linked list

C
2 years ago
/** * Run code pada text editor masing masing agar lebih jelas outputnya */ #include <stdio.h> #include <stdlib.h> typedef struct Number { int number;

Linked List

C
2 years ago
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct Numbers { int number; struct Numbers *next; } Numbers; /**

date of birth compare

C
2 years ago
#include <stdio.h> typedef struct { int d, m, y; } Date; typedef struct { char name[60]; double averageScore; Date dob; // date of birth

comparing-date

C
2 years ago
#include <stdio.h> typedef struct { int d, m, y; } Date; int sameDay(Date day1, Date day2); void main ( ) { Date

test struct 2

C
2 years ago
#include <stdio.h> #include <string.h> #define MAX 50 typedef struct StructMahasiswa { char nama[MAX]; char grade; float nilaiTugas, nilaiUTS, nilaiUAS, nilaiAkhir; } StructMahasiswa;

test struct

C
2 years ago
#include <stdio.h> #include <string.h> #define MAX 50 typedef struct StructMahasiswa { char nama[MAX]; char grade; float nilaiTugas, nilaiUTS, nilaiUAS, nilaiAkhir; } StructMahasiswa;

alphabet frequent counter

C
2 years ago
#include <stdio.h> void main() { const int lowerCaseStart = 97; const int upperCaseStart = 65; char str[] = "Hitung{+_' frekuensi 8&29Huruf y]ang munc12ul dik?>alim12at ini!}"; int character[26]; for (int i = 0; i < sizeof(str)

3. pesan makan

C
2 years ago
#include <stdio.h> #include <string.h> struct Menu { char code; char type[10]; int price; }; struct Order {

per baris

C
2 years ago
#include <stdio.h> void main() { char str[] = "Saya belajar bahasa pemrograman c"; int x = sizeof(str) - 1; for (int i = 0; i < x; i++) { if (str[i] == ' ') { printf("\n"); continue;

palindrome

C
2 years ago
#include <stdio.h> void main() { char str[] = "KASUK RUSAK"; int x = sizeof(str) - 2; char str2[x]; int j = 0; for(int i = x; i >= 0; i--, j++) str2[j] = str[i];

piramida kata

C
2 years ago
#include <stdio.h> char str[] = "POLITEKNIK"; int strLength = sizeof(str) - 1; void main() { char reverse = 'x'; for (int i = 0, y = strLength; i < strLength; i++) { for (int j = 0; j < y; j++) {