+ 6

Is it good for the challenge?

Updated GRAPHIC version https://code.sololearn.com/Wdkm7CGt4PJo/?ref=app I think it’s a nice try, do you? 🤙🏻🤙🏻🤙🏻🤙🏻🤙🏻🤙🏻🤙🏻🤙🏻🤙🏻🤙🏻

18th Apr 2018, 9:00 PM
Alberto Cini - Noviia
Alberto Cini - Noviia - avatar
1 Answer
+ 2
Cool visuals on your code Alberto! This function took me a few days to work out. I was trying to find a general formula to find the number of squares a knight can move on any square. You call it as follows: knight_function('c', 3), and it will tell you how many moves a knight can make at C3. int knight_function2(char file, int rank) { double x=fabs((file-'a')-3.5),y=fabs(4.5-rank); return x<=1.5&&y<=1.5?8:(int)round(2*(5.7-sqrt(x*x+y*y))); } https://code.sololearn.com/cd2qp3yOK86v/#c
26th Apr 2018, 6:36 PM
Emma