JS Developers & Regex Experts Wanted: Javascript Coding Task

in #utopian-io7 years ago (edited)

[UPDATE]

We have received enough contributions for this task request already. Thanks for participating!

Repository

https://github.com/utopian-io/v2.api.utopian.io

Utopian.io is looking for an exceptional contribution from skilled JS Developers and Regex experts. The task is quite straightforward in terms of coding effort, but it requires proficiency in handling regular expressions.

utopian-post-banner.png

Task Details

Create a GitHub gist with a Javascript script that can perform the following:

Receive text as input
Parse the text and compare it with a set of regular expressions
Return a different object or an error result based on the scenarios listed below

Possible text scenarios

@utopian-bot !utopian

In this scenario, the text contains a mention at the start and a predefined text !utopian right after, both of which never change.

If this condition is met, then return the following object:

{
    beneficiaries: [],
}
Possible Errors

The whole sentence is not properly formatted
Some parts are missing or
Unrelated text is contained

RESULT: Return an appropriate error.

@utopian-bot !utopian @mention1 @mention2 @mention3 @mention4

In this scenario, the text contains a mention at the beginning and the predefined text !utopian just as in the previous scenario, but also contains a variable set of additional mentions right after. These mentions may be one or more and should be unique.

In the event of such a scenario, the following object should be returned, dividing 100% by the number of mentions.

{
    beneficiaries: [
            {mention1: 25},
            {mention2: 25},
            {mention3: 25},
            {mention4: 25},
        ],
}
Possible Errors
  • The same username is mentioned multiple times
  • The text is not properly formatted, some parts are missing, or there is additional unrelated text.
  • There are more than 8 beneficiaries

RESULT: Return an appropriate error.

@utopian-bot !utopian @mention1:15% @mention2:35% @mention3:25% @mention4:25%

This scenario, which adds on to the previous ones, handles additional syntax and allows for custom percentages. The text requirements are the same for the initial mention, the predefined text that follows, as well as the preceding mentions.

When handling this text input, the following object must be returned (making sure the sum of all the percentages is exactly 100%):

{
    beneficiaries: [
            {mention1: 15},
            {mention2: 35},
            {mention3: 25},
            {mention4: 25},
],
}
Possible Errors
  • The same username is mentioned multiple times
  • The text is not properly formatted, some parts are missing or there is unrelated text in it
  • The sum of all the percentages does not equal 100%
  • There are more than 8 beneficiaries

RESULT: Return an appropriate error.

General Errors

These are meant to handle scenarios that do not match any ones mentioned above.

If the text input does not match any of the required scenarios above, then an error must be returned.
A more specific error should be returned if possible for that scenario

Deadline

Friday 25th of May 2018

Communication

Get in touch with @utopian#2644 on Discord

Rewards

Write a Utopian contribution under the Development category. The best contribution will be scored and rewarded accordingly.

Make sure to paste your contribution in the comments of this task as soon as you are done.

In Utopian we love collaboration. Use the comments section to collaborate with other awesome developers on this task and split the rewards via the beneficiaries, using a tool like @steemplus.

First Time Contributing in Utopian?

Learn how to contribute on our website

Utopian Witness

Vote for our witness!

Sort:  

There is some error with the second and third beneficiaries in JSON format

        {
            beneficiaries: [
                    mention1: 25,
                    mention2: 25,
                    mention3: 25,
                    mention4: 25,
                ]
        }

in suppose to be

{
      beneficiaries: [
            { mention1: 25 },
            { mention2: 25 }, 
            { mention3: 25 }, 
            { mention4: 25 }
      ]
    }

Ups u r right! :) We'll update it!

I almost going to finish it, will create a repo for that.

But need more testing LOL

cool made some updates to the post. Especially this possible error:

There are more than 8 beneficiaries

I think it's done, will add create a repo soon

https://gist.github.com/superoo7/6e8b440750596a1047e62356e976922c

Edit: Created a repo https://github.com/superoo7/utopian-task-regex (Testing with Jest)

Screen Shot 2018-05-24 at 9.22.25 PM.png

Let me check!!

Haven't optimise yet and a few error need a better explanation, but it works.

Didn't know the project is written in TypeScript, should have used that.

hmm that's a good time for developers

Can I ask five plumbers to install water in five duplicate houses and pay only one of them? That's basically a bounty system in software. Show these terms to five plumbers and I'll show you five runners.

what do you mean

Congratulation utopian.tasks! Your post has appeared on the hot page after 5min with 5 votes.
Thanks to @souldelas.

There should be probably handled a scenario when there are more than 8 mentions (you cannot set more than 8 beneficiaries).

That's perfectly true! @jakipatryk.

Loading...

Coin Marketplace

STEEM 0.26
TRX 0.25
JST 0.040
BTC 92903.81
ETH 3331.70
USDT 1.00
SBD 3.29