Contest 12 - Knight Moves
Programming Contest – Knight Moves
For all those who haven't participated in the contest please read the FAQ
Overview
Given a position on a chessboard, list all available positions that a knight can move to.
For example, if I input G1 then the program should output:
Languages
C, C#, C++, F#, Java, JavaScript(musts include HTML and CSS, but markup/styling will not be graded), LUA, Perl, Python, and VB.Net
Deadline
August 4th, 2017
Rules for Contest
The rules followed will be specific to the contest and not the game.
- You must submit the source code and include a fiddle(ideone, dotnetfiddle, codepen, etc.)
- Allow the user to enter the String in the following format: E2(where E is the column name and 2 is the row index)
Marking
Each entry will be judged on the following things.
- Accuracy - Does the program follow all of the rules?
- Length - How concise is the submitted code?
- Execution - How quick did the code execute?
- Efficiency - How efficient is the algorithm(s) you chose?
Prizes
You will get to brag that you won a VBForums contest and I'll also include a special avatar!
Please submit all entry's to the forum below with the title in the following format "Contest 12: Knight Moves - [User Name]"
Contest Entries Forum
Re: Contest 12 - Knight Moves
Do you also allow g1 (as opposed to G1) or is this considered invalid input?
Does the order of the available positions in the output be as shown or would another order be judged as good. ie for the example given
would
be just as acceptable?
Re: Contest 12 - Knight Moves
Casing doesn't matter, nor does alphabetical sorting.
Re: Contest 12 - Knight Moves
Quote:
Accuracy - Does the program follow all of the rules?
Length - How concise is the submitted code?
Execution - How quick did the code execute?
Efficiency - How efficient is the algorithm(s) you chose?
What is the weighting of these? I guess accuracy would be first, but what about concise code that is slower than more efficient verbose code? I've noticed in previous contests that concise code seems to win over efficient code?
Re: Contest 12 - Knight Moves
This one will take into account how many passes the code makes vs. how concise the code is.
Re: Contest 12 - Knight Moves
@dday9 - I made a submission and I just realized, I did Bishop moves instead of Knight moves :blush
Can I have that removed and resubmit later?
Re: Contest 12 - Knight Moves
dday9
1. Is VB6 ok?
2. What is a "fiddle" ?
3. How would I include an image?
EDIT:
4. Now that I think about it, how do I upload the code? .. :blush:
Spoo
Re: Contest 12 - Knight Moves
@Spooman
4-
Quote:
Please submit all entry's to the forum below with the title in the following format "Contest 12: Knight Moves - [User Name]"
Contest Entries Forum
Re: Contest 12 - Knight Moves
Quote:
Originally Posted by
Spooman
dday9
1. Is VB6 ok?
2. What is a "fiddle" ?
3. How would I include an image?
Re 'fiddle'. See http://www.vbforums.com/showthread.p...ing-Characters for more info.
Re: Contest 12 - Knight Moves
Quote:
Originally Posted by
4x2y
@Spooman
4-
Thanks .. that's the where.
What I don't know is the what.
I'm familiar with pasting a code snippet to a thread using the CODE wrapper, and with uploading an IMAGE.
But what is involved here?
Spoo
2 Attachment(s)
Re: Contest 12 - Knight Moves
Quote:
Originally Posted by
2kaud
Thanks. Good link.
And it appears to address the VB6 question .. not allowed.
At the risk of sounding cheeky .. that sucks.
So I'll settle with posting two images here.
Init example
Attachment 150017
Max example
Attachment 150019
The foregoing "sucks" comment aside, I nonetheless had fun developing the app.
Spoo
Re: Contest 12 - Knight Moves
So far we only have 3 entries for the contest (excluding Spoo's nonqualified VB6 entry). Keep in mind, the contest ends on 11:59PM CST so be sure to submit your entry before then!
Re: Contest 12 - Knight Moves
Is it canceled? Is all entries are wrong?
Re: Contest 12 - Knight Moves
Quote:
Originally Posted by
Absolute_Zero
Is it canceled? Is all entries are wrong?
No it's still being judged
Re: Contest 12 - Knight Moves
I see, but it takes too long to judge just 3 entries :)
Re: Contest 12 - Knight Moves
They're not all written in the same Programming Language. Got to wait for another judge...
Re: Contest 12 - Knight Moves
I want to thank everyone who participated in the Knight Moves contest!
I got to the judging a little later than I had hoped to because I had some moderators flake on me that promised to judge C++ entries, but it has been judged none-the-less. And the winner for the contest is....
http://www.cutecatgifs.com/wp-conten...4/01/metal.gif
2kaud for his C++ entry!
Re: Contest 12 - Knight Moves
Re: Contest 12 - Knight Moves
Quote:
Originally Posted by
4x2y
Congratulations 2kaud
Yeah... Congrats from me too :D
Re: Contest 12 - Knight Moves
Had my solution implemented already a few weeks before (really weird this VB6-exclusion BTW),
and have choosen a different approach (based on a stepwise progressing rotation of 1/8th of a full circle -
using a 2D-Matrix-Class for recalculation, in combination with an "OnBoard-check" of the resulting Coords in each step):
Maybe that's interesting for others (because it's a bit "outside the box" algo-wise).
Code:
Function GetKnightStrikePositions(BoardPos As String) As cArrayList
Set GetKnightStrikePositions = New_c.ArrayList(vbString) 'set the return-type-instance
On Error GoTo 1
Dim x As Double, y As Double, M As cCairoMatrix, i As Long
x = Asc(UCase$(Trim$(BoardPos))) - 65 'convert the Chess-Notation into x, ...
y = Asc(Right$(Trim$(BoardPos), 1)) - 49 'and y Coords ... [0 to 7],[0 to 7]
If Not OnBoard(x, y) Or Len(Trim$(BoardPos)) <> 2 Then Err.Raise 5 'sanity-check
Set M = Cairo.CreateIdentityMatrix 'Ok, the whole approach is based on a 2D-Matrix-Class
M.TranslateCoords x + 0.5, y + 0.5 'move to the center of the given (Int-Coord-based) Field
For i = 1 To 8 'check all 8 potential positions in a loop
x = 1: y = 2 'the typical 1:2-move of the knight (from the current point)
M.CalculatePoint x, y 'let the Matrix calculate the location of the new Point for us
If OnBoard(Int(x), Int(y)) Then GetKnightStrikePositions.Add Chr$(65 + Int(x)) & Chr$(49 + Int(y))
M.RotateCoordsDeg -360 / 8 'clockwise rotate the Matrix further by 1/8th of the full circle
Next
1 If Err Then GetKnightStrikePositions.Add "Invalid BoardPos"
End Function
Private Function OnBoard(ByVal x As Long, ByVal y As Long) As Boolean
OnBoard = Not (x < 0 Or x > 7 Or y < 0 Or y > 7) 'outsourced "OnBoard-check"
End Function
Usage then for example:
Code:
MsgBox GetKnightStrikePositions(InputBox("Enter Knight-position")).Join(", ")
Olaf
Re: Contest 12 - Knight Moves
dday
You definitely need to repost that video here
http://www.vbforums.com/showthread.p...37#post5182937
EDIT-1:
Oh yeah, congrats from me too, even though it wasn't written in VB6
EDIT-2:
Olaf
Quote:
(really weird this VB6-exclusion BTW)
Amen
Re: Contest 12 - Knight Moves
Thanks to all.
IMO VB6 should be allowed - anything to increase the number of participants. If a forum moderator can't comment upon code in the language for which they are a mod...........
Re: Contest 12 - Knight Moves
Congrats 2kaud, but I liked 4x2y's entry, he used a smart way to find moves out of board :thumb:
Re: Contest 12 - Knight Moves
Quote:
Originally Posted by
Absolute_Zero
Congrats 2kaud, but I liked 4x2y's entry, he used a smart way to find moves out of board :thumb:
Yes, I like that as well :thumb: