inheritance-vs-composition.md
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
<?php | |
namespace F3\Changelog; | |
use Composer\Semver\Semver; | |
use F3\Changelog\Exception\NoTagsFound; | |
use F3\Changelog\Exception\TagNotFound; | |
class ReleaseNotes | |
{ | |
/** |
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
<?php | |
$actionList = [ | |
'action-1' => "Начало дня", | |
'action-2' => "Поднимаюсь с кровати с левой ноги", | |
'action-3' => "Поднимаюсь с кровати с правой ноги", | |
'action-4' => "Падаю с кровати", | |
'action-5' => "Пробежка по аллее", | |
'action-6' => "Физ. зарядка на балконе", | |
'action-7' => "Варю крепкий кофе", |
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
function longest_ones_sequence(m) { | |
for ( | |
var r = m.length - 1, c = m[0].length - 1; | |
r >= 0 && c >= 0; | |
m[r][c] === '1' ? c-- : r-- | |
); | |
return m[0].length - c - 1; | |
} | |
console.log( |
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
function TreeBuilder() { | |
var makeEmptyNode = function() { | |
return { | |
"_items": [] | |
}; | |
}; | |
var root = makeEmptyNode(); |
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
#!/usr/bin/env php | |
<?php | |
require_once __DIR__ . '/vendor/autoload.php'; | |
$renamedClasses = (new NamespacePrefixAdder()) | |
->addPrefix( | |
'MyPrefix', | |
Files::inDirectories(['src', 'test']) | |
); |
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
/* | |
Баг в initializeIdAndName | |
1. Подумать, что в программе неправильно. | |
2. Вынести реализацию метода initializeIdAndName в класс User. | |
3. initializeIdAndName в классе User должен возвращать тип User. | |
4. Поправить программу, чтобы компилировалась и работала. | |
Такой код изначальный. | |
*/ |
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
function interpret(code) { | |
if (code.length == 0) return ''; | |
const machine = new (function(code) { | |
var x = 0; | |
var y = 0; | |
var dir = 'r'; | |
var stack = []; | |
var out = ''; | |
var skipNextMove= false; |
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
/* | |
Count the number of equivalence classes in an equivalence relation. | |
*/ | |
function EqRelation(len) { | |
let parent = []; | |
for (let i = 0; i < len; i++) parent.push(i); | |
const root = function(x) { | |
while (x !== parent[x]) x = parent[x]; | |
return x; |
- Design the object model for a currency conversion library. Assume you're working for a bank which allows its clients to deposit money into their USD account. Customers have cash in different currencies and want to know the amount in USD which will be added to their account. You want to create a library for a widget which calculates the resulting amount in USD.
UI looks like this:
[Currency name] [Amount]
[Currency name] [Amount]
[+]
…
[Resulting amount in USD]