Test der einzelnen zugefügten Features
This theme allows you to use MathJax directly in your Markdown! Click on this article to see some fancy math in action. Little teaser: $$ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} $$
Some fancy math thingy:
$$ \frac{d}{dx} \left( \int_{0}^{x} f(u) , du \right) = f(x) $$
$$ \frac{d}{dx} \left( \int_{g(x)}^{h(x)} f(u) , du \right) = f(h(x)) h’(x) - f(g(x)) g’(x) $$
$$ \texttt{Isn’t that cool?!} $$
Another cool thingy
We will prove this statement by induction on $h$.
Base Case: $h = 0$
The AVL tree of height 0 has no nodes, so $N_0 = 0$. The Fibonacci number $F_{0+2} = F_2 = 1$. Therefore,
$$ N_0 = 0 \geq F_2 - 1 = 1 - 1 = 0 $$
which holds true.
Base Case: $h = 1$
The AVL tree of height 1 has one node, so $N_1 = 1$. The Fibonacci number $F_{1+2} = F_3 = 2$. Therefore,
$$ N_1 = 1 \geq F_3 - 1 = 2 - 1 = 1 $$
which holds true.
Inductive Step:
Assume the claim holds true for $h = k$. That is,
$$ N_{k} \geq F_{k+2} - 1 \tag{I.H.} $$
For $h = k+1$, we know:
$$ N_{k+1} = N_{k} + N_{k-1} + 1 \tag{def. of $N_h$} $$
From the inductive hypothesis, $N_{k} \geq F_{k+2} - 1$ and $N_{k-1} \geq F_{k+1} - 1$. Substituting:
$$ N_{k+1} = N_{k} + N_{k - 1} + 1 \geq (F_{k+2} - 1) + (F_{k+1} - 1) + 1 $$
Thus, we get:
$$ N_{k+1} \geq F_{k+2} + F_{k+1} - 1 $$
By the definition of Fibonacci numbers:
$$ N_{k+1} \geq F_{k+3} - 1 $$
By the principle of mathematical induction, the statement holds for all $h \geq 0$.
Different $\LaTeX$ Fonts
$$ \text{Normal text.}\ \textit{Italic text.}\ \texttt{Typewriter text.}\ $$
<?php
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\Micro;
use Phalcon\Http\Response;
use Phalcon\Http\Request;
use Random\RandomException;
$di = new FactoryDefault();
$app = new Micro($di);
$request = new Request();
$response = new Response();
$redis = new Redis();
$response->setHeader('Content-type', 'text/html');
$response->setContentType('text/html', 'utf-8');
try { $redis->pconnect('127.0.0.1'); } catch (RedisException $e) {}
/**
* @throws RandomException
*/
function randomString($length = 10): string
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[random_int(0, $charactersLength - 1)];
}
return $randomString;
}
/**
* @throws RedisException
*/
function handleGo($id): void
{
global $response, $redis;
$return = $redis->get($id);
$response->redirect($return, true)->send();
}
/**
* @throws RedisException
* @throws RandomException
*/
function handleNew($id): void
{
global $response, $request, $redis;
if(empty($id)) { $id = randomString(); }
$url = $request->get('url');
$redis->set($id, $url);
$response->setContent("URL $url added with ID $id")->send();
}
function info(): void
{
$data = [
# 'Endpoints:',
# '- /go/<id> -> Redirect to URL given by id',
# '- /new/<id> -> Create Redirect to URL given by id, if id is empty, it is randomly generated'
];
$response = new Response();
$response->setContent(implode("<br>", $data))->send();
}
$app->get('/', 'info');
$app->get('/go/{id}', 'handleGo');
$app->get('/new/{id}', 'handleNew');
$app->handle($_SERVER['REQUEST_URI']);