0
I’m on a college job and it’s hard to solve... it’s like those wordlists that hackers use, but it’s for didactic study.
QT: Generates a file with all possible groupings using the concept of simple arrangements in which we have n arranged elements p to p, with n >= p. Before generating the file report an output telling how many arrangements and size the file has.
Ex:
Were generated x arrangements and the file size is y (bytes, MB, GB or TB). Continue, [S]im or [N]ão?
I don’t even know how to start, because how do I calculate the total bytes without even having created the file. Complicated. The way I thought was to calculate the total of arrangements that would give "so many" lines and on each line would have 7 bytes, if each row is 7 bytes, multiplied by the total possible arrangements.
Formula:
A(n! /(n-p)!)
Ex:
A(22!/(22-7)!) = A(22!/(15)!) = 859,541,760 million words arranged 7 to 7 of 22 elements
Now I take this result and multiply by 7 that would give the total bytes and I would convert to the other sizes. Now why did I multiply by 7? Because each character is worth 1 byte, apart from the accented characters and the arrangement of all lines are with 7 characters.
The same problem is this, calculating the file size.
Depending on the structure of your arrangement, it can be the size of your file, if your arrangement is in
string
, use thelen
to get the size, when writing to the file the size will be the same– Brumazzi DB
In the module
sys
has the method getsizeof() that allows you to get the size of an object in bytes, I believe this method can help you to get the size of an object that will be the content of a particular file before its creation.– gato