2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
60// expect(firstStar(``), "*1 sample 2").to.equal("?");
61
62function firstStar(input: string) {
63 const [, seedsInput, ...mapsInput] = input.split(/\s*[a-z -]+:\s*/m);
64 const seeds = extractNumbers(seedsInput);
71expect(secondStar(sample), "*2 sample 1").to.equal(46);
72// expect(secondStar(``), "*1 sample 2").to.equal("?");
73function secondStar(input: string) {
74 const [, seedsInput, ...mapsInput] = input.split(/\s*[a-z -]+:\s*/m);
75 const maps = mapsInput.map(parseMap);
91console.log("solution *2:", secondStar(input()));
92
93function input() {
94 return `seeds: 3121711159 166491471 3942191905 154855415 3423756552 210503354 2714499581 312077252 1371898531 165242002 752983293 93023991 3321707304 21275084 949929163 233055973 3626585 170407229 395618482 226312891
95
282
283// [0,1,2,3].reduce(sum, 0) => 6
284function sum(sum: number, current: number) {
285 return sum + current;
286}
287// wrap a value to print and return it
288function debug<T>(value: T, msg = "debug"): T {
289 console.log(msg, value);
290 return value;
2
3// Fetches a random joke.
4function fetchRandomJoke() {
5 const SAMPLE_JOKE = {
6 "setup": "What do you call a group of disorganized cats?",
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
26});
27
28export async function getCrateInfo(crateName: string, version?: string) {
29 const createURL = joinURL(API_URL, `/crates/${crateName}`);
30 const crateInfo = parse(CrateInfoSchema, await ky.get(createURL).json());
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
17});
18
19export async function getPkgInfo(pkgName: string, version = "latest") {
20 const pkgURL = new URL(encodeURIComponent(pkgName).replace(/^%40/, "@"), REGISTRY_URL);
21 const headers = {
58export default app.fetch;
59
60async function getBadgeOptions(rssUrl: string | URL): Promise<BadgenOptions> {
61 const label = BADGE_LABEL;
62 try {
1export function isSpotifyPodcast(podcastURL: URL | string) {
2 try {
3 podcastURL = new URL(podcastURL);
9}
10
11export function getSpotifyId(podcastURL: URL | string) {
12 try {
13 podcastURL = new URL(podcastURL);
1export function isApplePodcast(podcastURL: URL | string) {
2 try {
3 podcastURL = new URL(podcastURL);
9}
10
11export function getItunesId(podcastURL: URL | string) {
12 try {
13 podcastURL = new URL(podcastURL);
A helper function to build a file's email
Simple functional CSS library for Val Town
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.