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.
Prints a line containing
Somewhere in the Rough (73)
f(t:string, s:string, n:integer) -> i
iis the index of the
Curry for Dinner (6235)
f(x:function, y: function) -> gWhere
gis a function that will call
nis the return value of
f(p:string)Writes to file at
pand fills it with a randomly sized rectangle of random characters (ascii).
Treasure Hunt (75)
f(p:string, c:char) -> (x, y)Reads file at
pwhich contains a grid of symbols and returns the
ycoordinates 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 for
l. E.g for
/+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.
Time Flies When You're Playing Golf (1157)
f(p:string) -> [h, m]Reads file at
pwhich 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.
f(p:string) -> b:booleanWhere 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.
____ |/\| | |
|__ | |
|__ \\| |
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 of
r, then writes the new titles to a html file at
p, 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
- You may not use the HN api.
- You may not use Regex.
- You may not use angle braces anywhere in your code.
- 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.
- 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