Skip to content

Instantly share code, notes, and snippets.

View grantmwilliams's full-sized avatar

Grant Williams grantmwilliams

View GitHub Profile
%% Standard Genetic Algorithm -- Solves For A User Input String
clear;close all;clc; %Clears variables, closes windows, and clears the command window
tic % Begins the timer
%% Select Target String
target = 'Hello, world!';
% *Can Be Any String With Any Values and Any Length!*
%% Parameters
%% Monkey Evolutionary Algorithm
clear;close all;clc;
tic
target = ('MORE GIDDY IN MY DESIRES THAN A MONKEY');
ideal = double(target);
best = inf;
Gen = 0;
phrase = randi([min(ideal) max(ideal)],1,length(target));
for Gen = 1:1e6 %arbitrarily large
% Monkey 1
// fib_method.cpp -- Grant Williams \\
#include <stdio.h>
#include <fstream>
#include <math.h>
using namespace std;
//Uses matrix operations \\
void multiply(int F[2][2], int M[2][2]);
std::vector<int> get_primes(int limit)
{
std::vector<char> primes(limit, 1);
std::vector<int> final;
// 0 and 1 are nonprime by definition
primes[0] = 0; primes[1] = 0;
for (int i = 2; i * i <= limit; i++)
{
std::vector<int> get_primes(int limit)
{
std::vector<char> primes(limit + 1, 1);
std::vector<int> final;
// 0 and 1 are nonprime by definition
primes[0] = 0; primes[1] = 0;
for (int i = 2; i * i <= limit; i++)
{
arr[10001] = {0}
count = 1;
arr[0] = 2;
num = 2;
bool is_prime;
while (count < 10001) // loop through all numbers
{
num++; // starts with 3
is_prime = true; // sets the number to prime unless we find otherwise
#include <iostream>
#include <vector>
#include <cmath> // std::sqrt
#include <algorithm> // std::fill
#include <chrono>
// implementation of sieve of eratosthenes.
long get_primes(const unsigned long limit)
{
int count_lim = 10001;
-module(solution).
-export([main/0]).
% 1. If contains a "0" return DEAD
% 2. Use Deterministic Miller-Rabin Primality To Check Primality
% 3. If stripping from Left and Right gives primes return "CENTRAL"
% 4. Else If stripping from Left gives primes return "LEFT"
% 5. Else If stripping from Right gives primes return "RIGHT"
% 6. Else Return "DEAD"
""" This file uses a decision tree to classify the input data
and then loads the appropriate auxiliary dataset from the classification result
Uses SKlearn's decision tree implementation and as an example the
SKlearn iris dataset
"""
import sys
import numpy as np # only used to create our example datasets.
import pandas as pd # only used to create our example datasets.
from sklearn.datasets import load_iris
@grantmwilliams
grantmwilliams / iter_parquet.py
Created June 27, 2021 12:45
Pyarrow iter_batches as python native iterable
import s3fs
import pyarrow as pa
import pyarrow.parquet as pq
from itertools import chain
from typing import Tuple, Any
def iter_parquet(s3_uri: str, columns = None, batch_size=1_000) -> Tuple[Any]: