Skip to main content
added 1242 characters in body
Source Link
Link Ng
  • 593
  • 2
  • 10

C#6, 321321 303 bytes

using System.Linq;string F(int x,int y)=>S(x,y)??"~<.,,>~~";string S(int x,int y)=>x<0|y<0?null:y<1?x<1?"":null:y<2?x<3?null:C(x):y*3>x?S(x-1,y-2)!=null?S(x-1,y-2)+"<.,.> ":S(x-2,y-2)!=null?S(x-2,y-2)+",<..>, ":null:string.Concat(new int[y].Select((_,k)=>k<1?C(x-y*3+3):C(3)));string C(int x)=>$"<{new string(',',x)}.> ";

Call F(). The other two functions are helpers. repl.it demorepl.it demo

// Coalesce failed combinations with commaleon
string F(int x,int y)=>S(x,y)??"~<.,,>~~";
// Get successful combination or null
string S(int x,int y)=>
    x<0|y<0
        // Fail: Out of range
        ?null
        :y<1
            ?x<1
                // Successful: All commas and periods accounted for
                ?""
                // Fail: Not enough periods for commas
                :null
            :y*3>x
                // Not all commapillars
                ?S(x-1,y-2)!=null
                    // Try koala
                    ?S(x-1,y-2)+"<.,.> "
                    // Try crab
                    :S(x-2,y-2)!=null
                        ?S(x-2,y-2)+",<..>, "
                        // Epic fail
                        :null
                // All commapillars
                :string.Concat(new int[y].Select((_,k)=>k<1
                    // This commapillar takes most of commas
                    ?C(x-y*3+3)
                    // The rest each takes 3
                    :C(3)));
// Generate single commapillar
string C(int x)=>$"<{new string(',',x)}.> ";

C#6, 321 bytes

using System.Linq;string F(int x,int y)=>S(x,y)??"~<.,,>~~";string S(int x,int y)=>x<0|y<0?null:y<1?x<1?"":null:y<2?x<3?null:C(x):y*3>x?S(x-1,y-2)!=null?S(x-1,y-2)+"<.,.> ":S(x-2,y-2)!=null?S(x-2,y-2)+",<..>, ":null:string.Concat(new int[y].Select((_,k)=>k<1?C(x-y*3+3):C(3)));string C(int x)=>$"<{new string(',',x)}.> ";

Call F(). The other two functions are helpers. repl.it demo

C#6, 321 303 bytes

using System.Linq;string F(int x,int y)=>S(x,y)??"~<.,,>~~";string S(int x,int y)=>x<0|y<0?null:y<1?x<1?"":null:y*3>x?S(x-1,y-2)!=null?S(x-1,y-2)+"<.,.> ":S(x-2,y-2)!=null?S(x-2,y-2)+",<..>, ":null:string.Concat(new int[y].Select((_,k)=>k<1?C(x-y*3+3):C(3)));string C(int x)=>$"<{new string(',',x)}.> ";

Call F(). The other two functions are helpers. repl.it demo

// Coalesce failed combinations with commaleon
string F(int x,int y)=>S(x,y)??"~<.,,>~~";
// Get successful combination or null
string S(int x,int y)=>
    x<0|y<0
        // Fail: Out of range
        ?null
        :y<1
            ?x<1
                // Successful: All commas and periods accounted for
                ?""
                // Fail: Not enough periods for commas
                :null
            :y*3>x
                // Not all commapillars
                ?S(x-1,y-2)!=null
                    // Try koala
                    ?S(x-1,y-2)+"<.,.> "
                    // Try crab
                    :S(x-2,y-2)!=null
                        ?S(x-2,y-2)+",<..>, "
                        // Epic fail
                        :null
                // All commapillars
                :string.Concat(new int[y].Select((_,k)=>k<1
                    // This commapillar takes most of commas
                    ?C(x-y*3+3)
                    // The rest each takes 3
                    :C(3)));
// Generate single commapillar
string C(int x)=>$"<{new string(',',x)}.> ";
Post Undeleted by Link Ng
added 59 characters in body
Source Link
Link Ng
  • 593
  • 2
  • 10

C#6, 262321 bytes

stringusing System.Linq;string F(int x,int y)=>S(x,y)??"~<.,,>~~";string S(int x,int y)=>x<0|y<0?null:y<1?x<1?"":null:y<2?x<3?null:C(x):y<3&x>5y*3>x?C(x/2)+C(x/2+x%2):S(x-1,y-2)!=null?S(x-1,y-2)+"<.,.> ":S(x-2,y-2)!=null?S(x-2,y-2)+",<..>, ":null;stringnull:string.Concat(new int[y].Select((_,k)=>k<1?C(x-y*3+3):C(3)));string C(int x)=>$"<{new string(',',x)}.> ";

Call F(). The other two functions are helpers. repl.it demorepl.it demo

C#6, 262 bytes

string F(int x,int y)=>S(x,y)??"~<.,,>~~";string S(int x,int y)=>x<0|y<0?null:y<1?x<1?"":null:y<2?x<3?null:C(x):y<3&x>5?C(x/2)+C(x/2+x%2):S(x-1,y-2)!=null?S(x-1,y-2)+"<.,.> ":S(x-2,y-2)!=null?S(x-2,y-2)+",<..>, ":null;string C(int x)=>$"<{new string(',',x)}.> ";

Call F(). The other two functions are helpers. repl.it demo

C#6, 321 bytes

using System.Linq;string F(int x,int y)=>S(x,y)??"~<.,,>~~";string S(int x,int y)=>x<0|y<0?null:y<1?x<1?"":null:y<2?x<3?null:C(x):y*3>x?S(x-1,y-2)!=null?S(x-1,y-2)+"<.,.> ":S(x-2,y-2)!=null?S(x-2,y-2)+",<..>, ":null:string.Concat(new int[y].Select((_,k)=>k<1?C(x-y*3+3):C(3)));string C(int x)=>$"<{new string(',',x)}.> ";

Call F(). The other two functions are helpers. repl.it demo

Post Deleted by Link Ng
Source Link
Link Ng
  • 593
  • 2
  • 10

C#6, 262 bytes

string F(int x,int y)=>S(x,y)??"~<.,,>~~";string S(int x,int y)=>x<0|y<0?null:y<1?x<1?"":null:y<2?x<3?null:C(x):y<3&x>5?C(x/2)+C(x/2+x%2):S(x-1,y-2)!=null?S(x-1,y-2)+"<.,.> ":S(x-2,y-2)!=null?S(x-2,y-2)+",<..>, ":null;string C(int x)=>$"<{new string(',',x)}.> ";

Call F(). The other two functions are helpers. repl.it demo