Results for “Small algorithms & bit operations”
Small, practical examples. Search by task or narrow things down below.
Inspect a file length without reading it
C#: Use FileInfo.Length to retrieve a logical size in bytes.
C#✓ Tested
Join array items with a one-character separator
Bash Scripts: A local IFS controls the separator used by the quoted star expansion.
Bash Scripts✓ Tested
List regular files recursively in sorted order
C++: Collect relative paths before sorting because directory iteration order is unspecified.
C++✓ Tested
Locate a value in a sorted array
Java: Use Arrays.binarySearch only after establishing ascending order.
Java✓ Tested
Merge two sorted sequences
C++: Both inputs must use the same ordering before merge is called.
C++✓ Tested
Move a file into another directory
PowerShell: Move-Item transfers an existing file to the chosen destination directory.
PowerShell✓ Tested
Move a file to a new filename
C#: File.Move changes the file path without loading its contents.
C#✓ Tested
Move a file to a new name
Java: Files.move changes the path and returns the destination Path.
Java✓ Tested
Normalize a path without touching the filesystem
C++: lexically_normal removes redundant dot components using path syntax alone.
C++✓ Tested
Normalize relative path components
Java: Path.normalize removes redundant dot components without accessing the filesystem.
Java✓ Tested
Pair corresponding values from two arrays
PowerShell: Check lengths before indexing to reject mismatched input collections.
PowerShell✓ Tested
Prepend items while preserving existing array values
Bash Scripts: Construct a new array with the new values before the quoted original expansion.
Bash Scripts✓ Tested