Skip to content

Instantly share code, notes, and snippets.

View chuckgreenman's full-sized avatar

Chuck Greenman chuckgreenman

View GitHub Profile
@chuckgreenman
chuckgreenman / output.txt
Last active October 21, 2017 16:07
Example output of insert sort on an array.
==== Starting Array State ====
[4 7 3 2 8 9 3 1]
==== Permutations of Array ====
[4 7 3 2 8 9 3 1]
[3 4 7 2 8 9 3 1]
[2 3 4 7 8 9 3 1]
[2 3 4 7 8 9 3 1]
[2 3 4 7 8 9 3 1]
[2 3 3 4 7 8 9 1]
[1 2 3 3 4 7 8 9]
@chuckgreenman
chuckgreenman / insert_sort.go
Created October 21, 2017 16:01
This is an implementation of insertion sort in Go.
package main
import (
"fmt"
)
func main() {
array := []int{4,7,3,2,8,9,3,1}
for i:=1; i<len(array); i++ {
for j:=i; j>0 && array[j-1]>array[j]; j-- {
package main
import (
bcrypt "golang.org/x/crypto/bcrypt"
"fmt"
)
func main() {
password := []byte("password123")
fmt.Println("Creating hashword")
@chuckgreenman
chuckgreenman / pse3.2
Created October 15, 2017 17:04
Project Euler Problem #3 Solution
#!/bin/python3
import sys, math
t = int(input().strip())
for a0 in range(t):
n = int(input().strip())
factor_list = []
while (n % 2 == 0):
factor_list.append(2)
@chuckgreenman
chuckgreenman / fermat.sudo
Created October 11, 2017 18:59
Fermat Factorization Method Sudocode
FermatFactor(N): // N should be odd
a ← ceil(sqrt(N))
b2 ← a*a - N
while b2 is not a square:
a ← a + 1 // equivalently: b2 ← b2 + 2*a + 1
b2 ← a*a - N // a ← a + 1
endwhile
return a - sqrt(b2) // or a + sqrt(b2)
@chuckgreenman
chuckgreenman / pse2.2.py
Created October 11, 2017 17:59
Project Euler Problem #2 Solution
#!/bin/python3
import sys
t = int(input().strip())
for a0 in range(t):
n = int(input().strip())
s = 0
previous_fibonacci = 0
@chuckgreenman
chuckgreenman / pse2.1.py
Created October 11, 2017 16:53
Beginning State of Project Euler Problem 2.1
#!/bin/python3
import sys
t = int(input().strip())
for a0 in range(t):
n = int(input().strip())
@chuckgreenman
chuckgreenman / pse1.1
Created October 11, 2017 15:48
Beginning state of Project Euler Problem #1 on HackerRank
#!/bin/python3
import sys
t = int(input().strip())
for a0 in range(t):
n = int(input().strip())
@chuckgreenman
chuckgreenman / pes1.py
Created October 11, 2017 15:40
Project Euler Problem 1 Solution
#!/bin/python3
import sys
import math
t = int(input().strip())
for a0 in range(t):
n = int(input().strip())
n=n-1
sumd = 0
sumd += (5*((math.floor(n/5)*(math.floor(n/5)+1))//2))
@chuckgreenman
chuckgreenman / source.go
Created July 23, 2017 22:21
A simple script to get the source of a webpage in golang
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func get_page_source(url string) string {
response, error := http.Get(url)