diff --git a/C#/Countdown Numbers Game/Countdown Numbers Game/Program.cs b/C#/Countdown Numbers Game/Countdown Numbers Game/Program.cs index 5335b0d..7c9d623 100644 --- a/C#/Countdown Numbers Game/Countdown Numbers Game/Program.cs +++ b/C#/Countdown Numbers Game/Countdown Numbers Game/Program.cs @@ -7,6 +7,19 @@ using System.Threading.Tasks; namespace Countdown_Numbers_Game { class Program { static void Main(string[] args) { + + Console.ForegroundColor = ConsoleColor.Cyan; + Console.WriteLine(" 888 888 "); + Console.WriteLine(" 888 888 "); + Console.WriteLine(" 888 888 "); + Console.WriteLine(" .d8888b .d88b. 888 88888888b. 888888 .d88888 .d88b. 888 888 88888888b. "); + Console.WriteLine("d88P\" d88\"\"88b888 888888 \"88b888 d88\" 888d88\"\"88b888 888 888888 \"88b "); + Console.WriteLine("888 888 888888 888888 888888 888 888888 888888 888 888888 888 "); + Console.WriteLine("Y88b. Y88..88PY88b 888888 888Y88b. Y88b 888Y88..88PY88b 888 d88P888 888 "); + Console.WriteLine(" \"Y8888P \"Y88P\" \"Y88888888 888 \"Y888 \"Y88888 \"Y88P\" \"Y8888888P\" 888 888 "); + Console.WriteLine(""); + Console.ForegroundColor = ConsoleColor.White; + Program p = new Program(); p.getInput(); } @@ -46,33 +59,34 @@ namespace Countdown_Numbers_Game { string output = solve.getSolution(target, inputArray); if (output == "false") { - + Console.WriteLine("A soulution could not be found... \nPress any key to exit..."); } else { - + Console.WriteLine("Solution found: " + output); + Console.WriteLine("Press any key to exit..."); } Console.ReadKey(); } class Solver { - public string getSolution(int target, int[] inputArray) { inputArray = SortArray(inputArray); + Console.Write("Sorted Array: "); for (int i = 0; i < inputArray.Length; i++) { Console.Write(inputArray[i] + " "); } + Console.WriteLine(); if (!isPossible(target, inputArray)) { return "false"; } - return findMethod(target, inputArray); } private bool isPossible(int target, int[] inputArray) { for (int i = 1; i < inputArray.Length; i++) { - if (inputArray[i] + inputArray[i-1] == target { + if (inputArray[i] + inputArray[i-1] == target) { return true; } } @@ -81,6 +95,11 @@ namespace Countdown_Numbers_Game { } private string findMethod(int target, int[] inputArray) { + for (int i = 1; i < inputArray.Length; i++) { + if (inputArray[i] + inputArray[i - 1] == target) { + return inputArray[i] + " + " + inputArray[i-1] + " = " + target; + } + } return " "; } diff --git a/C++/Soph/classes.h b/C++/Soph/classes.h new file mode 100644 index 0000000..b901ebf --- /dev/null +++ b/C++/Soph/classes.h @@ -0,0 +1,8 @@ +#include +using namespace std; +class Person { + public: + string cute() { + return "true"; + }; +}; diff --git a/C++/Soph/soapi.cpp b/C++/Soph/soapi.cpp new file mode 100644 index 0000000..f0ed9fa --- /dev/null +++ b/C++/Soph/soapi.cpp @@ -0,0 +1,13 @@ +#include "classes.h" +#include +#include + +using namespace std; + +int main() { + Person Soapi; + string s; + cout << "Soapi.cute() = " << Soapi.cute() << "\n"; + cin >> s; + return 0; +} \ No newline at end of file