class PrettyPrinter {

	public String format(List<Long> appliedChanges) {
		if (appliedChanges.isEmpty()) {
			return "(none)";
		}
		
		StringBuilder builder = new StringBuilder();
		
		Long lastRangeStart = null;
		Long lastNumber = null;
		
		for (Long thisNumber : appliedChanges) {
			if (lastNumber == null) {
				// first in loop
				lastNumber = thisNumber;
				lastRangeStart = thisNumber;
			} else if (thisNumber == lastNumber + 1) {
				// continuation of current range
				lastNumber = thisNumber;
			} else {
				// doesn't fit into last range - so output the old range and
				// start a new one
				appendRange(builder, lastRangeStart, lastNumber);
				lastNumber = thisNumber;
				lastRangeStart = thisNumber;
			}
		}

		appendRange(builder, lastRangeStart, lastNumber);
		return builder.toString();
	}

}