Have a suggestion?

Click here to suggest a blog item.

Newsletters Archive

Catch up with DonationCoder by browsing our past newsletters, which collect the most interesting discussions on our site: here.

Editorial Integrity

DonationCoder does not accept paid promotions. We have a strict policy of not accepting gifts of any kind in exchange for placing content in our blogs or newsletters, or on our forum. The content and recommendations you see on our site reflect our genuine personal interests and nothing more.


Latest News

July 19, 2022
Software Update

Jan 3, 2022
Event Results

May 13, 2020
Software Updates

Mar 24, 2020
Mini Newsletter

Dec 30, 2019
Software Updates

Jan 22, 2020
Software Updates

Jan 12, 2020
Newsletter

Jan 3, 2020
Event Results

Jan 2, 2020
Software Updates

Dec 30, 2019
Software Updates

April 27, 2019
Software Updates

Feb 26, 2019
Software Updates

Feb 23, 2019
Software Updates

Feb 14, 2019
Software Updates

Jan 6, 2019
Event Results

Dec 2, 2018
Software Updates

Nov 13, 2018
Software Releases

July 30, 2018
Software Updates

June 24, 2018
Software Updates

June 6, 2018
Software Updates

Apr 2, 2018
Fundraiser Celebration

Apr 2, 2018
Software Updates

Feb 24, 2018
Software Updates

Jan 14, 2018
Major Site News

Jan 10, 2018
Event Results

Latest Forum Posts

Our daily Blog

This page spotlights the most interesting posts collected from our forum every day.

You are viewing a specific blog item. Click here to return to the main blog page.

Experimenting with Other Programming Languages

blog clipart
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.
Answer: 2+(15/(6-3))



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"

Continue reading the rest of the entry and discuss..



Share on Facebook