New answers tagged programming-challenge
1
vote
Accepted
Python Logic Gate Circuit Simulator
Note: In the future, you should probably post a snippet of your code that you have the most doubts about or that is typical of your code, then provide a link to the rest. All good though!
Overall, ...
1
vote
Efficient Solution for Finding Product of Largest Pair in Array
If you sort the input, then the larger the item, the bigger the index of the item will be.
So the largest two items would simply be the last two items.
And you can simply access them by using indexing:...
1
vote
Efficient Solution for Finding Product of Largest Pair in Array
You can almost halve the number of comparisons to expect for large uniform random input comparing to the runner-up first:
...
1
vote
Efficient Solution for Finding Product of Largest Pair in Array
You can simplify your code by using heapq.nlargest. Since heapq is written in C, with a Python fallback, the code is likely faster than pure Python. The docs say ...
2
votes
Accepted
Determine the chance a streak of 6 HEADs or 6 TAILS appear in 100 flips, repeated 10000 times
Logical
numberOfStreaks += (int(len(item)) // 6)
Does a streak of 12 H mean 2 streaks?
how often a streak of six ...
Top 50 recent answers are included
Related Tags
programming-challenge × 3309python × 995
algorithm × 654
java × 633
performance × 632
time-limit-exceeded × 497
c++ × 481
python-3.x × 435
beginner × 427
c# × 302
javascript × 287
strings × 211
primes × 180
c × 152
functional-programming × 114
array × 104
haskell × 97
python-2.x × 93
interview-questions × 92
dynamic-programming × 84
recursion × 78
object-oriented × 76
ruby × 76
palindrome × 73
combinatorics × 70