Skip to content

Instantly share code, notes, and snippets.

View ConnorBaker's full-sized avatar
⚱️
burnt out

Connor Baker ConnorBaker

⚱️
burnt out
  • Costa Mesa, CA
  • 20:19 (UTC -07:00)
View GitHub Profile
@ConnorBaker
ConnorBaker / CeilingFunctionAlt.hs
Created May 24, 2020 14:07
Solution to https://open.kattis.com/problems/ceiling, using paths to represent shapes of trees
{-# LANGUAGE DeriveFoldable, DeriveFunctor, ScopedTypeVariables #-}
module Main where
import Prelude hiding ( Left
, Right
)
import Data.List hiding ( insert )
import Control.Monad
{-# LANGUAGE DeriveFoldable, DeriveFunctor, ScopedTypeVariables #-}
module Main where
import Data.List hiding ( insert )
import Control.Monad
data BTree a = Leaf | Branch (BTree a) a (BTree a)
deriving (Eq, Foldable, Functor, Ord, Show)
import json
from typing import Any, List, Type, Union
db_names: List[str] = []
db_name_prefix: str = 'db'
db_name_extension: str = '.json'
BOILER_PLATE: str = """drop table if exists department;
drop table if exists course;
drop table if exists prereq;

Keybase proof

I hereby claim:

  • I am connorbaker on github.
  • I am connorbaker (https://keybase.io/connorbaker) on keybase.
  • I have a public key ASDavI4e5NYfd4HiaXd8ehN-lv_erDyAQD_t-nJt0bTjDgo

To claim this, I am signing this object:

@ConnorBaker
ConnorBaker / HW2-macOS-setup.md
Last active March 22, 2020 01:22
HW2 macOS Setup

Hello all,

After a two incredibly frustrating hours I finally got my connection working on macOS. I thought I'd share the difficult (at least, it was for me) portion of the setup.

Prerequisites

  • macOS 10.15.3
  • Python 3.7.3 (installed via brew)
  • zorba 3.1 (installed via brew)
module WeightForWeight
( main
)
where
import Data.Char
import Data.List
-- Inspired by https://raymii.org/s/blog/Weight_for_Weight_a_coding_exersize_that_kept_me_busy.html
fn contiguous_subsequences(v: Vec<u64>) -> Vec<Vec<u64>> {
let n = v.len();
let mut ret: Vec<Vec<u64>> = vec![Vec::with_capacity(1); n * (n + 1) / 2];
let mut index: usize = 0;
for i in 1..n + 1 {
for j in 0..n - i + 1 {
ret[index] = v[j..j + i].to_vec();
index+=1;
}
import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import static java.util.stream.Collectors.toList;
public class Main {
public static List<Long> binaryNialpdromes(int n) {
public static List<Long> binaryNialpdromes(int n) {
final var ret = new ArrayList<Long>(n*(n+1)/2);
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
ret.add((long) (Math.pow(2.0, i) - Math.pow(2.0, j)));
}
}
return ret;
@ConnorBaker
ConnorBaker / Lib.hs
Last active November 3, 2019 20:13
Trying to work out some math stuff
{-# OPTIONS_GHC -Wall -Wredundant-constraints -Wall-missed-specialisations#-}
-- The more things that we export from the module, the larger the performance
-- penalty. This is odd and I don't like it.
module Lib
( someFunc
-- , selectFrom
-- , binaryNialpdromes
-- , binaryNialpdromesOfLength
-- , powersOfTwo