#230 - Fibonacci Words

For any two strings of digits, $A$ and $B$, we define $F_{A,B}$ to be the sequence $(A,B,AB,BAB,ABBAB,\dots)$ in which each term is the concatenation of the previous two.

Further, we define $D_{A,B}(n)$ to be the $n^{\text{th}}$ digit in the first term of $F_{A,B}$ that contains at least $n$ digits.

Example:

Let $A = 1415926535$, $B = 8979323846$. We wish to find $D_{A,B}(35)$, say.

The first few terms of $F_{A,B}$ are: \(1415926535 \\ 8979323846 \\ 14159265358979323846 \\ 897932384614159265358979323846 \\ 1415926535897932384689793238461415\mathbf{\color{red}9}265358979323846\)

Then $D_{A,B}(35)$ is the $35^{\text{th}}$ digit in the fifth term, which is 9.

Now we use for $A$ the first 100 digits of $\pi$ behind the decimal point:

$14159265358979323846264338327950288419716939937510$

$58209749445923078164062862089986280348253421170679$

and for $B$ the next hundred digits:

$82148086513282306647093844609550582231725359408128$

$48111745028410270193852110555964462294895493038196$

Find $\sum_{n=0}^{17}10^n\times D_{A,B}((127+19n)\times 7^n)$

Using UNet and PyTorch Lightning to detect Contrails in Images

Using UNet and PyTorch Lightning to detect Contrails in Images

Using an image segmentation approach to tackle the Contrail Detection Kaggle competition by Google Research

This is part 1 in a short series of notebooks that will aim to tackle the Kaggle competition of predicting the presence of contrails in infrared image bands. The competition itself was hosted by Google Research and has since ended.

#308 - An Amazing Prime-generating Automaton

A program written in the programming language Fractran consists of a list of fractions.

The internal state of the Fractran Virtual Machine is a positive integer, which is initially set to a seed value. Each iteration of a Fractran program multiplies the state integer by the first fraction in the list which will leave it an integer.

For example, one of the Fractran programs that John Horton Conway wrote for prime-generation consists of the following 14 fractions: \(\frac{17}{91}, \frac{78}{85}, \frac{19}{51}, \frac{23}{38}, \frac{29}{33}, \frac{77}{29}, \frac{95}{23}, \frac{77}{19}, \frac{1}{17}, \frac{11}{13}, \frac{13}{11}, \frac{15}{2}, \frac{1}{7}, \frac{55}{1}\) Starting with the seed integer 2, success iterations of the program produce the sequence:

15, 825, 725, 1925, 2275, 425, …, 68, 4, 30, …, 136, 8, 60, …, 544, 32, 240, …

The powers of 2 that appear in this sequence are $2^2$, $2^3$, $2^5$, …

It can be shown that all the powers of 2 in this sequence have prime exponents and that all the primes appear as exponents of powers of 2, in proper order!

If someone uses the above Fractran program to solve Project Euler Problem 7 (find the $10001^{\text{st}}$ prime), how many iterations would be needed until the program produces $2^{10001\text{st prime}}$?

#345 - Matrix Sum

We define the Matrix Sum of a matrix as the maximum possible sum of matrix elements such that none of the selected elements share the same row or column.

For example, the Matrix Sum of the matrix below equals 3315 (= 863 + 383 + 343 + 959 + 767):

  7  53 183 439 863
497 383 563  79 973
287  63 343 169 583
627 343 773 959 943
767 473 103 699 303

Find the Matrix Sum of:

  7  53 183 439 863 497 383 563  79 973 287  63 343 169 583
627 343 773 959 943 767 473 103 699 303 957 703 583 639 913
447 283 463  29  23 487 463 993 119 883 327 493 423 159 743
217 623   3 399 853 407 103 983  89 463 290 516 212 462 350
960 376 682 962 300 780 486 502 912 800 250 346 172 812 350
870 456 192 162 593 473 915  45 989 873 823 965 425 329 803
973 965 905 919 133 673 665 235 509 613 673 815 165 992 326
322 148 972 962 286 255 941 541 265 323 925 281 601  95 973
445 721  11 525 473  65 511 164 138 672  18 428 154 448 848
414 456 310 312 798 104 566 520 302 248 694 976 430 392 198
184 829 373 181 631 101 969 613 840 740 778 458 284 760 390
821 461 843 513  17 901 711 993 293 157 274  94 192 156 574
 34 124   4 878 450 476 712 914 838 669 875 299 823 329 699
815 559 813 459 522 788 168 586 966 232 308 833 251 631 107
813 883 451 509 615  77 281 613 459 205 380 274 302  35 805

#176 - Right-angled triangles that share a cathetus

The four right-angled triangles with sides (9, 12, 15), (12, 16, 20), (5, 12, 13) and (12, 35, 37) all have one of the shorter sides (catheti) equal to 12. It can be shown that no other integer sided right-angled triangle exists with one of the catheti equal to 12.

Find the smallest integer that can be the length of a cathetus of exactly 47547 different integer sided right-angled triangles.


#282 - The Ackermann Function

For non-negative integers $m$, $n$, the Ackermann function $A(m, n)$ is defined as follows: \[A(m, n) = \begin{cases} n + 1\quad\quad &\text{if }m = 0 \\ A(m - 1, 1)\quad\quad &\text{if }m > 0\text{ and }n = 0 \\ A(m - 1, A(m, n - 1))\quad\quad &\text{if }m > 0\text{ and }n > 0 \end{cases}\]

For example $A(1, 0) = 2$, $A(2, 2) = 7$ and $A(3, 4) = 125$.

Find $\displaystyle\sum_{n=0}^6 A(n, n)$ and give your answer mod $14^8$.

#285 - Pythagorean Odds

Albert chooses a positive integer $k$, then two real numbers $a$, $b$ are randomly chosen in the interval $[0, 1]$ with uniform distribution. The square root of the sum $(k\cdot a + 1)^2 + (k\cdot b + 1)^2$ is then computed and rounded to the nearest integer. If the result is equal to $k$, he scores $k$ points; otherwise he scores nothing.

For example, if $k=6$, $a=0.2$ and $b=0.85$, then $(k\cdot a + 1)^2 + (k\cdot b + 1)^2 = 42.05$. The square root of $42.05$ is $6.484\cdots$ and when rounded to the nearest integer, it becomes $6$. This is equal to $k$, so he scores $6$ points.

It can be shown that if he plays 10 turns with $k=1, k=2, \dots, k=10$, the expected value of his total score, rounded to five decimal places, is $10.20914$.

If he plays $10^5$ turns with $k=1,k=2,k=3,\dots,k=10^5$, what is the expected value of his total score, rounded to five decimal places?

Wildfire Incidence III - Basic Neural Network

Wildfire Incidence III - Basic Neural Network

Part 3 of predicting wildfire incidence. I show a basic example of using a neural network on the same data for prediction.

We have seen how to properly preprocess the 3 data sources (historical wildfire incidence, climatology, and land usage) to get it ready to push it through a logistic regression model. However, the beauty of machine learning is that there is often more than one tool for the job.

Wildfire Incidence Prediction - Part II - Spatial Logistic Regression

Wildfire Incidence Prediction - Part II - Spatial Logistic Regression

Part 2 of predicting wildfire incidence. After preprocessing, we perform spatial logistic regression using all the data on hand.

This is second in a series of posts detailing how to predict incidence of wildfires. For input data, we use historical wildfires, land usage data, and climatology data. In terms of preprocessing, we force all datasets to have the same 702 x 306 shape. The fire matrix contains a count of how many fires have occurred in that location. Please see Wildfire Incidence I - Preprocessing for a detailed code overview of the actual preprocessing.

Pagination