Skip to main content
Commonmark migration
Source Link

#Mathematica, 349 346 341 chars h = If[StringMatchQ[#, ("H" | "Q" | "9" | "+") ...], b = If[# > 0, ToString@#, "No"] <> " bottle" <> If[# == 1, "", "s"] <> " of beer" &; w = b@# <> " on the wall" &; Print /@ StringCases[#, {"H" -> "Hello, world!", "Q" -> #, "9" -> "" <> Table[w@n <> ",\n" <> b@n <> ".\ntake one down, pass it around,\n" <> w[n - 1] <> If[n == 1, ".", ".\n\n"], {n, 99, 1, -1}]}];, "Source code contains invalid characters"] &

Mathematica, 349 346 341 chars

h = If[StringMatchQ[#, ("H" | "Q" | "9" | "+") ...], 
   b = If[# > 0, ToString@#, "No"] <> " bottle" <> 
      If[# == 1, "", "s"] <> " of beer" &; 
   w = b@# <> " on the wall" &; 
   Print /@ 
    StringCases[#, {"H" -> "Hello, world!", "Q" -> #, 
      "9" -> "" <> 
        Table[w@n <> ",\n" <> b@n <> 
          ".\ntake one down, pass it around,\n" <> w[n - 1] <> 
          If[n == 1, ".", ".\n\n"], {n, 99, 1, -1}]}];, 
   "Source code contains invalid characters"] &

#Mathematica, 349 346 341 chars h = If[StringMatchQ[#, ("H" | "Q" | "9" | "+") ...], b = If[# > 0, ToString@#, "No"] <> " bottle" <> If[# == 1, "", "s"] <> " of beer" &; w = b@# <> " on the wall" &; Print /@ StringCases[#, {"H" -> "Hello, world!", "Q" -> #, "9" -> "" <> Table[w@n <> ",\n" <> b@n <> ".\ntake one down, pass it around,\n" <> w[n - 1] <> If[n == 1, ".", ".\n\n"], {n, 99, 1, -1}]}];, "Source code contains invalid characters"] &

Mathematica, 349 346 341 chars

h = If[StringMatchQ[#, ("H" | "Q" | "9" | "+") ...], 
   b = If[# > 0, ToString@#, "No"] <> " bottle" <> 
      If[# == 1, "", "s"] <> " of beer" &; 
   w = b@# <> " on the wall" &; 
   Print /@ 
    StringCases[#, {"H" -> "Hello, world!", "Q" -> #, 
      "9" -> "" <> 
        Table[w@n <> ",\n" <> b@n <> 
          ".\ntake one down, pass it around,\n" <> w[n - 1] <> 
          If[n == 1, ".", ".\n\n"], {n, 99, 1, -1}]}];, 
   "Source code contains invalid characters"] &
added 7 characters in body
Source Link
alephalpha
  • 50k
  • 7
  • 68
  • 182

#Mathematica, 349 346 346341 chars h = If[StringMatchQ[#, ("H" | "Q" | "9" | "+") ...], b = If[# > 0, ToString@#, "No"] <> " bottle" <> If[# == 1, "", "s"] <> " of beer" &; w = b@# <> " on the wall" &; Print /@ StringCases[#, {"H" -> "Hello, world!", "Q" -> #, "9" -> "" <> Table[b@nTable[w@n <> " on the wall,\n" <> b@n <> ".\ntake one down, pass it around,\n" <> b[nw[n - 1] <> " on the wall." <> If[nIf[n == 1, """.", "\n\n"]".\n\n"], {n, 99, 1 1, -1}]}];, "Source "Source code contains invalid characters"] &

#Mathematica, 349 346 chars h = If[StringMatchQ[#, ("H" | "Q" | "9" | "+") ...], b = If[# > 0, ToString@#, "No"] <> " bottle" <> If[# == 1, "", "s"] <> " of beer" &; Print /@ StringCases[#, {"H" -> "Hello, world!", "Q" -> #, "9" -> "" <> Table[b@n <> " on the wall,\n" <> b@n <> ".\ntake one down, pass it around,\n" <> b[n - 1] <> " on the wall." <> If[n == 1, "", "\n\n"], {n, 99, 1, -1}]}];, "Source code contains invalid characters"] &

#Mathematica, 349 346 341 chars h = If[StringMatchQ[#, ("H" | "Q" | "9" | "+") ...], b = If[# > 0, ToString@#, "No"] <> " bottle" <> If[# == 1, "", "s"] <> " of beer" &; w = b@# <> " on the wall" &; Print /@ StringCases[#, {"H" -> "Hello, world!", "Q" -> #, "9" -> "" <> Table[w@n <> ",\n" <> b@n <> ".\ntake one down, pass it around,\n" <> w[n - 1] <> If[n == 1, ".", ".\n\n"], {n, 99, 1, -1}]}];, "Source code contains invalid characters"] &

Source Link
alephalpha
  • 50k
  • 7
  • 68
  • 182

#Mathematica, 349 346 chars h = If[StringMatchQ[#, ("H" | "Q" | "9" | "+") ...], b = If[# > 0, ToString@#, "No"] <> " bottle" <> If[# == 1, "", "s"] <> " of beer" &; Print /@ StringCases[#, {"H" -> "Hello, world!", "Q" -> #, "9" -> "" <> Table[b@n <> " on the wall,\n" <> b@n <> ".\ntake one down, pass it around,\n" <> b[n - 1] <> " on the wall." <> If[n == 1, "", "\n\n"], {n, 99, 1, -1}]}];, "Source code contains invalid characters"] &