Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm trying to write a python program that allows a user to input as many positive integers as they want. When the user inputs a positive or negative integer, the program generates a list of the inputted numbers that is sorted and also generates an average of the list inputted by the user.
Someone please help. I need to know this by this evening.
We don't do your homework here, but without divulging a complete solution, think about writing a loop to query the user for integers and add them to a Python list. You can make use of the sorted() and sort() functions in Python to sort your data. Averaging values in a list is trivial and can be easily found online or with basic programming knowledge (sum the values in the list and divide that total by the length of the list). Also beware of integer division depending on your version of Python.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Hi all I am trying to create a random pairs of the specific number of mines in my minessweeper game.
so I need to make method that takes a mines number, (width,hight) and returns a list of random positions [(x,y)]
https://www.fpcomplete.com/school/starting-with-haskell/libraries-and-frameworks/randoms
This should help. Basically just use the System.Random module (https://hackage.haskell.org/package/random-1.1/docs/System-Random.html)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to solve the following problem:
Give a linear-time algorithm to determine if a text T is a cyclic rotation of another string T'. For example, arc and car are cyclic rotations of each other.
I have no idea where to start. How can I solve this problem?
As a hint: if x and y have the same length, then x is a cyclic rotation of y iff x is a substring of yy. Try proving this and using this as the basis for your algorithm.
Hope this helps!
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Given a set of 10 symbols and a set of strings(at max 100) of length at max 20 each consisting of these symbols, find the maximum length string which can be made from these symbols that doesn't have any of the given strings as its sub-string. In case, if we can have infinite long string satisfying the property, print -1.
Besides brute force algorithm which will go exponential in time, I am not able to get any solution for this.
Any hint to approach this problem will be thankful.
Given a set of strings that need to be matched, my immediate reaction is to use http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm to create a matcher. This matcher is a finite state machine that accepts one character at a time and tells you which state you end up in next, given that character.
So I think you can reduce the problem to accepting a directed graph and a starting point and finding the longest route through that graph that does not go through the nodes that correspond to pattern matches - which I think we can simply delete from the graph. This is covered in http://en.wikipedia.org/wiki/Longest_path. Constructing this graph is also linear so the whole thing seems to be O(n)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a hash of result messages. Each message has 4-5 different parameters. I want to match parameter values with the values stored in an excel sheet. If they match its pass or fail
Can you help me how to read from an excel sheet and match it line by line with my current message in hash.
The best way to read from an Excel file is using a CPAN module, like Spreadsheet::XLSX
If you are using MS Excel 2003 or earlier, you can use - ParseExcel
If you are using excel 2007 or higher (xlsx), then Spreadsheet::XLSX does the job.
If you want something very quick and simple try - Simple Its an easy to use wrapper around ParseExcel.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How do I find if a string contains a contiguous palindromic sequence ? I could try the naive solution in O(n^2) time where n is the string size , but any efficient algos to it ?
Well looking for just any palindrome isn't particularly interesting since every one character string is a palindrome. If you are looking for the longest palindrome you may be interested in Manacher's Algorithm.
A good description of the algorithm can be found here.
This is a quite common problem, and has ample results on google:
http://en.wikipedia.org/wiki/Longest_palindromic_substring
Rather than using Manacher's Algorithm you should use one of the parallel algorithms.
duplicate of : how to find longest palindromic subsequence?