Last active
April 3, 2019 11:13
-
-
Save alpharder/a2d1100a874dd705e68d7f40bec7099e to your computer and use it in GitHub Desktop.
У вас нет доступа к библиотекам для работы с большими числами. Дано два положительных целых числа в виде строки. Числа могут быть очень большими, могут не поместиться в 64 битный integer. Использование exec не допускается. Задание: Написать функцию которая вернет сумму этих чисел.
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
<?php | |
$sum_test_cases = [ | |
['1', '2', '3'], | |
['1', '100', '101'], | |
['0', '0', '0'], | |
['1234567', '1', '1234568'], | |
['9999999', '1', '10000000'], | |
// Следующие значения значительно больше, чем Int64 | |
['9923372036854775807', '9923372036854775807', '19846744073709551614'], | |
['8547758079923372036', '282076016637471277188', '290623774717394649224'], | |
['716677228283328742446576', '88239450377928284756249776848', '88240167055156568084992223424'], | |
]; | |
function add(string $left, string $right): string | |
{ | |
return ''; | |
} | |
foreach ($sum_test_cases as $case) { | |
list($left, $right, $expected_result) = $case; | |
assert(add($left, $right) === $expected_result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment