csharp Advanced exercises: Tetris - rotating mass [Difficulty: Level 2] - view the C # programming classic exam, exercises of varying difficulty C #, C # novice suitable for self-study of advanced training

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_45444821/article/details/102716745

csharp Advanced exercises: Tetris - rotating mass [Difficulty: Level 2]:

Nintendo embodiment of a block "A'- button: the Russian side Kuaikuai Boolean matrix, where the true and false apparatus means that the block part of the background is represented example, this would be." L "shaped blocks:


[T,F],
 [T,F],
 [T,T]]

This will be the square blocks


[T,T],
 [T,T]]

Each time the A button will call you conversion function, which rotates clockwise 90 degrees blocks Thus, for example, conversion of the square block will return the same block, and transform block returns L:


[T,T,T],
 [T,F,F]]
 

Programming objectives:

public static class Tetris
{
  public static bool[,] Rotate(bool[,] block)
  {
  }
}


Test sample:

using NUnit.Framework;
using System;
[TestFixture]
public class KataTests
{
  [Test]
  public void SquareBlock()
    bool[,] square = {{true, true},
                      {true, true}};
    Assert.AreEqual(square, Tetris.Rotate(square)); 
  }
  [Test]
  public void LBlock()
  {


Best answer (multiple solutions):

Click to view answer

More related topics:

Disclaimer

This blog All programming topics and answers were collected from the Internet, users are mainly used for study and reference, if any violation of your rights, please contact the administrator to delete, thank
entitled to collect https://www.codewars.com/
HTTPS: / /www.codewars.com/kata/tetris-rotate-the-block

Guess you like

Origin blog.csdn.net/weixin_45444821/article/details/102716745