- Prepare
- C++
- Inheritance
- Magic Spells
- Discussions
Magic Spells
Magic Spells
+ 2 comments Hint to all that was like me, the generic spell is quite a challange. They are asking for "Longest Common Subsequence". Search and learn what the algorithm does!
For a long frustrating time, I thought the generic spell asked for how many common characters does the spell vs journal have. Hard challange indeed
+ 0 comments Can someone please explain to me what exactly they want you to do with generic spells? It says "subsequence of letters" which made me think they wanted the longest substring, but the example they give is not a substring of either string. So I assumed instead they wanted just the number of characters in string1 that are also in string2, but that's not passing the tests. So I revealed the test data it was using, and the journal entry contained every letter anyway, so I really don't understand what I'm being asked to do here.
+ 3 comments hotdog
if(dynamic_cast<Fireball*>(spell)) static_cast<Fireball*>(spell)->revealFirepower(); else if(dynamic_cast<Frostbite*>(spell)) static_cast<Frostbite*>(spell)->revealFrostpower(); else if(dynamic_cast<Thunderstorm*>(spell)) static_cast<Thunderstorm*>(spell)->revealThunderpower(); else if(dynamic_cast<Waterbolt*>(spell)) static_cast<Waterbolt*>(spell)->revealWaterpower(); else { string spellName = spell->revealScrollName(); string journalName = SpellJournal::read(); int lcs[spellName.length() + 1][journalName.length() + 1]; for(int i = 0; i < spellName.length() + 1; i++) lcs[i][0] = 0; for(int i = 0; i < journalName.length() + 1; i++) lcs[0][i] = 0; int c = 1, r = 1; for(r = 1; r < spellName.length() + 1; r++) { for(c = 1; c < journalName.length() + 1; c++) { if(spellName[r - 1] == journalName[c - 1]) lcs[r][c] = lcs[r - 1][c - 1] + 1; else lcs[r][c] = (lcs[r - 1][c] > lcs[r][c - 1]) ? lcs[r - 1][c] : lcs[r][c - 1]; } } cout << lcs[spellName.length()][journalName.length()] << endl; }
+ 1 comment Can someone provide me with a clear solution and explanation for this question? I find it a bit confusing
+ 2 comments Can please someone explain me about what is the expecting behaviour for the nongeneric spells?
Sort 104 Discussions, By:
Please Login in order to post a comment