Skip to content

Instantly share code, notes, and snippets.

View Asatelit's full-sized avatar
😋

Yuri Kuschinsky Asatelit

😋
View GitHub Profile
@Asatelit
Asatelit / ts_pick-vs-record.ts
Last active May 4, 2023 20:38
TypeScript: Pick VS Record
// Definition of types
type Pick<T, K extends keyof T> = {
[P in K]: T[P];
}
type Record<K extends string, T> = {
[P in K]: T;
}
/*
Solution for HackerRank > Algorithms > Warmup > Diagonal Difference
https://www.hackerrank.com/challenges/simple-array-sum/diagonal-difference
See explanation in Russian at https://www.coursera.org/learn/algoritmizacija-vychislenij/lecture/zinYi/opriedielieniie-indieksov-eliemientov-matritsy-raspolozhiennykh-na-nad-i-pod
*/
(function solve(n, matrix) {
const diagonals = [0, 0];
for (let i = 1; i < n + 1; i += 1) {
/*
Solution for HackerRank > Algorithms > Warmup > Simple Array Sum
https://www.hackerrank.com/challenges/simple-array-sum/
*/
(function solve(n, ar) {
return ar.reduce((a, b) => a + b);
})(6, [1, 2, 3, 4, 10, 11]);
/*
Solution for HackerRank > Algorithms > Warmup > Compare the Triplets
https://www.hackerrank.com/challenges/compare-the-triplets
*/
(function solve(a0, a1, a2, b0, b1, b2) {
var aa = [a0, a1, a2];
var bb = [b0, b1, b2];
var a = 0;
var b = 0;