This file contains 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 <stdlib.h> | |
#include <math.h> | |
void cholesky(float* m, int n) { | |
for (int i = 0; i < n; i++) { | |
for (int j = 0; j < i; j++) { | |
float sum = 0; | |
for (int k = 0; k < j; k++) { | |
sum += m[i * n + k] * m[j * n + k]; |
This file contains 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 <stdarg.h> | |
void fmt_int(char* buf, int n) { | |
int i = 0; | |
if (n < 0) { | |
*buf++ = '-'; | |
n = -n; | |
} |
This file contains 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 <stdlib.h> | |
#include <stdarg.h> | |
#include <string.h> | |
#include <assert.h> | |
#include <signal.h> | |
#include <execinfo.h> | |
void panic(const char* format, ...) { |
This file contains 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 <stdlib.h> | |
#include <string.h> | |
#include <math.h> | |
void* xmalloc(size_t size) { | |
void* ptr = malloc(size); | |
if (ptr == NULL) { | |
fprintf(stderr, "Failed to allocate %ld bytes\n", size); | |
exit(EXIT_FAILURE); |
This file contains 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 <stdlib.h> | |
#include <stdbool.h> | |
#define SDL_MAIN_HANDLED | |
#include <SDL2/SDL.h> | |
void* xmalloc(size_t size) { | |
void* ptr = malloc(size); | |
if (ptr == NULL) { |
This file contains 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
public class Main { | |
public static void main(String[] args) throws Exception { | |
var p = new RationalEllipticCurve.Point(new Rational(1), new Rational(2)); | |
var a = new Rational(-7); | |
var b = new Rational(10); | |
var curve = new RationalEllipticCurve(a, b); | |
var r = curve.multiply(p, -10); | |
System.out.println(r); |
This file contains 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
# Does the decimal expansion of 1/q terminate? | |
def terminates(q): | |
while q % 2 == 0: | |
q //= 2 | |
while q % 5 == 0: | |
q //= 5 | |
return q == 1 | |
# If the decimal expansion of 1/q terminates return 0, else return the period of the repeating digits. | |
def period(q): |
This file contains 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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <cstdint> | |
using namespace std; | |
using Digit = uint8_t; | |
using BigInt = vector<Digit>; |
This file contains 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
import math | |
SQRT_5 = math.sqrt(5) | |
PHI1 = (0.5, 0.5) | |
PHI2 = (0.5, -0.5) | |
def s5n_sub(s5n_1, s5n_2): | |
(a, b) = s5n_1 | |
(c, d) = s5n_2 | |
return (a - c, b - d) |
This file contains 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
if ARGV.length == 0 | |
puts "Usage: ruby esc.rb [filename]" | |
exit | |
end | |
prog = File.read ARGV[0] | |
prog = prog.gsub(/auto/, "automático") | |
prog = prog.gsub(/const/, "constante") | |
prog = prog.gsub(/double/, "doble"); |