Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / Sudoku.js
Created October 8, 2023 20:12
Sudoku in javascript, created using Bing ChatGPT GPT4 https://jsbin.com/bivoficadi/edit?js,output
class Sudoku {
constructor(emptyCellCount = 20) {
this.solvedBoard = this.generateSudoku();
this.board = JSON.parse(JSON.stringify(this.solvedBoard));
this.clearCells(emptyCellCount);
}
clearCells(K) {
// Remove K elements randomly to create an 'easy' puzzle
for (let i = 0; i < K; i++) {
@primaryobjects
primaryobjects / app.js
Created October 3, 2023 03:28
RobotC car driving simulator, built in javascript with ThreeJs. Supports car movement, forwards, reverse, turning, and for loops. https://www.brightonk12.com/cms/lib/MI02209968/Centricity/Domain/517/robotc_tutorial1.pdf Demo at https://simple-robotc-simulator.primaryobjects.repl.co
// Create a scene
var scene = new THREE.Scene();
// Create a camera
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 5;
// Create a renderer
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
@primaryobjects
primaryobjects / text-analysis.R
Created October 1, 2023 01:26
Text analysis with word frequency, topic modeling using LDA, and word clouds. https://www.coursera.org/learn/applying-data-analytics-business-in-marketing/home/week/3
# Load the rvest package
library(rvest)
library(ggplot2)
library(tidytext)
library(tidyverse)
library(topicmodels)
library(tm)
library(wordcloud)
library(RColorBrewer)
@primaryobjects
primaryobjects / bogleheads-network.R
Last active September 30, 2023 21:08
Network analysis in a connected graph. Building a social network for most influential post authors based on post and replies https://www.coursera.org/learn/applying-data-analytics-business-in-marketing/lecture/7FPYu/network-analysis-with-r-part-2
# Network Analysis with R
# https://www.coursera.org/learn/applying-data-analytics-business-in-marketing/lecture/7FPYu/network-analysis-with-r-part-2
# Create a method in R to extract all posts listed on https://bogleheads.org and return their Author, Title, and Url.
#
# For example, the first result in the list might be:
# Title: Helping elderly parents with diminishing mental capacity
# Author: yakk0
# Url: https://www.bogleheads.org/forum/viewtopic.php?f=2&t=413715&newpost=7484050
@primaryobjects
primaryobjects / zombie.ipynb
Last active September 26, 2023 18:43
Quantum computing zombie simulation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@primaryobjects
primaryobjects / 1-word-cloud-comparison.Rmd
Last active September 11, 2023 13:08
Word Cloud Comparison Review using Bogleheads.org forum post title web scraping keywords in R https://www.coursera.org/learn/intro-business-analytics
---
title: "Word Cloud Comparison"
author: "Kory Becker"
date: "2023-09-11"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@primaryobjects
primaryobjects / creature.ipynb
Last active September 12, 2023 14:33
Quantum computing qiskit to generate a magical creature based upon a state vector. Uses DALLE to generate an image.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@primaryobjects
primaryobjects / rps.py
Last active September 8, 2023 17:52
Rock paper scissors quantum computing qiskit using 1 qubit
# Import Qiskit and numpy
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer
import numpy as np
# Define the quantum register and the classical register
qreg = QuantumRegister(1)
creg = ClassicalRegister(1)
qc = QuantumCircuit(qreg, creg)
# Define the basis states for rock, paper, and scissors
// Given an input of a dictionary of words and an input senetnce that does not contain spaces, write a method that returns the input sentence split into words.
// Input: "applesauceisfun", ["apple","applesauce","is","good"]
// Output: "applesauce is fun"
const dict = ["apple","applesauce","is","good"];
// Simple approach with indexOf (uses shorter words).
const sentenceSplit = (s, dict) => {
dict.sort((a, b) => { return b.length - a.length }).forEach(word => {
const merge = (nums1, m, nums2, n) => {
let index = m + n - 1; // Pointer to the current index being written to.
let i = m - 1; // Pointer to value to compare in nums1.
let j = n - 1; // Pointer to value to compare in nums2.
// Move from right to left, compare values i, j and write larger at index.
// If no more vaues in nums2, just choose nums1.
while (index >= 0) {
nums1[index--] = j < 0 || nums1[i] > nums2[j] ? nums1[i--] : nums2[j--];
}