internal void Question2() { if (!TryParseInput()) { MessageBox.Show("Can't parse"); return; } m_system.TryAddRule("8: 42 | 42 8"); m_system.TryAddRule("11: 42 31 | 42 11 31"); var sb = new StringBuilder(); int nbValidMessages = 0; foreach (var message in m_messages) { if (m_system.CheckMessage(message, 0)) { sb.AppendLine(message.Text); nbValidMessages++; } } sb.Append($"Number of valid messages: {nbValidMessages}"); Result.Text = sb.ToString(); }