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 | |
require_once "./DbSimple/Generic.php"; | |
class PampersTrash { | |
private static $instance; | |
private static $dbConf = array( | |
"user" => "root", | |
"password" => "******", | |
"database" => "storages", | |
"host" => "localhost", |
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
var rs = require('request'), max_downloaded = 5, cnt = 0, data_str = '', links = [], queue = [], finished = [], save_dir = 'tmp', fs = require('fs'), regexp = /filename=\"(.*)\"/gi; | |
process.stdin.on('data', function(data) { | |
data_str += data; | |
if (data_str.match("\n")){ | |
links = data_str.split("\n").filter(url => url.length > 10); | |
parseLinks(); | |
} | |
}); | |
function parseLinks() { |
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
1. Обработка строк без регулярных выражений с примитивными типами: | |
fscanf($stdin, "%d\n", $ar_count); | |
fscanf($stdin, "%[^\n]", $ar_temp); | |
2. Обработка массива и преобразование типа: | |
$ar = array_map('intval', preg_split('/ /', $ar_temp, -1, PREG_SPLIT_NO_EMPTY)); | |
3. Вместо foreach для суммирования можно использовать: array_sum |
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 | |
// Complete the diagonalDifference function below. | |
function diagonalDifference($arr) { | |
$count = count($arr); | |
$d1=0; $d2=0; | |
for($i=0;$i<$count;$i++){ | |
$d1+=$arr[$i][$i]; | |
$d2+=$arr[$i][$count-$i-1]; | |
} |
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
Из чужих решений узнал про функцию bcdiv: | |
string bcdiv ( string $dividend , string $divisor [, int $scale = 0 ] ) | |
Операция деления для чисел произвольной точности |
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
Искал перловое 'STR' x SCALAR, но не помнил название функции, в итоге в солюшинах нашел str_repeat |
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
крутое решение на питоне: | |
a = input().strip().split(' ') | |
for i in range(0, len(a)): | |
a[i] = int(a[i]) | |
s = sum(a) | |
print(str(s - max(a)) + " " + str(s - min(a))) |
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 | |
// Complete the birthdayCakeCandles function below. | |
function birthdayCakeCandles($ar) { | |
$maxHeight = max($ar); $cnt=0; | |
foreach($ar as $candle){ | |
if($candle == $maxHeight){ | |
$cnt++; | |
} | |
} |
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 | |
/* | |
* Complete the timeConversion function below. | |
*/ | |
function timeConversion($s) { | |
if (preg_match('/(.+?)(\w{2})$/',$s, $matches)){ | |
$date = explode(":", $matches[1]); | |
if ($matches[2] == 'PM' && $date[0] < 12){ | |
$date[0]+=12; |
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
Новые функции при работе с массивами: | |
end - последний элемент (а я то трахался с тем чтобы -1 получить) | |
current - текущий элемент (когда мы берем элементы через next()) | |
next - следующий элемент массива, не знаю зачем оно может пригодиться если что. |
OlderNewer