CTU Open Contest 2018 - Horsemeet

View as PDF

Submit solution

Points: 10
Time limit: 0.6s
Memory limit: 256M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Traditional games such as chess or checkers with slight modifications, are also played in Binary Casino. However, not many people play them, as these games are often referred as boring. The visitors are more attracted to more dynamic games which cause adrenaline rushes. To attract players to traditional games, your boss wants to introduce a chess-based game called Horsemeet. The rules of the game are:

The game is played by two players on a 8 \times 8 chessboard. One player plays a white knight and the other player plays a black knight. The players alternate in moves, the white knight moves first. In each move a knight is moved from its current position to a random valid position. Valid position within the chessboard is a position, which is two tiles away in one coordinate and one tile away in other coordinate from the original position. All moves to a valid position are equally probable. The first knight to move to a tile already occupied by the other knight wins.

In order to check whether this game could be at least partially interesting to visitors you have to determine the probability of victory for knights at given start positions. If the probabilities of victory for both knights differs by less than 10^{-6} the outcome of such configuration is a draw.

Input Specification

The first line of input contains two integers A and B (1 \le A, B \le 8), the start position of the white knight. The second line of each input consists of two integers C and D (1 \le C, D \le 8), the start position of the black knight. You can assume both positions are distinct.

Output Specification

Output the knight with a higher probability of victory: white or black. In case of equal probabilities output draw.

Sample Input 1

1 1
4 7

Sample Output 1


Sample Input 2

1 1
8 8

Sample Output 2

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported


There are no comments at the moment.