The 9 Hole Challenge
- 9 code golfing challenges of varying difficulty.
- Penalties for using the same language more than once.
The question will be updated with pars, hole champions and trophy winners.
This comes from a competition I have with some friends, it's not the usual format, but I hope some of you will appreciate the different spin on it. Challenges, rules and trophies below.
Holes
Greenway (24)
f(c:string, n:integer)
Prints a line containingn
instances ofc
.Somewhere in the Rough (73)
f(t:string, s:string, n:integer) -> i
Wherei
is the index of thenth
instance ofs
int
.Curry for Dinner (6235)
f(x:function, y: function) -> g
Whereg
is a function that will cally
,n
times; wheren
is the return value ofx
Spew (92)
f(p:string)
Writes to file atp
and fills it with a randomly sized rectangle of random characters (ascii).Treasure Hunt (75)
f(p:string, c:char) -> (x, y)
Reads file atp
which contains a grid of symbols and returns thex
andy
coordinates of the first instance of that symbol within the grid, assume it exists.Bridge on the River Kwai (179)
f(l:list[int])
Prints difference bridges diagram forl
. E.g for[1,7,3,17,1]
/+6\ /-4\ /+14\ /-16\ 1 7 3 17 1
Make sure that the spaces are created according to the size of the number above. For a 3 digit long number, you are going to need 4 spaces between the digits on the line below.
Catch: Somewhere, your code must spell trousers (Must have at least 1 non-alphanumeric delimiters. E.g.
tr(ou,se)(rs)
Time Flies When You're Playing Golf (1157)
f(p:string) -> [h, m]
Reads file atp
which contains an ASCII representation of an analogue clock, where the hour hand is represented with one lines, and the minutes by two. Output a list containing two elements: the hours and minutes shown on the clock. If only one hand is visible, assume both point to that position.Here are all the possible combinations for a hand.
\ | / \|/ --o-- /|\ / | \
These positions, respectively are (12, 1, 3, 5, 6, 7, 9, 11). Assume that the other characters within the clock face are spaces.
Timber! ()
f(p:string) -> b:boolean
Where p is the path to a file with an ascii building in. Blocks with white space underneath them will fall. (Except from slashes, which stay in place if there is a stable block in the opposite direction to the way they face). If the building is structurally integral return true, otherwise return false. All non whitespace blocks are counted as being solid and other than slashes, they all fall.Structurally safe
____ |/\| | |
Not Safe
|__ | |
Safe version
|__ \\| |
Slacker News (218)
f(s:string, r:string, p:string)
Gets the titles of the top 20 stories on Hacker News and changes all instances ofs
tor
, then writes the new titles to a html file atp
, where each title is contained within a h1 element.The outputted file should something like this
<h1>Some title</h1></h1>Some other title</h1>...etc
Catch:
- You may not use the HN api.
- You may not use Regex.
- You may not use angle braces anywhere in your code.
Scoring
- Character count is the length of the function that will compile & run correctly. However you still need to submit the full code, including imports.
- +10% for every repeated language in your submission. (E.g. If you use Ruby for 3 solutions, then your final score will be multiplied by 1.2). Different versions of the same language count still count as the same language.
- Par will be average score for each hole.
- Submit your solutions in one answer.
- Your overall score is your character count + your language penalty, then round it up.
Trophies
- Gold Jacket - (@Sprigyig - 1290) Lowest overall score
- Shooter - (@Sprigyig - 9) Most languages used
- Bunker - Most above par score on any hole
- Snakes on a Plane - (@AsksAnyway - 1727) Highest python character submission in a single solution
- Good Parts - (@AsksAnyway - 255) Highest JS character count in a single solution
- Shakey Steve - Shortest solution that uses interfaces
- You're Not From Round Here - Shortest unique language solution that's language has the shortest wikipedia page.
- Happy Gilmoore - (@AsksAnyway - 31) Shortest solution that has the word 'alligator' in the code.
- Unicycling Dwarf Magic - The default extensions of your 9 submission source files are a perfect anagram of a word in the Oxford Dictionary.
You are only eligible for a trophy once you have completed all 9 holes
Submissions
- @Sprigyig 1290
- @Firefly 1320
- @grc 1395
- @Trevor M 1465
- @C Gearhart 1654
- @Guy Sirton 1719
- @AsksAnyway 4651
<
&>
\$\endgroup\$/
position to refer to 1 o'clock or 2 o'clock? (and similarly for all the rest of the diagonals) \$\endgroup\$