I am creating a simple program to see which combination of letters generates the most possible words for the NY Times Spelling Bee puzzle. What I have so far is a text file containing 80,000+ words and the below code which naively selects a required char and then generates a random combination of 6 characters. I then compile my pattern
Tag: algorithm
Find the highest, second highest, and lowest of three random generated numbers without using conditional statements
As a 1st year college IT student, I have a Java assignment where I must display three random generated numbers and order them highest, second highest, lowest. The challenge given by our professor is to not use any conditional statements or arrays. Here is the code: The problem I am facing is that I am struggling to get the “in-between”
Binary search on a sorted list of E(startTime,endTime) to find all E’s matched by a given time range (t1,t2)
I have Event objects as follows, They are sorted by startTime ASC, Events can overlap in any way. I need to obtain a List of all Events matching (incl. partially) a particular range t1,t2 (also ints for minutes since midnight). I don’t want to go through the whole list and check e.getStartTime() <= t1 && e.getEndTime() >= t2. Since the
Finding path through DAG with a total path cost equal or as close as possible to some value
I am working on a problem that I have generalised to what I have described in the title. Essentially I have a DAG that will look something like this: (I know it doesn’t matter what the DAG looks like I just thought it might show where I am at). I’ve drawn the vertex values as the edge distance (or cost)
Is there an O(n) way to find all indices of a value in an array? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 months ago. Improve this question Requirement find all indices in new int[]{2, 1, 3, 1, 4, 2, 1, 3} The time complexity is within O(n)
All array combinations with zero in a loop
The following array is given I now want to loop to output all combinations of these numbers with 0. Each number can occur alone or with any other numbers in the array (the rest should be 0). The original position of the numbers should be maintained when they are included in a combination. The numbers of the original array should
Algorithm to extract combinations of array
I’m stuck with the problem to find possible combinations in an array. Currently, i solving this problem using Java Programming language. Here is the example: And here is the output that i want, so i can solve the fundamental issues: The purpose is to generate combinations with sorted conditions as pairs of array like that. How to solve this? I
what’s the growth order of “find a peak” algorithm
hello i need to apply an algorithm similar to this but the problem is that i need the complexity to be O(logn). the complexity of the code below is said to be O(logn) but from what i understand a recursive method has the growth order of O(n). so the question is what is the growth order of the code below.
Does the number generated by this function obey uniform distribution ? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. This post was edited and submitted for review last year and failed to reopen the post: Original close reason(s) were not resolved Improve this question I have implemented a
How to count the number of comparisons in this algorithm?
I’m learning to analyze the performance of an algorithm. Here, I have created an algorithm to count the number of capital letters in a sentence. But I don’t understand how to calculate comparisons in an algorithm. Here is my algorithm: And this is the pseudocode: Can someone help me? Answer The number of comparisons made is the same as the