Python Forum
Can someone help me optimize this game for large number of strings
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can someone help me optimize this game for large number of strings
#8
You are making progress, but the logic required for this problem is actually much simpler than you realize (and you are not alone, it is easy to overthink this one). Where it gets confusing is when you think of things like "N appears twice so it gets 2 points". You don't really need to parse it out that way, you just need to get the total number of substrings that start with consonants and the total that start with vowels. As long as you are getting the correct total count, you don't need to be concerned with how many times a given substring exists.

From your test case using "BANANA", you know that Stuart's score (count of substrings beginning with a consonant) is 12. Note that there are 6 substrings that begin with B (B, BA, BAN, BANA, BANAN, BANANA), 4 substrings that start with the first N (N, NA, NAN, NANA), and 2 that start with the final N (N, NA). That adds up to 12.
Reply


Messages In This Thread
RE: Can someone help me optimize this game for large number of strings - by GOTO10 - Jun-27-2020, 07:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help - random number/letter guessing game juin22 1 3,210 Aug-16-2020, 06:36 AM
Last Post: DPaul
  Dynamically chosing number of players in a "game" nsadams87xx 5 4,189 Jul-17-2020, 02:00 PM
Last Post: deanhystad
  making a guessing number game blacklight 1 2,210 Jul-02-2020, 12:21 AM
Last Post: GOTO10
  Guess the number game jackthechampion 5 3,206 Mar-07-2020, 02:58 AM
Last Post: AKNL
  Asking for help in my code for a "Guess the number" game. Domz 5 3,829 Aug-14-2019, 12:35 PM
Last Post: perfringo
  Guess a number game Drone4four 4 5,285 Nov-16-2018, 03:56 AM
Last Post: Drone4four
  Strings inside other strings - substrings OmarSinno 2 3,690 Oct-06-2017, 09:58 AM
Last Post: gruntfutuk
  trying to get my random number guessing game to work! NEED HELP RaZrInSaNiTy 4 6,906 Oct-06-2016, 12:49 AM
Last Post: tinabina22

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020