Skip to content

Commit

Permalink
feat: competition 2
Browse files Browse the repository at this point in the history
  • Loading branch information
1723newbit committed Sep 19, 2024
1 parent 12163ae commit 602798e
Show file tree
Hide file tree
Showing 14 changed files with 316 additions and 444 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { PROBLEM_DATASOURCE } from '../Problems/ProblemData';

type Props = {
currentUserContest?: IUserContest;
contestType: number;
};

const LIMIT_PAGE = 50;
Expand All @@ -50,7 +51,7 @@ const Leaderboard = (props: Props) => {
try {
return getListLeaderboard({
...params,
contest_type: UserContestType.COMPETITION,
contest_type: props.contestType,
});
} catch (error) {
console.error('Error fetching leaderboard data', error);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
export const PROBLEM_STRING_SIMILARITY_MARKDOWN = `
# StringSimilarity
### *Problem ID: 27*
 
A binary string is a string where each character is either $0$ or $1$. Two binary strings $a$ and $b$ of equal length are similar, if they have the same character in some position (there exists an integer $i$ such that $a_i=b_i$). For example:
 
* \`10010\` and \`01111\` are similar (they have the same character in position 4);
* \`10010\` and \`11111\` are similar;
* \`111\` and \`111\` are similar;
* \`0110\` and \`1001\` are not similar.
 
You are given an integer $n$ and a binary string s consisting of $2n−1$ characters. Let's denote $s[l..r]$ as the contiguous substring of s starting with l-th character and ending with r-th character (in other words, $s[l..r]=s_ls_{l+1}s_{l+2}...s_r$).
You have to construct a binary string $w$ of length $n$ which is similar to all of the following strings: $s[1..n], s[2..n+1], s[3..n+2], ..., s[n..2n−1]$.
 
## Implementation details:
 
Your smart contract needs to implement the following function(s):
\`\`\`js
function solve(string memory s) external returns (string memory);
\`\`\`
- $s$: One string --- the binary string $s$ of length $2n−1$. Each character $s_i$ is either \`0\` or \`1\`.
- This function need to return one string --- the corresponding binary string $w$ of length $n$.
- This function will be called exactly once with gas limit of $1\,000\,000$.
## Constraints:
- $1$ ≤ $|s|$ ≤ $1000$
 
## Examples:
 
### Example 1:
 
Consider the following function call:
\`\`\`js
solve(1)
\`\`\`
* $1$ is similar to $s[1..1]=1$.
The function therefore should return $1$.
 
### Example 2:
 
Consider the following function call:
\`\`\`js
solve(00000)
\`\`\`
* $000$ is similar to $s[1..3]=000$;
* $000$ is similar to $s[2..4]=000$;
* $000$ is similar to $s[3..5]=000$.
The function therefore should return $000$.
 
### Example 3:
 
Consider the following function call:
\`\`\`js
solve(1110000)
\`\`\`
* **10**1**0** is similar to $s[1..4]$=**1**1**10**;
* **1**01**0** is similar to $s[2..5]$=**1**10**0**;
* **10**1**0** is similar to $s[3..6]$=**10**0**0**;
* 1**0**1**0** is similar to $s[4..7]$=0**0**0**0**.
The function therefore should return $1010$.
 
### Example 4:
 
Consider the following function call:
\`\`\`js
solve(101)
\`\`\`
&textbf;
* 0**0** is similar to $s[1..2]$=1**0**;
* **0**0 is similar to $s[2..3]$=**0**1.
The function therefore should return $000$.
`;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
export const PROBLEM_FAVORITE_NUMBERS_MARKDOWN = `
# Favorite Numbers
### *Problem ID: 28*
 
Ringo loves the integer $200$. Solve the problem below for him.
Given a sequence $A$ of $N$ positive integers, find the pair of integers $(i,j)$ satisfying all of the following conditions:
* $1$ &le; $i < j$ &le; $N$
* $A_i - A_j$ is a multiple of $200$.
&nbsp;
## Implementation details:
&nbsp;
Your smart contract needs to implement the following function(s):
\`\`\`js
function solve(int256[] calldata a) external returns (uint256);
\`\`\`
- $a$: An array of length $n$.
- This function need to return the number of pair of integers satisfying the problem.
- This function will be called exactly once with gas limit of $1\,000\,000$.
&nbsp;
## Constraints:
- $2$ &le; $N$ &le; $2$ &times; $10^3$
- $1$ &le; $A_i$ &le; $10^9$
&nbsp;
## Examples:
&nbsp;
### Example 1:
&nbsp;
Consider the following function call:
\`\`\`js
solve([123, 223, 123, 523, 200, 2000])
\`\`\`
For example, for $(i,j)=(1,3)$, $A_1 - A_3 =0$ is a multiple of 200.
We have four pairs satisfying the conditions: $(i,j)=(1,3),(1,4),(3,4),(5,6)$.
The function therefore should return $4$.
&nbsp;
### Example 2:
&nbsp;
Consider the following function call:
\`\`\`js
solve([1, 2, 3, 4, 5])
\`\`\`
There is no pair satisfying the conditions.
The function therefore should return $0$.
&nbsp;
### Example 3:
&nbsp;
Consider the following function call:
\`\`\`js
solve([199, 100, 200, 400, 300, 500, 600, 200])
\`\`\`
The function therefore should return $9$.
`;
Loading

0 comments on commit 602798e

Please sign in to comment.