v2 refactor to label-based koans, and add discord

This commit is contained in:
2025-09-04 02:29:48 +10:00
parent fda6847671
commit 89173f1676
10 changed files with 679 additions and 76 deletions

19
koans/lib.py Normal file
View File

@@ -0,0 +1,19 @@
from typing import Optional
import datetime as dt
from datetime import datetime
def minify(content: str, maxlength: int, strip: Optional[str] = ' ', newlines: str = ' '):
content.replace('\n', newlines)
if strip:
content = content.strip(strip)
if len(content) > maxlength:
new_content = content[maxlength-3] + '...'
else:
new_content = content
return content
def utc_now():
return datetime.now(dt.UTC)