Roman Numerals Round Trip
Convert numbers to roman numerals and back with match-driven mapping, exercising both encoding loops and parse validation.
Page 23 of 50
Convert numbers to roman numerals and back with match-driven mapping, exercising both encoding loops and parse validation.
Move a file cursor with SeekFrom start, end, and current offsets to read fixed headers, tails, and records without scanning the whole file.
Find a median without sorting everything: select_nth_unstable partitions the slice in place and returns lower, middle, and higher parts.
Locate the first element failing a predicate in sorted data with partition_point, replacing hand-written binary search loops.
Rotate a slice in place with rotate_left and rotate_right, a cheap way to move a buffered window without allocating or copying manually.
Sort with slice::sort_by_cached_key so each key is computed once per element instead of on every pairwise comparison.
Render control characters with str escape_default, rebuild the same text char by char, and compare it with escape_debug output.
Split text with split_inclusive so each piece keeps its terminator, then contrast the result with lines and a custom predicate.
Implement Sum and Product for a custom type so iterator collect and fold adapters reuse the standard numeric reduction API.
Bounded sync_channel capacity blocks the producer when the consumer lags, giving you backpressure without an external queue crate.
Accept loopback clients with TcpListener, echo each line from a cloned writer, and close cleanly when the peer drops the connection.
Create threads with explicit names and stack sizes through thread::Builder so logs and panic messages identify each worker.
Hand a signal between threads with thread::park and Thread::unpark, which needs no channel and keeps an unpark that arrives before the park.
Store heterogeneous handlers behind Box<dyn Trait> so a registry can dispatch at runtime while each implementation stays a separate type.
Locate the first pair adding up to a target in one pass, remembering seen values in a HashMap instead of rescanning the slice.
Print readable type names with std::any::type_name for generics and nested containers, keeping the output strictly for diagnostics.
Exchange datagrams over loopback with UdpSocket, learning how connectionless peers, packet boundaries, and source addresses behave.
Replace a middle range in place with Vec::splice, keep the removed elements, and reuse the same call with an empty iterator to delete.
Rotate a VecDeque ring buffer into one slice with make_contiguous, compare as_slices before and after, and keep pushing afterward.
Use Wrapping to make overflow deliberate, comparing wrapping_add, checked_add, and saturating_add near the integer limit.
Write several IoSlice buffers through Write::write_vectored, handle partial writes in a loop, and verify the assembled byte stream.
Count subsets in one pass with the FILTER clause on aggregates, replacing repeated CASE expressions and extra scans of the same rows.
Persist server settings with ALTER SYSTEM, reload postgresql.auto.conf, inspect pg_settings, and reset a value.
Collect group values in encounter order with array_agg and an inner ORDER BY, preserving sequence that plain aggregates lose.
Create a bloom index over equality-filtered columns, inspect its definition, and see why range predicates cannot use it.
Define a parent CHECK with NO INHERIT so child tables accept rows the parent rejects, then compare inherited and local rules.
Attach documentation to tables, columns, and indexes with COMMENT ON, then read it back from the system catalogs.
Generate every grouping subset in one CUBE query, separate real nulls from rollup nulls with GROUPING, and compare with GROUPING SETS.
Run anonymous procedural code inline with a DO block, using an integer FOR loop and RAISE NOTICE to emit progress lines from a psql session.
Convert bytea values to hex and base64 with encode, parse them back with decode, and verify round trips and byte lengths.
Compare FOR UPDATE with FOR NO KEY UPDATE and FOR KEY SHARE, then check which row lock modes still block foreign key checks.
Build a gap-free calendar with generate_series and LEFT JOIN daily totals, so missing dates report zero instead of disappearing.
Store IPv4 and IPv6 subnets in inet columns, then use containment and overlap operators to match addresses.
Compare INTERSECT and INTERSECT ALL on duplicate rows, combine them with EXCEPT ALL, and confirm multiset counts in a grouped query.
Constrain a jsonb column with the IS JSON OBJECT predicate and test VALUE, ARRAY, SCALAR, and unique-key variants.
Insert into jsonb arrays and objects with jsonb_insert, choose before or after the target index, and persist the change with UPDATE.
Aggregate grouped rows into keyed JSON objects with jsonb_object_agg, expand them again, and deduplicate repeated keys first.
Create a GIN index with jsonb_path_ops, query containment with @>, and compare it with jsonb_ops for key-existence filters.
Filter JSONB documents with jsonb_path_query and its variants, using JSONPath predicates, arrays, first matches, and bound variables.
Map jsonb documents onto a composite type with jsonb_populate_record, including missing keys and ignored extras.
Remove null-valued object fields recursively with jsonb_strip_nulls and confirm that array elements keep their shape.
Turn a JSONB array into typed rows with jsonb_to_recordset, then query nested fields and arrays as ordinary relational columns.
Match a column against several patterns at once with LIKE ANY and ILIKE ANY, including patterns supplied by a subquery.
Compose a multi-stage query as named CTE layers — filter, deduplicate, then aggregate — so each stage reads independently and later stages stay simple.
Use PostgreSQL's column-list ON DELETE SET NULL so a composite foreign key clears only the reviewer column and keeps its order.
Import explicit IDs into GENERATED ALWAYS identity columns with OVERRIDING SYSTEM VALUE and contrast it with user value.
Score how each row ranks with percent_rank, including how ties collapse to the same percentile inside a window ordering.
Load a table or index into shared_buffers with pg_prewarm before benchmarking, so the first measured run does not pay the cold-cache disk read cost.
Compare sequential and index scan counts per table in pg_stat_user_tables, exposing which tables the planner reads by index and which it scans end to end.
Handle errors inside a PL/pgSQL EXCEPTION block: the block runs as a subtransaction, so failed statements roll back without aborting the caller.
Unquoted identifiers fold to lowercase while quoted identifiers keep their exact spelling, so mixed-case quoted names need quoting in every later reference.
Open read-only transactions that reject writes and row locks, then reset the session default after reporting queries finish.
Extract capture groups with regexp_matches, return every match with the g flag, and index the resulting text array.
Wrap a parameterized query in RETURNS TABLE so callers can select from it and join or aggregate the result like a view.
Grant one role to another so privileges flow through membership, and control whether members inherit automatically or must SET ROLE first.
Aggregate sales with ROLLUP to get region and month subtotals plus a grand total, then mark total rows with the GROUPING function.
Compare row constructors directly to express composite key ranges, paginate by tuple order, and match multiple keys with IN.
Grant a function owner privileges with SECURITY DEFINER, pin search_path against hijacking, and restrict execution to one role.
Run SERIALIZABLE transactions that can fail with SQLSTATE 40001, and retry the whole unit of work on serialization conflicts.
Defer a unique constraint with SET CONSTRAINTS, shift every seat number in one transaction, and validate before commit.
Use statement-level triggers with transition tables to audit an entire multi-row UPDATE once, comparing old and new rows in a single insert.
Build highlighted search snippets with ts_headline, websearch_to_tsquery, and custom StartSel and StopSel markers.
Rank matches with ts_rank and ts_rank_cd, weight title above body, and combine ranking with a GIN index on a generated tsvector column.
Run a two-phase commit with PREPARE TRANSACTION, then finish it from another session with COMMIT PREPARED or ROLLBACK PREPARED.
A mapped handler object keyed by the event discriminant makes dispatch exhaustive: adding a kind without a handler breaks the object literal at compile time.
Promise.any settles with the first fulfilled attempt and only throws AggregateError when every input rejects, keeping each original cause in errors.
A Record keyed by the Role union forces every role to declare its capabilities, so adding a role without a permission list fails to compile.
response.json() and response.text() drain the same stream once; bodyUsed flips to true and a second read throws, while clone forks the body for two consumers.
Decoding a payload split inside a multibyte character needs stream: true; one-shot decodes turn the torn prefix into replacement characters instead.
Type a plugin registry with abstract new constructors, then cast to a concrete signature only at the instantiation boundary.
Collect every field failure and throw one AggregateError, letting callers inspect all validation errors in a single pass instead of one at a time.
Wrap cursor pagination in an async generator so callers consume pages with for await and stop early without managing tokens.
Declare class state with the accessor keyword, read the generated getter and setter, and convert Celsius to Fahrenheit through the accessor pair.
Constrain sizes with bigint literal types, compute block-aligned allocations, and reject unsupported values at compile time with ts-expect-error.
Keep userId and orderId apart at compile time with branded types, so a refactor cannot silently pass one where the other belongs.
Type a callable object with a call signature plus a property, build it with Object.assign, and call it through the interface.
Model a class factory with a construct signature, accept only compatible constructors, and build parsers with different separators.
Model curried functions with recursive conditional types so each partial application peels one parameter and keeps the remaining types.
Merge interfaces and namespaces with declaration merging so related types stay in one place and extensions type-check without inheritance.
Use declare class fields so they emit no runtime property, assign them later with Object.assign, and verify ownership before and after hydration.
Build DeepPick from recursive tuple paths so nested types survive, and intersect multiple paths into one precise shape.
Recursively strip optional modifiers with a DeepRequired utility so nested configuration objects must provide every key at every level.
Use a definite assignment assertion for a map initialized in init(), then guard reads and writes until the cache is ready.
Distribute Omit across each union member so per-variant fields survive, and compare it with the common-keys collapse of plain Omit.
Load a module on demand with dynamic import(), read its typed exports, and keep the import inside an async function so startup stays lazy.
Attach the underlying failure with ErrorOptions cause, then walk the cause chain to log root causes without losing the original stack.
Type an event emitter against an event map so emitting or subscribing with a wrong event name or payload is a compile error.
Force every enum member to be handled by routing the default branch through a never assignment, so adding a variant fails the build.
Use Extract with a channel discriminant to derive per-variant required shapes, then switch exhaustively over the narrowed union.
Declare overload signatures so callers get precise return types per argument shape, with one implementation handling the union.
Constrain generic parameters with keyof so a helper can only be called with real property names, and the return type follows the key.
Augment the built-in Window interface with declare global, add typed application fields, and read them through a narrowed global scope.
Read import.meta.url, resolve a sibling fixture with new URL, and inspect the resulting file URL and query parameters.
Locate module specifiers with import.meta.resolve, check node and file URL results, and resolve a relative asset path without reading the file.
Derive field types with indexed access types, write a generic getField helper, and index the whole object with keyof.
Use infer extends inside conditional types to capture tuple members as string or number literals, with a never fallback for mismatches.
Merge three interface declarations into one type, add optional fields from each block, and inspect the combined key union.
Extend a class with an interface to inherit its members, attach extra audit fields, and call inherited methods on the typed instance.
Combine call signatures with an intersection type, implement one runtime function, and call the overloaded converter with string, number, and boolean.
Derive union types from a frozen object with keyof typeof, keeping string literals and lookup tables in sync without a separate enum.