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
# This works | |
status = ps5000a.ps5000aSetSimpleTrigger( | |
self.handle, # handle | |
ctypes.c_int16(1), # enable | |
ps5000a.PS5000A_CHANNEL['PS5000A_EXTERNAL'], | |
ctypes.c_int16(800), | |
ps5000a.PS5000A_THRESHOLD_DIRECTION[f'PS5000A_RISING'], | |
ctypes.c_uint32(0), | |
ctypes.c_int16(1000) | |
) |
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
type MachineContext = { | |
fromDate: Date; | |
toDate: Date; | |
glucose: GlucoseReading[]; | |
}; | |
type MachineEvent = | |
| { | |
type: 'SET_FROM_DATE'; | |
fromDate: Date; |
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
var Node = function(key, value, next, previous) { | |
this.key = key | |
this.value = value | |
this.next = next | |
this.previous = previous | |
} | |
/** | |
* @param {number} capacity | |
*/ |
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
var mostCommonWord = function(paragraph, banned) { | |
const words = paragraph.toLowerCase().split(/\W+/) | |
const freqs = frequencies(words, banned) | |
return findMaxWord(freqs) | |
}; | |
function frequencies(words, banned) { | |
const freqs = {} | |
for (let w of words) { | |
if (w && !banned.includes(w)) { |
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
var maxProduct = function(nums) { | |
let max = -Infinity | |
const memo = {} | |
for (let i=0; i < nums.length; i++) { | |
const result = dp(nums, i, nums.length, memo) | |
if (result.max > max) { | |
max = result.max | |
} | |
} | |
return max |
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
var minimumDeviation = function(nums) { | |
nums.sort((a,b) => a - b) | |
let diff = nums[nums.length-1] - nums[0] | |
let diffExt = nums[0] !== nums[nums.length-1] | |
let canOperate = nums[0] % 2 !== 0 || nums[nums.length-1] % 2 === 0 | |
while (diffExt && canOperate && diff > 1) { | |
console.log(nums, diff) | |
let oper = false | |
if (nums[0] % 2 !== 0) { | |
oper = true |
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
var convert = function(s, numRows) { | |
if (numRows === 1) return s | |
const mat = buildMatrix(s, numRows) | |
return buildResult(mat) | |
}; | |
function buildMatrix(s, numRows) { | |
const mat = initMatrix(numRows) | |
let r = 0, c = 0, down = true |
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
var findAllConcatenatedWordsInADict = function(words) { | |
const result = [] | |
for (let i=0; i < words.length; i++) { | |
if (findWord(i, words[i], words)) { | |
result.push(words[i]) | |
} | |
} | |
return result | |
}; |
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
var averageOfLevels = function(root) { | |
const valuesByLevel = [] | |
dfs(root, 0, valuesByLevel) | |
const result = [] | |
for (let i=0; i < valuesByLevel.length; i++) { | |
const arr = valuesByLevel[i] | |
result.push(average(arr)) | |
} | |
return result |
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
var isPossible = function(nums) { | |
if (nums.length === 0) return true | |
if (nums.length < 3) return false | |
const clone = [...nums.slice(1)] | |
const seq = [nums[0]] | |
for (let i=0; i < nums.length && seq.length < 3; i++) { | |
const next = seq[seq.length - 1] + 1 | |
if (nums[i] === next) { | |
clone.splice(i-seq.length, 1) |
NewerOlder