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
#2
Your program requires a lot of overhead because you are converting your string into lists of substrings unnecessarily, and also creating a dictionary that you don't need. Keep in mind that you don't need to store the values you are counting, you just need to count them and store that value. Also, don't forget that a string behaves like a list, in that you can iterate through it and use indexes with it.

With your current code, try your "BANANA" test case and have your subsConsonant() and subsVowels() functions print the length of the list they are returning. Notice anything about the length of the list returned by subsConsonant() and how it correlates to the player's scores?

I can think of one other hint to share, but it might make the solution too obvious. Let me know if you are still stuck.
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help - random number/letter guessing game juin22 1 3,286 Aug-16-2020, 06:36 AM
Last Post: DPaul
  Dynamically chosing number of players in a "game" nsadams87xx 5 4,394 Jul-17-2020, 02:00 PM
Last Post: deanhystad
  making a guessing number game blacklight 1 2,271 Jul-02-2020, 12:21 AM
Last Post: GOTO10
  Guess the number game jackthechampion 5 3,306 Mar-07-2020, 02:58 AM
Last Post: AKNL
  Asking for help in my code for a "Guess the number" game. Domz 5 3,986 Aug-14-2019, 12:35 PM
Last Post: perfringo
  Guess a number game Drone4four 4 5,452 Nov-16-2018, 03:56 AM
Last Post: Drone4four
  Strings inside other strings - substrings OmarSinno 2 3,766 Oct-06-2017, 09:58 AM
Last Post: gruntfutuk
  trying to get my random number guessing game to work! NEED HELP RaZrInSaNiTy 4 7,072 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