The full source code for the Jeopardy Console Application is available on GitHub

ChatGPT Meets Jeopardy

Solution for Trivia Aficionados

Discover how ChatGPT integrates Jeopardy questions into a C# application, combining trivia enthusiasm with advanced data analysis in .NET.

As a developer passionate about trivia and data analysis, I've been exploring ways to blend my interests in a single, engaging project. My journey led me to a unique intersection: incorporating a vast dataset of Jeopardy questions into my existing applications, TriviaSpark and the Data Analysis Demo, using C# and .NET.

TriviaSpark: Engaging the Mind

TriviaSpark, my trivia application, has been a playground for trivia enthusiasts, offering a wide range of quizzes across various domains. Designed with C#, it's been a testament to the versatility and power of .NET in creating interactive, user-friendly applications.

The TriviaSpark application represents the entertainment side of C#, offering a web-based trivia platform that's both engaging and informative. Through the integration of Jeopardy questions, TriviaSpark becomes more than just a game; it's a journey through a myriad of topics, challenging the intellect of trivia aficionados and casual players alike.

Leveraging the capabilities of ChatGPT, TriviaSpark provides dynamic content that keeps the game fresh and exciting. The application demonstrates how AI can enhance user interaction, making each trivia session unique and tailored to the player's preferences.

Data Analysis Unleashed

In my Data Analysis Demo, I delve into CSV files to unearth patterns, insights, and stories hidden within the data. This C#-powered project showcases the potential of .NET in processing and visualizing complex datasets, making data analysis accessible and insightful.

On the flip side, the Data Analysis Demo showcases the analytical prowess of C# and .NET, focusing on the dissection and visualization of CSV file data. This demo illuminates the process of turning raw data into meaningful insights, exemplifying how complex datasets can be made accessible and interpretable.

Through the innovative use of data analysis libraries, the demo offers a glimpse into the world of data science, inviting users to explore data in ways they may have never considered before. It's a testament to the power of C# in bridging the gap between data and decision-making.

A Serendipitous Discovery

On a quest for intriguing CSV datasets, I stumbled upon a goldmine: a comprehensive CSV file of Jeopardy questions. This serendipitous find seemed like the perfect bridge between TriviaSpark and the analytical depth of the Data Analysis Demo, promising a fusion of trivia and data analytics.

This find represented the perfect fusion of TriviaSpark's engaging gameplay and the Data Analysis Demo's insightful exploration, bringing together the best of both worlds in a C# application that entertains as much as it informs.

Crafting the Solution

With the Jeopardy dataset in hand, I embarked on integrating it into a C# application. This endeavor was not just about importing data; it was about breathing life into the numbers and texts, turning them into an interactive trivia experience enriched with the analytical prowess of C# and .NET.

Step 1: Define Data Model

Define a class to match the JSON structure.

public class JeopardyQuestion
{
  public required string Category { get; set; }
  [JsonPropertyName("air_date")]
  public required string AirDate { get; set; }
  public required string Question { get; set; }
  public required string Value { get; set; }
  public required string Answer { get; set; }
  public required string Round { get; set; }
  [JsonPropertyName("show_number")] // Maps "show_number" in JSON to this property
  public required string ShowNumber { get; set; }
}

public class JeopardyQuestions : List<JeopardyQuestion>
{

}
Step 2: Deserialize JSON

Use `System.Text.Json` to convert the JSON file into a list of objects.

string jsonFilePath = "JEOPARDY_QUESTIONS.json";
string json = File.ReadAllText(jsonFilePath);
var options = new JsonSerializerOptions
{
  PropertyNameCaseInsensitive = true
};
var questions = JsonSerializer.Deserialize<JeopardyQuestions>(json, options);
Step 3: Select Random Category

Use LINQ to query for a random category from the list.

// Group questions by category, air date, and round, then select a random group
var random = new Random();
var groupedQuestions = this
  .GroupBy(q => new { q.Category, q.AirDate, q.Round })
  .ToList();
if (groupedQuestions.Count == 0)
{
  Console.WriteLine("No groups of questions available.");
  return;
}

var randomGroup = groupedQuestions[random.Next(groupedQuestions.Count)];


Step 4: Retrieve Questions

Select 5 questions from the chosen category.

var randomGroup = groupedQuestions[random.Next(groupedQuestions.Count)];
var selectedQuestions = randomGroup.Take(5).ToList(); // Take up to 5 questions from the selected group

// Displaying the details of the questions from the selected group
if (selectedQuestions.Any())
{
  Console.WriteLine($"Selected Category: {selectedQuestions.First().Category}");
  Console.WriteLine($"Air Date: {selectedQuestions.First().AirDate}");
  Console.WriteLine($"Round: {selectedQuestions.First().Round}");

  foreach (var question in selectedQuestions)
  {
    Console.WriteLine($"----------");
    Console.WriteLine($"Question: {question.Question}");
    Console.WriteLine($"Value: {question.Value}");
    Console.WriteLine($"Answer: {question.Answer}");
  }
}
else
{
  Console.WriteLine("No questions found in the selected group.");
}
Step 5: Display in Console

Output the show number, air date, category, and answers, asking for the questions.

Selected Category: ALL A DREAM
Air Date: 2011-04-19
Round: Double Jeopardy!
----------
Question: 'Add 3 letters to reve, French for "dream", & you'll have this word for a daydream'
Value: $400
Answer: reverie
----------
Question: 'Eat that 11 p.m. quesadilla & you might have a pesadilla, Spanish for this'
Value: $800
Answer: a nightmare
----------
Question: 'In 1899 he wrote of hypermnesic dreams, in which memories, inaccessible by day, turn up in the dream'
Value: $1200
Answer: Freud
----------
Question: 'Misty thoughts while smoking opium are the origin of the expression this type of dream'
Value: $7,000
Answer: pipe dreams
----------
Question: 'You might have surreal dreams when you try to sleep when your temperature is 102, defined as this 5-letter condition'
Value: $2000
Answer: fever

Conclusion

This integration marks a milestone in my journey as a developer. It symbolizes the confluence of trivia, data analysis, and software development, illustrating how diverse interests can converge into a single, cohesive project. With ChatGPT's insights and C#'s flexibility, the Jeopardy project stands as a testament to the endless possibilities in the realm of software development.