Results for “ratio”
Small, practical examples. Search by task or narrow things down below.
Visit adjacent pairs
Python: Use itertools.pairwise to process neighboring items without indexing.
Python✓ Tested
Visit associative-array keys in a stable order
Bash Scripts: Associative arrays have no defined iteration order, so sort their keys explicitly.
Bash Scripts✓ Tested
Visit files recursively
Java: Close the stream returned by Files.walk and sort relative paths for stable output.
Java✓ Tested
Write and read binary bytes
Java: Use the byte-oriented Files methods when text encoding should not be involved.
Java✓ Tested
Write and read bytes without text conversion
C++: Use binary stream modes and check each I/O operation before consuming its result.
C++✓ Tested
Write and read raw bytes
C#: Use the byte-oriented file APIs when no text encoding should be applied.
C#✓ Tested
Add and remove values at both ends
C++: Deque supports efficient end operations without requiring contiguous storage.
C++✓ Tested
Apply an enhancement only when a feature is supported
CSS: A supports rule preserves the baseline outside browsers that understand the selected declaration.
CSS✓ Tested
Await an asynchronous method result
C#: Use Task<T> for an async operation with a typed result.
C#✓ Tested
Blink the built-in LED three times
Alternate the built-in LED with a short blocking delay.
blink✓ Tested
Change an LED delay with a variable
Arduino / C: Assign a new value to a variable to change the next LED pulse duration.
Arduino / C✓ Tested
Check any and all stream elements
Java: Use short-circuiting match operations for predicates over a Java collection.
Java✓ Tested