3 kyu
One line task: Is the King in check ?
57 of 140Torkel
Loading description...
Restricted
Puzzles
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Finally, holy, that was tough, spent 3 days, but the satisfaction is huge. At first I didn't notice that I had to fit into 280 characters – wrote 1700 :D
I found a solution on the easier version of this kata, copy pasted it over, and it worked first try. I did not mean for it to work, so I obviously don't want the honor/points, so I am currently trying to do this kata my way. Having said that, is there a way to block solutions like this on the easier kata, and possibly make it a feature to hide solutions after submitting?
hidden.
'won't happen. The first use of it would be copycats trying to hide the fact they are cheating.
true, but what if the feature was only allowed for trusted moderators/people? would that work?
Such feature is already there, moderators can hide submitted solutions. And yes, this function is used to handle spoilers. But such spoiler solution has to be reported first, so mods know what to hide :)
This comment has been hidden.
I got it down to 179. I hope theres no issues with submitting multiple times. It seems my past solutions are still there, is there a way to remove them?
sadly, no.
This was very hard, but finally I attempted my solution on Python in 271 symbols!
Got it down to 299 characters in Clojure using some very dirty tricks, and
I don't think I can get any lower without a radically new approach(update: I did it, although the approach was sub-optimal as shown by other solutions).But it's been tremendously fun! :)
The semicolon restriction for js is crazy
Hi,
You need more edge test cases to avoid solutions, such as my python's solution, which can't work when there is a chess blocking another's line of sight, passing the test.
Should be updated to Python 3.8
.
This comment has been hidden.
Hi everybody. I don't understand what "is_check=lambda board: False" in the first line of the solution means. Am I not supposed to write a function def is_check(board) where board is a list and return a boolean ?
you write either a lambda or a regular function, it's totally up to you. If your question is actually "what a lambda is?"... I guess you shouldn't try code golf kata yet, then... ;o
ok ;) Thank you for the answer. Does "no newline" mean that I have to write the code in one single line ?
yes
OMG. So, it's impossible to use a regular function... I will first try the simple version ;)
Do that. This is code golf kata, which requires more knowledge and practise than normal katas. If you've never done golf katas, stay away from this one for now ;-)
Ok, thanks for the tip. Could you give me a link to a simple golf kata for me to begin ?
Try searching for "one line task" or "code golf". I don't really know any 'simple' golf katas :D Maybe something like this one.
Thanks :)
I solved the "regular" 5 kyu version in 70 lines... LOL ! We're far from a single line :(
Any chess players here?
Here is a question:
Consider such a board:
When the white pawn reaches the the very last line of the oposite side, it has a right to transform into any chess piece. By default it's a queen. So in the above case the king would automatically be in check.
So, does such a case have to be handled as well?
Nope, you are given a fixed board state so all that matters is how a piece can move from where it is right now.
Noted. Thanks.
This kata was brutal. I started from 390 chars and had to cut 110 from my solution. I almost gave up. I think is one of the hardest 3 kyu kata I did
Agreed. Wish I'd thought of dropping the obvious unnecessary keyword! I started at about 500 chars!
Which language did you try it in? I suppose that some are rather more difficult than others—but yes, it might well deserve a difficulty bump. I'm going to try it in Clojure, will probably never finish, but here goes anyway!
This comment has been hidden.
This comment has been hidden.
I think this was rushed out of beta. 10 completions from 300 user attempts is also ridicolous for 3 kyu.
I can provide some tests, but I guess I won't be able to achieve the update of the solution withint the char limit.
Are you saying the solution is wrong? On what test?
This comment has been hidden.
yours, I didn't check, but mine and most of the ones alike are, in the way they wouldn't handle some special cases. The problem isn't the ref solution but the cases generated by the tests, which aren't covering those edge cases
(EDIT: looking at yours, I believe it's correct: you used the trick I just thought about to handle those edge cases)
This comment has been hidden.
Would you consider this solved?
depends...? what about the update of the random tests? :o (maybe you did it?)
you need at least other examples, like those and their equivalent boards when filpping them left <-> right and/or top/bottom
tried and failed at 320.. any hints??
Language? In general you should probably come up with logically shortest algo and then try to refactor it to make use of most golfing tricks. Or reset and think about problem from completely other side.
This comment has been hidden.
You should mark this as spoiler ;) and you have the right idea, all you lack is optimizations.
?
'kay... one day, maybe... x)
what happened to
savoki
(user8751232)^ That. Why? I dunno.
Since no one had anything to say, approved.
You should use a specific length bound for each language. For example in Python, I have obtained a 220-character-long solution, which is far below initial requirements of 280 characters.
Unnamed even has 176 chars in Ruby.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
With the current rank assesments, it isn't even possible to approve it at 4 kyu, as in the rank options it's only 3, 2, and 1 kyu.
That's why it's probably best to not be hasty with approval and wait for more solutions.
or maybe it's appropriate...?
You should solve it ;P
I wish I could! :p
I changed my mind about the rank. I agree with @Torkel, specially that one-line task doesn't have to take only monotone solutions(1) and have very strict length limit(2). I'll approve this as 3kyu in couple hours unless someone comes up with a strong argument why it shouldn't be.
1) the shorter way, even if easier for experienced users, is probably more time consuming and prone to screw-ups (more time wasted) which should offset the difference in length
2) the longer way solutions should set the limit (+-5, grasping too hard for chars is not really that neccesary), so for now it should be fine for rb, py, js (don't know about kotlin or clojure but they are niche, so shouldn't be that bad)
Edit: The limit on ruby maybe ify considering you can assign variables as you go unlike python (no walrus operator yet).
Snake case is required in Python. Moreover your python solution contains a semicolon.
Semicolons are valid in python, though.
Yes but it is a kata requirement to not use semicolon
Fixed
Thanks
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
No semicolons makes it impossible to use for loops, is that on purpose?
For people who don't know chess, it might be nice to specify that pawns take forward diagonally.
I think
snake_case
is usually used in Ruby for methods.Fixed
Don't put HTML formatting in a code block.
:)
That was absolutely brutal. Excellent golf course.
Thanks, nice solution! Starting to think it might be a purple, considering no one else has been able to solve it yet.