21 Matchsticks Problem | C # implementation of the approach ; Function to return the optimal strategy ; Removing matchsticks in blocks of five ; Driver code
using System ; class GFG { static void TwentyoneMatchstick ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i += 1 ) { Console . Write ( 5 - arr [ i ] + " ▁ " ) ; } Console . Write ( " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 4 , 2 , 2 } ; int N = arr . Length ; TwentyoneMatchstick ( arr , N ) ; } }