Skip to content
Find two numbers that add up to the given number (by default is 8), such that the product multiplied by the difference produces the largest possible value.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
HighestNumberPairing.xcodeproj
Sources
Tests
.gitignore
Info.plist
Package.swift
README.md

README.md

Highest Number Pairing Problem

This program solves a simple math problem...

Problem

Find two numbers that add up to the given number (by default is 8), such that the product multiplied by the difference produces the largest possible value.

To Build

From the command line, enter to build:

$ swift build

To Run

From the command line, enter to run:

$ swift run

or

$ swift run HighestNumberPairing

You will get a prompt that allows you to enter the number to use. The default is 8, if nothing is entered.

Optionally, you can add the number as a second argument:

$ swift run HighestNumberPairing 16

This runs the program with 16 as the number to use.

By default, the program displays up to 10 other top results (sorted high to low). You can pass no or false as an optional second parameter in the command line to opt out of collecting other results.

$ swift run HighestNumberPairing 8 no

or

$ swift run HighestNumberPairing 8 false

To Test

From the command line, enter to run all unit tests:

$ swift test

Tests can also be run from within Xcode.

New

  • New recursive method to find more accurate answer
  • New ability to take user input from command line or input prompt
  • Collecting and displaying other results is now optional
  • Added unit tests
  • Revised module structure for better command line testability

To Do

  • More unit testing.
  • Improve number formatting for printout (low priority)
You can’t perform that action at this time.