blob: d81de5ee643eb08cb5ce07e4d344eb22ae0a8f7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
Challenge 1: "Create a script that accepts two strings, let us call it,
"stones" and "jewels". It should print the count of "alphabet" from the
string "stones" found in the string "jewels". For example, if your stones
is "chancellor" and "jewels" is "chocolate", then the script should print
"8". To keep it simple, only A-Z,a-z characters are acceptable. Also
make the comparison case sensitive."
My notes: Not very clearly defined, but to get 8 in the example, I infer
that it means "form a set from the first string (thus ignoring repeated
letters) and then count up how many occurrences of each letter in that set
in the second word". That's trivial, let's do it.
Challenge 2: "Create a script that prints mean angles of the given list
of angles in degrees. Please read
https://en.wikipedia.org/wiki/Mean_of_circular_quantities
that explains the formula in details with an example."
My notes: So, means of circular quantities as applied to angles, in short
meanangle = atan2( average(sin(ai)), average(cos(ai)) )
(where ai are the input angles a1..aN). Ok, that seems trivial.
|