โ† Smartprix questions

String formatting with positional and indexed replacements

Filed under Smartprix

The question

Write a program that takes a format string containing curly braces and a replacement array. If there is a number inside the curly braces, print the element of the replacement array at that index if it exists, otherwise print whatever is inside the braces. If nothing is inside the curly braces, number them sequentially from left to right and replace them with the corresponding elements from the replacement array.

No write-up yet. Related questions below have one.

Related Smartprix questions

Collected from public candidate posts and coding forums. Updated Nov 2026.