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 one = 'Naharis'; | |
const two = 'Mormont'; | |
const three = 'Sand'; | |
//мое первое решение чез извлечение букв из строки | |
// BEGIN (write your solution here) | |
console.log(one[2] + two[1] + three[3] + two[4] + two[2]); | |
// END | |
// мое второе решение (через интерполяцию) |
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
// 1-ое решение | |
import { calculateDistanceBetweenTowns } from 'hexlet-basics/got'; | |
const from = 'The Twins'; | |
const to = 'The Eyrie'; | |
// BEGIN (write your solution here) | |
const route = `${from}-${to}`; | |
console.log(calculateDistanceBetweenTowns(route)); |
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 { getParentFor } from 'hexlet-basics/got'; | |
// мое 1-ое решение | |
// BEGIN (write your solution here) | |
const grandFatherOfJoffrey = getParentFor(getParentFor('Joffrey Baratheon'), 'father'); | |
console.log(grandFatherOfJoffrey); | |
// END | |
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
/*Спрятывание номера карты любым количеством звездочек*/ | |
// BEGIN (write your solution here) | |
const getHiddenCard = (cardNum, starCount = 4) => { | |
const cardNumCut = cardNum.slice(starCount, cardNum.length); | |
return cardNumCut.padStart(cardNum.length, '*'); | |
}; | |
// END | |
export default getHiddenCard; |
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
// BEGIN (write your solution here) | |
const capitalize = (str) => str.slice(0, 1).toUpperCase() + str.slice(1); | |
// END | |
export default capitalize; | |
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
/* Задание: | |
Реализуйте и экспортируйте по умолчанию функцию, которая переворачивает цифры в переданном числе и возвращает новое число. | |
Примеры: | |
reverseInt(13); // 31 | |
reverseInt(-123); // -321 | |
reverseInt(8900); // 98 | |
*/ |
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(m,n), принимает два неотрицательных целых числа в качестве параметров и возвращает натуральное число. | |
Эта функция растёт очень быстро, например, число A(4,4) настолько велико, что количество цифр в порядке этого числа многократно | |
превосходит количество атомов в наблюдаемой части Вселенной. | |
Функция Аккермана определяется рекурсивно для неотрицательных целых чисел m и n следующим образом: | |
= n + 1 при m = 0; | |
A(m, n) = A(m - 1, 1) при m > 0, n = 0; | |
= A(m - 1, A(m, n - 1) при m > 0, n > 0; |
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), цитозин (C), гуанин (G) и тимин (T). | |
Четыре нуклеотида в РНК это аденин (A), цитозин (C), гуанин (G) и урацил (U). | |
Цепь РНК составляется на основе цепи ДНК последовательной заменой каждого нуклеотида: | |
G -> C | |
C -> G | |
T -> A | |
A -> U |
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
/* Реализуйте и экспортируйте по умолчанию функцию, которая принимает на вход количество минут (прошедших с начала суток) и возвращает строку, являющуюся временем в формате чч:мм. Если количество минут содержит больше 24 часов (1 суток), то функция возвращает время, прошедшее с полуночи последних суток. | |
Примеры: | |
formattedTime(5); // 00:05 | |
formattedTime(15); // 00:15 | |
formattedTime(60); // 01:00 | |
formattedTime(67); // 01:07 | |
formattedTime(175); // 02:55 | |
formattedTime(600); // 10:00 |
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
Сумма квадратов первых десяти натуральных чисел это 12 + 22 + 32 + ... + 10 2 = 385. | |
Квадрат суммы первых десяти натуральных чисел это (1 + 2 + 3 + ... + 10)2 = 552 = 3025. | |
Разница между квадратом суммы и суммой квадратов первых десяти натуральных чисел: 3025 − 385 = 2640. | |
Напишите функцию sumSquareDifference(), которая принимает аргумент n и возвращает разницу между квадратом суммы и суммой квадратов первых n натуральных чисел. | |
// Натуральные числа - числа, возникающие естественным образом при счёте (1, 2, 3, 4, 5, 6, 7 и так далее. | |
// Отрицательные и нецелые числа к натуральным не относят. |
OlderNewer