9-hole mini-golf: Text Manipulation 9-hole mini-golf: Description


9 (mostly fairly easy) code golfing challenges of varying difficulty
Penalties for using the same language more than once
All challenges about a specific theme (this theme: Text Manipulation)
Input and output can be anywhere reasonable (i.e. STDIN and STDOUT, reading from/writing to a file, function argument and return value, etc.) but must NOT be hardcoded into the program
Heavily inspired by 9 Hole Challenge and Text Mechanic


Holes


Code-golf bag

Take two strings as input.
Output the first string's character count, while ignoring any occurence of any character in the second string.
Example: f("foobarbaz", "ao") => 5
A pre-text for golfing

Take two strings as input.
Output the first string, with every line prefixed with the second.
Example: f("foo\nbar\nbaz", "a") => "a foo\na bar\na baz"
War of tabs vs spaces

Take a string s, a number n, and a boolean b (specified however you want) as input.
If b is true, output s with every tab converted to n spaces.
Else, output the s with every n spaces converted to tabs.
Example: f("if (x) {\n\tdoStuff();\n}", 4, true) => "if (x) {\n[sp][sp][sp][sp]doStuff();\n}" ([sp] means space)
Pillars of golf

Take a string s, a number n, and another number m as input.
Output s in columns of n lines each and m characters per column.
Also have padding of one space between the columns.
Example: f("this is some placeholder text, foo bar baz...", 3, 5) =>

this  aceho  foo 
is so lder  bar b
me pl text, az...

Friendly letters

Take a string s and a number n as input.
Output the most common group of n letters in s.
If there is a tie, output any or all of them.
Example: f("abcdeabcfghiabc", 3) => "abc"
Scrambled eggs letters for breakfast

Take a string as input.
Output the string with all of its words scrambled (letter order randomized) except their first and last letters.
For simplicity, assume that the input will be a list of "word"s, space separated (i.e. in @$&amp;_():;" foo bar, @$&amp;_():;" is considered a "word.")
Example: f("this is a sentence that will be scrambled") => "tihs is a stcneene that wlil be sclamrbed"
ASCIIfy

Take a string as input.
If the string only contains numbers and spaces, then replace the numbers with their respective ASCII characters (removing the spaces).
Else, do the reverse (characters to numbers).
Example: f("ASCIIfy challenge") => "65 83 67 73 73 102 121 32 99 104 97 108 108 101 110 103 101"
Example 2: f("65 83 67 73 73 102 121 32 99 104 97 108 108 101 110 103 101") => "ASCIIfy challenge"
Mini-mini-markdown transformation

Take a string as input.
Output the string converted with mini-markdown, as used in comments on Stack Exchange.
This is an even mini-er version: you only need to handle **bold**, *italics*, and `code`.
You need not handle invalid nesting, like **foo *bar** baz*. Also assume that when you see a delimiter (* or `), it will always mean to format (i.e. te**st**ing => te&lt;b&gt;st&lt;/b&gt;ing, and foo* bar *baz => foo&lt;i&gt; bar &lt;/i&gt;baz).
Example: f("**foo** *bar **baz*** `qux`") => "&lt;b&gt;foo&lt;/b&gt; &lt;i&gt;bar &lt;b&gt;baz&lt;/b&gt;&lt;/i&gt; &lt;code&gt;qux&lt;/code&gt;"
Only the best characters

Take a string s, number n, and string r as input.
Output the nth character of each word in s. (0-indexed, words are space-separated).
If the length of the word is less than n, use r for that word instead.
Example: f("this is a test sentence foo bar baz", 2, "-") => "i--snorz"


Scoring

Your score is the sum of the character counts of your programs. For every repeated language, multiply by 110%. For example, if you have three Ruby solutions, and the total character count of all of your solutions is 1000, your score is 1000 * 1.1 * 1.1 = 1210. Round down if you have a non-integer score.

Good luck!
Score: 382 * 1.12 = 462

Languages prone to change.

1. APL, 8 4

Thanks @marinus for shaving 4 chars off.

f←⍴~


Called with the strings as the left and right arguments, eg.

      'foobarbaz' f 'ao'
5


2. Ruby, 35 31

Thanks @DoorknobofSnow for shaving 4 chars off.

f=-&gt;s,r{s.gsub(/(?&lt;=^)/,r+' ')}


3. Python, 48

f=lambda s,n,b:s.replace(*['\t',' '*n][::2*b-1])


4. GolfScript, 20

{@//zip{' '*}%n*}:f;


Assumes that the arguments are on the stack. Test online

5. J, 50

f=:({~[:(i.&gt;./)+/"1@=@(}.~0-1{$))@|:@([$~],1+[:$[)


Called with the string as the left argument and the number as the right, eg.

   'abcdeabcfghiabc' f 3
abc


6. Ruby, 61

f=-&gt;s{s.gsub(/(?&lt;!^| )[^ ]+(?!$| )/){[*$&amp;.chars].shuffle*''}}


7. GolfScript, 39 35 34

{[.10,' '*-{{}/]' '*}{~]''+}if}:f;


Again, assumes the argument is on the stack. Test online

8. Perl, 98

sub f{$_=@_[0];s!\*\*(.+?)\*\*!&lt;b&gt;$1&lt;/b&gt;!g;s!\*(.+?)\*!&lt;i&gt;$1&lt;/i&gt;!g;s!`(.+?)`!&lt;code&gt;$1&lt;/code&gt;!g;$_}


9. Haskell, 36

f s n r=[(x++cycle r)!!n|x&lt;-words s]