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 assert = require('node:assert'); | |
const parseInt = (n) => Number.parseInt(n) | |
function versionComparator(v1, v2) { | |
const v1arr = v1.split('.').map(parseInt); | |
const v1arrlen = v1arr.length; | |
const v2arr = v2.split('.').map(parseInt); | |
const v2arrlen = v2arr.length; | |
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
### The original Author of this package had enabled CloudFlare JS verification. As a result, this automated script will not work. | |
### Therefore you have to download each package and install it manually. | |
## Change Directory | |
cd /tmp/ | |
## Update opkg | |
opkg update | |
## If wget not installed already |
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
/** | |
* Дан массив из чисел | |
* Все значения, кроме одного, повторяются. | |
* Найти уникальное значение за O(n). | |
* Известно, что уникальное значение одно и только одно | |
* Пример: | |
* Вход: [5,9,6,1,9,6,5] | |
* Выход: [1] | |
* | |
*/ |
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
// using string sequence, get object key | |
//'red.big.apple', {red: { big: { apple: 'apple'}}} => 'apple' | |
// 'red.fast.fancy.car', { red: { slow: 'something'}} => undefined | |
const get = (keySequence, nestedObject) => { | |
const seqArr = keySequence.split("."); | |
let result = nestedObject; | |
while (seqArr.length > 0) { | |
let key = seqArr.shift(); // seqArr now has length-1 |
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
import React from "react"; | |
import ReactDOM from "react-dom"; | |
// counter app | |
function App() { | |
const [counter, setCounter] = React.useState(0); | |
const [working, setWorking] = React.useState(false); | |
React.useEffect(() => { | |
if (!working) return; |
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
// Simple Promise.all realization | |
function promiseAll(promises) { | |
try { | |
let len = promises.length; | |
let count = len; | |
const results = new Array(len).fill(null); | |
return new Promise((resolve, reject) => { | |
promises.forEach((p, idx) => { | |
p.then((res) => { |
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
/** | |
* Дан массив A из n — 1 целых чисел, находящихся в интервале от 1 до n. | |
* Все числа встречаются в нём ровно один раз, за исключением одного отсутствующего числа. | |
* Найти это отсутствующее число. | |
*/ | |
const findMissingNumber = (A, n) => { | |
// XORing from 1 to n+1 |
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
version: 2.1 | |
orbs: | |
aws-s3: circleci/[email protected] | |
node: circleci/[email protected] | |
workflows: | |
version: 2 | |
build_and_deploy: | |
jobs: |
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
faced_cards = {'Jack': 11, 'Queen': 12, 'King': 13, 'Ace': 14} | |
cards_in_hand = [int(x) if faced_cards.get(x) is None else faced_cards.get(x) for x in [input() for _ in range(6)]] | |
print(sum(cards_in_hand)/len(cards_in_hand)) | |
# Sample Input 1: | |
# | |
# Ace | |
# 4 | |
# 9 | |
# Jack |
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
package main | |
import ( | |
"context" | |
"encoding/json" | |
"errors" | |
"fmt" | |
"io" | |
"io/ioutil" | |
"log" |
NewerOlder