This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <inttypes.h> | |
| #include <time.h> | |
| #include <stdbool.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| static size_t bits_popcount(uint64_t const x) { | |
| size_t count = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # derivative estimator. | |
| cont = True | |
| while cont: | |
| xs, ys = [], [] | |
| while True: | |
| a = input('enter X: ') | |
| if len(a) < 1: | |
| break | |
| xs.append(float(a)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stock void RunScript(const char[] sCode, any ...) { | |
| /** | |
| * Run a VScript (Credit to Timocop) | |
| * | |
| * @param sCode Magic | |
| * @return void | |
| */ | |
| static int iScriptLogic = INVALID_ENT_REFERENCE; | |
| if( iScriptLogic==INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Fdr.h>//was Fdr.h | |
| Fdr fdr; //I am defining fdr as type Fdr. | |
| #include <Wire.h> | |
| /************************************** | |
| Modems | |
| *************************************** | |
| The near modem is the one in the payload. The far modem is who we are talking with via satellite. | |
| *************************************** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stock float simpsons_func(float x) { | |
| return 0.0; /// replace with math operations desired. | |
| } | |
| /** | |
| * Composite Simpson's Rule: approximates the area of a function. | |
| * 'a' represents the lower bounds | |
| * 'b' represents the upper bounds | |
| * 'num_intervals' is for how many iterations needed (this is for increasing accuracy) | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| long double adaptive_simpsons(long double (*f)(long double), long double a, long double b, long double epsilon) { | |
| long double c = (a + b) / 2.0L; | |
| long double h = b - a; | |
| long double fa = f(a); | |
| long double fb = f(b); | |
| long double fc = f(c); | |
| long double integral = (h / 6.0L) * (fa + 4.0L * fc + fb); | |
| long double d = (a + c) / 2.0L; | |
| long double e = (c + b) / 2.0L; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// for int32. | |
| /// a * (1/b) == (a * [(2^16 / b) + 1]) >> 16 | |
| #include <stdio.h> | |
| int make_recip(int const b) { | |
| return ((1 << 16) / b) + 1; | |
| } | |
| int fast_div(int const a, int const recip) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <limits.h> | |
| #include <time.h> | |
| #include <math.h> | |
| ssize_t ipow(ssize_t const x, size_t n) { | |
| ssize_t r = 1; | |
| while( n > 0 ) { | |
| if( n & 1 ) { | |
| r *= x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <inttypes.h> | |
| #include <stdio.h> | |
| static inline uint8_t bitwise_ceil8(uint8_t x) { | |
| x |= x >> 1; | |
| x |= x >> 2; | |
| x |= x >> 4; | |
| return x; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def int_to_aii_numeral(num): | |
| # greedy approach similar to https://leetcode.com/problems/integer-to-roman/description/ | |
| # time O(1) | |
| # space O(1) | |
| # based on the numerals here: https://en.wiktionary.org/wiki/Module:number_list/data/aii | |
| numerals = [ | |
| (1000, 'ܐ݇'), | |
| (900, 'ܨ̈'), (800, 'ܦ̈'), (700, 'ܥ̈'), (600, 'ܣ̈'), (500, 'ܢ̈'), (400, 'ܬ'), | |
| (300, 'ܫ'), (200, 'ܪ'), (100, 'ܩ'), (90, 'ܨ'), (80, 'ܦ'), (70, 'ܥ'), (60, 'ܣ'), |