You might already be familiar with the game: Basketball FRVR in facebook. There are two types of score you can make:

• A virgin-shot:(we call it so in our country :D) When the ball enters the basket without touching the rim or
• A stale shot: When the ball enters the basket, but after touching the rim.

The game is over once you miss a shot. Stale shot always scores 2 points.The first in a run of consecutive virgin-shots scores 3 points, the second scores 6 points, and subsequent ones score 9 points each.

For example,

Hits             Total score

S-V-V-V          2+3+6+9 = 20
S-V-V-V-V        2+3+6+9+9 = 29 (see how added score for consecutive virgin-
shots
saturates at the 5th hit)
S-V-S-V-V-S-V    2+3+2+3+6+2+3= 21


Using simple mathematics, it can easily be proven that any score greater than 1 n>1 can be scored in the game

# The Challenge

For any given number 1<n<100, output all the possible ways to score n.

# Rules:

• You can either write a complete program or function(s), snippets however are not acceptable.
• Hard-coding the output or loading from memory/other programs/website is strictly prohibited, you must compute the output in real-time.
• The output must be a well-separated collection of string of Ss and Vs. For eg: ['SVS','SSV','VSS'] or {'SVS','SSV','VSS'}.
• It is encouraged to, but the collection need not be sorted or contain only unique elements. Brownie points if you output sorted and unique collection of strings.

# Winning condition:

• This is so the shortest code in bytes wins.

# Input/Output (Test-cases)

2: {'S'}
3: {'V'}
4: {'SS'}
12: {'SSSSSS', 'VSSVS', 'VSVSS', 'VSSSV', 'SSVSV', 'SVSVS', 'SVSSV'}
16: {'SSSVSVS', 'SSSVSSV', 'VSSSSSV', 'SSVSSVS', 'SVVSV', 'VSSSSVS', 'SVSVV', 'SVSSSSV', 'VVSSV', 'VSVVS', 'SVSVSSS', 'SVSSSVS', 'VSSVSSS', 'SSVSSSV', 'SSSSSSSS', 'VVSVS', 'VSSSVSS', 'SVSSVSS', 'VSVSSSS', 'SSSSVSV', 'SSVSVSS', 'VSSVV'}


Thanks to Peter Taylor for improving this question

• In case anyone cares, as an American, I always called rimless (and backboardless) shots "swishes" (and Wikipedia backs me up here: Swish, a basketball shot that goes through the basket without touching the rim or backboard) – Stephen Jul 5 '17 at 14:43
• I'm mostly just curious where they call them 'virgin shots'... I'm afraid to look it up behind my company's firewall xD – bendl Jul 5 '17 at 14:49
• @bendl Nepal or Npl when censored. xD – officialaimm Jul 5 '17 at 15:04
• Very nice question—not hard, but definitely not trivial, and allows for different approaches :) – Greg Martin Jul 5 '17 at 17:17
• I think 28 should be 29 in the second test case. – Julian Wolf Jul 5 '17 at 17:34

# Jelly, 30 bytes

o2,5ṁo8‘
Hṗ@€⁾VSẎðOḂŒgÇ€FS=ðÐf


A monadic link returning a list of the strings (lists of characters).

Try it online! - The footer calls the link and separates the entries by newlines since a full program's implicit output would smash them together.

### How?

o2,5ṁo8‘ - Link 1, helper to form shot scores: list of shots grouped by type (S=1 and V=0)
-                                e.g. [[1,1],[0,0,0,0,0],[1,1],[0],[1,1]]
2,5     - 2 paired with 5 = [2,5]
o        - logical or (vectorises)             [[1,1],[2,5,0,0,0],[1,1],[2,5],[1,1]]
ṁ    - mould like the input                [[1,1],[2,5,0,0,0],[1,1],[2],[1,1]]
o8  - logical or with 8                   [[1,1],[2,5,8,8,8],[1,1],[2],[1,1]]
‘ - increment                           [[2,2],[3,6,9,9,9],[2,2],[3],[2,2]]

Hṗ@€⁾VSẎðOḂŒgÇ€FS=ðÐf - Link: number, total score, n
H                     - halve n
⁾VS               - literal ['V','S']
ṗ@€                  - Cartesian power with swapped @rguments for €ach
-   ...i.e. for each in [1,2,...,floor(half n)]
-   yielding all strings of Vs and Ss from length 1 to floor(half n)
Ẏ              - tighten (from a list of lists of lists to a list of lists)
ð         ðÐf - filter keep those entries for which this yields a truthy value:
O            -   cast to ordinals (S->83, V->86)
Ḃ           -   modulo 2         (S->1, V->0)
Œg         -   group equal runs (e.g. [0,0,1,1,0] -> [[0,0],[1,1],[0]])
Ç€       -   call the last link (1) as a monad for €ach (transform to scores)
F      -   flatten (make one list of scores)
S     -   sum (calculate the total score of the string)
=    -   equals right argument (n)?


The resulting order is actually lexicographical in reverse, to have it forward sorted just reverse it by appending Ṛ.

• Nice. Your brownie 🍪. – officialaimm Jul 6 '17 at 7:54
• @officialaimm We usually call those cookies but whatever... – Erik the Outgolfer Jul 6 '17 at 12:00

## JavaScript (ES6), 73 72 bytes

Prints all unique, lexically sorted combinations.

f=(n,p=0,s='')=>n?n>1&&f(n-2,0,s+'S')&f(n-(p-9?p+=3:9),p,s+'V'):alert(s)


### Test cases

In this snippet, alert() has been replaced by console.log() for user-friendliness.

f=(n,p=0,s='')=>n?n>1&&f(n-2,0,s+'S')&f(n-(p-9?p+=3:9),p,s+'V'):console.log(s)

;[2, 3, 4, 12, 16]
.forEach(n => { console.log('[' + n + ']'); f(n); })

• Here's a crunchy brownie: 🍪 – officialaimm Jul 5 '17 at 16:02

# PHP>=7.1, 158 bytes

function b($s="",$g=0){global$r,$i;$g-$i?$g>$i?:b($s."2",$g+2)&b($s.($n=$s[-1]>2?min(9,$s[-1]+3):3),$g+$n):$r[]=strtr($s,2369,SVVV);}$i=$argn;b();print_r($r);  PHP Sandbox Online Expanded function b($s="",$g=0){ global$r,$i;$g-$i ?$g>$i ? :b($s."2",$g+2) # recursive call add a S &b($s.($n=$s[-1]>2?min(9,$s[-1]+3):3),$g+$n) # recursive call add a V :$r[]=strtr($s,2369,SVVV); # add to result array if reach score replace integers with S and V }$i=$argn; #short input variable b(); #call the function print_r($r); #print results

• @officialaimm You must use a PHP Version equal greater than 7.1 – Jörg Hülsermann Jul 5 '17 at 15:28
• @officialaimm you can change the version to the highest available version. At the first time you visit the site it is not set to a PHP 7.1 Version And the only output I reach for input=6 with a Version 7.1 is SSS – Jörg Hülsermann Jul 5 '17 at 15:39
• Oh, its fine now.Anyways, its quite weird how different versions of PHP are giving different outputs for the same code though.. :D – officialaimm Jul 5 '17 at 15:43