Skip to content

Instantly share code, notes, and snippets.

View coreyjs's full-sized avatar

Corey Schaf coreyjs

View GitHub Profile
@coreyjs
coreyjs / sum_pairs.py
Created August 6, 2020 16:52
K-diff pairs in an array
from collections import Counter
def find_pairs(nums, k) -> int:
# if k < 0, the result is 0
if k < 0:
return 0
count = Counter(nums)
pairs = set([])
@coreyjs
coreyjs / left.rb
Created August 6, 2020 01:44
Left Rotate an Array
#!/bin/ruby
require 'json'
require 'stringio'
# Complete the rotLeft function below.
def rotLeft(a, d)
out = Array.new(a.length)
(0..a.length-1).each do |i|
new_location = (i + (a.length - d)) % a.length
@coreyjs
coreyjs / string_permuatations.rb
Created July 25, 2020 15:37
Hash all string permutations
hash = {}
0.upto(s1.length.to_i - 1).flat_map do |start|
1.upto(s1.length - start).map do |length|
hash[s1[start, length]] = length
end
end.uniq
@coreyjs
coreyjs / two_strings_problem.rb
Last active July 25, 2020 16:09
Compare two strings to see if there is a subset
#!/bin/ruby
require 'json'
require 'stringio'
require 'set'
# Complete the twoStrings function below.
#s1, s2: two strings to analyze .
def twoStrings(s1, s2)
@coreyjs
coreyjs / landscape_M.txt
Last active March 13, 2019 18:02
Unreal Basic Landscape Material
Begin Object Class=/Script/UnrealEd.MaterialGraphNode_Root Name="MaterialGraphNode_Root_0"
Material=PreviewMaterial'"/Engine/Transient.My_Landscape_M"'
NodePosX=560
NodePosY=-240
NodeGuid=3AE30DA94F8C789AFCCA76A064E7DFA7
CustomProperties Pin (PinId=8465D6104324CDFC1236A7AA3BF0C172,PinName="Base Color",PinType.PinCategory="materialinput",PinType.PinSubCategory="5",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(MaterialGraphNode_8 BD5EE9314271722DEBE601979B4CDC2F,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=72F1750A40A5CF95548D899BDCDA51EF,PinName="Metallic",PinType.PinCategory="materialinput",PinType.PinSubCategory="6",PinType.PinSubCatego
@coreyjs
coreyjs / dcp3.rb
Created February 25, 2019 18:53
Daily Coding Email Challenge 3
puts 1
@coreyjs
coreyjs / dcp1.rb
Created February 25, 2019 18:53
Daily Coding Email Challenge 2
puts 'Daily Coding Challenge 1'
puts 'Given a list of numbers and a number k, return whether any two numbers from the list add up to k.'
input = [10, 15, 3, 7]
k = 17
puts "input = #{input.to_s}"
puts "k = #{k}"
input.each_with_index do |num, i|
@coreyjs
coreyjs / dcp2.rb
Created February 25, 2019 18:52
Daily Coding Email Problem 2
#Given an array of integers, return a new array such that
# each element at index i of the new array is the product of all the
# numbers in the original array except the one at i.
input = [1, 2, 3, 4, 5]
input2 = [3, 2, 1]
def sum_array(input)
total = input.reduce(1, :*)
out = []
@coreyjs
coreyjs / gist:3197326b6016acb444a18a8251b15c88
Created November 1, 2018 12:44
flake8 cli for serverless python
flake8 --exit-zero --count --max-line-length 120 --exclude=node_modules,.cache,.serverless_plugins,.circleci,.pytest_cache,postman,sls,.serverless
require 'test_helper'
class AppTest < ActiveSupport::TestCase
# 1
test "app should save with unqiue name and token" do
app1 = App.new(name: 'Hello World', token: '13456')
app2 = App.new(name: 'Goodbye World', token: 'abcdef')
assert app1.save
assert app2.save