Cody

Problem 1288. Balanced Ternary Numbers: Easy as |, |-, |o

Solution 210501

Submitted on 28 Feb 2013 by James
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%% d = 3; bt_correct = '|o'; bt = balanced_ternary(d); assert(isequal(bt,bt_correct))

``` btc = |o ```

2   Pass
%% d = 52; bt_correct = '|-o-|'; bt = balanced_ternary(d); assert(isequal(bt,bt_correct))

``` btc = |-o-| ```

3   Pass
%% d = 182; bt_correct = '|-|-|-'; bt = balanced_ternary(d); assert(isequal(bt,bt_correct))

``` btc = |-|-|- ```

4   Pass
%% d = 26; bt_correct = '|oo-'; bt = balanced_ternary(d); assert(isequal(bt,bt_correct))

``` btc = |oo- ```

5   Pass
%% d = -5; bt_correct = '-||'; bt = balanced_ternary(d); assert(isequal(bt,bt_correct))

``` btc = -|| ```

6   Pass
%% d = -164; bt_correct = '-|oo-|'; bt = balanced_ternary(d); assert(isequal(bt,bt_correct))

``` btc = -|oo-| ```

7   Pass
%% d = 512; bt_correct = '|-o|oo-'; bt = balanced_ternary(d); assert(isequal(bt,bt_correct))

``` btc = |-o|oo- ```