This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
int digitDegree(int n) | |
{ | |
var str = n.ToString(); | |
var i = 0; | |
for (; str.Length > 1; i++) | |
{ | |
str = str.Sum(c => int.Parse(c.ToString())).ToString(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
bool bishopAndPawn(string bishop, string pawn) => | |
Math.Abs(bishop[0] - pawn[0]) == Math.Abs(bishop[1] - pawn[1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
bool isBeautifulString(string inputString) | |
{ | |
var list = Enumerable.Range(Convert.ToInt32('a'), 26).Select(i => inputString.Count(c => c == i)).ToList(); | |
return list.SequenceEqual(list.OrderByDescending(i => i)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
int[][] minesweeper(bool[][] matrix) => | |
matrix.Select((row, i) => row.Select((_, j) => | |
matrix.Skip(i - 1).Take(i == 0 ? 2 : 3) | |
.SelectMany(r => r.Skip(j - 1).Take(j == 0 ? 2 : 3)).Count(m => m) - | |
(matrix[i][j] ? 1 : 0)).ToArray()).ToArray(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
static List<string> FizzBuzz(int count) => Enumerable | |
.Range(1, count) | |
.Select(i => (i % 3 == 0, i % 5 == 0) switch | |
{ | |
(true, false) => "Fizz", | |
(false, true) => "Buzz", |