We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet core 2.1.302
Hardware :
Processor Name: Intel Core i5 Processor Speed: 1.7 GHz Number of Processors: 1 Total Number of Cores: 2 L2 Cache (per Core): 512KB L3 Cache: 3 MB Memory: 6 GB
Program
using System; using System.IO; namespace SumNumbers { class Program { static void Main(string[] args) { SumIntegers(); } public static void SumIntegers() { var startTime = DateTime.Now; //replace with directory path var dirPath = Directory.GetCurrentDirectory() + @"\files"; var folders = Directory.GetDirectories(dirPath); long total = 0; for (int i = 0; i < folders.Length; i++) { var folder = folders[i]; var files = Directory.GetFiles(folder); for (int j = 0; j < files.Length; j++) { var file = files[j]; var fileContent = File.ReadAllLines(file); for (int k = 0; k < fileContent.Length; k++) { var numbers = fileContent[k].Split(','); for (int l = 0; l < numbers.Length; l++) { total += Convert.ToInt64(numbers[l]); } } } } Console.WriteLine("total : " + total); Console.WriteLine("Milliseconds : " + (DateTime.Now - startTime).TotalMilliseconds); } } }
total : 49947871404 Milliseconds : 15210.5908
The text was updated successfully, but these errors were encountered:
No branches or pull requests
dotnet core 2.1.302
Hardware :
Program
Output
total : 49947871404
Milliseconds : 15210.5908
The text was updated successfully, but these errors were encountered: