Skip to main content
Josiah's user avatar
Josiah's user avatar
Josiah's user avatar
Josiah
  • Member for 7 years, 7 months
  • Last seen this week
  • United Kingdom
awarded
awarded
awarded
awarded
awarded
awarded
answered
Loading…
Loading…
answered
Loading…
comment
A Text-Based Game
I don't have time for a full review right now, but wanted to mention one possible bug. You keep using the pattern of loot = random.randint(0, 2). That random call will get run once at class definition, which means that all your gnomes will have the same amount of loot as all other gnomes. If that isn't what you want, you'll need to move the randint call somewhere that gets run repeatedly, such as an __init__ method.
answered
Loading…
Loading…
comment
Optimising function to strip honorifics from names
If you want something like this in production, it may be worth exploring the re regular expressions module.
comment
Find all combinations of length 3 whose sum is divisible by a given number
In the same way, the number of combinations of length 3 is in an array of length 3 is n!/((n-3)!3!), or (n(n-1)(n-2))/6. Again this is cubic in n.
comment
Find all combinations of length 3 whose sum is divisible by a given number
@RichardNeumann, there are three loops implicit in this combinations call and it is O(n^3), even if each loop does not traverse the entire list and there is a scaling factor. For your intuition, combinations of size 2 loops i from start to end and j from i to end. It counts out a triangle number of tuples rather than a square number of them, but critically is still of quadratic order.
Loading…
comment
Membrane protein diffusion in different confinement models
Whelp. Seems I recommended a whole library you were already using, and just forgot to finish some of my sentences. But I'm glad you found it useful.
Loading…
Loading…
revised
Loading…
1
2 3 4 5
18