Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NB. wrap our data with a meaningless 0 index row for safety!
- dat=: 0,.|:0,.|:a$~2$%:#a
- NB. score a user row (count of invited users in row)
- sc=: 3 : '+/y{dat'
- NB. children of a user row (users they invited)
- ch=: 3 : 'I.y{dat'
- NB. recursively score a row, row + score of children (however deep)
- t1=: 3 : 0
- NB. if we have any children
- if. 0<scr"0 y
- NB. sum children scores plus 1 for the child itself
- do. +/1+t1"0 ch"0 y
- NB. if we don't have any children
- else. 0
- end.
- )
- NB. get our top 3 users
- t3=:(i.3){\:~,;t1"0 i.#dat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement