Not too long ago I decided to create a rather useless project. It shows emoji and color of the day. All of this is calculated by my formulas using my own algorithms on client-side.
*`t` - timestamp - const - 00:00 of this day in UTC.
### Emojis:
The formula incorporates certain coefficients that are already substituted. The formula is not fully adapted. Some Unicode characters are missing, so I tried to find the longest consecutive sequences of emojis.
*`tr` - `vector<int>` - const - the start of emoji sequences (in Unicode).
*`ts` - `vector<int>` - const - the difference between the numbers of the first and last elements in the sequences.
*`cet(t)` - a function used to calculate the sequence number of an emoji.
*`cev(t)` - a function used to calculate the decimal value of the emoji in Unicode.
Here, some cyclic operations are used, making it challenging to represent in a formulaic manner. I'll express it in pseudocode with a mix of mathematical formulas. This pseudocode may seem unconventional, but I am a genius, billionaire, and philanthropist. I have the complete right to use my algorithmic language if I am confident it will be understood by the reader (generally a mix of languages, but I believe it's quite evident).
*`sv(t)` - a function used to fill an array (not implemented as a function).
*`cf(n)` - a function used to precalculate factorial (not implemented as a function).
*`num2permutation(k, n)` - a function used to determine the required permutation (from $n!$) of the sequence corresponding to number k in lexicographical order.
```
func sv(int t) -> vector<int> {
vector<int> el(3, 0);
el[0] = t mod 1000;
el[1] = ⌊(t mod 1000000 - el[0]) / 1000⌋;
el[2] = ⌊(t - el[1] - el[0]) / 1000000⌋;
return el;
}
```
```
func cf(int n) -> vector<int> {
vector<int> factorials(n + 1, 1);
for i from 2 to n + 1 {
factorials.push(factorials[i - 1] * i);
}
return factorials;
}
```
```
func num2permutation(int k, int n) -> vector<string> {
*p.s. I feel that the problem of finding the required permutation can be solved with a lower asymptotic complexity (`color.js`). If you have ideas, please let me know about them.*