DEV Community

Discussion on: Daily Challenge #259 - Duplicate Encoder

Collapse
 
jessekphillips profile image
Jesse Phillips • Edited

I'm a little late, but rather than solving the problem I instead took the different approaches people posted, wrote them in D (dlang.org) and did some basic performance ploting.

GitHub logo JesseKPhillips / devto-challenge259-dupencoder

An attempt to capture performance with different implementation approaches for a Challenge

Dev.to has a daily challenge and I happened upon the Duplicate Encoder #259 for 2020

I didn't really want to solve the challenge per se, so instead I took the top comments for implementation and wrote them in D Lang.

For clarity these are all implemented in D and do not reflect the language performance that the implementation is based on.

Image of Yaktocat

The "Haskel" implementation utilizes a range based map/filter approach to detecting duplicates.

The "PHP" implementation utilizes a nested loop apporach to intentify that the character occurs again.

The "Pointer" implementation was just something I wanted to try. It duplicates the array so it is mutable after which point it does not loop over the arry twice and instead stores pointers to the location of the same character. It takes quite a bit for this approach to see any performance gain.




I might do more work on this and write up my own post about what I did. Keep in mind that I use the terms 'php' and 'haskel' not to indicate the performance of those languages... it was just the language utilized for the approach taken. All timings are from D.