Results for “Small algorithms & bit operations”
Small, practical examples. Search by task or narrow things down below.
Copy selected rows into another table
Postgres: INSERT SELECT performs a set-based copy with an explicit destination column list.
Postgres✓ Tested
Copy selected rows into another table
SQLite: INSERT SELECT performs a set-based copy with an explicit destination column list.
SQLite✓ Tested
Count a result even when it is empty or has one item
PowerShell: Wrap pipeline results in an array subexpression for consistent Count behavior.
PowerShell✓ Tested
Count days between UTC-midnight dates
JavaScript: A day is exactly 86400000 milliseconds for these explicitly UTC-midnight inputs.
JavaScript✓ Tested
Count days between UTC-midnight dates
TypeScript: A day is exactly 86400000 milliseconds for these explicitly UTC-midnight inputs.
TypeScript✓ Tested
Count elements satisfying a predicate
C++: count_if counts matches without constructing a filtered collection.
C++✓ Tested
Count occurrences in a sorted sequence
C++: equal_range finds the half-open interval containing values equal to the key.
C++✓ Tested
Count the elements in an array
Bash Scripts: The array length form counts assigned elements, not characters in the first value.
Bash Scripts✓ Tested
Create a file only when it does not exist
C#: FileMode.CreateNew prevents accidental replacement of existing content.
C#✓ Tested
Create a file without overwriting an existing one
Python: Use exclusive creation mode and handle FileExistsError explicitly.
Python✓ Tested
Create a ZIP archive from a file
Python: Give a ZIP entry a relative archive name instead of exposing its source directory.
Python✓ Tested
Create and clean up a temporary file
Java: Create a unique file and remove it in finally even when the operation fails.
Java✓ Tested