using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(ValidateTimeIntervals(new string[] { "23:59:59-23:59:59", "23:59:59-23:59:59" }));
}
static string ValidateTimeIntervals(string[] timeIntervals)
{
int[,] ranges = new int[timeIntervals.Length, 2];
for (int i = 0; i < timeIntervals.Length; i++)
{
string[] splitStr = timeIntervals[i].Split('-');
ranges[i, 0] = TimeToInt(splitStr[0]);
ranges[i, 1] = TimeToInt(splitStr[1]);
}
for (int i = 0; i < timeIntervals.Length; i++)
public string GetDateTime()
{
return DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
}
public void group_multi_column_and_calculate_amount_and_quantity()
{
var c = new ListCollectionView(Items)
{
GroupDescriptions =
{
new PropertyGroupDescription("Name"),
new PropertyGroupDescription("Date")
}
};
c.GroupDescriptions.Add(new PropertyGroupDescription("Name"));
c.GroupDescriptions.Add(new PropertyGroupDescription("Date"));
c.GroupDescriptions.Add(new PropertyGroupDescription("Product"));
c.GroupDescriptions.Add(new PropertyGroupDescription("Quantity"));
c.GroupDescriptions.Add(new PropertyGroupDescription("Amount"));
dataGrid.ItemsSource = c;
}
public IEnumerable<Order> GetOrdersByMonth(int year)
{
var orders = from order in _orders
where order.OrderedDate.Year == year
group order by order.OrderedDate.Month into g
orderby g.Key
select g;
foreach (var group in orders)
{
Console.WriteLine($"Month: {group.Key}");
foreach (var order in group)
{
Console.WriteLine($"\t{order}");
}
}
}
public Func<DateTime, DateTime, IEnumerable<MeasurementData>> FilterByDateRange = (from, to) =>
{
return Measurements.Where(x => x.Timestamp >= from && x.Timestamp <= to);
};
class WorkOrder
{
string number;
string month;
object technologicalOperation;
float quantity;
float price;
float amount;
object worker;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Globalization;
using System.Collections;
using System.IO;
class Solution {
static void Main(String[] args) {
int N = int.Parse(Console.ReadLine());
var times = new ArrayList();
var intervals = new ArrayList();
int i = 0;
while(i < N){
var time = Console.ReadLine();
if(!times.Contains(time)){
times.Add(time);
}
i++;
}
foreach(var time in times){
var interval = time.Split('-');
var left = interval[0];
var right = interval[1];
intervals.Add(new Interval(left, right));
}
bool valid = true;
for(int j = 0; j <
class workOrder
{
public int number;
public string month;
public technologicalOperation technologicalOperation;
public double quantity;
public double price;
public double amount;
public worker worker;
}
public class MyClass
{
public string ItemName { get; set; }
public string ItemType { get; set; }
public string ItemGroup { get; set; }
}
var myView = new CollectionViewSource {Source = myCollection}.View;
myView.GroupDescriptions.Add(new PropertyGroupDescription("ItemGroup"));
myView.SortDescriptions.Add(new SortDescription("ItemType", ListSortDirection.Ascending));
myView.SortDescriptions.Add(new SortDescription("ItemName", ListSortDirection.Ascending));
// reference: http://stackoverflow.com/a/13017748/1768303
// model
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string City { get; set; }
}
// ViewModel
List<Person> people = new List<Person>
{
new Person { FirstName = "John", LastName = "Doe", City = "London"},
new Person { FirstName = "John", LastName = "Smith", City = "New York" },
new Person { FirstName = "Jane", LastName = "Smith", City = "London" },
new Person { FirstName = "John", LastName = "Smith", City = "Paris" },
};
ListCollectionView view = new ListCollectionView(people);
view.GroupDescriptions.Add(new PropertyGroupDescription("FirstName"));
view.GroupDescriptions.Add(new PropertyGroupDescription("LastName"));
// View
<ListBox x:Name="my
public void GroupByMulti(ListCollectionView _list, string[] _properties)
{
var groupProperty = _list.GroupDescriptions.FirstOrDefault();
if (groupProperty == null)
{
foreach (string _property in _properties)
{
_list.GroupDescriptions.Add(new PropertyGroupDescription(_property));
}
}
else
{
for (int i = 1; i < _properties.Length; i++)
{
_list.GroupDescriptions.Add(new PropertyGroupDescription(_properties[i]));
}
}
}
public ICollectionView GroupItems(ICollectionView view)
{
view.GroupDescriptions.Add(new PropertyGroupDescription("FirstName"));
view.GroupDescriptions.Add(new PropertyGroupDescription("LastName"));
return view;
}
class WorkOrder
{
private string number;
private string month;
private string technologicalOperation;
private string quantity;
private string price;
private string amount;
private string worker;
}
private void ListCollectionView_GroupingColumnsChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (ListCollectionView.IsGrouping == true)
{
if (ListCollectionView.Groups.Count > 0)
{
int count = 0;
int quantity = 0;
for (int i = 0; i < ListCollectionView.Groups.Count; i++)
{
foreach (InventoryItem item in ListCollectionView.Groups[i].Items)
{
count++;
quantity += item.Quantity;
}
}
_groupQuantity = quantity;
_groupCount = count;
OnPropertyChanged("GroupQuantity");
OnPropertyChanged("GroupCount");
}
else
{
_groupCount = 0;
_groupQuantity = 0;
OnPropertyChanged("GroupQuantity");
OnPropertyChanged("GroupCount");
}
}
}
public static string FormatDateTime(DateTime datetime)
{
return datetime.ToString("yyyy-MM-dd HH:mm:ss");
}
class FriendRecommender:
def recommend(self, n, friends):
"""
:param n: the number of users in the network
:type n: int
:param friends: two-dimensional list of integers representing the structure of the network
:type friends: list[list[int]]
:return: list of possible friends for each user
:rtype: list[set[int]]
"""
using System;
using System.Collections.Generic;
using System.Linq;
namespace Test
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
string[] param = Console.ReadLine().Trim().Split(new[] { ' ' });
var input = new List<string[]>();
for (int j = 0; j < param.Length; j++)
{
input.Add(param[j].Split(new[] { ':' }));
}
int hour1 = int.Parse(input[0][0]);
int min1 = int.Parse(input[0][1]);
int second1 = int.Parse(input[0][2]);
int hour2 = int.Parse(input[1][0]);
int min2 = int.Parse(input[1][1]);
int second2 = int.
private void GroupingByMultipleColumns(ObservableCollection<DummyModel> p_list)
{
var _listcollectionview = new ListCollectionView(p_list);
_listcollectionview.GroupDescriptions.Add(new PropertyGroupDescription("Name"));
_listcollectionview.GroupDescriptions.Add(new PropertyGroupDescription("Age"));
Datagrid1.ItemsSource = _listcollectionview;
}
## Author
* **Thomas Finsterwald** - *Initial work* - [ThomasFinsterwald](https://github.com/ThomasFinsterwald)
## Acknowledgments
* **HackerRank** - *Initial work* - [Hackerrank](https://www.hackerrank.com/)
public class GroupData
{
public string Column1 { get; set; }
public string Column2 { get; set; }
}
List<GroupData> data = new List<GroupData> ();
ListCollectionView view = new ListCollectionView (data);
view.GroupDescriptions.Add (new PropertyGroupDescription ("Column1"));
view.GroupDescriptions.Add (new PropertyGroupDescription ("Column2"));
class WorkOrder
{
public int Number { get; set; }
public int Month { get; set; }
public string TechnologicalOperation { get; set; }
public int Quantity { get; set; }
public double Price { get; set; }
public double Amount { get; set; }
public string Worker { get; set; }
}
using System;
using System.Collections.Generic;
using System.IO;
class Solution
{
static void Main()
{
var testCases = int.Parse(Console.ReadLine());
for(var i = 0; i < testCases; i++)
{
var times = new List<TimeSpan>();
var timesCount = int.Parse(Console.ReadLine());
for(var j = 0; j < timesCount; j++)
{
var timeString = Console.ReadLine();
var timeSplit = timeString.Split('-');
var leftTime = timeSplit[0];
var rightTime = timeSplit[1];
var leftTimeSpan = TimeSpan.Parse(leftTime);
var rightTimeSpan = TimeSpan.Parse(rightTime);
if(leftTimeSpan > rightTimeSpan)
{
Console.WriteLine("NO");
break;
}
if(
public class FormatConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
DateTime date = (DateTime)value;
return date.Date.ToString("d");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
using System;
using System.Collections.Generic;
namespace Friends
{
public class Friends
{
public static void Main()
{
int n = int.Parse(Console.ReadLine());
var network = new List<List<int>>();
for (int i = 0; i < n; i++)
{
var line = Console.ReadLine().Trim();
if (line.Length == 0)
network.Add(new List<int>());
else
network.Add(new List<int>(Array.ConvertAll(line.Split(' '), int.Parse)));
}
var possibleFriends = new List<List<int>>();
for (int i = 0; i < n; i++)
{
possibleFriends.Add(new List<int>());
for (int j = 0; j < n; j++)
{
if (i == j || network[i].Contains(j))
continue;
int mutualFriends = 0;
fore
var results = list.GroupBy(x => x.Month)
.Select(x => new {
Month = x.Key,
Sum = x.Sum(y => y.OrderTotal)
})
var operations = from wo in db.workorders
join w in db.workers
on wo.worker equals w.id
group jo by new { w.id, w.name} into g
select new {
id = g.Key.id,
name = g.Key.name,
operations = g.Count()
};
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var date = (DateTime)value;
if (date == DateTime.MinValue)
return "";
return date.ToString("d", CultureInfo.CurrentCulture);
}
List<Person> Filter(List<Person> persons, DateTime from, DateTime to)
{
return persons.Where(p => p.BirthDate >= from && p.BirthDate <= to)
}
public class ProductSummary
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public double Amount { get; set; }
public double Quantity { get; set; }
}
private List<Product> products;
public List<Product> Products
{
get { return products; }
set { products = value; RaisePropertyChanged("Products"); }
}
public ListCollectionView ProductsCollectionView { get; set; }
private void Grouping()
{
ProductsCollectionView = new ListCollectionView(Products);
ProductsCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("CategoryId"));
ProductsCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("TypeId"));
ProductsCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("VendorId"));
ProductsCollectionView.CustomSort = new ProductComparer();
ProductsCollectionView.GroupSummary.Add(new GroupSummary<Product, ProductSummary>()
{
PropertySelector = (x
public string ToString(DateTime dateTime)
{
if (dateTime == null)
{
return string.Empty;
}
return dateTime.ToString("dd/MM/yyyy");
}
#include <iostream>
#include <vector>
using namespace std;
struct Relation {
int user;
int friend_;
};
class Network {
public:
Network(int n) : nodes(n), friends(n) {}
void Add(const Relation& r) {
nodes[r.user - 1].emplace_back(r.friend_ - 1);
nodes[r.friend_ - 1].emplace_back(r.user - 1);
}
vector<vector<int>> FindPotentialFriends() {
for (int i = 0; i < nodes.size(); ++i) {
for (auto fi : nodes[i]) {
for (auto ffi : nodes[fi]) {
if (i == ffi) continue;
++friends[i][ffi];
}
}
}
vector<vector<int>> res;
for (int i = 0; i < friends.size(); ++i) {
vector<int> cur_friends
public class NameOfClass : ListCollectionView
{
public override bool PassesFilter(object item)
{
var date = ((MyObject)item).Date;
var currentMonth = DateTime.Now.Month;
return date.Month == currentMonth;
}
}
using System;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
string[] time = Console.ReadLine().Split(' ');
List<DateTime> start = new List<DateTime>();
List<DateTime> end = new List<DateTime>();
foreach (string s in time)
{
string[] times = s.Split('-');
string[] star = times[0].Split(':');
string[] endd = times[1].Split(':');
DateTime sta = new DateTime(2017, 1, 1, int.Parse(star[0]), int.Parse(star[1]), int.Parse(star[2]));
DateTime en = new DateTime(2017, 1, 1, int.Parse(endd[0]), int.Parse(
public ObservableCollection<TimeEntry> FilterMonth()
{
string currentMonth = DateTime.Now.ToString("MMMM");
return new ObservableCollection<TimeEntry>(TimeEntries.Where(x => x.Date.ToString("MMMM") == currentMonth));
}
using System;
using System.Collections.Generic;
using System.Linq;
namespace FriendsInNeed
{
class Program
{
private static int[][] graph;
private static List<int>[] possibleFriends;
private static HashSet<int>[] friends;
private static int[] degrees;
static void Main(string[] args)
{
ReadGraph();
possibleFriends = new List<int>[graph.Length];
friends = new HashSet<int>[graph.Length];
degrees = Enumerable.Repeat(0, graph.Length).ToArray();
CalculateDegrees();
CalculateFriends();
CalculatePossibleFriends();
PrintPossibleFriends();
}
private static void CalculatePossibleFriends()
{
for (int i = 1; i < possibleFriends.Length; i++)
{
var possibleFriend = possibleFriends[i];
possibleFriend.Sort();
possibleFriends[i] = possibleFriend;
}
}
private static void
public static void GroupBy(this ListCollectionView lcv, params string[] properties)
{
if (lcv == null)
return;
if (lcv.GroupDescriptions != null)
lcv.GroupDescriptions.Clear();
if (properties != null && properties.Length > 0)
{
foreach (string p in properties)
{
PropertyGroupDescription groupDescription = new PropertyGroupDescription(p);
lcv.GroupDescriptions.Add(groupDescription);
}
}
else
{
lcv.IsLiveGrouping = false;
}
}
private void GetGroupedProducts(ObservableCollection<Product> products, ICollectionView view)
{
view.GroupDescriptions.Add(new PropertyGroupDescription("Category.Name"));
var group = view.Groups[0];
MessageBox.Show(
"The category is " + group.Name + " and there are " +
group.ItemCount + " products in this category with a total value of " +
group.Items.Cast<Product>().Sum(p => p.UnitPrice * p.UnitsInStock));
}
ListCollectionView view = new ListCollectionView(lv.ItemsSource as IEnumerable);
if (view.GroupDescriptions != null)
{
view.GroupDescriptions.Clear();
}
else
{
view.GroupDescriptions = new ObservableCollection<GroupDescription>();
}
view.GroupDescriptions.Add(new PropertyGroupDescription("Location"));
view.GroupDescriptions.Add(new PropertyGroupDescription("Batch"));
for (int i = 0; i < view.Groups.Count; i++)
{
Console.WriteLine("Amount: {0}", (view.Groups[i] as CollectionViewGroup).Items[0].GetType().GetProperty("Amount").GetValue((view.Groups[i] as CollectionViewGroup).Items[0]));
Console.WriteLine("Quantity: {0}", (view.Groups[i] as CollectionViewGroup).Items[0].GetType().GetProperty("Quantity").GetValue((view.Groups[i] as CollectionViewGroup).Items[0]));
var collection = new List<Result>
{
new Result {Name = "A", Security = "S1", Quantity = 5, Amount = 20},
new Result {Name = "A", Security = "S2", Quantity = 5, Amount = 20},
new Result {Name = "A", Security = "S3", Quantity = 5, Amount = 20},
new Result {Name = "B", Security = "S1", Quantity = 5, Amount = 20},
new Result {Name = "B", Security = "S2", Quantity = 5, Amount = 20},
new Result {Name = "C", Security = "S1", Quantity = 5, Amount = 20},
new Result {Name = "C", Security = "S2", Quantity = 5, Amount = 20},
new Result {Name = "C", Security = "S3", Quantity = 5, Amount = 20},
};
var cvs = new CollectionViewSource { Source = collection };
cvs.GroupDescriptions.Add(new PropertyGroupDescription("Name"));
cvs.GroupDescriptions.Add
public static string getTime(object time)
{
if (time == null) return "";
DateTime dt = (DateTime)time;
return dt.ToString("yyyy-MM-dd HH:mm");
}
var view = (ListCollectionView)CollectionViewSource.GetDefaultView(this.Items);
view.GroupDescriptions.Add(new PropertyGroupDescription("FirstColumn"));
view.GroupDescriptions.Add(new PropertyGroupDescription("SecondColumn"));
using System;
using System.Collections.Generic;
using System.Linq;
namespace Friends
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[,] matrix = new int[n, n];
for (int i = 0; i < n; i++)
{
int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
for (int j = 0; j < arr.Length; j++)
{
matrix[i, arr[j] - 1] = 1;
matrix[arr[j] - 1, i] = 1;
}
}
for (int i = 0; i < n; i++)
{
List<int> friends = new List<int>();
int mutualFriends = 0;
for (int j = 0; j < n; j++)
{
if (matrix[i, j] == 0 && i
// Worker
public class Worker
{
public int Number { get; set; }
public string Name { get; set; }
public string Profession { get; set; }
public List<WorkOrder> WorkOrders { get; set; }
public Worker()
{
WorkOrders = new List<WorkOrder>();
}
public Worker(int number, string name, string profession)
{
Number = number;
Name = name;
Profession = profession;
WorkOrders = new List<WorkOrder>();
}
public void AddWorkOrder(WorkOrder workOrder)
{
WorkOrders.Add(workOrder);
}
public int GetNumberOfWorkOrdersByMonth(int month)
{
return WorkOrders.Count(wo => wo.Month == month);
}
}
public class ViewModel {
private readonly ListCollectionView _collectionView;
public ViewModel() {
_collectionView = new ListCollectionView(myList);
_collectionView.GroupDescriptions.Add(new PropertyGroupDescription("Name"));
_collectionView.GroupDescriptions.Add(new PropertyGroupDescription("Age"));
}
public IEnumerable MyCollectionView {
get {
return _collectionView;
}
}
}
public class DateComparer : IComparer<DateTime>
{
public int Compare(DateTime x, DateTime y)
{
if (x.Year == y.Year && x.Month == y.Month)
return 0;
return 1;
}
}
//...
ListCollectionView lstCollView = new ListCollectionView(lst);
lstCollView.Filter = (obj) =>
{
DateTime dt = (DateTime)obj;
if (dt.Year == DateTime.Now.Year && dt.Month == DateTime.Now.Month)
return true;
return false;
};