aboutsummaryrefslogtreecommitdiff
path: root/entries
diff options
context:
space:
mode:
authorbraxtonhall2022-10-23 18:20:39 +0000
committerbraxtonhall2022-10-23 18:20:39 +0000
commitb5b18e46e3a5c4daaa3b4613395b1a216a47bc17 (patch)
tree13312c71c0a2968cb34f86527a82bb1e33abb4b0 /entries
Initial commit
Diffstat (limited to 'entries')
-rw-r--r--entries/braxtonh/adam/main.py16
-rw-r--r--entries/braxtonh/express/index.js22
-rw-r--r--entries/braxtonh/homework/fib.cpp32
-rw-r--r--entries/braxtonh/homework/fib.hpp4
-rw-r--r--entries/braxtonh/types/index.ts18
-rw-r--r--entries/braxtonh/types/test.ts19
6 files changed, 111 insertions, 0 deletions
diff --git a/entries/braxtonh/adam/main.py b/entries/braxtonh/adam/main.py
new file mode 100644
index 0000000..71cb8da
--- /dev/null
+++ b/entries/braxtonh/adam/main.py
@@ -0,0 +1,16 @@
+# from tensorflow.keras.optimizers import Adam
+# from tensorflow.keras.models import Sequential
+# from tensorflow.keras.layers import Dense
+
+def main():
+ # model = Sequential()
+ # model.add(Dense(12, input_shape=(8,), activation='relu'))
+ # model.add(Dense(8, activation='relu'))
+ # model.add(Dense(1, activation='sigmoid'))
+
+ # model.fit(X, y, epochs=4000)
+ pass # TODO fill out the rest of this stupid idea
+
+
+if __name__ == '__main__':
+ main()
diff --git a/entries/braxtonh/express/index.js b/entries/braxtonh/express/index.js
new file mode 100644
index 0000000..2da6092
--- /dev/null
+++ b/entries/braxtonh/express/index.js
@@ -0,0 +1,22 @@
+import { get } from "axios";
+import express from "express";
+
+const app = express();
+
+const getURL = (n) => `/fib?${new URLSearchParams({n})}`;
+
+app.get("/fib", async (res, req, next) => {
+ const {n} = req.params;
+ if (n <= 0) {
+ res.send(n).status(200);
+ } else {
+ const futures = [get(getURL(n - 1)), get(getURL(n - 2))];
+ const [nSub1, nSub2] = await Promise.all(futures);
+ res.send(nSub1 + nSub2).status(200);
+ }
+ return next();
+});
+
+app.start();
+
+// TODO... is this syntax correct???
diff --git a/entries/braxtonh/homework/fib.cpp b/entries/braxtonh/homework/fib.cpp
new file mode 100644
index 0000000..900c9d0
--- /dev/null
+++ b/entries/braxtonh/homework/fib.cpp
@@ -0,0 +1,32 @@
+#include "fib.hpp"
+
+#include <string>
+#include <iostream>
+#include <stdexcept>
+
+using namespace std;
+
+int Fibonacci::fib(const int n) const
+{
+ // cout << "start" << endl;
+ if (n < 0) {
+ // HOW??
+ cout << "wtfff got ( " << n << " )" << endl;
+ // https://stackoverflow.com/questions/8480640/how-to-throw-a-c-exception
+ throw invalid_argument("received negative value");
+ } else if (n == 0) {
+ // cout << "********************* LINE 12" << endl;
+ // https://stackoverflow.com/questions/1451170/in-the-fibonacci-sequence-is-fib0-0-or-1
+ return 0; //1; ??????
+ } else if (n == 1) {
+ // cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!! LINE 15" << endl;
+ return 1;
+ } else {
+ // cout << "GOT TO LINE 19" << endl;
+ // cout << "got here" << endl;
+ // int retVal = fib(n - 1) + fib(n - 2);
+ return fib(n - 1) + fib(n - 2);
+ // // cout << "here" << endl;
+ // cout << "returning: (" << retVal << " )" << endl;
+ }
+}
diff --git a/entries/braxtonh/homework/fib.hpp b/entries/braxtonh/homework/fib.hpp
new file mode 100644
index 0000000..a7bbd30
--- /dev/null
+++ b/entries/braxtonh/homework/fib.hpp
@@ -0,0 +1,4 @@
+class Fibonacci
+{
+ int fib(const int n) const;
+};
diff --git a/entries/braxtonh/types/index.ts b/entries/braxtonh/types/index.ts
new file mode 100644
index 0000000..11f4086
--- /dev/null
+++ b/entries/braxtonh/types/index.ts
@@ -0,0 +1,18 @@
+type Zero = "😰";
+
+type Succ<N> = {prev: N};
+
+type Prev<N> = N extends Succ<infer P> ? P : never;
+
+type Add<A, B> = B extends Zero ? A : Succ<Add<A, Prev<B>>>;
+
+type _Fib<N, AccumulatorA, AccumulatorB> =
+ N extends Zero
+ ? AccumulatorA
+ : N extends Succ<Zero>
+ ? AccumulatorB
+ : _Fib<Prev<N>, AccumulatorB, Add<AccumulatorA, AccumulatorB>>;
+
+type Fib<N> = _Fib<N, Zero, Succ<Zero>>;
+
+export type {Zero, Succ, Fib};
diff --git a/entries/braxtonh/types/test.ts b/entries/braxtonh/types/test.ts
new file mode 100644
index 0000000..2ce83e7
--- /dev/null
+++ b/entries/braxtonh/types/test.ts
@@ -0,0 +1,19 @@
+import {Zero, Succ, Fib} from "./index";
+
+const zero: Zero = "😰";
+const one: Succ<typeof zero> = {prev: zero};
+const two: Succ<typeof one> = {prev: one};
+const three: Succ<typeof two> = {prev: two};
+const four: Succ<typeof three> = {prev: three};
+const five: Succ<typeof four> = {prev: four};
+const six: Succ<typeof five> = {prev: five};
+const seven: Succ<typeof six> = {prev: six};
+const eight: Succ<typeof seven> = {prev: seven};
+
+const fibZero: Fib<typeof zero> = zero;
+const fibOne: Fib<typeof one> = one;
+const fibTwo: Fib<typeof two> = one;
+const fibThree: Fib<typeof three> = two;
+const fibFour: Fib<typeof four> = three;
+const fibFive: Fib<typeof five> = five;
+const fibSix: Fib<typeof six> = eight;