DEV Community

Discussion on: Daily Coding Puzzles - Oct 29th - Nov 2nd

Collapse
 
dance2die profile image
Sung M. Kim • Edited

Here is a C# version

Note: Aggregate is equivalent to reduce in JavaScript or other languages
and seed value is the first argument unlike in JavaScript, in which it's the last argument.

using System;
using System.Linq;
namespace Solution
{
    class Kata
    {
        public static int binaryArrayToNumber(int[] a)
        {
            return Convert.ToInt32(a.Aggregate("", (acc, n) => acc + n.ToString()), 2);
        }
    }
}