solved 24

but could use better algorythm