Password Algorithm [closed] - algorithm

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
Could anyone tell me what type of Algotithm/Hash Function the following passwords use?
password: scrambled text
hhhhhhhhhhhhhhh : .!_-*/P_.!_-*/P
iiiiiiiiiiiiiii : / ^,+.Q^/ ^,+.Q
jjjjjjjjjjjjjjj : ,#]/(-R],#]/(-R
kkkkkkkkkkkkkkk : -"\.),S\-"\.),S
lllllllllllllll : *%[).+T[*%[).+T

It just looks like
char[i] = someMap[i%6, char[i%6]]
and the someMap[i] submaps are sequentially taken from ascii.
You don't have to guess the exact formula to reproduce it : a char of ascii code c at index i%6 always give the same char, so, with 127 tests (or more if you want to handle more chars), you can build your own map of dimension 127 x 6.
Note that it's impossible with your small test data to be sure there is no cumulative function in which a permutation could be function of the precedent char.

Related

Sort code in Prolog [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I'm writing a program in prolog and need some help. This could probably be considered a homework question.
I have two sort algorithms written and working. My goal is to pass in a list, and if it is greateror equal to than length 5, use sort method 1. if it's less than 5, use sort method 2. The sort methods both return a sorted list, and the main method that they are used in should return the sorted list.
here's the main method that I'm working with:
%Main method to run program
main(List, Result) :-
size(List, N),
( N => 5;
sort1(List, X),
sort2(List, X)).
Every time I try to run this, though, I get an error:
?- main([1,5,1,4,2,6,1]).
ERROR: Undefined procedure: main/1
ERROR: However, there are definitions for:
ERROR: main/2
false.
I'm not sure what this error means. Could anyone help me please?
You must correct the syntax. From your description:
main(List, Result) :-
length(List, N),
( N >= 5
-> sort1(List, Result)
; sort2(List, Result)
).

How to decrypt this transposition cipher? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
My problem is that I am trying to decrypt following cipher text:
AWGNEYDTBSREAHGIDEIEEIHKIWABHPRCROIWSSBHTE
OCSNASLAIGTTOTYIOBNANNOOCHENEHSADUAIEOSNTH
TEOOAWUTOVTISNTVIFIHSNADVOGOREAPTBETSIT
DCSNASAAHOOULITUREICBNOERSNETTNOITTNTSDEOO
RERNINTOVTINTEFKGITPRCROEEIGREIGREHKFN
HOCWHPDTOSREGTOUREINDIUATHCHIEOSN
I know that it is English language. I know that it was encrypted only once by substitution, monoalphabetic or transposition.
I checked the Index of Coincidence and I received: 0.06833754056978002
I also checked frequency of letter and I received:
T 11.02, E 10.59, O 10.16, I 9.74, N 8.47, S 6.77, A 6.35, R 5.93, H 5.93, G 3.38, D 3.38, C 3.38, U 2.54, B 2.54, W 2.11, V 1.69, P 1.69, K 1.27, F 1.27, Y 0.84, L 0.84.
So I claim that it is transposition cipher. Am I right?
I checked all combinations of Rail Fence Transposition. I did not receive something sensible.
I checked all combinations of Columnar Transposition without changing order. I did not receive something sensible.
I checked a few combinations of Columnar Transposition with changing order. I did not receive something sensible.
Do you have idea how I can resolve this interesting task?

Regex to ristrict to accept maximum 14 digits [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Last time I was asked for checking string for minimum 8 digits. And I got following regex:
/^(?=(.*\d){8,})[\d\(\)\s+-]{8,}$/
You can see the question here: Checking string with minimum 8 digits using regex
Now I want to restrict string to accept maximum 14 digits in same regex. And I tried this:
/^(?=(.*\d){8,14})[\d\(\)\s+-]{8,}$/
No luck. Please anyone help me in fixing this.
UPDATE
After getting 2 down votes I thought better to write my own. I constructed regex using previous regex. Following regex works for me:
/^(?=(.*\d){8})(?!(.*\d){15})[\d\(\)\s+-]{8,}$/
By your request, the regex should be as simple as:
/^\d{8,14}$/
From your answer, and your other question, it seems like you are encoding a whole bunch of different rules into one increasingly complicated regex:
the string must be at least 12 chars long
it can only contain digits, parentheses, + and - signs, and spaces
there must be between 8 and 14 digits
While it's possible to do this with a regex, is it worthwhile? I'd argue that such a complicated regex is impossible to read, and therefore difficult to maintain.
If you split up the different criteria, it'll be much clearer.
string.length >= 12
string =~ /^[\d()+-\s]+$/ - note that by using square brackets to create a character class, you don't need to escape things, which also makes it much simpler.
(8..14).include?(string.count("0-9")) - check out the docs for String#count
So, altogether,
def valid?(string)
string.length >= 12 &&
string =~ /^[\d()+-\s]+$/ &&
(8..14).include?(string.count("0-9"))
end
It's a bit longer but it's a heck of a lot more understandable.
Try:
/^(?=(.*\d){8,14}(?!.*\d))[\d\(\)\s+-]{8,}$/
If I got the placement of the negative look ahead right I should fail to match a strimg with more than 14 digits.
Try also adding the 14 after the second instance of "8," if the previous regex achieved what you wanted - but it really is more complex than just 8-14 digits!

Matlab code optimization [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
f = #(w) test(w, phis, t, r_coeff);
function test(w, phis, t, r_coeff)
M = size(phis, 2);
expt = exp(-t .* (phis * w'));
coeff = expt .* t .^ 2 ./ (1 + expt) .^ 2;
averaging_coef = 1.0 / M; % mean replace
G = bsxfun(#times, phis', coeff' * averaging_coef) * phis + 2 * r_coeff * eye(M);
end
w - size is (1xM)
phis - size is (NxM)
t - size is (Nx1)
r_coeff is const
Help me please to optimize this piece of code, because function f runs a thousand times and N is around 300-800, M have mostly the same size. When I'm doing this * phis performance goes down.
As you can see it depends only on w - which I don't know.
It already is fairly well "optimized". Just because you want it to run faster does not make that possible.
You can buy/find/borrow/lease a faster/bigger computer. You can choose to solve smaller problems. You can just let it run overnight. Or you can change your problem to be something simpler and approximate, that runs more quickly.
This is what happens in research problems. They expand to the limits of your capability and just a bit more, because solving something easy is not worth a paper or a thesis. Computers make it easy to gather much data too, so problems get surprisingly large very quickly.
A special, rare skill in mathematics and modeling is knowing how to simplify your problem, deleting terms that are not truly important, while retaining the same basic behavior that you wish to study. This often involves linear approximations to nonlinear terms.

What is the difference between loop and iteration? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
What kinds of data structure are used to implement loop and iteration?
Loop refers to the code...
iteration refers to the process in which the content of loop is executed once..
so 1 iteration refers to 1 time execution of loop..
so basically one loop can undergo many iterations..
loop is used for fixed no. of element or certain condition occurs while iterator is used for itearing element dynamically that have different no. of elements at runtime
Only such of kind 1.
Some have tried using data structures of kind 42 for this purpose, but failed miserably.
Iteration is simply the number of time/times a loop can be executed, while loop is the code which generate or causes expressions to be iterated iteration when the loop is executing.
An example of lines of code in c++:
for(i=1; i<=10; i++)
{
cout<<"this is printed 10 times";
}
The above code is a for_loop in which the execution of the statement "this is printed 10 times" will be iterated/repeated 10 times.

Resources