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
| #!/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
| 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' | |
| 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
| 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
| 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
| 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
| #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 = [] |
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
| flake8 --exit-zero --count --max-line-length 120 --exclude=node_modules,.cache,.serverless_plugins,.circleci,.pytest_cache,postman,sls,.serverless |
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
| 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 |