Code golf is a type of recreational computer programming competition in which participants strive to achieve the shortest possible source code that solves a certain problem. Code golf challenges and tournaments may also be named with the programming language used. --- Wikipedia
- Submit code you wrote. Don't reuse someone else's code.
- NO AI
- Don't Google/Bing/DDG/Kagi for answers.
- All pull requests must be opened before Aug 14 2025 11:30 AM EDT.
The shortest correct program wins. In the event no submissions fully pass the test suite winners will be selected by number of passing test cases and code brevity.
- C#
- Python
- Go
- Typescript/Javascript
Convert numbers written with Arabic numerals into Roman numerals.
Arabic | Roman |
---|---|
1 | I |
2 | II |
3 | III |
4 | IV |
5 | V |
10 | X |
20 | XX |
25 | XXV |
30 | XXX |
40 | XL |
50 | L |
100 | C |
200 | CC |
400 | CD |
500 | D |
1000 | M |
27
→ XXVII
238
→ CCXXXVIII
2019
→ MMXIX
All submissions should expect to be invoked from the command line with a single argument, the path to a text file. This file will contain 5 numbers written using Arabic numerals. Numbers are separated by a newline (\n
). Submissions are expected to iterate over the numbers printing the Roman numeral translation for each to the console/stdout.
import sys
def main():
# Exit with error status if no filename provided
if len(sys.argv) < 1:
print("Filename missing!")
sys.exit(1)
print(f"Input file: {sys.argv[0]}")
# Open the file for reading
with open(sys.argv[1], "r") as fd:
line = fd.readline().strip()
while line != "":
# Convert line to Roman numeral
print(line)
line = fd.readline().strip()
if __name__ == "__main__":
main()
This repo contains a sample file you can use for development.