-
-
Save jechtom/730e0affc65147d16eb7acab6e8c0c48 to your computer and use it in GitHub Desktop.
Test code generation OpenAI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write C# code that find longest line of text in directory. | |
using System; | |
using System.IO; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
string directoryPath = @"C:\"; | |
string longestLine = ""; | |
//Get all the files in the specified directory | |
string[] files = Directory.GetFiles(directoryPath); | |
//Loop through the files | |
foreach (string file in files) | |
{ | |
//Read the file | |
string[] lines = File.ReadAllLines(file); | |
//Loop through the lines in the file | |
foreach (string line in lines) | |
{ | |
//Check if the line is longer than the current longest line | |
if (line.Length > longestLine.Length) | |
{ | |
longestLine = line; | |
} | |
} | |
} | |
//Output the longest line | |
Console.WriteLine("The longest line in the directory is:"); | |
Console.WriteLine(longestLine); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write C# code that find longest line of text in directory. Don't use arrays. | |
string longestLine = string.Empty; | |
string directoryPath = @"C:\directory"; | |
foreach (string file in Directory.EnumerateFiles(directoryPath, "*.*")) | |
{ | |
using (StreamReader sr = new StreamReader(file)) | |
{ | |
while (!sr.EndOfStream) | |
{ | |
string line = sr.ReadLine(); | |
if (line.Length > longestLine.Length) | |
{ | |
longestLine = line; | |
} | |
} | |
} | |
} | |
Console.WriteLine(longestLine); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write C# code that find in directory with longest line of text. Use funny variable names with Star Wars references. | |
string hanSolo = @"C:\"; | |
string longestLine = string.Empty; | |
DirectoryInfo lukeSkywalker = new DirectoryInfo(hanSolo); | |
FileInfo[] chewbacca = lukeSkywalker.GetFiles(); | |
foreach(FileInfo c3po in Chewbacca) | |
{ | |
string r2d2 = File.ReadAllText(c3po.FullName); | |
if(r2d2.Length > longestLine.Length) | |
{ | |
longestLine = r2d2; | |
} | |
} | |
Console.WriteLine($"The longest line of text is {longestLine}"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write C# code that find in directory with longest line of text. Make code compact. | |
string maxLine = string.Empty; | |
string path = @"C:\myDir"; | |
foreach (string file in Directory.EnumerateFiles(path, "*.txt")) | |
{ | |
StreamReader reader = File.OpenText(file); | |
string line; | |
while ((line = reader.ReadLine()) != null) | |
{ | |
if (line.Length > maxLine.Length) | |
{ | |
maxLine = line; | |
} | |
} | |
} | |
Console.WriteLine(maxLine); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write C# code that find in directory with longest line of text. Make code impossible to read by human. | |
int n=0;string s="";string t="";for(int i=0;i<Directory.GetFiles("C:/").Length;i++){foreach(string l in File.ReadAllLines(Directory.GetFiles("C:/")[i])){if(l.Length>n){n=l.Length;s=l;t=Directory.GetFiles("C:/")[i];}}}Console.WriteLine($"Longest line is {s} in {t}"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write C# code that find in directory with longest line of text. And add some comments. Each comment must contain at least one interjection. | |
// Woah! Let's find the longest line of text in a directory! | |
string longestLine = ""; | |
// Holy cow! Let's loop through all the files in the directory. | |
foreach (string file in Directory.EnumerateFiles(@"myDirectory")) | |
{ | |
// Whoa! Now let's loop through all the lines of the file. | |
foreach (string line in File.ReadLines(file)) | |
{ | |
// Oh wow! Is this line longer than the previous one? | |
if (line.Length > longestLine.Length) | |
{ | |
longestLine = line; | |
} | |
} | |
} | |
// Unbelievable! We've found the longest line of text. | |
Console.WriteLine(longestLine); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It gets crazier. The interjection in comments, variable names and variants and many more.
And all the typos as a human !! lol
Here's an attempt to combine some with some deep stuff
Prompt: write an advanced machine learning model with emotional modulation c# code and cmment every line with atleast one interjection and name all variables from marvel characters and use iron man for output simulation example code block
and another iteration yielded
Prompt: write an advanced machine learning model with emotional modulation c# code and cmment every line with atleast one interjection and name all variables from marvel characters and use iron man only for output simulation example code block