using System.Collections.Generic;
public string Title { get; set; }
public string Link { get; set; }
public DateTime Date { get; set; }
public CategoryType Category { get; set; }
public static void Main()
const string url = "https://www.reddit.com/r/dailyprogrammer/.rss";
var xdoc = XDocument.Load(url);
var items = from item in xdoc.Descendants("item")
let title = item.Element("title").Value
Link = item.Element("link").Value,
Date = DateTime.Parse(item.Element("pubDate").Value),
Category = ExtractCategory(title)
var sorted = items.OrderBy(x => x.Category);
var array = Split(sorted);
private static CategoryType ExtractCategory(string title)
var categories = new Dictionary<string, CategoryType>
{ "[Easy]", CategoryType.Easy },
{ "[Intermediate]", CategoryType.Intermediate },
{ "[Hard]", CategoryType.Hard }
return categories.FirstOrDefault(x => title.Contains(x.Key)).Value;
private static void Print(Item[,] array)
Console.WriteLine("Other | Easy | Intermediate | Hard ");
Console.WriteLine("------|------|--------------|------");
for (int i = 0; i < array.GetLength(0); i++)
for (int j = 0; j < array.GetLength(1); j++)
Console.Write("| " + (item != null ?
string.Format("[{0}]({1})", item.Title, item.Link)
private static Item[,] Split(IEnumerable<Item> items)
var splitedItems = items.GroupBy(j => j.Category).ToArray();
var array = new Item[splitedItems.Max(x => x.Count()), splitedItems.Length];
for (var i = 0; i < splitedItems.Length; i++)
for (var j = 0; j < splitedItems.ElementAt(i).Count(); j++)
array[j, i] = splitedItems.ElementAt(i).ElementAt(j);