Browse in : |
All
> Topics
> Design
All > Journals > CVu > 294 Any of these categories - All of these categories |
Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.
Title: A New Competition
Author: Bob Schmidt
Date: 02 September 2017 16:11:08 +01:00 or Sat, 02 September 2017 16:11:08 +01:00
Summary: Francis Glassborow presents a new challenge for CVu readers.
Body:
Many years ago, when I was editor of CVu, I ran a number of programming challenges. The most successful of these was to design a deterministic sort algorithm (i.e. it must terminate so looping through random shuffles and checking if the result was sorted did not qualify). Some readers managed to come up with some truly horrendous algorithms. I suppose that spending so much time working hard to write good efficient and correct code makes the challenge of writing bad, inefficient but correct code a relief.
I was reminded of this by one of the events at the recent ACCU conference where teams clearly enjoyed the challenge of writing code that would compile but with a serious number of constraints such as the twin requirements to keep the character count low whilst including particular keywords or tokens. Some of the entries were tours de force and I am not sure of the adjudicator’s decision to rule against a piece of code that compiled because of a bug in the compiler. To my mind that sort of thing should get a bonus.
I thought that it might be fun to run some more coding challenges in CVu and I hope that lots of you will take part (not only try the challenge but submit your code to the editor).
I will aim to be imaginative and provide challenges that are nothing like what you have to do in the day job. I do not promise to provide one for every issue but I will do my best.
Challenge 1
Many years ago, a programmer wrote a piece of machine code that ran on two different machines to do two entirely different things. The author had spotted that a specific instruction was valid on both systems but on one it was an unconditional jump and on the other it was effectively a harmless instruction that could be ignored. So the first instruction of his program was that and on one machine the code simply ran from the start; on the other, it jumped to code that was valid on the other machine.
That leads me to your first programming challenge: write a program that will compile both as C and as C++ but will do different things. To keep things simple you need to use a GCC C and C++ compiler. The code must compile for the current versions of C (11) and C++ (14).
The entries will be judged on two criteria.
- One (subjective): how different the output is for the C and C++ versions.
- Two: the ratio of instructions executed in the C version to the overall number of instructions in the original source code. In other words you should strive to have the maximum amount of commonality.
There is a further limitation in that you may only use standard header files.
Notes:
More fields may be available via dynamicdata ..