Skip to Content
Event Information

SAP Community Coding Challenge 2 – Contestants

Here’s a list of the SAP Community Coding Challenge 2 contestants who were successful in their submissions. Congratulations to them all! 

Following the update blog post and the live stream last week (recording here) I thought it was time for a main list of successful contestants.

The current SAP Community Coding Challenge has seen a wonderful array of submissions, and for that we thank you all. Over the course of the submission period we received 79 in total, with a success rate (i.e. where the submission produced the correct answer) was over 90%, which is great.

Styles

We saw all kinds of styles, from beginner JavaScript coders to advanced, some opting for a class based approach, others for a more functional one. With a language as flexible as JavaScript it was clear that we were going to see folks’ personalities in places too … from the use of whitespace, to how variables and functions were named and capitalised, to how commenting was used to good effect (or, in some cases, how no comments were used at all).

Speed

Another factor that came up was how performant the submissions were. Although speed was not a factor explicitly stated in the original post, it was clear that many of you enjoyed making your submissions run as fast as possible, and so we saw a number of common optimisations. The most common was a cache of the sequence lengths for a given starting term, so that when working through a sequence, if the term arrived at was one already seen, that sequence could be short-circuited there and then by adding the length thus far to the length for that term.

There were also more subtle optimisations, such as the use of the bitwise operator to check for an odd number, which did give a very slight but ultimately perceptible speed advantage at the scale of the problem. Commonly, checking for an odd (or even) number is done using modulo arithmetic, like this:

isOdd = x => x % 2 !== 0

(i.e. x is odd if the remainder of x / 2 is not zero)

But there’s the bitwise AND operator that was used by some:

isOdd = x => x & 1

(i.e. x is odd if x, when AND-ed with 1 (binary 00000001) gives a non-zero value (i.e. 1))

Use of libraries

For the most part, the submissions were independent of any external (3rd party) library. JavaScript, esp. in the Node.js flavour, has a cornucopia of libraries that can be used to good effect (although sometimes this is not so much the case, but that’s a story for another time!)

We did see a small amount of library use, for example the mathjs library (which offers a max function, amongst other things), yosay, for making output a little more fun, and Ramda, a functional programming library offering a rich set of functions. Indeed, we had one or two submissions that were “Ramda-oriented”, which delighted me no end.

Lack of range

One thing that was clear, and common, was that many of you came across the issue that there’s no native ‘range‘ function in JavaScript – to generate a range of numbers in a simple way. Of course, there’s the more procedural ‘for loop’ approach, but for those wanting to level up and move away from telling the machine how to do something it should already know, you came up with a lovely, err, array of approaches. See if you can spot them all in the submissions.

Out of bounds

There were a couple of submission that didn’t quite conform to the submission requirements but we thought they were fun and creative nonetheless (and accompanied a proper submission, which made things OK :-)).

There were also some submissions that sadly didn’t produce the correct result; the most common issue was a focus on the initial example in the problem statement, rather than the question itself.

The submissions

So without further ado, here is the complete list (in no particular order) of successful submissions. Take a look at your fellow community members’ submissions and see how they coded their solutions – I for one really enjoyed studying all of them. There are some really thoughtful and educational pieces in this collection. Thank you all.

Contestant Submission
Alexander Frank https://repl.it/@AlexMFrank/ccc2 (see also https://answers.sap.com/articles/13036691/ccc2-my-runtime-optimized-and-hopefully-readable-s.html)
Heiko Walter Bernhart https://repl.it/repls/ScornfulMicroWebpage
Olivier Huet https://repl.it/@djgalak/SAPCommunityCodeChallenge02
Grzegorz Malczewski https://jsfiddle.net/3vwt4gzu/10/
António Vaz https://repl.it/repls/GrowlingUniqueReality
Deepak Tewari https://jsfiddle.net/Gunner708/qds20ern/
Juzer Ali https://jsfiddle.net/j9ktxmws/
Mark Jans https://jsfiddle.net/hwoy0dzk/
Rikus van Vuuren https://repl.it/@rikusv/LongestCollatzSequence
Sergei Haller https://repl.it/@bistrOmath/CCC2-Compute-Manually (see also https://answers.sap.com/articles/13035066/ccc2-two-completely-different-approaches-for-solvi.html)
Christian Drumm https://repl.it/@ceedee666/SAP-Community-Code-Challange-2-1
Frank Schuler https://answers.sap.com/articles/13035919/ccc2-solving-the-longest-collatz-sequence-problem.html (using SAP Data Intelligence)
Geert-Jan Klaps https://jsfiddle.net/k5uomf1e/
Paweł Graczyk https://runkit.com/smentek/sap-community-coding-challenge-nr.2
Matthias Bartsch https://repl.it/@mbartsch71/ACC2
Moritz Lautenschlager https://repl.it/repls/FlawedEllipticalPixels (see also https://github.com/MoritzLaut/SAP-Community-Coding-Challenge)
Kleber da Silva Santos https://jsfiddle.net/cyk30nx7/1/
Christian Drumm https://repl.it/@ceedee666/SAP-Community-Code-Challange-2-2
Christian Drumm https://repl.it/@ceedee666/SAP-Community-Code-Challange-2-3
Deepak Tewari https://answers.sap.com/articles/13038623/ccc2-my-approach-for-challenge-no-2-as-a-ui5-devel.html
Siva Rama Krishna Pabbaraju https://plnkr.co/plunk/soCuCWNdD8lZLRzm
vinay s  https://repl.it/@vinays66/Challenge2Collatz
Deepak Tewari https://jsfiddle.net/Gunner708/5aL8nexd/
Morten Wittrock https://repl.it/repls/TemptingInstructiveForce
Alessandro Spadoni https://repl.it/@AlessandroSpado/SAPCommunityChallenge2
Gaurav Chaudhary https://codepen.io/zgaur/pen/YzyEVqQ
K Jyothir Aditya https://repl.it/@kjyothiraditya/AwkwardZealousCodeview
Vinita Kasliwal https://jsfiddle.net/j901qpdm/
Sumit Kundu https://repl.it/@SumitKundu/Collatz
Andrew Barnard https://repl.it/@D023604/SiennaWateryProspect
Jorge L. Casanova Joven https://jsfiddle.net/41toLzu9/
Carlos López Vázquez https://jsfiddle.net/Lpw614aq/18/
Raúl Ruiz https://repl.it/@raulruiz4/Challenge-Version3
Huseyin Dereli https://sccc2.glitch.me/
Raúl Ruiz https://repl.it/@raulruiz4/Challenge-Version5
Ajit Kumar Panda https://jsfiddle.net/Ajit_Kumar_Panda/aetuw5L0/6/ (see also https://answers.sap.com/articles/13043696/ccc2-project-euler14-longest-collatz-sequence-solu.html)
Jaime Rolo Cáceres https://jsfiddle.net/rj4q2ude/
Peter Jaeckel https://jsfiddle.net/hapejot/5etnfczs/
Rahul Gupta https://answers.sap.com/articles/13047125/ccc2-longest-collatz-euler-14-solution-using-recur.html
Michael Zwick https://jsfiddle.net/m2rt1d4e/
Renato Rodrigues https://answers.sap.com/articles/13045764/ccc2-longest-collatz-sequence-problem.html
Thales Batista https://repl.it/@thalesvb/Collatz-Functional
Thales Batista https://repl.it/@thalesvb/Collatz-MultiImpl
Alexander Karpov https://repl.it/@karpovas1505/ExcitingFrenchBoastmachine
Alfonso Carlos Tello Mora https://jsfiddle.net/alfonsotellomora/7hz3vr1g/1/
Andreas Münster https://repl.it/@andreasmuenster/SapCodingChallenge2
Blake McKeany https://jsfiddle.net/bmckeany/0ev53jzr/2/
Carlos Fortes Román https://jsfiddle.net/59vk0Lxa/1/
Domi Bigl https://repl.it/@bigld/SAPCCC2
Flavio Ciotola https://repl.it/@flaviociotola/CollatzSequence
Kevin Hu https://repl.it/@whocann/CollatzProblem
L López Burgos https://repl.it/@shokimc/Js
Mateusz Adamus https://jsfiddle.net/0a74ecf6/ (see also http://mateuszadamus.pl/sap/sap-community-coding-challenge-nr.2.html)
Miguel Fiúza https://repl.it/repls/KnobbyGiantToolbox (see also https://answers.sap.com/articles/13048142/ccc2-getting-the-longest-collatz-sequence-from-one.html)
Marcello Urbani https://repl.it/@marcellourbani/longestCollatzimmutable#index.js
Marcello Urbani https://repl.it/@marcellourbani/longestCollatzfastest#index.js
Marcello Urbani https://answers.sap.com/articles/13048264/ccc2-longest-collatz-euler-14.html
Olmo Ruiz Arjona https://jsfiddle.net/hqdpuo2g/7/
Rohit Singhal https://jsfiddle.net/rohit_rahi/ej4dv7no/33/
Miguel Santana https://answers.sap.com/articles/13047029/ccc2-the-longest-collatz-sequence-solution.html
Kristoffer Hell https://js.do/clippersys/439087
Kristoffer Hell OO_SAPCommunityCodingChallengeNr2_20200514
Kadir Özgür https://repl.it/@kadirozgur/LongestCollatzSequence
Mahesh kumar Palavalli https://repl.it/@MaheshKumarKum3/ccc2-2
Nischchal Manjanbail https://repl.it/@NishchalManjanb/map-approach
Nischchal Manjanbail https://repl.it/@NishchalManjanb/cached-collatz
Nischchal Manjanbail https://repl.it/@NishchalManjanb/Basic-Collatz-Soln (see also https://answers.sap.com/articles/13049099/ccc2-different-approaches-and-ideas-for-solving-lo.html)
Markus Urschel https://jsfiddle.net/megges/bvu8choa
Monalisa Biswal https://jsbin.com/kogolot/edit?html,console,output
Jesús Pacheco Patricio https://repl.it/join/rpsvffuv-jesuspacheco
Senthil Kumar https://answers.sap.com/articles/13049204/ccc2-longest-collatz-sequence-challange.html
Tom Demuyt https://jsfiddle.net/konijn_gmail_com/jgv1xLyo/

Congratulations to everyone!

Check out the recording of last week’s live stream for a look at some of these.

Next steps

So now we have all the successful submissions listed here, we’ll be posting an entry into the Community Q&A area later this week with a shortlist of finalists, for you to vote on as the overall winner. Stay tuned!

 

Appendix – Performance testing

For those interested, I loaded all the submissions that I could into a local project, and ran them through a little script to get a rough idea of the throughput. For some of the submissions that presented the output in HTML, I had to make minor modifications to allow them to be executed directly in Node.js at the command line, but other than that, I ran the scripts unaltered.

I used hyperfine, a command line benchmarking tool, which worked really well for me. I wrapped it in a script for convenience. Here’s a screenshot of the tool in action — showing an entry that was outside of the allowed submissions 😉 — and the wrapper script itself. Share & enjoy!

A%20screenshot%20of%20hyperfine%20in%20action

#!/usr/bin/env bash

# Performance tests
# Run as either 'perftest' (and pick a submission) or 'perftestall' (via the symlink) to process all of them.
# Uses 'hyperfine' with a single run as warmup, and the average taken from 10 (the default) runs.

subdir=submissions

heading() { figlet -w $(tput cols) $@ | lolcat; }
pick() { ls -1 ${subdir} | fzf; }

if [ $(basename $0) = "perftestall" ]
then
  candidatelist=$(ls -1 ${subdir})
else
  candidatelist=${1:-$(pick)}
fi

for sub in ${candidatelist}
do
  heading ${sub} \
  && hyperfine --time-unit millisecond --warmup 1 "node ${subdir}/${sub}/index"
done
/
A%20screenshot%20of%20hyperfine%20in%20action
3 Comments
You must be Logged on to comment or reply to a post.