Skip to content

Instantly share code, notes, and snippets.

@jszmajda
Last active September 29, 2016 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jszmajda/bf3d433b7469b67d7ae9302e31609d11 to your computer and use it in GitHub Desktop.
Save jszmajda/bf3d433b7469b67d7ae9302e31609d11 to your computer and use it in GitHub Desktop.
DCRUG CoderNight 20161013

tl;dr - Coder Night is to practice development. You write code in pairs or individually and submit the code to me (joshsz @ gmail.com). I post an anonymized repo and you have a few days to look at all the solutions before a friendly night of code review.

The Problem

DNA Encoding! (see DNA.md below)

Submissions Due

Tuesday October 11th at 11:59pm.

Coder Night

Coder Night is a chance to practice your coding skills outside your work environment or help get started if you are just learning. Coder Night provides an ego-free environment to perform deliberate coding practice and to receive critical but judgement free feedback on your progress.

Coder Night welcomes people of all skill levels from "I just wrote my first line of code" to "I have invented my own language"

Please RSVP if you intend on submitting code and participating in the meetup.

How does it work?

We will send out a homework statement a couple weeks before the meeting. You'll complete the assignment and submit your code anonymously (you may submit more than one entry). A few days before the meeting we'll start sharing solutions for everyone to read and review. During the meeting, the group will review and provide feedback for the posted solutions. The purpose of the meeting is to provide feedback to those who submitted code.

Your submission should also state what you are trying to achieve with the solution provided. Examples include:

  • Just learning to code so I just want this to WORK.
  • Learning Ruby, practicing writing with the "Ruby style"
  • Trying "everything is an object"
  • Golfing (fewest possible number of characters/lines) attempt
  • 100% Test Driven (include the tests)

If you consider yourself an experienced developer and you raced through the assignment, you are "doin' it wrong" and should find an area to focus on. You should attempt to solve these assignments using techniques that are outside of your comfort zone. For example, perhaps try "TDD as if you meant it" or try to avoid using primitives (eschew integers for objects).

We will publish a full anonymized catalog of submissions with enough time to review them prior to the meetup.

Please do not just copy/paste a solution from the internet. That's definitely not the point of this meetup! :)

If you get stuck please join us in the DCTech Slack in the #ruby channel. Someone will definitely love to help you figure it out!

The Meetup

What the meeting is:

  • A place to get honest, critical, and helpful feedback on your code either anonymously or face-to-face
  • A place to ask questions about the positive and negative qualities of many ways to solve the same problem (I guarantee there will be more ways than you'd expect)
  • A chance to identify areas of problem solving, coding and Ruby you'd like to improve on. (and perhaps focus on for the next meeting)
  • A great chance to help others.

What the meeting is NOT:

  • Grandstanding ("Look at MY code, I'm the king of the world") -- I'll kick you out.
  • Pick on the noob ("ZOMG, 200 lines, I could totally do that in 6!") -- Again, I'll kick you out

A few meetings rules:

  • Please be sure to have reviewed solutions and be prepared to speak about them. We are not going to read each line of each submission as a group. The meeting only works if you have prepared notes.
  • You can be critical, but you must be kind. Otherwise, yeah, you got it, I'll kick you out.
  • You must be willing to follow up with people who want to ask questions or for additional detail regarding your comments.
  • Please don't ask "Who wrote this anonymous solution?" -- Anonymity helps people feel safe. You can reveal yourself if you like but it's not required.

I understand people can be self-conscious of their code. It sometimes feels like an extension of yourself and you don't want to be criticized by others. This is why the anonymous option and "be critical but kind" is so important to the format of this event.

Finally, this has been stolen/adapted from Arlington Ruby, who stole/adapted it from Gavin and the folks from Tampa Ruby. Thanks for being awesome!

Challenge

Write an encoder (and a decoder) that takes a string as input and outputs the string encoded in the style of a strand of DNA.

DNA

DNA is made up of four types of nucleotide:

  • Adenine (A)
  • Thymine (T)
  • Cytosine (C)
  • Guanine (G)

Adenine and thymine pair up together to make AT or TA. Similarly, cytosine and guanine pair up together to make CG or GC.

Let's call these pairs units. This means that your encoded string is only allowed to contain the four units AT, TA, CG and GC. This means that: ATTAGACG would be invalid because it contains the unit GA, which is impossible. Similarly, TAGCGCCGATA is invalid because the final A does not have a thymine to pair up with.

Example

Encode the following example text:

I have a friend who's an artist and has sometimes taken a view which I don't agree with very well. He'll hold up a flower and say "look how beautiful it is," and I'll agree. Then he says "I as an artist can see how beautiful this is but you as a scientist take this all apart and it becomes a dull thing," and I think that he's kind of nutty. First of all, the beauty that he sees is available to other people and to me too, I believe. Although I may not be quite as refined aesthetically as he is ... I can appreciate the beauty of a flower. At the same time, I see much more about the flower than he sees. I could imagine the cells in there, the complicated actions inside, which also have a beauty. I mean it's not just beauty at this dimension, at one centimeter; there's also beauty at smaller dimensions, the inner structure, also the processes. The fact that the colors in the flower evolved in order to attract insects to pollinate it is interesting; it means that insects can see the color. It adds a question: does this aesthetic sense also exist in the lower forms? Why is it aesthetic? All kinds of interesting questions which the science knowledge only adds to the excitement, the mystery and the awe of a flower. It only adds. I don't understand how it subtracts.

How many pairs did it take for your encoder to represent this text? How can you modify your encoder to produce a shorter result?

Rules

Your encoder and decoder programs must work for any string supplied. Therefore, your encoder must produce a genuine encoding and your decoder should not simply hardcode the example text.

You must support all printable ASCII characters:

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

If you can support more characters, that is acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment