Looking for Concept Exercise ideas

Exercism has practice exercises to implement rational numbers and complex numbers from scratch. However, several language tracks have these built-in as standard types, so a few of us have been trying to add these to each track’s learning syllabus.

  • Python has merged the concepts for fractions and complex-numbers after @BethanyG and I wrote them a year ago, though without associated exercises they are not yet easily visible to students .
  • Julia will soon have the same problem, with both concepts drafted (PRs #800 and #801) and a syllabus taking shape (14 PRs merged in the last week!).
  • The R syllabus is, regrettably, pretty moribund at the moment, but there is PR #390 for a complex-numbers concept.
  • I can’t immediately think of other tracks that have these types available in the test runner, but maybe there are one or two.

Bethany and I exchanged a few vague ideas last year for exercises, but I’m struggling to find those messages at the moment. They were soon pushed aside by more urgent priorities (mainly 48in24 support). As any exercise could now be used on multiple tracks, it may be time for another think.

Any suggestions?

And in case you wondered, it’s not “too mathy”. Given the use cases and user base for these languages, there are good reasons for these to be standard types, exactly like float and integer. It’s not like adding them to the JavaScript track!

I am struggling to find that thread as well. I will keep looking. I do have two things we were batting about tho:

  1. Some sort of 3D Darts tossing, mayap? existing darts exercise, darts video, darts writeup at 3Blule1Brown
  2. Save Schrödinger’s Cat

Will add more as I find more. :slightly_smiling_face:


  1. As a series of problems: Power Flow and Optimal Power Flow. This includes graphs and graph theory as well. Power Flow & Optimal Power Flow, and a Julia forum question with related issues
  2. Using complex numbers for lat and long. Real Python Bermuda Triangle
1 Like

A distinct but related issue is finding an exercise for the “splat” and “slurp” operators in Julia. These are related to *args and **kwargs in Python for argument expansion (and its inverse). I think some other languages use splat (Ruby?), spread (JS?) or gather/scatter.

I feel there must be an existing concept exercise out there that includes this, but I haven’t yet found it. Any suggestions?

In Python, we folded *args and **kwargs into Unpacking and multiple assignment with Locomotive Engineer as the exercise, but we might double back and handle the special case of *args and **kwargs use as function arguments.

It might be better to look explicitly at spread and splat in JS and Ruby, since Python uses splat in a bunch of different ways.

From memory, fractions could stay simple and go down the route of middle-school arithmetic (I don’t have kids, and my own education long since vanished over the memory horizon).

For complex numbers, we agreed that asking for digital signal filters or bandgap energies in photovoltaics would get us into trouble with Exercism management. We need something simpler!

Brilliant, thank you! I figured these must be out there in the wild. We have

  • python/locomotive-engineer (which I did last year…)
  • javascript/elyses-destructured-enchantments

I’ll go through them and decide which is the best fit for splat/slurp, with suitable modification.

I’m sticking with my prediction that the more mathy ones will be a bit harder.

1 Like

So. For fractions, this site has a bunch of ideas, one of which is cooking.
This PDF has a bunch of additional cooking themed problems all centered around fractions.

Some riffs/thoughts:

  • I think it would require modification, but the Elixir track has Kitchen Calculator that might be a starting point for either calculating quantities or “scaling up” something.
  • You might also consider an extension of Lasagna where ingredients get added in fractional amounts based on some metric or requirement, and adding ingredients changes prep and bake time by some fractional amount. Like making it three-cheese Lasagna where each cheese is 1/3 of the amount, etc. and that increases prep time by 20% and bake time by 5%…to just pull numbers out of my arse.
  • Pizza Slices could be modified to use fractional calculations… I think?
  • Pizza-Pi from the lisp track could be extended or modified, I think. Similar to my suggestions for Lasagna above.
1 Like

Thanks, that’s a great bunch of suggestions, which I’ll work through over the next day or so. I need to do the splat/slurp stuff first, plus a couple of other things, but once we have a Julia exercise for rationals I’m sure it will be adaptable to Python fractions. Let’s get mathy!

(Within limits. The draft plan for the first 30 or so concepts still doesn’t include Linear Algebra, though I’m hopeful for the longer term.)

Also, I should have been clearer that @depial has been superb in pushing the early syllabus through review, revision and merge. There can’t be a syllabus without a very engaged partner.

1 Like

Caveat: I’ll see what I can do in the next week or so, but there may be another hiatus (much shorter than the recent 4-month gap, I hope). I have a visitor flying over from England to spend 10 days with me, and @depial also has other commitments mid-March. Lack of progress will not imply lack of enthusiasm.

1 Like

@Nerwosolek has one suggestion for a Complex exercise on Discord. We should continue the discussion here.

I see we now need complex numbers concept exercise. What about doing our own based around different simple applications of such numbers. Like the example of 2D rotation I proposed in a review:

x <- 1
y <- 2
angle <- pi/2
rot_z <- complex(modulus = 1, argument =  angle)
rot_z * (x + 1i*y)

That might be a good one! As a related note, IIRC Julia has a WIP exercise that does some similar translate/transform on a 2D image:

exercism-matrix

I’ve taken a look at it several times, but was unable to get my brain to reformat/adapt it fully to complex-numbers (I think rotating more than 90 will be needed, and also translating diagonally). But maybe we can think it through as a team? I haven’t taken a close look at it recently, being distracted by the Bootcamp and other issues.

1 Like

Also pinging @depial, who is deeply involved in the Julia syllabus currently.

Along the lines of 2D vector rotation, I was considering that we could create an exercise based around the idea of a stopwatch (to give it a bit of a “real worldish” backstory), which uses the argument to represent seconds and the magnitude to represent minutes. I think the abs and angle methods might be able to be used wisely to keep the need for familiarity with the math to a minimum.

1 Like

I’ll see if I can mock something up in the coming days

1 Like

That would be great!

I’m a bit tied up at the moment, trying to get inventory-management finished, plus getting my cracked windshield replaced urgently.

2 Likes

I’ve come across a bit of a hiccup. The angle method returns a value between -π and π, with the discontinuity on the negative real axis, while I’m accustomed to the argument being between 0 and 2π with the discontinuity on the positive real axis…

I was considering writing an arg function for the student to use in this exercise, which goes between 0 and 2π with the discontinuity on the positive imaginary axis, so it would better fit the concept of a clock, but I’m not sure if this is straying too far from the two conventions noted above.

My current arg implementation:
arg(z) = angle(z*cispi(1/2))-π
(Note: this returns a negative argument, since we’re rotating clockwise.)

I figure this could even be used as an example of how rotations are handled with complex numbers with an explanation of the function, considering there is one in the definition to shift the discontinuity (where cispi(x) == exp(im*π*x)).

Let me know if you think this is still worth pursuing, or if something should be designed around the convention that the inbuilt angle method uses.

Edit: Also a further complication to note is that, if we decide to include magnitude changes (i.e. use more than seconds), we’d have to choose careful examples so as to avoid the need for modular arithmetic. Of course, the stopwatch could be made to be an hour long, with only rotations allowed…

Is this too close to All Your Base?

I checked around, and this seems to be the usual programming convention: Python, R and Matlab all do the same. I don’t know if they are all using the same C code internally, but I wouldn’t be surprised.

Would it be possible to design an exercise that makes the students do the conversion as one of the tasks? Then it would be fairly easy to port to other tracks,

Would it be possible to design an exercise that makes the students do the conversion as one of the tasks?

We could do that. It would make up the meat of the exercise, if the idea was to be based around rotations. This also might have the nice side effect of teaching students how to manage different conventions.

I’m currently a bit under the weather, so I’ll give it another look when I’ve got a bit more energy/concentration.

1 Like

You have my heartfelt sympathy - I lost several days last week with a streaming cold and zero energy, so I know how it feels.

I’m currently working on my tax return, which should ensure a relapse (if not a nervous breakdown). People in Britain are quite startled when I try to explain that dealing with the IRS makes me quite nostalgic for the simplicity of the UK Inland Revenue.

1 Like