Skip to content

Instantly share code, notes, and snippets.

@ribaptista
Last active August 12, 2021 13:00
Show Gist options
  • Save ribaptista/c7ca73eee70059bbfc3e801b92df2e7e to your computer and use it in GitHub Desktop.
Save ribaptista/c7ca73eee70059bbfc3e801b92df2e7e to your computer and use it in GitHub Desktop.

Javascript Challenge

Instructions

In this challenge we will assess your coding skills. Create a little project implementing a solution for the problem shown below. After you're done, please push your code to a public GitHub repository.

Number Translation Problem

You have arrived in a long forgotten island, called kwego. After 3 days on this island, you realized that their numeric system is the same as the roman system but with different names and came up with the following kwegonian to roman translation table:

kil   	I
jin    	V
pol   	X
kilow 	L
jij   	C
jinjin	D
polsx  	M

Now you'll code a library to translate from kwego system to decimal system.

Your library should pass the following jest test suite:

const kwegoToDec = require('./your-lib');

test('kwego to decimal translation', () => {
  expect(kwegoToDec('kil kil kil')).toBe(3);
  expect(kwegoToDec('jin kil')).toBe(6);
  expect(kwegoToDec('kil jin')).toBe(4);
  expect(kwegoToDec('kilow pol')).toBe(60);
  expect(kwegoToDec('pol jij')).toBe(90);
  expect(kwegoToDec('polsx polsx pol jin kil')).toBe(2016);
  expect(kwegoToDec('polsx polsx jinjin pol kilow kil jin')).toBe(2544);
});

Implementing the library using pure funcional paradigm would be a plus!

Important notes

  • You should come up with the translation algorithm for yourself (that's the point of the challenge)
  • Feel free to look up online javascript documentation any time you need to!

Good luck!


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment