Skip to content

Instantly share code, notes, and snippets.

View overloadedargs's full-sized avatar

Crawford Wynnes overloadedargs

View GitHub Profile
@overloadedargs
overloadedargs / isbn.go
Created April 23, 2020 16:34
Isbn checkdigits
package main
import "fmt"
import "strings"
import "strconv"
func isbn10(s string) string {
ss := strings.Split(s, "")
sum := 0
@overloadedargs
overloadedargs / checkout.rb
Created April 21, 2020 13:24
Another checkout
require_relative 'product'
class Checkout
attr_reader :checkout_items, :products
def initialize
@products = Hash.new
@checkout_items = []
load_products
@overloadedargs
overloadedargs / happy.py
Created April 21, 2020 12:47
Happy Numbers
def is_happy(n):
while (n != 1):
digits = str(n)
sum = 0
i = 0
print n
while (i < len(digits)):
sum += int(digits[i]) ** 2
i += 1
n = sum
@overloadedargs
overloadedargs / distance.rb
Created April 21, 2020 12:43
Longest distance between identical numbers in a list ignoring identical numbers in between
# Longest distance between identical numbers in a list ignoring identical numbers in between
# e.g. input number of numbers 5, then each number followed by a return
# use gets.chomp to get console input
n = gets.chomp.to_i
h = Hash.new
(1..n).each do |i|
n = gets.chomp.to_i
if h[n]
h[n] << i
@overloadedargs
overloadedargs / loops.go
Created April 21, 2020 12:41
Showing the differences between loop types
package main
import "fmt"
func for_loop() {
sum := 0
for i := 0; i < 10; i++ {
sum += i
}
fmt.Println(sum)