This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| puts 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/ruby | |
| require 'json' | |
| require 'stringio' | |
| require 'set' | |
| # Complete the twoStrings function below. | |
| #s1, s2: two strings to analyze . | |
| def twoStrings(s1, s2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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([]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Storage | |
| attr_accessor :value | |
| def initialize | |
| @value = nil | |
| @map = {} # string, Storage | |
| end | |
| def map |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Function for calculating auc and roc | |
| def build_roc_auc(model, X_train, X_test, y_train, y_test): | |
| ''' | |
| INPUT: | |
| model - an sklearn instantiated model | |
| X_train - the training data | |
| y_train - the training response values (must be categorical) | |
| X_test - the test data | |
| y_test - the test response values (must be categorical) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def sigmoid(x): | |
| return 1 / (1 + np.exp(-x)) | |
| def output_formula(features, weights, bias): | |
| return sigmoid(np.dot(features, weights) + bias) | |
| def error_formula(y, output): | |
| return - y*np.log(output) - (1 - y) * np.log(1-output) | |
| def update_weights(x, y, weights, bias, learnrate): |