mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
CONTRACTS: Fix nbsp rendering as text rather than a space (#2225)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -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(" ");
|
||||
|
||||
@@ -12,7 +12,7 @@ export const minimumPathSumInATriangle: Pick<CodingContractTypes, CodingContract
|
||||
}
|
||||
const numSpaces = numLevels - level + 1;
|
||||
|
||||
let str: string = [" ".repeat(numSpaces), "[", data[level].toString(), "]"].join("");
|
||||
let str: string = [" ".repeat(numSpaces), "[", data[level].toString(), "]"].join("");
|
||||
if (level < numLevels - 1) {
|
||||
str += ",";
|
||||
}
|
||||
@@ -32,10 +32,10 @@ export const minimumPathSumInATriangle: Pick<CodingContractTypes, CodingContract
|
||||
"The triangle is represented as a 2D array of numbers:\n\n",
|
||||
`${triangle}\n\n`,
|
||||
"Example: If you are given the following triangle:\n\n[\n",
|
||||
" [2],\n",
|
||||
" [3,4],\n",
|
||||
" [6,5,7],\n",
|
||||
" [4,1,8,3]\n",
|
||||
" [2],\n",
|
||||
" [3,4],\n",
|
||||
" [6,5,7],\n",
|
||||
" [4,1,8,3]\n",
|
||||
"]\n\n",
|
||||
"The minimum path sum is 11 (2 -> 3 -> 5 -> 1).",
|
||||
].join(" ");
|
||||
|
||||
@@ -7,7 +7,7 @@ export const shortestPathInAGrid: Pick<CodingContractTypes, CodingContractName.S
|
||||
desc: (data: number[][]): string => {
|
||||
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<CodingContractTypes, CodingContractName.S
|
||||
"If there is no path, the answer should be an empty string.\n",
|
||||
"NOTE: The data returned for this contract is an 2D array of numbers representing the grid.\n\n",
|
||||
"Examples:\n\n",
|
||||
" [[0,1,0,0,0],\n",
|
||||
" [0,0,0,1,0]]\n",
|
||||
" [[0,1,0,0,0],\n",
|
||||
" [0,0,0,1,0]]\n",
|
||||
"\n",
|
||||
"Answer: 'DRRURRD'\n\n",
|
||||
" [[0,1],\n",
|
||||
" [1,0]]\n",
|
||||
" [[0,1],\n",
|
||||
" [1,0]]\n",
|
||||
"\n",
|
||||
"Answer: ''",
|
||||
].join(" ");
|
||||
|
||||
@@ -12,30 +12,25 @@ export const spiralizeMatrix: Pick<CodingContractTypes, CodingContractName.Spira
|
||||
// for (const line of n) {
|
||||
// d += `${line.toString()},\n`;
|
||||
// }
|
||||
d += " [\n";
|
||||
d += " [\n";
|
||||
d += n
|
||||
.map(
|
||||
(line: number[]) =>
|
||||
" [" +
|
||||
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(" ");
|
||||
|
||||
|
||||
@@ -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(" ");
|
||||
|
||||
@@ -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(
|
||||
<span key={i}>
|
||||
<span key={i} style={{ whiteSpace: "pre-wrap" }}>
|
||||
{value} <br />
|
||||
</span>,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user