I've spent most of my life coding C++, and dabbling in other languages (most recently Python).
But the list of programming languages that I've never written a line of code in is starting to get big, and I think it's time I put an end to that.
So I've decided I'm going to try to do a little experimenting with other programming languages, and wanted other coders here to join me, and post your updates here.
For my first stop on the tour, I spent today coding in Go
I was inspired to write a program to solve a homework assignment given to the daughter of one of our fellow DC members.
The assignment is as follows:
"Given a set of numbers, and a target value, find an expression using + - * / and which uses each of the numbers exactly once, which reaches the target."
For example, given the numbers [2, 3, 6, 15] find an expression that reaches the target value of 7.
Note that there may be multiple expressions that reach a given target value. Rather than find a specific solution to a specific problem -- I was more interested in writing a program that would find ALL possible expressions given a set of n numbers, and then looking for particular targets which have few possible solutions, reasoning that these would be nice and hard puzzles to solve.
I started out by trying to calculate a formula for the # of possible expressions of n numbers. That turned out to be a very fun mathematical journey, and I encourage the mathematically inclined among you to give it a try. I'll share my formula later so as not to spoil the problem.
Anyway, so today I coded this program in Go. Looks like about 400 lines of code, and definitely a non-trivial and interesting project.
Speed and memory seemed quite reasonable, no complaints there. Error messages were reasonable.
I'll post the source code soon after I give anyone else a chance to have some fun.
However, I can't say I really enjoy Go after my day with it. Some parts of it are ugly and unpleasant, and I don't approve of many of the language design decisions.
In fairness, this wasn't really something that made use of the real strengths of Go, so perhaps it wasn't the fairest of tests.
Here's a test for you if you decide to try coding this program. I will give out a prize of a free DC mug for anyone who can solve this by writing their own version of this program before I post my source code at the end of the month.
Given the numbers [2 3 4 5 6 7 8], find TWO good, and fundamentally different, solutions that yield the target value of "2741"