Loading...
JonHanes avatar JonHanes 0 Точки

Knight Game

Hello everyone.

 

I´m raising this topic as I´m questioning why my answer is correct.

The description of the exercise is as follows.

 

Chess is the oldest game, but it is still popular these days. For this task we will use only one chess piece – the Knight.

The knight moves to the nearest square but not on the same rowcolumn, or diagonal. (This can be thought of as moving two squares horizontally, then one square vertically, or moving one square horizontally then two squares vertically— i.e. in an "L" pattern.) 

The knight game is played on a board with dimensions N x N and a lot of chess knights 0 <= K <= N2.

You will receive a board with K for knights and '0' for empty cells. Your task is to remove a minimum of the knights, so there will be no knights left that can attack another knight.

Input

On the first line, you will receive the N size of the board

On the next N lines, you will receive strings with Ks and 0s.

Output

Print a single integer with the minimum number of knights that needs to be removed

Constraints

  • Size of the board will be 0 < N < 30
  • Time limit: 0.3 sec. Memory limit: 16 MB.

 

Examples

Input

Output

5

0K0K0

K000K

00K00

K000K

0K0K0

1

 

2

KK

KK

0

8

0K0KKK00

0K00KKKK

00K0000K

KKKKKK0K

K0K0000K

KK00000K

00K0K000

000K00KK

12

 

My solution is as listed: https://pastebin.com/rpezzFpb

As there seems to be more to this exercise than just finding relations between pieces, I do not believe my answer should be right.

 

However, I also believe that if the issue is with the exercise itself, the scope of the exercise would be way too complicated to solve.

I can see how it would be handled by creating sub-matrixes and calculating between them to calculate the minimum amount of moves necessary to solve the problem.

 

I´d appreciate your thoughts!

 

EDIT: I seem to have forgotten to remove the PrintMatrix function that I used for debugging which is not part of the output.

As such, please disregard that part.

This was only created so I could make it convenient for myself to graphically see what my program was doing.

Тагове:
0
C# Advanced 24/01/2020 09:43:33
Catchy_Title avatar Catchy_Title 2 Точки

There are so many games now. I can't imagine how you can't find something new. Most gambling platforms now provide both classic and innovative games. But personally, I like Bitcoin dice https://duckdice.io/. On the one hand, this is something more than classic, but on the other, Bitcoin investments bring something new to the gameplay. There are also cool bonuses. Try it, maybe this is what you are looking for.

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.