The Klein bottle was first described in 1882 by the German mathematician Felix Klein. It is an example of a non-orientable surface with no clear boundary. If likened to a bottle, it will be a bottle which you can never fill up. It is a two-dimensional manifold against which a system for determining a normal vector cannot be consistently defined. Its surface will never end.
On the occasion of the first anniversary of the Ontology MainNet launch, we would like to pay our respect to every blockchain developer by presenting “the Ontology Klein Bottle Contest”, a technical challenge with unlimited solutions. To encourage developers push back the frontiers of blockchain technology, we will choose the best solution in a week’s time and give away tens of thousands of ONG as rewards.
Just as you can never fill up a Klein Bottle, it is nevertheless a great achievement to explore the limits of the profound meaning within the limited space.
A regular expression is a sequence of characters that define a search pattern. Usually such patterns are used by string searching algorithms for "find" or "find and replace" operations on strings, or for input validation. Most programming languages today offer standard library of regular expression. However, smart contracts on the Ontology platform do not have a well-developed regular expression standard library yet.
The challenge is to develop a simple rule regular expression for smart contracts on the Ontology platform. The matching rules are excerpted from POSIX Basic Regular Expression as follows.
c matches any literal character c
. matches any single character
[] matches any one character listed between the brackets
[^] matches any one character not listed between the brackets
? matches any character one time if it exists
* matches zero or more occurrences of the previous character
+ matches declared element one or more times
^ matches the beginning of the input string
$ matches the end of the input string
For example, pattern x.y
can match xay
and x2y
, but not xy
or xaby
. ^.$
can match any single-character string, while ^*$
can match any string.
Smart contract template:
def Main(regex, args):
return match(regex, args[0])
def match(regex, target):
// Your Implementation Here
Test case examples:
"abc" ~ "abc"
"a.c" ~ "abc"
"a[123]c" ~ "a1c"
"a[^abc]c ~ "a1c"
"a?c" ~ "c"
"a*c" ~ "abbbbc"
"a+c" ~ "ac"
"^a" ~ "abc"
"^*c" ~ "abbbbc"
"^$" ~ ""
- Participants need to pass all the 200 test cases we have prepared. All characters are ASCII characters and the longest string has 1024 characters.
- Participants who used the fewest Ontology NeoVM instructions to complete all the tests will be the winner.
Reward:
- Basic Reward Pool 50,000 ONG
- Developer Boost Reward Pool (up to 50,000 ONG)
The Developer Boost Reward Pool is the extra incentives to encourage developer participation. 100 ONG will be added to the reward pool every time a new developer joins the Contest.
Get GitHub-verified ONT ID
- Download ONTO or install from appstore
- Click “ONT ID” and sign up
- Complete GitHub ID verification.
Submit the following information via Registration Form:
- GitHub-verified ONT ID
- GitHub account
- Your email address
After submitting the above information, every time developers use their GitHub account to Fork and Star the Ontology MainNet code, the boost value will be added once, which means 100 ONG will be added to the Developer Boost Reward Pool. The amount of the Reward Pool will be updated every 24 hours, please refer to the Ontology official Twitter account for the latest amount. You can find the Ontology MainNet code here.
After completing development and testing, developers must call the registry contract to record their ONT ID and contract hash (SHA-256) on the blockchain. You'll have to pay 0.01 ONG for calling this contract as transaction fee. The tutorial is here.
After completing the above steps, developers need to submit their contract source code via submission form. The information you need to submit includes:
- Your ONT ID and email address
- Transaction hash called by the registry contract
- Contract code
- Code submission time: 10:00 June 30th - 10:00 July 4th (UTC)
- Participants who used the fewest instructions to pass all the tests will be the winner (for more details please refer to the challenge rules)
- If there is more than one optimal solution, then participants who submitted first will be the winner. The submission time is determined by the time they called the registry contract
- If developers submit their codes more than once, we will judge the result based on the codes in the final submission.
The winner list will be announced on July 5th (UTC).
For further details, please refer to Ontology’s official Facebook or Twitter.
If the winner confirms to claim the rewards for the first round, then they can get 60% of the entire reward pool (Basic Reward Pool + Developer Boost Reward Pool). After that, the winner’s journey in Ontology Klein Bottle Contest ends.
The winner needs to decide whether to claim the reward within 24 hours after the announcement by replying to our email, otherwise, the reward will be automatically given to the winner.
All winners in the first round can accept challenges in the next round where all candidates have the chance to win the entire reward pool.
Time: Within 24hrs of the Twitter announcements of winners accepting challenges.
In this round, participants need to submit their codes to ontio/Anniversary via GitHub Pull Request. The list of developers who ranked in the top 3 in the previous round will be announced at the beginning of this round.
Rules:
- All developers can continue to sign up and submit their solutions, including the first-round winners.
- If the optimal results in this round are better than the last round, then the developers will win the entire reward pool, instead of the 60% rewards in the last round.
If you have any questions, please ask us on Ontology Discord.