Flutter is ready for the big stage. 🎸 We're officially 1 week away from #FlutterInProduction. → goo.gle/FiP See below for a special coding challenge!
3
32
228
14K
16
Download Video
Write Dart code to generate all 3-note combinations in the A to G scale. Bonus: only include ascending combos (e.g., 'ABC', not 'CBA'). Can you code the perfect harmony? Share below! 🎶
@FlutterDev Iterative (a bit dirtier than the nested for loops lol), and a recursive one, all still quadratic time
@FlutterDev import 'dart:math';void main() {var r = Random();var s = 'ABCDEFG'.split('');var h = '';var l = r.nextInt(4);while (true) {h += s[l];if (h.length == 3) break;l = l + 1 + r.nextInt(max(5 - l, 1));}print(h);} The code fits into a tweet 💙