Oleksandr
i don't understand compare logic of 2 strings, when "spell' is "not found"
Mihail
i don't understand compare logic of 2 strings, when "spell' is "not found"
if you're working with 2 std::string's you can simply compare them with the == operator
Mihail
not sure what you're asking tho
Oleksandr
and i've got bool result, but i need to get int length of max... max what?
Oleksandr
just read task, if u have a time for it
Ludovic 'Archivist'
do not pay attention to the "dynamic_cast part" of the excrcise, everything is clear here
I like when people say to ignore the partial solution to their problem
Oleksandr
that task in "OOP part", but, i think author - stupid asshole
Oleksandr
course "oop part" of this task pretty easy, and he insert algo-task at the end
Oleksandr
why for?
Ludovic 'Archivist'
that task in "OOP part", but, i think author - stupid asshole
Nope, given the "Spell" class provided it is just OOP
Oleksandr
special for u
Oleksandr
there is no OOP in that part
Oleksandr
there is only counting the longest char seq from str2 that appear in str1
Oleksandr
or smth like that... but i don't understand what they want from me
Ludovic 'Archivist'
Was there not some std lexicographical_compare or something in the std?
Mihail
so you need to find AuaVae from the other two?
Mihail
but would that be useful?
Ludovic 'Archivist'
but would that be useful?
Dunno, it is midnight and I am strained
Oleksandr
for example, here is the input: AquaVitae 999 AruTaVae // AquaVitae is spell, which not found // so we need to print int on the stdin // this int represent the longest subseq from str2 (AruTaVae) in str1(AquaVitae)
Mihail
Dunno, it is midnight and I am strained
https://en.cppreference.com/w/cpp/algorithm/set_intersection seems more useful
Oleksandr
AquaVitae | AruTaVae A (+1) skip r u (+2) skip T a (+3) V (+4) a (+5) e (+6) answer: 6
Oleksandr
ай, нахуй
Mihail
ай, нахуй
well good that most won't understand it
Oleksandr
and i write this kind of code, and it really pass 2/8 tests
Oleksandr
okay... i cover all "cases" that displayed in task, but its still not enough
Oleksandr
so, i don't understand task fully
Oleksandr
and ask somebody to explain, what they want from me in this task
Mihail
something like this maybe https://godbolt.org/z/wzXTkF
Mihail
which uses std::set_intersection
Mihail
and then gets the size
Mihail
but it probably isn't very efficient to construct a common string
Mihail
can't think of anything better tho
Oleksandr
1) can't use algorithm header 2) ur code just find count of char that appear in both str at the same time, that is not right
Mihail
1) can't use algorithm header 2) ur code just find count of char that appear in both str at the same time, that is not right
1) then you'll have to implement those yourself 2) isn't that what you wanted?
Mihail
so just find the common characters?
Mihail
i think so
Oleksandr
the common characters in needed order
Oleksandr
u can't just sort them
Oleksandr
and there is an "offset", if u find char 'A' at the index 4, than next char u must try to find starting from index 5
Oleksandr
etc.
Oleksandr
stupid task for OOP section, as i said early
Oleksandr
and my nested loop really do this
Mihail
like having one iterate over the first string and the nested searches for the character starting from that index
Oleksandr
BUT i pass only 2/8 tests in this site
Oleksandr
i think, that don't understand all the task
Mihail
BUT i pass only 2/8 tests in this site
looking at your "offset" rule when you find something in the nested loop you must continue the first for from the index that you found the character in the second string in
Oleksandr
str.find(char, offset);
Mihail
if i understand it correctly that is
Mihail
str.find(char, offset);
yes and then you must use that new position when you do the next find
Mihail
well run the code locally and write yourself some test cases to see where it's going wrong
Anonymous
Is the rule of having a single entry and a single exit point mandatory?
Anonymous
In C language more specifically.
Oleksandr
if i understand it correctly that is
and here is what i want somebody who know english better, who will read this shitty task, and explain me in human-readable form, what they want
Mihail
Is the rule of having a single entry and a single exit point mandatory?
single entry - yes, there'll always be a single function your os calls when your program has to be started
Mihail
likely _start
Mihail
not sure what you mean by exit point
Oleksandr
well run the code locally and write yourself some test cases to see where it's going wrong
in form "how i understand this task" my code works right
Mihail
in form "how i understand this task" my code works right
i mean i didn't understand it that well either
Mihail
so yeah can't help there
Anonymous
not sure what you mean by exit point
The return statement. What if I want to have multiple return statements in one routine? Should that routine be refactored to have only one return statement always?
Anonymous
Assuming I am writing functions in pure C.
Mihail
The return statement. What if I want to have multiple return statements in one routine? Should that routine be refactored to have only one return statement always?
well once you return from main it's over you don't have any control after that unless you spawned another process which isn't a child of the original. then it'll get to live
Mihail
but that's OS-specific
Mihail
you can have as many return statements as you want
Mihail
obviously returning from functions as much as you want
Oleksandr
just return the same type as in function prototype))))
Anonymous
well once you return from main it's over you don't have any control after that unless you spawned another process which isn't a child of the original. then it'll get to live
Thank you. I was wondering, because I've heard about the rule of one return statement per function, tried researching it on Stack Overflow. I've red different opinions and people seem to not reach a consensus on the practise.
Mihail
but you can have as many as you want
Oleksandr
so, return always is the return, end of function in any scenario
Oleksandr
i mean i didn't understand it that well either
https://en.wikipedia.org/wiki/Longest_common_subsequence_problem
Oleksandr
here is what that assholes want