computer-science

How to use the user’s input in an equation in python

How to use the user’s input in an equation in python Question: I’m new to comp sci and really need your help! My assignment is to code for a dessert shop. We had to create two functions, one to get the cost of a cake and the other to get the order of the client …

Total answers: 3

Distances between same numbers in list using single for loop

Distances between same numbers in list using single for loop Question: I have an assignment to get distances of every occurrence of same number in string and its time complexity should be O(n) so it shouldn’t use nested for loops. For example if my string contains "100101" and I need to get distances between ones …

Total answers: 3

How to speed up Sieve of Eratosthenes python list generator

How to speed up Sieve of Eratosthenes python list generator Question: My problem comes directly from the CS circles site. It’s the last problem on the bottom of this page called ‘Primed for Takeoff’. The basic rundown is they want a list of 1,000,001 length, where the index of each item is True if the …

Total answers: 3