BlogHide Resteemsdrago18121996 (68)in ita • 9 days agoCountexport function nucleotideCounts(lett:string) { const res: Record = { A: 0, C: 0, G: 0, T: 0,}; // ricordarsi la virgola alla fine! for(let i=0; idrago18121996 (68)in ita • 10 days agoBinary searchexport function find(haystack: number[], needle: number, counter: number = 0): number | never { const maxNumber = Math.max(...haystack); let middle = Math.floor(haystack.length/2); if(needle ===…drago18121996 (68)in ita • 11 days agoHandshakelet arr : string[] =["wink" ,"double blink","close your eyes", "jump"]; export function commands(num: number): string[] { let res: string[] = []; const binArr = num.toString(2).padStart(5…drago18121996 (68)in ita • 13 days agoLengthexport function encode(text:string) { let res = ""; let num = 1; for(let i=0; idrago18121996 (68)in ita • 15 days agoBasesexport function convert( digits: number[], inputBase: number, outputBase: number ): number[] { let res: number[] = []; let resNum = 0; let exp = digits.length-1; let toAdd = 0; if…drago18121996 (68)in ita • 19 days agoSeriesexport class Series { series: string; constructor(series: string) { this.series = series; if(this.series.length === 0) throw new Error('series cannot be empty'); } slices(sliceLength:…drago18121996 (68)in ita • last monthAffine{ let lower = phrase.toLowerCase().replaceAll(' ', ''); let alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m', 'n','o','p','q','r','s','t','u','v','w','x','y','z']; let m = 26;…drago18121996 (68)in ita • last monthAffinefunction encode(string $text, int $num1, int $num2): string{ $res = ""; $alphabet = range('a', 'z'); $lowerString = strtolower($text); $counter = 0; if(!isGcd($num1, 26)){throw new Exception();}drago18121996 (68)in ita • last monthSumdeclare(strict_types=1); function sumOfMultiples(int $number, array $multiples): int{ $res = 1; $setres = []; foreach($multiples as $mult){ if($mult < 1 || $mult > $number) continue; $i…drago18121996 (68)in ita • 2 months agoETLexport function transform(old: {[key: string]: string[]}) { let expected: {[key: string]: number} = {}; for(const [keys, values] of Object.entries(old)){ for(const elm of values){…drago18121996 (68)in ita • 2 months agoDiamontimport java.util.*; class DiamondPrinter { String repeatAllSegm(int count){drago18121996 (68)in ita • 2 months agoLindergarten// // This is only a SKELETON file for the 'Kindergarten Garden' exercise. // It's been provided as a convenience to get you started writing code faster. // const DEFAULT_STUDENTS: Student[] =…drago18121996 (68)in ita • 2 months agoGarden// // This is only a SKELETON file for the 'Kindergarten Garden' exercise. // It's been provided as a convenience to get you started writing code faster. // const DEFAULT_STUDENTS = […drago18121996 (68)in ita • 3 months agoAngramexport class Anagram { input : string; constructor(input: string) { this.input = input.toLowerCase(); } public matches(...potentials: string[]): string[] { let res: string[] = []; let…drago18121996 (68)in ita • 3 months agoComplex informationexport class ComplexNumber { r : number; i : number; constructor(real: number, imaginary: number) { this.r = real; this.i = imaginary; } public get real(): number { return this.r; }…drago18121996 (68)in ita • 3 months agoBobusing System; using System.Text.RegularExpressions; public static class Bob { public static string Response(string statement) { string statementmod= statement.Trim(); bool isQuestion =…drago18121996 (68)in ita • 3 months agoPHPdeclare(strict_types=1); function steps(int $number): int{ if($number 1){ if($number % 2 ==0){ $number /= 2; } else{ $number = 3*$number+1; } $counter +=1; } return $counter; }drago18121996 (68)in ita • 3 months agoAccumulatedeclare(strict_types=1); function accumulate(array $input, callable $accumulator): array{ $result = []; for($i=0; $idrago18121996 (68)in ita • 3 months agoHandshakeexport const commands = (numb) => { let result = []; if(numb & 1) result.push('wink'); if(numb & 2) result.push('double blink'); if(numb & 4) result.push('close your eyes'); if(numb & 8)…drago18121996 (68)in ita • 3 months agoGrainsexport const square = (num) => { if(num 64) throw new Error('square must be between 1 and 64'); return 2n**BigInt(num-1); }; export const total = () => { let result = 0n; for(let i=0; i