Samyak Gupta

Hello, notebook

Every post here is a single Typst file. The text is typeset by Typst, the drawings are stuck on afterwards, and the paper is โ€” well, the paper is CSS, but it is trying its best.

This is a sample post that exercises everything the layout can do, so there is something to look at while the real writing gets done.

A sum worth doodling about

The story goes that a schoolteacher, wanting a quiet hour, asked the class to add up every whole number from 1 to 100. One pupil wrote the answer down almost immediately. The trick is to write the sum twice, once forwards and once backwards, and add the two rows column by column:

2๐‘†=(1+๐‘›)+(2+(๐‘›โˆ’1))+โ‹ฏ+(๐‘›+1)

Every column comes to ๐‘›+1, and there are ๐‘› of them, so

๐‘†=โˆ‘๐‘˜=1๐‘›๐‘˜=๐‘›(๐‘›+1)2.

For ๐‘›=100 that gives 5050, and one very annoyed teacher. The same pairing idea is why the average of an evenly spaced list is just the average of its first and last entries.

Checking it the boring way

Code blocks work too, with syntax highlighting done by Typst at build time:

def triangle(n: int) -> int:
    return n * (n + 1) // 2

assert triangle(100) == sum(range(1, 101)) == 5050

So do footnotes1, emphasis, strong text, inline code, and lists:

  1. 1Which end up down here, at the bottom of the page.