-
Notifications
You must be signed in to change notification settings - Fork 21
The world's first monthly Go Challenge for developers (newbies included)
- This first Go challenge is now closed.
- There were 173 entries from 41 countries.
- The winners of the first Go Challenge are: Luke Champine (his solution) and Jeremy Jay (his solution).
- Sourcegraph interviewed our winners: Luke Champine and Jeremy Jay.
- Some of the participants blogged about their Go challenge experience: Christopher Saunders, Doug Cichon, Herrick Shen, Jason Gade and Tobias Schoknecht.
Feedback from the Evaluators
Difficult to give generalized comments, but here are some suggestions.
- Running
go vet
andgolint
should be a no-brainer. I found that a few entries failed this test.- Use the
defer
statement to free up resources after use - for example, on file open.- Do not over-engineer. Types are easy to define, but sometimes, all you need is a func.
- Comment your code well. What may seem obvious to you may not be so obvious to someone reading your code.
A more detailed feedback is available here.
The first Go Challenge author is [Matt Aimonetti](http://matt.aimonetti.net/), CTO and co-founder of [Splice](https://splice.com/), a technology platform for music creators. Splice streamlines the fragmented process of creating and sharing music, freeing musicians to spend their time and energy on the creative process.
Long before Splice, Matt was a former sound engineer who tried his hand as an artist before transitioning to full time programming, working for companies such as Sony PlayStation and LivingSocial. Matt has been active in the Open Source community for many years, developing or contributing to many projects (Merb, Rails, MacRuby and many more). He also wrote a free book about Go and is a published tech author for O'Reilly. Matt is based in Santa Monica, California.
Matt has this to say about the challenge:
"Very often developers just need an excuse to learn a new language or develop their own skills. The Go challenge is a great opportunity to work on a low-pressure, isolated, fun challenge and hopefully learn a lot. Getting out of the day to day programmer routine is an awesome way to challenge your brain and become a better developer."
This morning I took my daughter Giana to my secret lab to show her the various inventions I built over the years. That's when I realized that the awesome drum machine prototype I designed in the 90s had disappeared!!! The only related things I could find were printouts of the patterns I had created on the device as well as backups saved on floppy disks. Here are the printed patterns:
pattern_1.splice
Saved with HW Version: 0.808-alpha
Tempo: 120
(0) kick |x---|x---|x---|x---|
(1) snare |----|x---|----|x---|
(2) clap |----|x-x-|----|----|
(3) hh-open |--x-|--x-|x-x-|--x-|
(4) hh-close |x---|x---|----|x--x|
(5) cowbell |----|----|--x-|----|
pattern_2.splice
Saved with HW Version: 0.808-alpha
Tempo: 98.4
(0) kick |x---|----|x---|----|
(1) snare |----|x---|----|x---|
(3) hh-open |--x-|--x-|x-x-|--x-|
(5) cowbell |----|----|x---|----|
pattern_3.splice
Saved with HW Version: 0.808-alpha
Tempo: 118
(40) kick |x---|----|x---|----|
(1) clap |----|x---|----|x---|
(3) hh-open |--x-|--x-|x-x-|--x-|
(5) low-tom |----|---x|----|----|
(12) mid-tom |----|----|x---|----|
(9) hi-tom |----|----|-x--|----|
pattern_4.splice
Saved with HW Version: 0.909
Tempo: 240
(0) SubKick |----|----|----|----|
(1) Kick |x---|----|x---|----|
(99) Maracas |x-x-|x-x-|x-x-|x-x-|
(255) Low Conga |----|x---|----|x---|
pattern_5.splice
Saved with HW Version: 0.708-alpha
Tempo: 999
(1) Kick |x---|----|x---|----|
(2) HiHat |x-x-|x-x-|x-x-|x-x-|
I need your help to reverse engineer the binary format used by my drum machine and write a decoder so I will be able to implement a new drum machine, using Go this time!
You will find attached a zip file containing the starting point for this challenge.
Your goal is to implement the drum
package and make it pass the
provided tests.
My drum machine loads an audio sample per track, allowing the programmer to schedule the playback of the sound. The scheduling of the playback is done using the concept of steps. A step is one of the parts of the measure that is being programmed (the programmed measure is known as a pattern). The measure (also called a bar) is divided in steps.
My drum machine only supports 16 step measure patterns played in 4/4 time. The measure is comprised of 4 quarter notes, each quarter note is comprised of 4 sixteenth notes and each sixteenth note corresponds to a step. If all these music terms are confusing, don't worry, just know that the drum machine uses grid of 16 parts to let you trigger a sound. We have one sound per track and each track can be programmed independently. Each part is called a step. The speed of the playback is based on the tempo (aka bpm).
Taking an example from the printouts above:
(40) kick |x---|----|x---|----|
means that we have a track called "kick" (id 40) with the sound output being triggered on the first and ninth steps.
The goal of this challenge is to write a binary decoder that given a binary backup, outputs the same printouts as shown above. To do that you need to implement the DecodeFile(path string) (*Pattern, error)
function inside the drum package. Note that *Pattern
needs to be printable so it can be compared to the printouts. To help you, a test is provided. To run the test suite, use your terminal to navigate to the location of the unzip file and run go test -v
. You should see an output similar to this:
go test -v
=== RUN TestDecodeFile
--- FAIL: TestDecodeFile (0.00s)
decoder_test.go:69: decoded:
"&{}"
decoder_test.go:70: expected:
"Saved with HW Version: 0.808-alpha\nTempo: 120\n(0) kick\t|x---|x---|x---|x---|\n(1) snare\t|----|x---|----|x---|\n(2) clap\t|----|x-x-|----|----|\n(3) hh-open\t|--x-|--x-|x-x-|--x-|\n(4) hh-close\t|x---|x---|----|x--x|\n(5) cowbell\t|----|----|--x-|----|\n"
decoder_test.go:72: pattern_1.splice wasn't decoded as expect.
Got:
&{}
Expected:
Saved with HW Version: 0.808-alpha
Tempo: 120
(0) kick |x---|x---|x---|x---|
(1) snare |----|x---|----|x---|
(2) clap |----|x-x-|----|----|
(3) hh-open |--x-|--x-|x-x-|--x-|
(4) hh-close |x---|x---|----|x--x|
(5) cowbell |----|----|--x-|----|
FAIL
exit status 1
- Only use Go standard library. No third-party libraries may be imported.
- You are welcome to modify (improve) the included test suite or move the binaries, but the
DecodeFile
API must remain and the original test suite must still pass.
- Look around to see how data is usually serialized/encoded.
- Become familiar with encoding/binary package, especially binary.Read.
- hex.Dump can very useful when debugging binary data (read more about hex dump)
The first step is to reverse engineer the binary file format. Look at the hex values to see if you can detect patterns. Binary data usually contains some sort of headers, then the encoded data. You should expect to find the data described in the printouts:
- version
- tempo
- tracks with each track containing
- id
- name
- 16 steps
Then you need to write a decoder that takes one of the provided binary files and extracts/prints the data.
This advanced section is not for the faint of heart, in case you were about to complain about how easy this challenge was, or if you just want to push things further, here is some more!
How about editing the cowbell track to add more steps? Reading the binary format is one thing, being able to generate/modify the data is even more fun. Take a pattern of your choosing and add more cowbell! For instance convert pattern_2.splice
from:
pattern_2.splice
Saved with HW Version: 0.808-alpha
Tempo: 98.4
(0) kick |x---|----|x---|----|
(1) snare |----|x---|----|x---|
(3) hh-open |--x-|--x-|x-x-|--x-|
(5) cowbell |----|----|x---|----|
to:
pattern_2-morebells.splice
Saved with HW Version: 0.808-alpha
Tempo: 98.4
(0) kick |x---|----|x---|----|
(1) snare |----|x---|----|x---|
(3) hh-open |--x-|--x-|x-x-|--x-|
(5) cowbell |x---|x-x-|x---|x-x-|
Still not enough? Why not implementing the playback of the patterns using something like portaudio?
By participating in this challenge, you agree to be bound by the Challenge Rules below:
- The Challenge is open to individuals.
- After the challenge, all submissions will be made available online on GitHub under the BSD 3-Clause License.
- Evaluators cannot enter the challenge except under the "Just for Fun" category.
- Each entrant shall indemnify, defend, and hold JoshSoftware Pvt. Ltd. (who has sponsored the domain and is the organizer of these challenges) harmless from any third party claims arising from or related to that entrant's participation in the Challenge. In no event shall JoshSoftware Pvt. Ltd. be liable to an entrant for acts or omissions arising out of or related to the Challenge or that entrant's participation in the Challenge.
- Odds of winning depend on the number and quality of entries received.
- All taxes, including income taxes, are the sole responsibility of winners.
- No prize substitution is permitted.
- Create a zip of your Go source code and send the zip file to gochallenge [at] joshsoftware.com by the 13th of March 2015 (6 am IST). Use this link to find the equivalent time in your city/country. No new solutions will be accepted after that. In the email mention your full name, country of residence, and twitter id (if any). We shall be publishing on this blog, a list of participant names. If you don't want you name to appear kindly mention the same in your email. We are accepting anonymous submissions and will evaluate them too but then these participants are not eligible for the prizes. We will give your zip file to the evaluation team. Note: Avoid sharing your code with anyone else; if your solution becomes available to the general public it might impact evaluation of your submission.
Entries will be anonymized and evaluated by the challenge author and a team of evaluators.
- Functioning code and a test suite that passes.
- Code hygiene. Use gofmt, vet and lint. Review CodeReviewComments.
- Readability. How easy is it for another programmer to grasp what your entry is doing?
- Code structure. Do types and files have good names?
- Reliability. Are errors properly handled?
- Appropriate consideration given to memory and performance (nothing is unnecessarily expensive).
If you have any questions about this challenge, please join the golang-challenge channel on slack which is a room for people who are going to participate in the Go Challenge.
Nathan Youngman has agreed to set the guidelines for evaluation. Dominik Honnef, Guillaume J. Charmes, Jiahua Chen, Niket Patel, Pravin Mishra and Sanat Gersappa have agreed to go through all the submitted solutions of a challenge. They will comment and rank these solutions.
The author of the Go Challenge will decide the best two solutions. The author shall have the sole authority and discretion to select the award recipients.
The winning entries will be announced here on this blog. The winners will be sent their prizes by email/postal mail.
Two prizes will be awarded for the best solution as selected by the author.
Here are some great prizes provided by our sponsors for the event.
Winner 1:
- Anand D N - Essential-Go screencast
- Apcera - Go Gopher Messenger Bag
- CoreOS - Company T-Shirt and stickers and a free ticket to the CoreOS Fest in SFO.
- Crowd Interactive - GitHub Micro Personal Plan for three months
- Cube Root Software - An eBook Go-The Standard Library
- DigitalOcean - US$ 50 Amex Gift Card
- Helpshift - An eBook A Go Developer's Notebook
- InfluxDB - A US$ 50 Amazon digital gift card.
- John Sonmez - An eBook Soft Skills: The software developer's life manual
- Koding - A free Hobbyist plan for 3 months
- Manning Publications Co. - Two eBooks Go Web Programming and Go in Action
- NodePrime - An eBook The Go Programming Language Phrasebook (Developer's Library)
- O'Reilly - An eBook Introduction to Go Programming
- Packt Publishing - A print book Mastering Concurrency in Go
- Qwinix Technologies - An eBook The Docker Book: Containerization is the new virtualization
- RainingClouds - An eBook Level Up Your Web Apps With Go
- SoStronk - Counter-Strike: Global Offensive game. You will need to have a free Steam account to receive this gift.
- Sourcegraph - Interview with the winner on their blog and will get their shirt, stickers
Winner 2:
- Anand D N - Essential-Go screencast
- Apcera - Go Gopher Squishable
- CoreOS - Company T-Shirt and stickers and a free ticket to the CoreOS Fest in SFO.
- Crowd Interactive - GitHub Micro Personal Plan for three months
- DigitalOcean - US$ 50 Amex Gift Card
- Docker - A ticket to DockerCon 2015 in SFO, USA OR to DockerCon Europe (to be announced but probably in Dec. 2015).
- Helpshift - An eBook A Go Developer's Notebook
- InfluxDB - A US$ 50 Amazon digital gift card.
- John Sonmez - An eBook Soft Skills: The software developer's life manual
- Koding - A free Hobbyist plan for 3 months
- Manning Publications Co. - Two eBooks Go Web Programming and Go in Action
- NodePrime - An eBook The Go Programming Language Phrasebook (Developer's Library)
- Packt Publishing - An eBook Building Your First Application with Go-Video
- Qwinix Technologies - An eBook The Docker Book: Containerization is the new virtualization
- RainingClouds - An eBook Level Up Your Web Apps With Go
- SoStronk - Counter-Strike: Global Offensive game. You will need to have a free Steam account to receive this gift.
- Sourcegraph - Interview with the winner on their blog and will get their shirt, stickers
Anyone can a get 42% off on the price of the following eBooks from Manning Publications Co.:
- Go Web Programming - Use discount code: cftw15go
- Go in Action - Use discount code: cftw15go
Also, anyone can a get 25% off on the price (valid till 31st March 2015) of the following print and / or eBooks from Packt Publishing:
- Building Your First Application with Go-Video - Use discount code: byfag25
- Mastering Concurrency in Go - Use discount code: giccm25
- Go Programming Blueprints - Use discount code: bgpg25
After a winner wins the monthly challenge, he/she would be interviewed by Sourcegraph and the interview will be published on their blog.
You can check out the list of participants for this challenge i.e. for March 2015.
All the solutions submitted by the participants are available here.
Matt Aimonetti has selected the winners of this challenge. They are:
**Winner #1 Luke Champine** never expected to wind up as a programmer; in college he first studied electrical engineering, and then computer engineering. But he got involved in his school's open source community, which sparked his love of programming and introduced him to Go. He left school without graduating and moved to Boston to co-found [Nebulous](https://twitter.com/NebulousLabs), a cryptocurrency startup.Outside of programming, his interests include linguistics, Buddhism, and chess.
His solution to the challenge.
**Winner # 2 Jeremy Jay** has been a developer for almost 20 years now. He earned his PhD in Computer Science in 2013, and runs a freelance [software development company](http://stridatum.com/) specializing in mobile apps and complex data integration projects (which often go together!). He has developed applications for all 5 major Operating Systems (Linux, OSX, Windows, iOS, Android), some smaller/embedded ones, using the myriad languages he had picked up along his career. Go is by far his favorite, and has become his daily driver, even for things he used to write short python scripts for. Go's brevity and expressiveness makes it extremely versatile for his daily work.
His solution to the challenge.
Matt also mentioned that Doug Cichon was a very close #2.
This challenge's sponsors are: Anand D N, Apcera, CoreOS, Crowd Interactive, Cube Root Software, DigitalOcean, Docker, GopherCasts, Helpshift, InfluxDB, John Sonmez, JoshSoftware Pvt. Ltd., Manning Publications Co., NodePrime, O'Reilly, Packt Publishing, Qwinix Technologies, RainingClouds, SoStronk and Sourcegraph.
- The Gopher character is based on the Go mascot designed by Renée French and copyrighted under the Creative Commons Attribution 3.0 license.
- The Go Challenge is being organized by JoshSoftware Pvt. Ltd. with help from the Go community.