CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Practice(easy) » Correctness of Knight Move

Correctness of Knight Move

Problem code: KNIGHTMV

  • Submit
  • All Submissions

All submissions for this problem are available.

Chef develops his own computer program for playing chess. He is at the very beginning. At first he needs to write the module that will receive moves written by the players and analyze it. The module will receive a string and it should report at first whether this string represents the correct pair of cells on the chess board (we call such strings correct) and then report whether it represents the correct move depending on the situation on the chess board. Chef always has troubles with analyzing knight moves. So at first he needs a test program that can say whether a given string is correct and then whether it represents a correct knight move (irregardless of the situation on the chess board). The cell on the chessboard is represented as a string of two characters: first character is a lowercase Latin letter from a to h and the second character is a digit from 1 to 8. The string represents the correct pair of cells on the chess board if it composed of 5 characters where first two characters represent the cell where chess figure was, 3rd character is the dash "-" and the last two characters represent the destination cell.

Input

The first line contains a single integer T <= 50000, the number of test cases. T test cases follow. The only line of each test case contains a non-empty string composed the characters with ASCII-codes from 32 to 126. The length of the string is not greater than 10.

Output

For each test case, output a single line containing the word "Error" if the corresponding string does not represent the correct pair of cells on the chess board. Otherwise output "Yes" if this pair of cells represents the correct knight move and "No" otherwise.

Example

Input:
4
a1-b3
d2-h8
a3 c4
ErrorError

Output:
Yes
No
Error
Error


Author: anton_lunyov
Date Added: 13-06-2011
Time Limit: 1 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

http://www.codechef.com/views

chhabraamit @ 20 Jun 2011 02:25 AM
http://www.codechef.com/viewsolution/579918 can anyone please tell me, at what boundary cases my program is failing .. i am getting WA though i have tried a lot cases . thanks in advace

Chhabraamit: your wrong is if

eather @ 20 Jun 2011 08:11 AM
Chhabraamit: your wrong is if you give input with trailing Zero, its do no effect to the output. But Trailing Zero can be the inputs. Try it: a1-b3 your solution gives "Yes" but it is "Error"

Sorry, Trailing Zero meant

eather @ 20 Jun 2011 08:25 AM
Sorry, Trailing Zero meant Trailing Space

@chhabraamit try g4-d4

cracker2excel @ 20 Jun 2011 08:40 AM
@chhabraamit try g4-d4 answer should be "No"

@ eather & cracker2excel

chhabraamit @ 20 Jun 2011 10:26 AM
@ eather & cracker2excel ..thankyou for your help i have fixed that bug , but it is still giving the wrong answer can u look one more time , plz. http://www.codechef.com/viewsolution/580096

My input is not working

atris @ 20 Jun 2011 11:16 AM
My input is not working correctly....gets and fgets are not working in a loop.Please help. http://www.codechef.com/viewsolution/579632

@chhabraamit: How about

mukulgupta @ 20 Jun 2011 11:32 AM
@chhabraamit: How about testing your code for [space][enter]? Answer should be "Error".

@atris: Use a getchar() after

mukulgupta @ 20 Jun 2011 11:34 AM
@atris: Use a getchar() after scanf to trap buffered 'n'.

@mukulgupta...thanks a

atris @ 20 Jun 2011 11:47 AM
@mukulgupta...thanks a lot....but where will i store the input from getchar()???or should i discard it???

@mukulgupta ..thanks a lot

chhabraamit @ 20 Jun 2011 12:09 PM
@mukulgupta ..thanks a lot for pointing out that bug.. but it is still giving WA after solving that. http://www.codechef.com/viewsolution/580159

@atris: Discard. @amit: Very

mukulgupta @ 20 Jun 2011 01:27 PM
@atris: Discard. @amit: Very silly mistake in the first condition, if((a[i][0]>='a'&&a[i][1]<='h'))

@mukul. Thanks a lot !! you

chhabraamit @ 20 Jun 2011 03:30 PM
@mukul. Thanks a lot !! you saved my day :)

@mukul....i am not able to

atris @ 20 Jun 2011 03:59 PM
@mukul....i am not able to get exactly what you mean.Could you please give an example??

@atris.. he is saying after

chhabraamit @ 20 Jun 2011 04:02 PM
@atris.. he is saying after taking value of no of test cases , use getchar() to deal with buffered 'n' i.e scanf("%d",&test_cases); getchar(); // you dont need store this value .

@amit...its not

atris @ 20 Jun 2011 04:19 PM
@amit...its not working... scanf("%d",&n); getchar(); scanf("%d",&l); is not taking input in a single line..

i am repeatedly getting wrong

assasin143 @ 20 Jun 2011 05:06 PM
i am repeatedly getting wrong answer. can anybody please tell me the problem.....http://www.codechef.com/viewsolution/580391

please tell error in my

pprateek @ 21 Jun 2011 08:28 PM
please tell error in my program...... http://www.codechef.com/viewsolution/581209

anyone pls tell me where my

vioky @ 23 Jun 2011 05:09 PM
anyone pls tell me where my prog is failing... thanx in advance... http://www.codechef.com/viewsolution/582196

Time Limit Exceeds It seems

hoanglienson @ 24 Jun 2011 07:38 AM
Time Limit Exceeds It seems Java can not beat. :(

http://www.codechef.com/views

z_code @ 30 Jun 2011 08:53 PM
http://www.codechef.com/viewsolution/586080 the code is absolutely fine as far as i think... many submitted solution has the exact same thing which i did...but still its showing WA..!!.... Is there anyone who can help? O_o

@z_code: Try this

imnewcoder @ 1 Jul 2011 12:39 AM
@z_code: Try this case: 1 a1-b3

http://www.codechef.com/views

Ahmedsaud @ 23 Jul 2011 11:57 PM
http://www.codechef.com/viewsolution/603808 can anyone explain me what is wrong with this code

why cant i submit my

moody @ 1 Oct 2011 02:55 AM
why cant i submit my solution????

http://www.codechef.com/views

juampa @ 2 Jan 2012 05:52 AM
http://www.codechef.com/viewsolution/775230 I'm getting TLE error, although i checked with a 50.000 test case input and executing time was below 900ms. I know my computer could be faster than codechef's one, but beeing that JAVA is allowed a 2x time factor i think my code should be fast enough. Could you please tell me if there is any error in my code (im not asking for the error, would like to find it out myself) or is only a Java's time consuming problem? Thanks in advance

I've tried all the possible

avinash_jain @ 13 Apr 2012 12:44 AM
I've tried all the possible test case but still don't know why I'm getting WA. Please help me. http://www.codechef.com/viewsolution/978153

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold

HELP

Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:

 

  • Accepted Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark.
  • Time Limit Exceeded Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.
  • Wrong Answer Your program compiled and ran succesfully but the output did not match the expected output.
  • Runtime Error Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.
  • Compilation Error Your code was unable to compile. When you see this icon, click on it for more information.
  • If you are still having problems, see a sample solution here.

CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com