Hi I don't remember how but I got it done, one of my favorites btw (Y)
I spent the entire afternoon drawing DFA diagrams, and finally made it, but my regex is slightly longer than this. Is this also derived from a DFA or there is some other way to resolve this problem? It's the first time I see this kind of problem, ad I'd like to learn more about this subject :)
In my opinion, the assertion messages are quite confusing as divisor and iterations are input arguments:
Divisor is not wich was expected expected:<X> but was:<Y>
Number of iterations doesn't match expected:<X> but was:<Y>
I'd expect to see the error messages addressing output parameters instead.
Also, here is a few suggestions for the Java translation:
Too slow program
A little typo in the description: .. divisor of w[H]ich will be ..
.. divisor of w[H]ich will be ..
And by anonymous, it means you can define functions without naming it, which can be really useful sometimes.
An example of situation that anonymous functions are useful:
You want to duplicate every digit of an array, to do that you write the following code:
return 2 * n
arr = [1,2,3,4]
duplicated_arr = map(duplicate, arr) # the map function applies a given function on every element of the second argument.
It works, but you may have defined a function to just calculate this duplicated array, and problably you are not going to call this function anymore.
Instead, you could have defined the function anonymously:
arr = [1,2,3,4]
duplicated_arr = map(lambda x: 2*x, arr)
Doesn't this run into problems if a string longer than the tape length is passed in?
This is clever but definitely not best practice
This comment is hidden because it contains spoiler information about the solution
You can only do simple operations of one line; I guess the extensive docs of the version of Python you prefer (3, I guess?) will help you much more than me :)
Got it, thank you!
essentially the same as
Thank you again!
P.S. Can you elaborate what you mean here with limited and anonymous?
It is a (limited) way to define anonymous functions in Python.
can you please advise me what the "lambda s" is doing here? Specifically how it's helping remove the characters
I'm new to this.
'alr approved some time ago'
This is not how you write code
@B1ts Thank you so much for String.prototype.map = Array.prototype.map!
I've always been frustrated that strings weren't iterable, didn't know it was that easy to do.
String.prototype.map = Array.prototype.map