// MongoDB Query Exercises
// Use the sample collection below and write MongoDB queries for each task.
 
// Optional reset:
db.students.drop();
 
// Sample data
db.students.insertMany([
  { name: "Alice", age: 18, grade: 1, hobbies: ["reading", "sports"], scores: [80, 90, 85] },
  { name: "Bob", age: 20, grade: 2, hobbies: ["gaming"], scores: [60, 70, 65] },
  { name: "Charlie", age: 19, grade: 1, hobbies: ["reading", "music"], scores: [95, 85, 92] },
  { name: "Diana", age: 21, grade: 3, hobbies: ["sports", "music"], scores: [50, 60, 55] },
  { name: "Eve", age: 18, grade: 2, hobbies: ["gaming", "reading"], scores: [88, 91, 84] },
  { name: "Frank", age: 22, grade: 3, hobbies: ["reading", "music", "gaming"], scores: [72, 81, 90] },
  { name: "Grace", age: 17, grade: 1, hobbies: ["music"], scores: [99, 97, 100] },
  { name: "Henry", age: 20, grade: 2, hobbies: ["sports", "coding"], scores: [68, 74, 79] },
  { name: "Isabel", age: 19, grade: 2, hobbies: ["reading", "coding"], scores: [82, 86, 88] },
  { name: "Jack", age: 21, grade: 1, hobbies: ["sports", "music", "reading"], scores: [55, 89, 93] }
]);
 
// ======================================================
// TASKS
// Write a MongoDB query for each task.
// Example format:
// db.students.find({ age: 18 })
// ======================================================
 
// 1. Find students with age equal to 18.
 
// 2. Find students older than 19.
 
// 3. Find students with age greater than or equal to 20.
 
// 4. Find students with age less than 19.
 
// 5. Find students with age less than or equal to 18.
 
// 6. Find students whose grade is not 2.
 
// 7. Find students whose grade is either 1 or 3.
 
// 8. Find students whose grade is not in [1, 2].
 
// 9. Find students aged between 18 and 20 (inclusive).
 
// 10. Find students who are either 18 years old OR in grade 3.
 
// 11. Find students who are NOT older than 20.
 
// 12. Find students who are neither in grade 1 nor grade 2.
 
// 13. Find students whose hobbies include both "reading" AND "sports".
 
// 14. Find students with exactly 1 hobby.
 
// 15. Find students with exactly 2 hobbies.
 
// 16. Find students where at least one score is greater than 90.
 
// 17. Find students with at least one score between 85 and 95.
 
// 18. Find students who are (age >= 18 AND age <= 20) AND grade = 1.
 
// 19. Find students who are either in grade 1 OR have a score above 90.
 
// 20. Find students who do NOT have any score below 60.
 
// 21. Find students with hobbies including "reading" but NOT "gaming".
 
// 22. Find students with exactly 3 scores and at least one score above 90.
 
// 23. Find students whose scores contain ALL of [85, 90].
 
// 24. Find students where:
//     - age is between 18 and 21
//     - AND (grade is 1 OR grade is 2)
//     - AND hobbies include "reading"
 
// 25. Find students where:
//     - NOT (grade is 3)
//     - AND at least one score is less than 60
 
// 26. Find students where:
//     - hobbies include "music"
//     - AND scores have an element >= 90 AND <= 100
 
// 27. Find students where:
//     - age != 18
//     - AND hobbies size is 2
//     - AND scores do NOT contain values < 70
 
// 28. Find students where:
//     - (age < 19 OR age > 20)
//     - AND hobbies include BOTH "reading" and "music"
 
// 29. Find students where:
//     - all scores are between 80 and 100
//     - AND grade is not in [2, 3]
 
// 30. Find students where:
//     - hobbies contain all of ["sports", "music"]
//     - AND age is not 21
//     - AND grade is 1 or 3
 
// -------------------------
// HARDER TASKS
// -------------------------
 
// 31. Find students where:
//     - age is between 18 and 22
//     - AND hobbies contain "reading"
//     - AND hobbies do NOT contain "gaming"
//     - AND at least one score is > 90
 
// 32. Find students where:
//     - grade is 1
//     - AND (age < 18 OR age > 20)
//     - AND scores contain all of [89, 93]
 
// 33. Find students where:
//     - hobbies array has exactly 3 elements
//     - AND includes "music"
//     - AND does NOT include "gaming"
//     - AND at least one score is between 80 and 95
 
// 34. Find students where:
//     - NOT(age <= 18)
//     - AND NOT(grade = 2)
//     - AND hobbies include either "coding" OR "sports"
 
// 35. Find students where:
//     - scores have at least one value < 60
//     - OR hobbies contain all of ["reading", "music"]
 
// 36. Find students where:
//     - age is not in [17, 18]
//     - AND hobbies size is at least conceptually "not 1" (use available operators only)
//     - AND grade <= 2
 
// 37. Find students where:
//     - all scores are >= 70
//     - AND at least one score is >= 90
//     - AND hobbies include "reading"
 
// 38. Find students where:
//     - neither grade 2 nor grade 3
//     - AND age >= 18
//     - AND hobbies include "sports"
 
// 39. Find students where:
//     - age < 18 OR age > 21 OR grade = 3
//     - AND scores contain a value <= 55
 
// 40. Find students where:
//     - hobbies include all of ["reading", "music"]
//     - AND scores do NOT contain any value < 80
//     - AND age is not equal to 19
 
// 41. Find students where:
//     - grade is 1 or 2
//     - AND hobbies include "coding" or "music"
//     - AND age is between 19 and 21
 
// 42. Find students where:
//     - NOT(age < 20)
//     - AND NOT(hobbies contain "sports")
//     - AND scores contain at least one value > 85
 
// 43. Find students where:
//     - hobbies size is 2
//     - AND scores contain all of [82, 86]
//     - AND grade != 3
 
// 44. Find students where:
//     - all scores are <= 90
//     - AND at least one score is >= 80
//     - AND age is in [19, 20, 21]
 
// 45. Find students where:
//     - (grade = 1 AND hobbies contain "reading")
//       OR
//       (grade = 3 AND scores contain a value < 60)
 
// 46. Find students where:
//     - hobbies contain "reading"
//     - AND hobbies contain "music"
//     - AND hobbies contain "sports"
//     - AND scores contain at least one value > 90
 
// 47. Find students where:
//     - NOT(scores contain a value > 95)
//     - AND grade is not 2
//     - AND age >= 18
 
// 48. Find students where:
//     - scores contain at least one value between 70 and 80
//     - AND at least one value between 90 and 100
//     - AND hobbies include "reading"
 
// 49. Find students where:
//     - age <= 20
//     - AND not grade 1
//     - AND hobbies contain either "coding" or "gaming"
//     - AND scores do NOT contain values <= 60
 
// 50. Find students where:
//     - neither (age < 18) nor (grade = 3)
//     - AND hobbies contain all of ["reading"]
//     - AND scores array has exactly 3 elements