brute-force

Generating the power set of a list

前提是你 提交于 2019-12-19 04:14:37
问题 I have to write a brute-force implementation of the knapsack problem. Here's the pseudocode: computeMaxProfit(weight_capacity) max_profit = 0 S = {} // Each element of S is a weight-profit pair. while true if the sum of the weights in S <= weight_capacity if the sum of the profits in S > max_profit update max_profit if S contains all items // Then there is no next subset to generate return max generate the next subset S While the algorithm is fairly easy to implement, I haven't the slightest

Solving crosswords

落爺英雄遲暮 提交于 2019-12-18 11:56:33
问题 I have a crossword puzzle and a list of words which can be used to solve it (words can be placed multiple times or not even once ). There is always a solution for the given crossword and word list. I searched for clues on how to solve this problem and found out that it is NP-Complete. My maximal crossword size is 250 by 250, the maximal length of the list (amount of words which can be used to solve it) is 200. My goal is to solve crosswords of this size by brute force/backtracking, which

Brute Force Algorithm w/Java Passing String Error

一世执手 提交于 2019-12-18 09:26:40
问题 I think this may be a very simple solution but I am not too sure. I am trying to create an array of characters, sort through them by incrementing a particular index of the array and throwing them into a string at the end. I have accomplished this, (verified via printing the result out to the console. "aaaaaaaa" to "aaaaaaab" and so on. However, my new version of the code sorts through ASCII Values 33 - 126. '!' to '~' Now, the one thing I am trying to do is call that string in the main method

What is the best method to prevent a brute force attack?

ぃ、小莉子 提交于 2019-12-17 15:34:19
问题 I have my login page and of course I want to prevent brute force attacks and cause less delay for the users when they are logging in. Currently, you type in your username and password to log in. I am considering implementing a reCAPTCHA. However, this shows on login after 3 failed attempts. My question is: What do you base the attempt on. IP addresses? It can always be hidden... username? What if they're trying a user that doesn't exist? What would be the best method to count the failed login

Total sum from a set (logic)

人走茶凉 提交于 2019-12-17 13:40:12
问题 I have a logic problem for an iOS app but I don't want to solve it using brute-force. I have a set of integers, the values are not unique: [3,4,1,7,1,2,5,6,3,4........] How can I get a subset from it with these 3 conditions: I can only pick a defined amount of values. The sum of the picked elements are equal to a value. The selection must be random, so if there's more than one solution to the value, it will not always return the same. Thanks in advance! 回答1: This is the subset sum problem, it

How long to brute force a salted SHA-512 hash? (salt provided)

两盒软妹~` 提交于 2019-12-17 05:36:17
问题 Here is an algorithm in Java: public String getHash(String password, String salt) throws Exception { String input = password + salt; MessageDigest md = MessageDigest.getInstance(SHA-512); byte[] out = md.digest(input.getBytes()); return HexEncoder.toHex(out); } Assume the salt is known. I want to know the time to brute force for when the password is a dictionary word and also when it is not a dictionary word. 回答1: In your case, breaking the hash algorithm is equivalent to finding a collision

Can salt prevent dictionary or brute force attacks?

淺唱寂寞╮ 提交于 2019-12-14 03:56:20
问题 I just read an article. And it's said: So I’m not saying salts are without purpose, I’m saying that they don’t prevent dictionary or brute force attacks (which they don’t). If you have a database dump, with hashed passwords and salts, you can start brute force only if you know crypt algorithm. If you use open source, it can be a problem. But if you change algorithm a little, it's not a problem, until somebody know it. Am I right? 回答1: Troy Hunt recently wrote an excellent article, Our

C++ Error: 'no match for operator<…'

房东的猫 提交于 2019-12-13 11:18:32
问题 I have been attempting to create a password generator. The program is supposed to take input, and put out every possible combo of characters (brute force without the force). I am encountering this error: error: no match for 'operator<=' in 'i <= pear' I have no idea what to do. However, here is the code. Please let me know if I also messed up on anything else, but the error described is the main problem right now: #include <iostream> #include <string> using namespace std; void generate() {

Difference between two products nearest to zero: non brute-force solution?

帅比萌擦擦* 提交于 2019-12-12 08:19:45
问题 In a science museum in Norway I came across the following mathematical game: The goal is to place the 10 digits from 0 to 9 such that the difference between the two products is nearest to zero. (The 246 is the current lowest score). Back home I wrote the following brute-force code: import time from itertools import permutations def form_number(x, y, z, a, b): # not explicitly stated, but presume that leading zeroes are not allowed if x == 0 or a == 0: return 0 return ((100 * x) + (10 * y) + z

Maximum subarray problem brute force complexity

有些话、适合烂在心里 提交于 2019-12-12 06:50:48
问题 What is the runtime/memory complexity of the Maximum subarray problem using brute force? Can they be optimized more? Especially the memory complexity? Thanks, 回答1: Brute force is Omega(n^2). Using Divide and conquer you can do it with Theta(n lg n) complexity. Further details are available in many books such as Introduction to Algorithms, or in various resources on the Web, such as this lecture. 回答2: As suggested in this answer you can use Kadane's algorithm which has O(n) complexity. An