using System.Collections.Generic;
class Tile : IComparable<Tile>, IEquatable<Tile>
public int Number { get; set; }
public char Color { get; set; }
public int CompareTo(Tile other) {
var val = this.Color.CompareTo(other.Color);
return val == 0 ? val : this.Number.CompareTo(other.Number);
public bool Equals(Tile other) {
return this.Color == other.Color && this.Number == other.Number;
public override string ToString() {
return string.Format("{0}{1}", Color, Number);
static Random _r = new Random();
public static void Main(string[] args) {
Console.WriteLine(string.Join(" ", TileBag("PBYR", Enumerable.Range(1, 13)).OrderBy(t => _r.Next()).Take(14)));
static IEnumerable<Tile> TileBag(IEnumerable<char> colors, IEnumerable<int> numbers) {
foreach (var color in colors)
foreach (var number in numbers)
yield return new Tile { Color = color, Number = number };
yield return new Tile { Color = color, Number = number };