aboutsummaryrefslogtreecommitdiff
path: root/challenge-085/duncan-c-white/README
blob: 53a59c4fc84c0979c263bda8546e6993ce955f48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Task 1: "Triplet Sum

You are given an array of real numbers greater than zero.

Write a script to find if there exists a triplet (a,b,c) such that 1 <
a+b+c < 2. Print 1 if you succeed otherwise 0.

Example 1:

	Input: @R = (1.2, 0.4, 0.1, 2.5)
	Output: 1 as 1 < 1.2 + 0.4 + 0.1 < 2

Example 2:

	Input: @R = (0.2, 1.5, 0.9, 1.1)
	Output: 0

Example 3:

	Input: @R = (0.5, 1.1, 0.3, 0.7)
	Output: 1 as 1 < 0.5 + 1.1 + 0.3 < 2

My notes: simple, I think it means "pick any 3 elements a, b and c from the
array and determine if any a,b,c triple sums to between 1 and 2", although both
successful examples show 3 ADJACENT elements a, b and c...


Task 2: "Power of Two Integers

You are given a positive integer $N.

Write a script to find if it can be expressed as a ** b where a > 0 and
b > 1. Print 1 if you succeed otherwise 0.

Example 1:

Input: 8
Output: 1 as 8 = 2 ** 3

Example 2:

Input: 15
Output: 0

Example 3:

Input: 125
Output: 1 as 125 = 5 ** 3

My notes: clearly defined, not quite sure how to do it so.. let's brute force