import '@fontsource/geist-sans/latin.css' import 'katex/dist/katex.min.css' import katex from 'katex' import './styles.css' import { For, Show, createEffect, createMemo, createResource, createSignal } from 'solid-js' import { render } from 'solid-js/web' const LaTeX = ({ content }) => katex.render(content, el)} /> const generateScript = (value, expression) => { const vector = expression.split('+').map(part => part.split('^')[0].trim()) return ` # cambia queste due righe con i valori corretti file="my-file.pdf" sides="two-sided-long-edge" # otherwise use two-sided-short-edge or one-sided # stampa ${value} = ${expression} copie for sq in ${vector.join(' ')}; do lpr -P cdclf -# $sq -o media=a4 -o fit-to-page -o sides=$sides $file done` // <- this missing "\n" is intentional } // <- this missing "\n" is intentional const ResultItem = ({ value, expression }) => { const handleClick = () => { navigator.clipboard.writeText(generateScript(value, expression)) } return (
) } const App = ({}) => { const [rawData] = createResource(() => fetch('/shortest-squares-v2.txt').then(res => res.text())) const dict = createMemo(() => Object.fromEntries( (rawData() ?? '') .split('\n') .filter(Boolean) .map(line => { const [expression, value] = line.split('=').map(part => part.trim()) return [parseInt(value), expression] }) ) ) createEffect(() => { console.log('dict', dict()) }) const [text, setText] = createSignal('') const results = createMemo(() => { const entries = Object.entries(dict()) const query = text().trim() if (query === '') return entries if (!/^\d+$/.test(query)) return entries return entries.filter(([value]) => value.toString().includes(query)) }) const SHOW_COUNT = 8 return ( <>

Shortest Sum of Squares

Click a sum of squares to copy the lpr shell command to print that number of copies

setText(e.target.value)} />
SHOW_COUNT }}> {([value, expression]) => }

For now we pre-computed the shortest sums of squares up to 1000 as you shouldn't need to print more than that many copies of a document. Paper is a precious resource after all.

) } render(() => , document.getElementById('app'))