diff --git a/src/CodingContract/Contract.ts b/src/CodingContract/Contract.ts index bc8ba17fc..3a17dc9fc 100644 --- a/src/CodingContract/Contract.ts +++ b/src/CodingContract/Contract.ts @@ -88,7 +88,7 @@ export class CodingContract { } getDescription(): string { - return CodingContractTypes[this.type].desc(this.getData()).replaceAll(" ", " "); + return CodingContractTypes[this.type].desc(this.getData()); } getDifficulty(): number { diff --git a/src/CodingContract/contracts/Compression.ts b/src/CodingContract/contracts/Compression.ts index 36298365b..d20569f30 100644 --- a/src/CodingContract/contracts/Compression.ts +++ b/src/CodingContract/contracts/Compression.ts @@ -17,13 +17,13 @@ export const compression: Pick< "are encoded as a single ASCII digit; runs of 10 characters or more are encoded by splitting them", "into multiple runs.\n\n", "You are given the following input string:\n", - `    ${plaintext}\n`, + ` ${plaintext}\n`, "Encode it using run-length encoding with the minimum possible output length.\n\n", "Examples:\n\n", - "    aaaaabccc            ->  5a1b3c\n", - "    aAaAaA               ->  1a1A1a1A1a1A\n", - "    111112333            ->  511233\n", - "    zzzzzzzzzzzzzzzzzzz  ->  9z9z1z  (or 9z8z2z, etc.)", + " aaaaabccc -> 5a1b3c\n", + " aAaAaA -> 1a1A1a1A1a1A\n", + " 111112333 -> 511233\n", + " zzzzzzzzzzzzzzzzzzz -> 9z9z1z (or 9z8z2z, etc.)", ].join(" "); }, generate: (): string => { @@ -85,14 +85,14 @@ export const compression: Pick< "is the start of a new chunk. The two chunk types alternate, starting with type 1, and the final", "chunk may be of either type.\n\n", "You are given the following LZ-encoded string:\n", - `    ${compressed}\n`, + ` ${compressed}\n`, "Decode it and output the original string.\n\n", "Example: decoding '5aaabb450723abb' chunk-by-chunk\n\n", - "    5aaabb           ->  aaabb\n", - "    5aaabb45         ->  aaabbaaab\n", - "    5aaabb450        ->  aaabbaaab\n", - "    5aaabb45072      ->  aaabbaaababababa\n", - "    5aaabb450723abb  ->  aaabbaaababababaabb", + " 5aaabb -> aaabb\n", + " 5aaabb45 -> aaabbaaab\n", + " 5aaabb450 -> aaabbaaab\n", + " 5aaabb45072 -> aaabbaaababababa\n", + " 5aaabb450723abb -> aaabbaaababababaabb", ].join(" "); }, generate: (): string => { @@ -120,17 +120,17 @@ export const compression: Pick< "is the start of a new chunk. The two chunk types alternate, starting with type 1, and the final", "chunk may be of either type.\n\n", "You are given the following input string:\n", - `    ${plaintext}\n`, + ` ${plaintext}\n`, "Encode it using Lempel-Ziv encoding with the minimum possible output length.\n\n", "Examples (some have other possible encodings of minimal length):\n", - "    abracadabra     ->  7abracad47\n", - "    mississippi     ->  4miss433ppi\n", - "    aAAaAAaAaAA     ->  3aAA53035\n", - "    2718281828      ->  627182844\n", - "    abcdefghijk     ->  9abcdefghi02jk\n", - "    aaaaaaaaaaaa    ->  3aaa91\n", - "    aaaaaaaaaaaaa   ->  1a91031\n", - "    aaaaaaaaaaaaaa  ->  1a91041", + " abracadabra -> 7abracad47\n", + " mississippi -> 4miss433ppi\n", + " aAAaAAaAaAA -> 3aAA53035\n", + " 2718281828 -> 627182844\n", + " abcdefghijk -> 9abcdefghi02jk\n", + " aaaaaaaaaaaa -> 3aaa91\n", + " aaaaaaaaaaaaa -> 1a91031\n", + " aaaaaaaaaaaaaa -> 1a91041", ].join(" "); }, generate: (): string => { diff --git a/src/CodingContract/contracts/Encryption.ts b/src/CodingContract/contracts/Encryption.ts index 83dff80e8..c71a9dc32 100644 --- a/src/CodingContract/contracts/Encryption.ts +++ b/src/CodingContract/contracts/Encryption.ts @@ -14,7 +14,7 @@ export const encryption: Pick< "For example, with a left shift of 3, D would be replaced by A, ", "E would become B, and A would become X (because of rotation).\n\n", "You are given an array with two elements:\n", - `  ["${data[0]}", ${data[1]}]\n`, + ` ["${data[0]}", ${data[1]}]\n`, "The first element is the plaintext, the second element is the left shift value.\n\n", "Return the ciphertext as uppercase string. Spaces remains the same.", ].join(" "); @@ -73,25 +73,25 @@ export const encryption: Pick< return [ "Vigenère cipher is a type of polyalphabetic substitution. It uses ", "the Vigenère square to encrypt and decrypt plaintext with a keyword.\n\n", - "  Vigenère square:\n", - "         A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \n", - "       +----------------------------------------------------\n", - "     A | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \n", - "     B | B C D E F G H I J K L M N O P Q R S T U V W X Y Z A \n", - "     C | C D E F G H I J K L M N O P Q R S T U V W X Y Z A B\n", - "     D | D E F G H I J K L M N O P Q R S T U V W X Y Z A B C\n", - "     E | E F G H I J K L M N O P Q R S T U V W X Y Z A B C D\n", - "                ...\n", - "     Y | Y Z A B C D E F G H I J K L M N O P Q R S T U V W X\n", - "     Z | Z A B C D E F G H I J K L M N O P Q R S T U V W X Y\n\n", + " Vigenère square:\n", + " A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \n", + " +----------------------------------------------------\n", + " A | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \n", + " B | B C D E F G H I J K L M N O P Q R S T U V W X Y Z A \n", + " C | C D E F G H I J K L M N O P Q R S T U V W X Y Z A B\n", + " D | D E F G H I J K L M N O P Q R S T U V W X Y Z A B C\n", + " E | E F G H I J K L M N O P Q R S T U V W X Y Z A B C D\n", + " ...\n", + " Y | Y Z A B C D E F G H I J K L M N O P Q R S T U V W X\n", + " Z | Z A B C D E F G H I J K L M N O P Q R S T U V W X Y\n\n", "For encryption each letter of the plaintext is paired with the corresponding letter of a repeating keyword.", "For example, the plaintext DASHBOARD is encrypted with the keyword LINUX:\n", - "   Plaintext: DASHBOARD\n", - "   Keyword:   LINUXLINU\n", + " Plaintext: DASHBOARD\n", + " Keyword: LINUXLINU\n", "So, the first letter D is paired with the first letter of the key L. Therefore, row D and column L of the ", "Vigenère square are used to get the first cipher letter O. This must be repeated for the whole ciphertext.\n\n", "You are given an array with two elements:\n", - `  ["${data[0]}", "${data[1]}"]\n`, + ` ["${data[0]}", "${data[1]}"]\n`, "The first element is the plaintext, the second element is the keyword.\n\n", "Return the ciphertext as uppercase string.", ].join(" "); diff --git a/src/CodingContract/contracts/MinimumPathSumInATriangle.ts b/src/CodingContract/contracts/MinimumPathSumInATriangle.ts index cc10e3def..47d141906 100644 --- a/src/CodingContract/contracts/MinimumPathSumInATriangle.ts +++ b/src/CodingContract/contracts/MinimumPathSumInATriangle.ts @@ -12,7 +12,7 @@ export const minimumPathSumInATriangle: Pick 3 -> 5 -> 1).", ].join(" "); diff --git a/src/CodingContract/contracts/ShortestPathInAGrid.ts b/src/CodingContract/contracts/ShortestPathInAGrid.ts index d76ba3cc5..c191aaf38 100644 --- a/src/CodingContract/contracts/ShortestPathInAGrid.ts +++ b/src/CodingContract/contracts/ShortestPathInAGrid.ts @@ -7,7 +7,7 @@ export const shortestPathInAGrid: Pick { return [ "You are located in the top-left corner of the following grid:\n\n", - `  [${data.map((line) => `[${line}]`).join(",\n   ")}]\n\n`, + ` [${data.map((line) => `[${line}]`).join(",\n ")}]\n\n`, "You are trying to find the shortest path to the bottom-right corner of the grid,", "but there are obstacles on the grid that you cannot move onto.", "These obstacles are denoted by '1', while empty spaces are denoted by 0.\n\n", @@ -17,12 +17,12 @@ export const shortestPathInAGrid: Pick - "        [" + - line.map((x: number) => `${x}`.padStart(2, " ")).join(",") + - "]", - ) + .map((line: number[]) => " [" + line.map((x: number) => `${x}`.padStart(2, " ")).join(",") + "]") .join("\n"); - d += "\n    ]\n"; + d += "\n ]\n"; d += [ "\nHere is an example of what spiral order should be:\n\n", - "    [\n", - "        [1, 2, 3]\n", - "        [4, 5, 6]\n", - "        [7, 8, 9]\n", - "    ]\n\n", + " [\n", + " [1, 2, 3]\n", + " [4, 5, 6]\n", + " [7, 8, 9]\n", + " ]\n\n", "Answer: [1, 2, 3, 6, 9, 8 ,7, 4, 5]\n\n", "Note that the matrix will not always be square:\n\n", - "    [\n", - "        [1,  2,  3,  4]\n", - "        [5,  6,  7,  8]\n", - "        [9, 10, 11, 12]\n", - "    ]\n\n", + " [\n", + " [1, 2, 3, 4]\n", + " [5, 6, 7, 8]\n", + " [9, 10, 11, 12]\n", + " ]\n\n", "Answer: [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7]", ].join(" "); diff --git a/src/CodingContract/contracts/TotalWaysToSum.ts b/src/CodingContract/contracts/TotalWaysToSum.ts index 74499762f..58c162b45 100644 --- a/src/CodingContract/contracts/TotalWaysToSum.ts +++ b/src/CodingContract/contracts/TotalWaysToSum.ts @@ -10,10 +10,10 @@ export const totalWaysToSum: Pick< desc: (n: number): string => { return [ "It is possible write four as a sum in exactly four different ways:\n\n", - "    3 + 1\n", - "    2 + 2\n", - "    2 + 1 + 1\n", - "    1 + 1 + 1 + 1\n\n", + " 3 + 1\n", + " 2 + 2\n", + " 2 + 1 + 1\n", + " 1 + 1 + 1 + 1\n\n", `How many different distinct ways can the number ${n} be written as a sum of at least`, "two positive integers?", ].join(" "); diff --git a/src/ui/React/CodingContractModal.tsx b/src/ui/React/CodingContractModal.tsx index 3af334846..e61dd387a 100644 --- a/src/ui/React/CodingContractModal.tsx +++ b/src/ui/React/CodingContractModal.tsx @@ -66,7 +66,7 @@ export function CodingContractModal(): React.ReactElement { const description = []; for (const [i, value] of contractType.desc(contract.c.getData()).split("\n").entries()) { description.push( - + {value}
, );