Complete functional version for small input. The function RPS is clean. Further code arranging in the other functions is missing