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
function utopianTree(n) { | |
//A naive way to approach this is to just sum through our years | |
//alternating between multiplying by 2 and adding 1 | |
//But there is a better way by considering that our even cycles | |
//are actually the sum of 2^m for m in 0..n where n is the even | |
//number of years. | |
// | |
//This is a special sum whose value is 2^n-1 - 1. | |
//See https://math.stackexchange.com/questions/1990137/the-idea-behind-the-sum-of-powers-of-2 | |
//Then our result can be determined in O(c) time |
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
var maxNStored = 1; | |
var storedFactorials = [1n, 1n] | |
function getFactorial(n){ | |
//We can say that if n is not in our stored factors, no other factorials | |
//are in there. Don't worry, we can't fill that stored factorial list | |
//up too big as factorials get big FAST. | |
if(n > maxNStored){ | |
let factorial = storedFactorials[maxNStored]; | |
for(let i = maxNStored + 1; i <= n; ++i){ | |
factorial *= BigInt(i); |
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
function superDigit(n, k) { | |
//This reminds me of a clever math trick, and makes me | |
//wonder if there are more. If you recursively sum a number | |
//and it the final number like this is divisible by 3, | |
//then the number is divisble by 3. Therefore, if n, k times | |
//will just become sum(n) * k and sum(n) * k % 3 === 0 | |
//then the super digit is 3, 6, 9. | |
// | |
//In fact, if the sum of digits is 9, then the super number IS 9. | |
//In fact, there IS a relationship between the sum of the digits |
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
//Let us make a table of factorials as I feel they're | |
//going to be really useful. | |
var maxNStored = 1; | |
var storedFactorials = [1n, 1n] | |
function getFactorial(n){ | |
//We can say that if n is not in our stored factors, no other factorials | |
//are in there. Don't worry, we can't fill that stored factorial list | |
//up too big as factorials get big FAST. | |
if(n > maxNStored){ | |
let factorial = storedFactorials[maxNStored]; |
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
self.global_node_coordinates = [[0,0,0] for c in range(len(g_x_data))] | |
for i, x in enumerate(g_x_data): | |
self.global_node_coordinates[i][0] = x | |
if self.highest_global_x == None or x > self.highest_global_x: | |
self.highest_global_x = x | |
if self.lowest_global_x == None or x < self.lowest_global_x: | |
self.lowest_global_x = x | |
for i, y in enumerate(g_y_data): | |
self.global_node_coordinates[i][1] = y | |
if self.highest_global_y == None or y > self.highest_global_y: |
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 bpy | |
from mathutils import Vector | |
import bmesh | |
import numpy as np | |
from math import * | |
import random as rand | |
import os, sys | |
import operator | |
from operator import itemgetter |
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
rp1 = self.rotated_p1 | |
rp2 = self.rotated_p2 | |
rp3 = self.rotated_p3 | |
alpha_numerator = ((rp2[1] - rp3[1])*(intersection_point[0] - rp3[0]) + (rp3[0] - rp2[0])*(intersection_point[1] - rp3[1])) | |
alpha_denominator = ((rp2[1] - rp3[1])*(rp1[0] - rp3[0]) + (rp3[0] - rp2[0])*(rp1[1] - rp3[1])) | |
alpha = alpha_numerator / alpha_denominator | |
beta_numerator = ((rp3[1] - rp1[1])*(intersection_point[0] - rp3[0]) + (rp1[0] - rp3[0])*(intersection_point[1] - rp3[1])) | |
beta_denominator = ((rp2[1] - rp3[1])*(rp1[0] - rp3[0]) + (rp3[0] - rp2[0])*(rp1[1] - rp3[1])) | |
beta = beta_numerator / beta_denominator |
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
//I'm so sorry to whomever works with this - yes, it's not even remotely perfect and I have much work to do | |
//Apologies ahead of time - Dante | |
float wind_speed; | |
float sign_period = 4.0; | |
float time = 0.0; | |
integer time_2 = 0; | |
float theta_min = 0.0; | |
float theta_max = 0.0; | |
float v_f = 0.0; |
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
// | |
//This is what happens when you get Markov Chains wrong. Magic! >:{D | |
// | |
var markov_id = 0; | |
var markovChain = []; | |
function parseNameCSVData(){ | |
var rawWordData = $('#name-csv-data').val().split(','); | |
var words = []; |
NewerOlder