Week 0x4 ∪ 0x5
Crypto
I am a weapons-grade finitist. I don’t believe in numbers larger than two.
stdint
itertools
fields.py
uint
count()
-c
-c
flag to Python to run a script directly at command line.;
podman start -l ; podman exec -it -l
time
to… time things./bin/bash
$ /bin/bash
user@DESKTOP-THMS2PJ:~/tmp$ time python3 -c "from itertools import count; print(0 in count())"
True
real 0m0.013s
user 0m0.014s
sys 0m0.000s
$ /bin/bash
user@DESKTOP-THMS2PJ:~/tmp$ time python3 -c "from itertools import count; print(1000 in count())"
True
real 0m0.012s
user 0m0.012s
sys 0m0.000s
10^\(n\) | real |
---|---|
1 | 00.012 |
2 | 00.012 |
3 | 00.012 |
4 | 00.013 |
5 | 00.013 |
6 | 00.027 |
7 | 00.164 |
8 | 01.498 |
9 | 16.810 |
uint32_t
uint64_t
?
<limits.h>
uint
s and int
s in C are rings
uint
\(n\)_t
\(\nRightarrow a + b > a\)num.c
atoi
- alphabetical to int<stdlib.h>
per man atoi
, but might work without that.uint8_t
values are equivalent to operations on the natural numbers modulo \(2^8\) \[
\mathbb{N}/(2^8)
\]INT_MAX
, UINT_MAX
, CHAR_MAX
, etc.
stdint
namesuint
\(n\)_t
\(: a + b \equiv a + b \pmod {2^n}\)stdint
uint64_t
models infinite \(\mathbb{N}\)ft | in. | .in | |
---|---|---|---|
A’ja | 6 | 4 | 0 |
Mean | 5 | 9 | 3 |
ft | in. | .in | |
---|---|---|---|
A’ja | 6 | 4 | 0 |
Mean | 5 | 9 | 3 |
Diff | 7 |
3
is more than 0
ft | in. | .in | |
---|---|---|---|
A’ja | 6 | 4 | 0 |
Mean | 5 | 9 | 3 |
Carry | 0 | 1 | 0 |
Diff | 7 |
ft | in. | .in | |
---|---|---|---|
A’ja | 6 | 4 | 0 |
Mean | 5 | 9 | 3 |
Carry | 0 | 1 | 0 |
Diff | 6 | 7 |
ft | in. | .in | |
---|---|---|---|
A’ja | 6 | 4 | 0 |
Mean | 5 | 9 | 3 |
Carry | 1 | 0 | 0 |
Diff | 6 | 7 |
ft | in. | .in | |
---|---|---|---|
A’ja | 6 | 4 | 0 |
Mean | 5 | 9 | 3 |
Carry | 1 | 0 | 0 |
Diff | 0 | 6 | 7 |
UINT_MAX
or ULONG_MAX
by:
man scanf
hadder.c
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
int main() {
int buf[6];
printf("Insert 2 heights as XftY.Zin, each on their own line\n");
scanf("%dft%d.%din", &buf[0], &buf[1], &buf[2]);
scanf("%dft%d.%din", &buf[3], &buf[4], &buf[5]);
printf("%dft%d.%din\n", buf[0], buf[1], buf[2]);
return 0;
}
stdint
uint8_t
s as digits in base 256 arithmeticdivmod
)1 | 3 | 9 | 5 | |
---|---|---|---|---|
3 | - | - | - | - |
4 | - | - | - | - |
1 | 3 | 9 | 5 | |
---|---|---|---|---|
3 | 3 | 9 | 27 | 15 |
4 | 4 | 12 | 36 | 20 |
100 | 30 | 9 | .5 | |
---|---|---|---|---|
30 | 3000 | 900 | 270 | 15 |
4 | 400 | 120 | 36 | 2 |
100 | 30 | 9 | .5 | |
---|---|---|---|---|
30 | 3000 | 900 | 270 | 15 |
4 | 400 | 120 | 36 | 2 |
\[ \begin{align*} 5& \times 4 \times 10^{-1} &= 2&\\ +5& \times 3 \times 10^{0} &= 15&\\ +9& \times 4 \times 10^{0} &= 36&\\ +9& \times 3 \times 10^{1} &= 270&\\ +3& \times 4 \times 10^{1} &= 120&\\ +3& \times 3 \times 10^{2} &= 900&\\ +1& \times 4 \times 10^{2} &= 400&\\ +1& \times 3 \times 10^{3} &= 3000&\\ \end{align*} \]
\[ \begin{align*} 139.5& = &1 * 10^2 + &3 * 10^1 + &9 * 10^0& + 5 * 10^{-1}\\ 34& = &&3 * 10^1 + &4 * 10^0&\\ \end{align*} \]
Take \(x = 10\) \[ \begin{align*} 139.5& = &1 * x^2 + &3 * x + &9& + 5 * x^{-1}\\ 34& = &&3 * x + &4&\\ \end{align*} \]
That is polynomial; can work with those.
\[ (x^2 + 3x + 9 + 5x^{-1})(3x + 4) \]
\[ (x^2 + 3x + 9 + 5x^{-1})(3x) + (x^2 + 3x + 9 + 5x^{-1})(4) \]
\[ (3x^3 + 9x^2 + 27x + 15) + (4x^2 + 12x + 36 + 20x^{-1}) \]
\[ 3x^3 + 13x^2 + 39x + 51 + 20x^{-1} \]
\[ 3x^3 + 13x^2 + 39x + 51 + 20x^{-1} \]
uint32_t
uint32_t *alias;
;uint64_t
uint32_t *alias = &array;
uint64_t tmp = alias[5];
stdint
uint64_t
s or 128 uint32_t
suint64_t
value returned the carry value (it was nice to keep track of)stdint