np

Generate equation with the result value closest to the requested one, have speed problems

淺唱寂寞╮ 提交于 2021-02-06 02:03:19
问题 I am writing some quiz game and need computer to solve 1 game in the quiz if players fail to solve it. Given data : List of 6 numbers to use, for example 4, 8, 6, 2, 15, 50. Targeted value, where 0 < value < 1000, for example 590. Available operations are division, addition, multiplication and division. Parentheses can be used. Generate mathematical expression which evaluation is equal, or as close as possible, to the target value. For example for numbers given above, expression could be : (6

Generate equation with the result value closest to the requested one, have speed problems

微笑、不失礼 提交于 2021-02-06 02:02:01
问题 I am writing some quiz game and need computer to solve 1 game in the quiz if players fail to solve it. Given data : List of 6 numbers to use, for example 4, 8, 6, 2, 15, 50. Targeted value, where 0 < value < 1000, for example 590. Available operations are division, addition, multiplication and division. Parentheses can be used. Generate mathematical expression which evaluation is equal, or as close as possible, to the target value. For example for numbers given above, expression could be : (6

Generate equation with the result value closest to the requested one, have speed problems

为君一笑 提交于 2021-02-06 02:00:58
问题 I am writing some quiz game and need computer to solve 1 game in the quiz if players fail to solve it. Given data : List of 6 numbers to use, for example 4, 8, 6, 2, 15, 50. Targeted value, where 0 < value < 1000, for example 590. Available operations are division, addition, multiplication and division. Parentheses can be used. Generate mathematical expression which evaluation is equal, or as close as possible, to the target value. For example for numbers given above, expression could be : (6

Generate equation with the result value closest to the requested one, have speed problems

我的梦境 提交于 2021-02-06 02:00:54
问题 I am writing some quiz game and need computer to solve 1 game in the quiz if players fail to solve it. Given data : List of 6 numbers to use, for example 4, 8, 6, 2, 15, 50. Targeted value, where 0 < value < 1000, for example 590. Available operations are division, addition, multiplication and division. Parentheses can be used. Generate mathematical expression which evaluation is equal, or as close as possible, to the target value. For example for numbers given above, expression could be : (6

Generate equation with the result value closest to the requested one, have speed problems

蹲街弑〆低调 提交于 2021-02-06 02:00:46
问题 I am writing some quiz game and need computer to solve 1 game in the quiz if players fail to solve it. Given data : List of 6 numbers to use, for example 4, 8, 6, 2, 15, 50. Targeted value, where 0 < value < 1000, for example 590. Available operations are division, addition, multiplication and division. Parentheses can be used. Generate mathematical expression which evaluation is equal, or as close as possible, to the target value. For example for numbers given above, expression could be : (6

how do I construct np-reduction for this matching problem?

Deadly 提交于 2021-02-04 08:17:06
问题 I have a matching problem, which I think is np-hard: We need to arrange a dinner for a group of n people, some of the people are friends with eachother, some are not. We need to sit everyone at a table, but they should never sit with someone that they are not friends with. There are *k* tables K = r1+r2+···+rk=n. **Input** input is formatted as one first line k, then follow one line of k numbers, where each number represents a table and it's capacity. Then comes n lines of people, where we

Are all NP problems also NP-complete?

别等时光非礼了梦想. 提交于 2020-07-04 09:51:47
问题 The definition of NP-complete is A problem is NP-complete if it belongs to class NP all the other problems in NP polynomially transform to it So, if all other problems in NP transform to an NP-complete problem, then does that not also mean that all NP problems are also NP-complete? What is the point of classifying the two if they are the same? In other words, if we have an NP problem then through (2) this problem can transform into an NP-complete problem. Therefore, the NP problem is now NP

Given a collection of integers and threshold value T, divide the collection into as many groups as possible whose sum >= T

安稳与你 提交于 2020-05-12 07:56:07
问题 Given a collection of integers and threshold value T, divide the collection into as many groups as possible whose sum >= T. The remaining integers (whose sum < T, so another group cannot be formed) should be left outside of the groups. Constraints: length of the list <= 1,000 values and T <= 1,000,000 Is there an algorithm for this problem in polynomial time? For example given [25,25,25,50,50,50,10] and a threshold T = 70 it should return: [25,50] [25,50] [25,50] Remaining: [10] Selecting [25

Plot FFT as a set of sine waves in python?

笑着哭i 提交于 2020-03-02 19:13:25
问题 I saw someone do this in a presentation but I'm having a hard time reproducing what he was able to do. Here's a slide from his presentation: Pretty cool. He decomposed a dataset using FFT, then plotted the appropriate sine waves that the FFT specified. So in an effort to recreate what he did, I created a series of points that correspond to the combination of 2 sine waves: import matplotlib.pyplot as plt import numpy as np %matplotlib inline x = np.arange(0, 10, 0.01) x2 = np.arange(0, 20, 0

3-colouring of a graph (polynomial time)?

这一生的挚爱 提交于 2020-02-02 16:12:07
问题 Can we colour a graph in 3 colours in polynomial time? I read that colouring a graph with 2 colours is easy,but colouring a graph with 3 different colours(No two vertices have the same color) is np-hard.However,I wonder if there is a magic box that says 'yes' for 'A graph being 3-colourable in polynomial time?'.If it says 'yes' how would it solve it in polynomial time? Any Ideas ? 回答1: Add 3 new vertices to your graph called red/green/blue, each connected to the other 2 but nothing else. Then