List<string> GetAllPossibleCombinations(short x) { List<string> result=new List<String>(); int number = Convert.ToInt32(Math.Pow(2, x)); for (int i = 1; i < number; i++) { string str = ""; for (int j = 0; j < x; j++) { bool bit = (i & (1 << j)) != 0; if (bit) str += (j + 1).ToString() + ","; } result.Add(str.TrimEnd(',')); } return result.OrderBy(p=>p.Length).ToList(); }
/// <summary> /// Gets the unused analog pins. /// </summary> /// <returns>The unused analog pins.</returns> private APin[] GetUnusedAnalogPins() { var unusedpins = new List<APin> (); var numpins = Board.NumberOfAnalogPins; for (uint i = 0; i < numpins; i++) { unusedpins.Add (new APin () { Number = i, DigitalNumber = Board.HardwareAnalogPins [i], RX = (Board.RX [0] == i), TX = (Board.TX [0] == i), SDA = (Board.SDA [0] == i), SCL = (Board.SCL [0] == i) }); } foreach (IPin pin in Pins) { if (pin is APin) { unusedpins.RemoveAll (o => o.Number == pin.Number); } else if (pin is DPin) { unusedpins.RemoveAll (o => o.DigitalNumber == pin.Number); } } return unusedpins.OrderBy (o => o.Number).ToArray<APin> (); }