GithubHelp home page GithubHelp logo

aakkostus's Introduction

Coding assignment

Description

Code a simple implementation of a routine that sorts a string based on a transpose keystring.

The keystring is "QWERTYUIOPÅASDFGHJKLÖÄZXCVBNM" and the string to be sorted is"eke-elektroniikka"

Implementation

I deciced to use qsort as internal implementation because it is trusted part of the standard library and can easily be adapted to this kind of task just by tweaking the sortinc callback function.

I created an indexing function that returns the relative position of any given character in the keystring and used that as basisi of the qsort. As the keystring is all-caps and assignment specifies a lowercase-string as input I decided to convert lowercase characters to uppercase before indexing.

The specified inputstring contains a character not present in the keystring, namely "-", so I decided to clean the inputstring from illegal characters before sorting.

Testing

I tested the indexing function using corner cases of the end letters of the alphabet (a, A, ö, Ö) and end letters of the keystring (q, Q, m, M)

Notes

The original assignment text seems to contain an error, the resulting string that is presented is not correct. ("eeeertiioakkkln" is one k-letter shorter than the correct answer "eeeertiioakkkkln")

Code compiles and lints without errors on my fedora box, using gcc 9.3.1 20200408 (Red Hat 9.3.1-2) and splint 3.1.2

aakkostus's People

Contributors

juiceme avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.