This file has been truncated, but you can view the full file.
This file contains 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
There was an exception - NameError(undefined local variable or method `game' for #<GameChannel:0x00007fdf89352800 @connection=#<ApplicationCable::Connection:0x00007fdf8d3f9070 @coder=ActiveSupport::JSON, @env={"rack.version"=>[1, 6], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "rack.url_scheme"=>"http", "SCRIPT_NAME"=>"/cable", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"puma 5.6.8 Birdie's Version", "GATEWAY_INTERFACE"=>"CGI/1.2", "REQUEST_METHOD"=>"GET", "REQUEST_PATH"=>"/cable", "REQUEST_URI"=>"/cable", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_HOST"=>"localhost:3001", "HTTP_CONNECTION"=>"Upgrade", "HTTP_PRAGMA"=>"no-cache", "HTTP_CACHE_CONTROL"=>"no-cache", "HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "HTTP_UPGRADE"=>"websocket", "HTTP_ORIGIN"=>"http://localhost:4321", "HTTP_SEC_WEBSOCKET_VERSION"=>"13", "HTTP_ACCEPT_ENCODING"=>" |
This file contains 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
const countArrayInversions = (arr) => { | |
let count = 0; | |
let sortedArr = []; | |
arr.reverse().forEach(n => { | |
// Search in sorted arr for insertion index | |
// The number of elements < n in the sorted array are inversions of n | |
const i = binaryInsort(sortedArr, n); | |
count += i; | |
}) | |
return count; |
This file contains 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 a string sentence, return the sentence with the words in the reverse order | |
# "I like apples" => "apples like I" | |
def reverseSentence(sentence): | |
words = sentence.split(" ") | |
return " ".join(words[::-1]) | |
# If input is an array of characters instead of a string | |
# ['I', ' ', 'l' , 'i', 'k', e', ' ', 'a', 'p', 'p', 'l', 'e', 's'] | |
# => ['a', 'p', 'p', 'l', 'e', 's', ' ', 'l', 'i', 'k', 'e', ' ', 'I'] | |
def reverseSentenceArray(arr): |
This file contains 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
{ | |
"message": "This certifies that bcowell completed the mazebot race in 123.812 seconds.", | |
"elapsed": 123.812, | |
"completed": "2019-07-15T03:47:00.566Z" | |
} |
This file contains 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 flipAndInvertImage(self, A: List[List[int]]) -> List[List[int]]: | |
return [[int(not i) for i in row[::-1]] for row in A] |
This file contains 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 sortedSquares(self, A: List[int]) -> List[int]: | |
B = [i**2 for i in A] | |
B.sort() | |
return B |
This file contains 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
netsh int ipv4 set dynamicport tcp start=1025 num=64510 | |
netsh int ipv4 show dynamicport tcp | |
New-ItemProperty ` | |
-Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" ` | |
-Name "TcpTimedWaitDelay" ` | |
-Value "30" ` | |
-PropertyType "DWord" |
This file contains 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 sortArrayByParity(self, A): | |
A.sort(key=lambda x: x%2) | |
return A |
This file contains 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 twoSum(self, nums: 'List[int]', target: 'int') -> 'List[int]': | |
index = {} | |
for i,num in enumerate(nums): | |
# build dictionary | |
if index.get(num) == None: | |
index[num] = i; | |
# if (target - num) is in dict | |
if index.get(target - num) != None: | |
if i != index.get(target-num): # cannot use same element |
This file contains 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 shortestToChar(self, S: 'str', C: 'str') -> 'List[int]': | |
# store index of all chars c | |
ind = [] | |
for i,c in enumerate(S): | |
if (c == C): | |
ind.append(i) | |
# Find shortest distance | |
# from current i to indexed c | |
arr = [] |
NewerOlder