All Tracks Algorithms Greedy Algorithms Basics of Greedy Algorithms Problem

Harry Potter and the Sorcerer's Stone
Tag(s):

BFS, Dijkstra, Easy, Easy

Problem
Editorial
Analytics

Do you remember Harry, Ron and Hermione had to play the wizard chess to get to Voldemort, sorry, "You know who", in Harry Potter and the Sorcerer's Stone? Well, Harry needs to knock Ron's king out to get to "You know who" by using only his knight. As the time is running out, he needs to find out the minimum number of steps in which he can knock Ron's king out by using his knight, assuming Ron's king stays in the same position throughout the game.

Input

The only line contains four numbers x1,y1,x2,y2. x1,y1 are the coordinates of Harry's knight. x2,y2 are the coordinates of Ron's king.

Output

Print the minimum number of moves in one line.

Constraints

1 <= x1,y1,x2,y2 <=8

SAMPLE INPUT
2 1 6 5
SAMPLE OUTPUT
4
Explanation

He needs to make 4 minimum moves to knock the king out. Given in the image is one such path.

enter image description here

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Scala 2.11.8, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

NIT Surat

Challenge Name

Epiphany 6.2

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications