View money_amount_words.py
from num2words import num2words | |
def money_amount_words(amount, units='euros', cents='centimes', lang='fr'): | |
""" | |
Returns an iterator over the words describing the given amount | |
Args: | |
amount: decimal.Decimal, the amount of money | |
units: str, the currency units |
View polynomial.py
# See https://lipsum.dev/2020-05-1-pourquoi-les-polynomes/ | |
from numbers import Number | |
class Polynomial: | |
def __init__(self, *coefficients): | |
self.degree = -1 | |
self.coefficients = tuple(coefficients) | |
for i, coef in enumerate(self.coefficients): | |
if coef != 0: |
View RotatingCube.js
// RotatingCube React component, used in https://lipsum.dev/2020-09-1-rotations/ | |
import * as BABYLON from 'babylonjs' | |
import * as GUI from 'babylonjs-gui' | |
import React, { useEffect, useRef, useState } from 'react' | |
const canvasWidth = 500; | |
const canvasHeight = 300; | |
function initScene(canvas, rotationCb) { | |
const engine = new BABYLON.Engine(canvas); |
View AoC24.py
from cmath import e, pi | |
from collections import Counter | |
import fileinput | |
def tokenize(s): | |
prev = None | |
for i, c in enumerate(s): | |
if prev is None: | |
if c in ('s', 'n'): | |
prev = c |