MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply TodayThis Challenge is derived from GJam 2014 China Rational Number Tree.

The Goal is to determine the tree node if given [P,Q] or provide the [P,Q] if given a node. This is the small Challenge with a Max of 16 Tree levels. The large Challenge is 64 Tree levels.

Consider an infinite complete binary tree where the root node is 1/1 and the left and right childs of node P/Q are P/(P+Q) and (P+Q)/Q, respectively.

The Tree looks like:

1/1 ______|______ | | 1/2 2/1 ___|___ ___|___ | | | | 1/3 3/2 2/3 3/1

The nodes are 1/1, 1/2, 2/1, 1/3, 3/2, 2/3, 3/1,...

**Input:** [N] or [P,Q] where N is an integer node or [P,Q] are terms of a Node

**Output:** [P,Q] or [N] depends on Input type

**Examples:**

[Input] [Output] [2] [1 2] [1 2] [2] [5] [3 2] [3 2] [5]

**Contest Performance:** Best Delta Time of 14 minutes with 1193 out of 3058 completing in less than 3 hours.

15 correct solutions
7 incorrect solutions

Last solution submitted on Aug 26, 2015

1 player likes this problem