5 kyu
2D Cellular Automata [Code Golf]
23Dr Gabo
Loading description...
Mathematics
Restricted
Algorithms
Cellular Automata
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.
Python 3.8 should be enabled.
.
This comment has been hidden.
Done! I'm going update the weird maze one
Interesting, my solution was 234 chars all along!
I lowered the char limit to 240, thanks for pointing it out :)
Might be interesting to reduce the execution time: it's a bit weird to wait 9s to get feedback for this kind of task. You should begin with building your own version of deepcopy: this module/function is just fucking slow... x/ That should divide by 2 the time of execution of the tests, already.
You would be surprised by how little deepcopy matters in these tests. I can reduce the number of big tests (half maybe?), which seem to be approx. 80-90% of the execution time. Do you think it's more convenient that way?
ah right, I forgot what actually was the task... XD Yes I guess it would be better. There is no point to use so much ressources here. As long as you can check that the algo is correct...
Seems reasonable. Now the execution time should be around 4 secs.
This comment has been hidden.
This comment has been hidden.
spoiler... ;o
do you wan't to forbid them or not, so? (I have the tool x) )
oops :S
No, I think it's fine like this. What's more, I would kinda encourage their use to see what happens. Only time will tell if I'm wrong!
Edit: how do you do it?
with a long and intricate stuff... ;p
There are some katas where I put it in the preloaded part => solve one of those then open a fork of your solution:
not hard enough... ;p I could go lower than this (and I'm bad ot golfing XD )
239 and I bet there is a lot of room yet
Maan you make me feel bad without effort xD
I'll consider lowering it later if more people think the same.
228225 ;)Well, that just depends on the rank who wanna achieve. For now, it's rather around 6, I guess.
I lowered it to 260. Maybe I'll try to lower it to around 250 (maybe a little bit more), but it seems rather okayish as it is to me.
I guess it depends on how mad I get at people for solving it too easily ;)
;)
can we mutate the input?
My solution does not mutate anything, but you can with no problem
'kay. Maybe add the info in the description?
Done!
Hi,
The description is missing stuff (maybe for "non mathematically oriented ppl"...? x) ).
Let's say the matrix is
and rules are:
[[1,1,1]]
. how do you apply it to the matric exactly?anything else???
When several rules, if I understood correctly, we just apply all of them at "the same place" to determine if the central bit is 0 or 1, right?
=> you have to give an example matching the actual task. Examples only for 1D may have introductory purpose, but no more ;p
The second way is the correct one if I understood you correctly.
given a matrix
and a rule
It will slide like this:
In short, rules are not rotated. I will make that clear in the description :) (also some examples for the 2D case)
Also, you are right about the application of multiple rules. If any of the rules give a 1 when centered at some position, then it will be a one.
ok, good. About the wrapping, it happens only on a line? (seems evident, but just to be sure) I mean, not this way:
errr... what is
steps
... ? xo The number of "one step shift"? Or the number of passes over the complete matrix? Seems rather evident it's the first (...??), but make it clearThe description says that we define a transformation as applying the rules to the whole matrix.
step
specifies how many times you have to transform the matrix, so it's the number of passes over the complete matrix.I'm sorry if that wasn't creal :S
Also, I modified the description to add an example of the 2D case. Take a look if you may to see if it's clear enough :)
Shouldn't the very first 2D example rather be this one??
Seems we don't care about the evoluitons of M in the current "step". That's not pretty clear either (but visible with the example... If I didn't mess up my brain in the meantime... x) )
Intuitively, yes, but the order does not matter at all with this algorithm. I find it more easy to understand if the first example is not wrapping around.
Also, on the second question. A step is done on the matrix without modifications (you can see the example, it does not change when sliding), so we do not care about the previous steps when doing a rule application.
You're right, it only happens on the same row/column.
.