There are a **n** balls numbered from 0 to **n-1** (0,1,2,3,etc). Most of them have the same weight, but one is heavier. Your task is to find it.
Your function will receive two arguments - a `scales` object, and a ball count. The `scales` object has only one method:
```python
    get_weight(left, right)
```
where `left` and `right` are arrays of numbers of balls to put on left and right pan respectively.
If the method returns `-1` - left pan is heavier
If the method returns `1` - right pan is heavier
If the method returns `0` - both pans weigh the same
So what makes this the "ubermaster" version of this kata? First, it's not restricted to 8 balls as in the previous versions - your solution has to work for 8-500 balls. 
Second, you can't use the scale any more than mathematically necessary. Here's a chart:
    ball count | uses
    -----------------
           0-9 |    2
         10-27 |    3
         28-81 |    4
        82-243 |    5
       244-500 |    6
Too hard? Try lower levels by [tiriana](http://www.codewars.com/users/tiriana):
* [novice](http://www.codewars.com/kata/544047f0cf362503e000036e)
* [conqueror](http://www.codewars.com/kata/54404a06cf36258b08000364)
* [master](http://www.codewars.com/kata/find-heavy-ball-level-master)
from math import log
def find_ball(scales, ball_count):
    count=2 if ball_count <=9 else int(log(ball_count, 3))+1 if str(log(ball_count, 3))[-2:]!=".0" else int(log(ball_count, 3))
    res=[i for i in range(ball_count)]    
    for i in range(count):
        if len(res)<=2: break
        flag=scales.get_weight(res[:(len(res)+1)//3], res[(len(res))-(len(res)+1)//3:])
        if flag==-1: 
            res=res[:(len(res)+1)//3] 
        elif flag==1:
            res=res[(len(res))-(len(res)+1)//3:]
        elif flag==0:
            res=res[(len(res)+1)//3:(len(res))-(len(res)+1)//3] 
    if len(res)==1: return res[0]
    return res[0] if scales.get_weight(res[:1], res[1:])==-1 else res[1]
from math import log
def find_ball(scales, ball_count):
    count=2 if ball_count <=9 else int(log(ball_count, 3))+1 if str(log(ball_count, 3))[-2:]!=".0" else int(log(ball_count, 3))
    res=[i for i in range(ball_count)]    
    for i in range(count):
        if len(res)<=2: break
        flag=scales.get_weight(res[:(len(res)+1)//3], res[(len(res))-(len(res)+1)//3:])
        if flag==-1: 
            res=res[:(len(res)+1)//3] 
        elif flag==1:
            res=res[(len(res))-(len(res)+1)//3:]
        elif flag==0:
            res=res[(len(res)+1)//3:(len(res))-(len(res)+1)//3] 
    if len(res)==1: return res[0]
    return res[0] if scales.get_weight(res[:1], res[1:])==-1 else res[1]