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:
In the case, when output A invalid the error is Divisor is not wich was expected expected:<X> but was:<Y>
In the case, when output B invalid the error is 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:
In 75% Java solution hits the Too slow program timeout, which I don't think could be done faster then O(iterations)
Sample tests would be very helpful
The original GCD algorithm mentioned in the description has the 'a-b swap' step which gives a false impression that A and B order matters. Current tests don't count this. If that's expected, I'd add the note to the description. Otherwise, fix the tests to set the order.
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:
def duplicate(n):
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:
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 :)
@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.
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
anditerations
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
timeout, which I don't think could be done faster then O(iterations)A little typo in the description:
.. 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:
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:
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 :)
Hi Giacomo,
Got it, thank you!
So is:
lambda s:
essentially the same as
def(s):
Thank you again!
Josh
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.
Thank you!
Josh
'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.
Loading more items...