Hacker News new | past | comments | ask | show | jobs | submit login

while compact and looks elegant...

it is basically trying to group by 11 (divide by 2), if there no match (via backtracking) group by 111 (divide by 3) and so on

not very efficient by any stretch esp with string matches.




steps:

- it is turning the number into a string of 1s 3 => 111 4 => 1111 and so on

- then trying to simulate divisibility test by trying to find perfect groups of '11' to simulate division by 2 failing which (that is the backtracking part) and trying find perfect groups of '111' to simulate division by 3 and so on...

Clever but very inefficient




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: