# bdhurkett/LongestRomanSum

Least efficient (most characters) pair of integers for a given sum, when expressed as Roman numerals.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
 Failed to load latest commit information. LongestRomanSum .gitattributes .gitignore LongestRomanSum.sln README.txt

```LongestRomanSum
===============

Command-line Windows program that finds the least efficient way of writing an integer between 2 and 3999 as the sum of two integers, where 'efficiency' is the number of characters taken to express those two integers in Roman numerals.

Though the logic for calculating results is much the same past 3999, I couldn't figure out a good way to display Roman numerals for 4000 or above and shoddy program organisation made it hard to extend limits for the parts that don't print specific results.

For instance: the least efficient Roman-numeral-sum of 1776 is 888 + 888, or DCCCLXXXVIII + DCCCLXXXVIII (24 characters, not including the addition sign or spaces). On the other hand, there are two unique solutions of equal length for 4: 1 + 3 and 2 + 2, both four characters long when expressed as Roman numerals.

If you're curious as to the least-efficient numbers - as 888 is the "longest" Roman numeral below 1000 all the longest sums are variations of that, with 3776 the longest in the range of this program at 26 characters (1888+1888 and 2888+888). The numbers with the greatest variation of (equally-inefficient) sums are 3989 and 3998, both with 648!

Usage
=====

I mostly just added to this program depending on what I wanted to know, and it probably doesn't follow any guidelines. There are two ways to use it:
1. Directly from the command line, supplying the 'mode' as the first argument and the value as the second
2. Run the program and follow the vague directions, usually first supplying the number or limit and then the mode

Modes
=====
Simplest (s): For a + b = c, and given c, find the sum with the least difference between a and b. (Technically it just returns the first result found, but it works out that way because of the order of data.)
Random (r): Returns a random result of all possible variations. Perhaps not truly random, but all variations can potentially appear.
All (a): Print every single unique sum, sorted in order of increasing a - that is, if it finds a + b = c it won't later print b + a = c.
Count (c): Use a probably-slightly-faster way to just count the length of the least-efficient sum and number of variations of sums for a given value, without actually needing to find out the sums or 'translate' them into Roman numerals.
Most (m): For a given upper limit between 2 and 3999, and an optional lower limit, find the number(s) that have the most equally-inefficient sums.
Longest (l): Same as 'Most' except that it finds number(s) with the longest sums instead.
Writeall (w): For each number between 2 and an upper limit below 4000, write out its statistics to a file called 'out.csv' in the format "[value],[length of longest sum],[number of equal variations]".

How it works
============
I'll explain that when I get around to putting comments in the code. Apart from some particularly awful parts, it's mostly just glueing and rearranging individual digits based on a table I worked out earlier.
```