-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst_fibonacci_main.c
More file actions
35 lines (30 loc) · 933 Bytes
/
first_fibonacci_main.c
File metadata and controls
35 lines (30 loc) · 933 Bytes
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
/*
7 kyu
First Fibonacci
https://www.codewars.com/kata/6965d769930fb2eff921668f
*/
#include <stdio.h>
typedef struct {
unsigned first;
unsigned second;
} pair;
pair solution(unsigned first, unsigned second);
static void do_test(pair problem, pair expected) {
pair submitted = solution(problem.first, problem.second);
printf(
"Given = {%u, %u}, submitted = {%u, %u}, expected = {%u, %u} -> %s\n",
problem.first, problem.second, submitted.first, submitted.second,
expected.first, expected.second,
submitted.first == expected.first && submitted.second == expected.second
? "OK"
: "FAIL");
}
int main(void) {
do_test((pair){3, 5}, (pair){0, 1});
do_test((pair){398, 644}, (pair){2, 6});
do_test((pair){15, 28}, (pair){2, 13});
do_test((pair){186, 301}, (pair){3, 7});
do_test((pair){265, 429}, (pair){1, 12});
do_test((pair){1186, 1919}, (pair){2, 7});
return 0;
}