diff --git a/questions/00106-medium-trimleft/README.ja.md b/questions/00106-medium-trimleft/README.ja.md index 794496d2..20a43981 100644 --- a/questions/00106-medium-trimleft/README.ja.md +++ b/questions/00106-medium-trimleft/README.ja.md @@ -5,7 +5,7 @@ 例えば ```ts -type trimed = TrimLeft<' Hello World '> // expected to be 'Hello World ' +type trimmed = TrimLeft<' Hello World '> // expected to be 'Hello World ' ``` diff --git a/questions/00106-medium-trimleft/README.ko.md b/questions/00106-medium-trimleft/README.ko.md index 5ee6a403..ec74b1ae 100644 --- a/questions/00106-medium-trimleft/README.ko.md +++ b/questions/00106-medium-trimleft/README.ko.md @@ -5,7 +5,7 @@ 예시 ```ts -type trimed = TrimLeft<' Hello World '> // 기대되는 결과는 'Hello World '입니다. +type trimmed = TrimLeft<' Hello World '> // 기대되는 결과는 'Hello World '입니다. ``` diff --git a/questions/00106-medium-trimleft/README.md b/questions/00106-medium-trimleft/README.md index 8e80b4e9..36e8535a 100644 --- a/questions/00106-medium-trimleft/README.md +++ b/questions/00106-medium-trimleft/README.md @@ -5,7 +5,7 @@ Implement `TrimLeft` which takes an exact string type and returns a new strin For example ```ts -type trimed = TrimLeft<' Hello World '> // expected to be 'Hello World ' +type trimmed = TrimLeft<' Hello World '> // expected to be 'Hello World ' ``` diff --git a/questions/00106-medium-trimleft/README.zh-CN.md b/questions/00106-medium-trimleft/README.zh-CN.md index c59eaffa..f670efe0 100644 --- a/questions/00106-medium-trimleft/README.zh-CN.md +++ b/questions/00106-medium-trimleft/README.zh-CN.md @@ -5,7 +5,7 @@ 例如 ```ts -type trimed = TrimLeft<' Hello World '> // 应推导出 'Hello World ' +type trimmed = TrimLeft<' Hello World '> // 应推导出 'Hello World ' ```
返回首页 分享你的解答 查看解答

相关挑战

108・去除两端空白字符 4803・Trim Right diff --git a/questions/00108-medium-trim/README.ja.md b/questions/00108-medium-trim/README.ja.md index f26df5c4..a6827de8 100644 --- a/questions/00108-medium-trim/README.ja.md +++ b/questions/00108-medium-trim/README.ja.md @@ -5,7 +5,7 @@ 例えば ```ts -type trimed = Trim<' Hello World '> // expected to be 'Hello World' +type trimmed = Trim<' Hello World '> // expected to be 'Hello World' ``` diff --git a/questions/00108-medium-trim/README.zh-CN.md b/questions/00108-medium-trim/README.zh-CN.md index e58e2b7d..f9891067 100644 --- a/questions/00108-medium-trim/README.zh-CN.md +++ b/questions/00108-medium-trim/README.zh-CN.md @@ -5,7 +5,7 @@ 例如 ```ts -type trimed = Trim<' Hello World '> // expected to be 'Hello World' +type trimmed = Trim<' Hello World '> // expected to be 'Hello World' ``` diff --git a/questions/00529-medium-absolute/README.ja.md b/questions/00529-medium-absolute/README.ja.md index 8c90012b..d55573f6 100644 --- a/questions/00529-medium-absolute/README.ja.md +++ b/questions/00529-medium-absolute/README.ja.md @@ -1,6 +1,6 @@

Absolute 中級 #math #template-literal

by Andrey Krasovsky @bre30kra69cs

挑戦する    English 简体中文 한국어

-srting, number または bigint を受け取り、正の数を出力する `Absolute` 型を実装します。 +string, number または bigint を受け取り、正の数を出力する `Absolute` 型を実装します。 例えば diff --git a/questions/04803-medium-trim-right/README.ko.md b/questions/04803-medium-trim-right/README.ko.md index ad3c49bd..5479fdb7 100644 --- a/questions/04803-medium-trim-right/README.ko.md +++ b/questions/04803-medium-trim-right/README.ko.md @@ -5,7 +5,7 @@ 예시 ```ts -type Trimed = TrimRight<' Hello World '> // 기대되는 결과는 ' Hello World'입니다. +type Trimmed = TrimRight<' Hello World '> // 기대되는 결과는 ' Hello World'입니다. ``` diff --git a/questions/04803-medium-trim-right/README.md b/questions/04803-medium-trim-right/README.md index f253b4fc..9c2d9a10 100644 --- a/questions/04803-medium-trim-right/README.md +++ b/questions/04803-medium-trim-right/README.md @@ -5,7 +5,7 @@ Implement `TrimRight` which takes an exact string type and returns a new stri For example: ```ts -type Trimed = TrimRight<' Hello World '> // expected to be ' Hello World' +type Trimmed = TrimRight<' Hello World '> // expected to be ' Hello World' ``` diff --git a/questions/04803-medium-trim-right/README.zh-CN.md b/questions/04803-medium-trim-right/README.zh-CN.md index 776214c8..04480d4b 100644 --- a/questions/04803-medium-trim-right/README.zh-CN.md +++ b/questions/04803-medium-trim-right/README.zh-CN.md @@ -6,7 +6,7 @@ 例如 ```ts -type Trimed = TrimRight<' Hello World '> // 应推导出 ' Hello World' +type Trimmed = TrimRight<' Hello World '> // 应推导出 ' Hello World' ```
返回首页 分享你的解答 查看解答

相关挑战

106・去除左侧空白 108・去除两端空白字符 diff --git a/questions/07544-medium-construct-tuple/README.md b/questions/07544-medium-construct-tuple/README.md index 55bcba22..fd83f216 100644 --- a/questions/07544-medium-construct-tuple/README.md +++ b/questions/07544-medium-construct-tuple/README.md @@ -5,7 +5,7 @@ Construct a tuple with a given length. For example ```ts -type result = ConstructTuple<2> // expect to be [unknown, unkonwn] +type result = ConstructTuple<2> // expect to be [unknown, unknown] ``` diff --git a/questions/07544-medium-construct-tuple/README.zh-CN.md b/questions/07544-medium-construct-tuple/README.zh-CN.md index 5d37706c..431a79ae 100644 --- a/questions/07544-medium-construct-tuple/README.zh-CN.md +++ b/questions/07544-medium-construct-tuple/README.zh-CN.md @@ -5,7 +5,7 @@ 例如 ```ts -type result = ConstructTuple<2> // 期望得到 [unknown, unkonwn] +type result = ConstructTuple<2> // 期望得到 [unknown, unknown] ``` diff --git a/questions/09898-medium-zhao-chu-mu-biao-shu-zu-zhong-zhi-chu-xian-guo-yi-ci-de-yuan-su/README.md b/questions/09898-medium-zhao-chu-mu-biao-shu-zu-zhong-zhi-chu-xian-guo-yi-ci-de-yuan-su/README.md index ed47c359..64c1fa87 100644 --- a/questions/09898-medium-zhao-chu-mu-biao-shu-zu-zhong-zhi-chu-xian-guo-yi-ci-de-yuan-su/README.md +++ b/questions/09898-medium-zhao-chu-mu-biao-shu-zu-zhong-zhi-chu-xian-guo-yi-ci-de-yuan-su/README.md @@ -1,6 +1,6 @@

Appear only once medium

by X.Q. Chen @brenner8023

Take the Challenge    简体中文

-Find the elements in the target array that appear only once. For example:input: `[1,2,2,3,3,4,5,6,6,6]`,ouput: `[1,4,5]`. +Find the elements in the target array that appear only once. For example:input: `[1,2,2,3,3,4,5,6,6,6]`,output: `[1,4,5]`.
Back Share your Solutions Check out Solutions \ No newline at end of file diff --git a/questions/30575-hard-bitwisexor/README.md b/questions/30575-hard-bitwisexor/README.md index ccf76961..4d217607 100644 --- a/questions/30575-hard-bitwisexor/README.md +++ b/questions/30575-hard-bitwisexor/README.md @@ -1,6 +1,6 @@ -

BitwiseXOR hard

by jiangshan @jiangshanmeta

Take the Challenge

- -Implement ```BitwiseXOR``` which takes two binary string literal type and returns a binary string that reprents the bitwise XOR of S1 and S2 +

BitwiseXOR hard

by jiangshan @jiangshanmeta

Take the Challenge

+ +Implement ```BitwiseXOR``` which takes two binary string literal type and returns a binary string that represents the bitwise XOR of S1 and S2 For example: @@ -8,7 +8,7 @@ For example: BitwiseXOR<'0','1'> // expect '1' BitwiseXOR<'1','1'> // expect '0' BitwiseXOR<'10','1'> // expect '11' -``` - - +``` + +
Back Share your Solutions Check out Solutions \ No newline at end of file diff --git a/questions/32427-hard-unbox/test-cases.ts b/questions/32427-hard-unbox/test-cases.ts index f497ca14..01bc2b0c 100644 --- a/questions/32427-hard-unbox/test-cases.ts +++ b/questions/32427-hard-unbox/test-cases.ts @@ -1,5 +1,5 @@ import type { Equal, Expect } from '@type-challenges/utils' - + type cases = [ // Base cases Expect, number>>, @@ -13,7 +13,7 @@ type cases = [ // Bonus: Recursion Expect Promise<() => Array>>>, boolean>>, - // Bonus: Recusion levels + // Bonus: Recursion levels Expect () => () => () => number, 0>, number>>, Expect () => () => () => number, 1>, () => () => () => number>>, Expect () => () => () => number, 2>, () => () => number>>, @@ -37,4 +37,4 @@ type cases = [ Expect>>, 2>, Promise>>, Expect>>, 3>, number>>, Expect>>, 4>, number>>, -] +] diff --git a/scripts/build.ts b/scripts/build.ts index de4b4bcb..12317420 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -1,12 +1,12 @@ import path from 'node:path' import fs from 'fs-extra' -import { loadQuizes, resolveInfo } from './loader' +import { loadQuizzes, resolveInfo } from './loader' import { REPO, toPlaygroundUrl, toQuestionsRawREADME, toQuizREADME, toRawREADME, toShareAnswerFull, toSolutionsFull } from './toUrl' import { defaultLocale, supportedLocales } from './locales' import { formatToCode } from './actions/utils/formatToCode' export async function build() { - const quizes = await loadQuizes() + const quizzes = await loadQuizzes() const redirects: [string, string, number][] = [] // redirect homepage to github repo @@ -18,7 +18,7 @@ export async function build() { redirects.push([`/raw/${locale}`, toQuestionsRawREADME(locale), 302]) }) - for (const quiz of quizes) { + for (const quiz of quizzes) { for (const locale of supportedLocales) { const info = resolveInfo(quiz, locale) diff --git a/scripts/generate-play.ts b/scripts/generate-play.ts index 19cb6432..bf515e6c 100644 --- a/scripts/generate-play.ts +++ b/scripts/generate-play.ts @@ -5,7 +5,7 @@ import fs from 'fs-extra' import c from 'ansis' import prompts from 'prompts' import { formatToCode } from './actions/utils/formatToCode' -import { loadQuizes, resolveInfo } from './loader' +import { loadQuizzes, resolveInfo } from './loader' import { supportedLocales } from './locales' import { getQuestionFullName } from './actions/issue-pr' import type { QuizMetaInfo } from './types' @@ -32,14 +32,14 @@ function calculateFileHash(filePathFull: string): Promise { }) } -async function takeSnapshot(quizesPath: string) { +async function takeSnapshot(quizzesPath: string) { let snapshot: Snapshot = {} - const files = fs.readdirSync(quizesPath) + const files = fs.readdirSync(quizzesPath) for (const file of files) { // Might be a file, or a folder - const fPath = path.join(quizesPath, file) + const fPath = path.join(quizzesPath, file) const fStats = fs.statSync(fPath) if (fStats.isDirectory()) { @@ -142,10 +142,10 @@ async function generatePlayground() { await fs.ensureDir(playgroundPath) } - const quizes = await loadQuizes() - const incomingQuizesCache: Snapshot = {} + const quizzes = await loadQuizzes() + const incomingQuizzesCache: Snapshot = {} - for (const quiz of quizes) { + for (const quiz of quizzes) { const { difficulty, title } = resolveInfo(quiz, locale) as QuizMetaInfo & { difficulty: string } const code = formatToCode(quiz, locale) @@ -154,22 +154,22 @@ async function generatePlayground() { continue } - const quizesPathByDifficulty = path.join(playgroundPath, difficulty) + const quizzesPathByDifficulty = path.join(playgroundPath, difficulty) const quizFileName = `${getQuestionFullName(quiz.no, difficulty, title)}.ts` - const quizPathFull = path.join(quizesPathByDifficulty, quizFileName) + const quizPathFull = path.join(quizzesPathByDifficulty, quizFileName) if (!keepChanges || (keepChanges && isQuizWritable(quizFileName, overridableFiles!, playgroundSnapshot!))) { - if (!fs.existsSync(quizesPathByDifficulty)) - fs.mkdirSync(quizesPathByDifficulty) + if (!fs.existsSync(quizzesPathByDifficulty)) + fs.mkdirSync(quizzesPathByDifficulty) await fs.writeFile(quizPathFull, code, 'utf-8') - incomingQuizesCache[quizFileName] = await calculateFileHash(quizPathFull) + incomingQuizzesCache[quizFileName] = await calculateFileHash(quizPathFull) } } fs.writeFile(playgroundCachePath, JSON.stringify({ ...currentPlaygroundCache, - ...incomingQuizesCache, + ...incomingQuizzesCache, })) console.log() diff --git a/scripts/loader.ts b/scripts/loader.ts index 8a713a4b..305c3adf 100644 --- a/scripts/loader.ts +++ b/scripts/loader.ts @@ -67,17 +67,17 @@ export function loadInfo(s: string): Partial | undefined { export const QUIZ_ROOT = path.resolve(__dirname, '../questions') -export async function loadQuizes(): Promise { +export async function loadQuizzes(): Promise { const folders = await fg('{0..9}*-*', { onlyDirectories: true, cwd: QUIZ_ROOT, }) - const quizes = await Promise.all( + const quizzes = await Promise.all( folders.map(async dir => loadQuiz(dir)), ) - return quizes + return quizzes } export async function loadQuiz(dir: string): Promise { diff --git a/scripts/readme.ts b/scripts/readme.ts index 1dab9fc6..fd24108c 100644 --- a/scripts/readme.ts +++ b/scripts/readme.ts @@ -3,7 +3,7 @@ import process from 'node:process' import fs from 'fs-extra' import type { SupportedLocale } from './locales' import { defaultLocale, f, supportedLocales, t } from './locales' -import { loadQuizes, resolveInfo } from './loader' +import { loadQuizzes, resolveInfo } from './loader' import { toAnswerShort, toNearborREADME, toPlayShort, toQuizREADME, toSolutionsShort } from './toUrl' import type { Quiz, QuizMetaInfo } from './types' @@ -78,17 +78,17 @@ function quizToBadge(quiz: Quiz, locale: string, absolute = false, badge = true) ) } -function quizNoToBadges(ids: (string | number)[], quizes: Quiz[], locale: string, absolute = false) { +function quizNoToBadges(ids: (string | number)[], quizzes: Quiz[], locale: string, absolute = false) { return ids - .map(i => quizes.find(q => q.no === Number(i))) + .map(i => quizzes.find(q => q.no === Number(i))) .filter(Boolean) .map(i => quizToBadge(i!, locale, absolute)) .join(' ') } -function getAllTags(quizes: Quiz[], locale: string) { +function getAllTags(quizzes: Quiz[], locale: string) { const set = new Set() - for (const quiz of quizes) { + for (const quiz of quizzes) { const info = resolveInfo(quiz, locale) for (const tag of (info?.tags || [])) set.add(tag as string) @@ -96,14 +96,14 @@ function getAllTags(quizes: Quiz[], locale: string) { return Array.from(set).sort() } -function getQuizesByTag(quizes: Quiz[], locale: string, tag: string) { - return quizes.filter((quiz) => { +function getQuizzesByTag(quizzes: Quiz[], locale: string, tag: string) { + return quizzes.filter((quiz) => { const info = resolveInfo(quiz, locale) return !!info.tags?.includes(tag) }) } -async function insertInfoReadme(filepath: string, quiz: Quiz, locale: SupportedLocale, quizes: Quiz[]) { +async function insertInfoReadme(filepath: string, quiz: Quiz, locale: SupportedLocale, quizzes: Quiz[]) { if (!fs.existsSync(filepath)) return let text = await fs.readFile(filepath, 'utf-8') @@ -136,7 +136,7 @@ async function insertInfoReadme(filepath: string, quiz: Quiz, locale: SupportedL + toBadgeLink(`../../${f('README', locale, 'md')}`, '', t(locale, 'badge.back'), 'grey') + toBadgeLink(toAnswerShort(quiz.no, locale), '', t(locale, 'badge.share-your-solutions'), 'teal') + toBadgeLink(toSolutionsShort(quiz.no), '', t(locale, 'badge.checkout-solutions'), 'de5a77', '?logo=awesome-lists&logoColor=white') - + (Array.isArray(info.related) && info.related.length ? `

${t(locale, 'readme.related-challenges')}

${quizNoToBadges(info.related, quizes, locale, true)}` : '') + + (Array.isArray(info.related) && info.related.length ? `

${t(locale, 'readme.related-challenges')}

${quizNoToBadges(info.related, quizzes, locale, true)}` : '') + '', ) @@ -145,7 +145,7 @@ async function insertInfoReadme(filepath: string, quiz: Quiz, locale: SupportedL await fs.writeFile(filepath, text, 'utf-8') } -async function updateIndexREADME(quizes: Quiz[]) { +async function updateIndexREADME(quizzes: Quiz[]) { // update index README for (const locale of supportedLocales) { const filepath = path.resolve(__dirname, '..', f('README', locale, 'md')) @@ -154,11 +154,11 @@ async function updateIndexREADME(quizes: Quiz[]) { let prev = '' // difficulty - const quizesByDifficulty = [...quizes].sort((a, b) => DifficultyRank.indexOf(a.difficulty) - DifficultyRank.indexOf(b.difficulty)) + const quizzesByDifficulty = [...quizzes].sort((a, b) => DifficultyRank.indexOf(a.difficulty) - DifficultyRank.indexOf(b.difficulty)) - for (const quiz of quizesByDifficulty) { + for (const quiz of quizzesByDifficulty) { if (prev !== quiz.difficulty) - challengesREADME += `${prev ? '

' : ''}${toDifficultyBadgeInverted(quiz.difficulty, locale, quizesByDifficulty.filter(q => q.difficulty === quiz.difficulty).length)}
` + challengesREADME += `${prev ? '

' : ''}${toDifficultyBadgeInverted(quiz.difficulty, locale, quizzesByDifficulty.filter(q => q.difficulty === quiz.difficulty).length)}
` challengesREADME += quizToBadge(quiz, locale) @@ -167,10 +167,10 @@ async function updateIndexREADME(quizes: Quiz[]) { // by tags challengesREADME += `
${toDetailsInnerText('by-tags', locale)}
` - const tags = getAllTags(quizes, locale) + const tags = getAllTags(quizzes, locale) for (const tag of tags) { challengesREADME += `
${toBadge('', `#${tag}`, '999')}` - getQuizesByTag(quizesByDifficulty, locale, tag) + getQuizzesByTag(quizzesByDifficulty, locale, tag) .forEach((quiz) => { challengesREADME += quizToBadge(quiz, locale) }) @@ -182,9 +182,9 @@ async function updateIndexREADME(quizes: Quiz[]) { // by plain text prev = '' challengesREADME += `
${toDetailsInnerText('by-plain-text', locale)}
` - for (const quiz of quizesByDifficulty) { + for (const quiz of quizzesByDifficulty) { if (prev !== quiz.difficulty) - challengesREADME += `${prev ? '' : ''}

${toDifficultyPlainText(quiz.difficulty, locale, quizesByDifficulty.filter(q => q.difficulty === quiz.difficulty).length)}

    ` + challengesREADME += `${prev ? '
' : ''}

${toDifficultyPlainText(quiz.difficulty, locale, quizzesByDifficulty.filter(q => q.difficulty === quiz.difficulty).length)}

    ` challengesREADME += `
  • ${quizToBadge(quiz, locale, false, false)}
  • ` prev = quiz.difficulty } @@ -199,11 +199,11 @@ async function updateIndexREADME(quizes: Quiz[]) { } } -async function updateQuestionsREADME(quizes: Quiz[]) { +async function updateQuestionsREADME(quizzes: Quiz[]) { const questionsDir = path.resolve(__dirname, '../questions') // update each questions' readme - for (const quiz of quizes) { + for (const quiz of quizzes) { for (const locale of supportedLocales) { await insertInfoReadme( path.join( @@ -213,26 +213,26 @@ async function updateQuestionsREADME(quizes: Quiz[]) { ), quiz, locale, - quizes, + quizzes, ) } } } export async function updateREADMEs(type?: 'quiz' | 'index') { - const quizes = await loadQuizes() - quizes.sort((a, b) => a.no - b.no) + const quizzes = await loadQuizzes() + quizzes.sort((a, b) => a.no - b.no) if (type === 'quiz') { - await updateQuestionsREADME(quizes) + await updateQuestionsREADME(quizzes) } else if (type === 'index') { - await updateIndexREADME(quizes) + await updateIndexREADME(quizzes) } else { await Promise.all([ - updateIndexREADME(quizes), - updateQuestionsREADME(quizes), + updateIndexREADME(quizzes), + updateQuestionsREADME(quizzes), ]) } } diff --git a/scripts/translate-cli.ts b/scripts/translate-cli.ts index 2d2679e8..6db65327 100644 --- a/scripts/translate-cli.ts +++ b/scripts/translate-cli.ts @@ -1,11 +1,11 @@ import { updateREADMEs } from './readme' -import { translateAllQuizes } from './translate' +import { translateAllQuizzes } from './translate' import { defaultLocale } from './locales' async function run() { - await translateAllQuizes(defaultLocale, 'zh-CN') - await translateAllQuizes(defaultLocale, 'ja') - await translateAllQuizes(defaultLocale, 'pt-BR') + await translateAllQuizzes(defaultLocale, 'zh-CN') + await translateAllQuizzes(defaultLocale, 'ja') + await translateAllQuizzes(defaultLocale, 'pt-BR') await updateREADMEs() } diff --git a/scripts/translate.ts b/scripts/translate.ts index cdcf1d5a..da63a905 100644 --- a/scripts/translate.ts +++ b/scripts/translate.ts @@ -1,7 +1,7 @@ import path from 'node:path' import fs from 'fs-extra' import { translate } from '@vitalets/google-translate-api' -import { QUIZ_ROOT, loadQuizByNo, loadQuizes } from './loader' +import { QUIZ_ROOT, loadQuizByNo, loadQuizzes } from './loader' import { resolveFilePath } from './utils/resolve' import type { Quiz } from './types' import type { SupportedLocale } from './locales' @@ -59,10 +59,10 @@ export async function translateMarkdown(code: string, from: SupportedLocale, to: return result } -export async function translateAllQuizes(from: SupportedLocale, to: SupportedLocale) { - const quizes = await loadQuizes() +export async function translateAllQuizzes(from: SupportedLocale, to: SupportedLocale) { + const quizzes = await loadQuizzes() - for (const quiz of quizes) { + for (const quiz of quizzes) { if (quiz.readme[to] || !quiz.readme[from]) { console.log(`Skipped #${quiz.no}`) continue