This commit is contained in:
krahets 2023-07-31 03:27:06 +08:00
parent e0d4aed887
commit 3501592bbc
10 changed files with 627 additions and 257 deletions

View File

@ -332,7 +332,28 @@ comments: true
=== "C" === "C"
```c title="preorder_traversal_ii_compact.c" ```c title="preorder_traversal_ii_compact.c"
[class]{}-[func]{preOrder} /* 前序遍历:例题二 */
void preOrder(TreeNode *root, vector *path, vector *res) {
if (root == NULL) {
return;
}
// 尝试
vectorPushback(path, root);
if (root->val == 7) {
// 记录解
vector *newPath = newVector();
for (int i = 0; i < path->size; i++) {
vectorPushback(newPath, path->data[i]);
}
vectorPushback(res, newPath);
}
preOrder(root->left, path, res);
preOrder(root->right, path, res);
// 回退
vectorPopback(path);
}
``` ```
=== "C#" === "C#"
@ -607,7 +628,30 @@ comments: true
=== "C" === "C"
```c title="preorder_traversal_iii_compact.c" ```c title="preorder_traversal_iii_compact.c"
[class]{}-[func]{preOrder} /* 前序遍历:例题三 */
void preOrder(TreeNode *root, vector *path, vector *res) {
// 剪枝
if (root == NULL || root->val == 3) {
return;
}
// 尝试
vectorPushback(path, root);
if (root->val == 7) {
// 记录解
vector *newPath = newVector();
for (int i = 0; i < path->size; i++) {
vectorPushback(newPath, path->data[i]);
}
vectorPushback(res, newPath);
res->depth++;
}
preOrder(root->left, path, res);
preOrder(root->right, path, res);
// 回退
vectorPopback(path);
}
``` ```
=== "C#" === "C#"
@ -1281,17 +1325,60 @@ comments: true
=== "C" === "C"
```c title="preorder_traversal_iii_template.c" ```c title="preorder_traversal_iii_template.c"
[class]{}-[func]{isSolution} /* 判断当前状态是否为解 */
bool isSolution(vector *state) {
return state->size != 0 && ((TreeNode *)(state->data[state->size - 1]))->val == 7;
}
[class]{}-[func]{recordSolution} /* 记录解 */
void recordSolution(vector *state, vector *res) {
vector *newPath = newVector();
for (int i = 0; i < state->size; i++) {
vectorPushback(newPath, state->data[i]);
}
vectorPushback(res, newPath);
}
[class]{}-[func]{isValid} /* 判断在当前状态下,该选择是否合法 */
bool isValid(vector *state, TreeNode *choice) {
return choice != NULL && choice->val != 3;
}
[class]{}-[func]{makeChoice} /* 更新状态 */
void makeChoice(vector *state, TreeNode *choice) {
vectorPushback(state, choice);
}
[class]{}-[func]{undoChoice} /* 恢复状态 */
void undoChoice(vector *state, TreeNode *choice) {
vectorPopback(state);
}
[class]{}-[func]{backtrack} /* 前序遍历:例题三 */
void backtrack(vector *state, vector *choices, vector *res) {
// 检查是否为解
if (isSolution(state)) {
// 记录解
recordSolution(state, res);
return;
}
// 遍历所有选择
for (int i = 0; i < choices->size; i++) {
TreeNode *choice = choices->data[i];
// 剪枝:检查选择是否合法
if (isValid(state, choice)) {
// 尝试:做出选择,更新状态
makeChoice(state, choice);
// 进行下一轮选择
vector *nextChoices = newVector();
vectorPushback(nextChoices, choice->left);
vectorPushback(nextChoices, choice->right);
backtrack(state, nextChoices, res);
// 回退:撤销选择,恢复到之前的状态
undoChoice(state, choice);
}
}
}
``` ```
=== "C#" === "C#"

View File

@ -269,9 +269,52 @@ comments: true
=== "C" === "C"
```c title="permutations_i.c" ```c title="permutations_i.c"
[class]{}-[func]{backtrack} /* 回溯算法:全排列 I */
void backtrack(vector *state, vector *choices, vector *selected, vector *res) {
// 当状态长度等于元素数量时,记录解
if (state->size == choices->size) {
vector *newState = newVector();
for (int i = 0; i < state->size; i++) {
vectorPushback(newState, state->data[i]);
}
vectorPushback(res, newState);
return;
}
// 遍历所有选择
for (int i = 0; i < choices->size; i++) {
int *choice = malloc(sizeof(int));
*choice = *((int *)(choices->data[i]));
// 剪枝:不允许重复选择元素 且 不允许重复选择相等元素
bool select = *((bool *)(selected->data[i]));
if (!select) {
// 尝试:做出选择,更新状态
*((bool *)selected->data[i]) = true;
vectorPushback(state, choice);
// 进行下一轮选择
backtrack(state, choices, selected, res);
// 回退:撤销选择,恢复到之前的状态
*((bool *)selected->data[i]) = false;
vectorPopback(state);
}
}
}
[class]{}-[func]{permutationsI} /* 全排列 I */
vector *permutationsI(vector *nums) {
vector *iState = newVector();
int select[3] = {false, false, false};
vector *bSelected = newVector();
for (int i = 0; i < nums->size; i++) {
vectorPushback(bSelected, &select[i]);
}
vector *res = newVector();
// 前序遍历
backtrack(iState, nums, bSelected, res);
return res;
}
``` ```
=== "C#" === "C#"

View File

@ -182,9 +182,40 @@ comments: true
=== "C" === "C"
```c title="subset_sum_i_naive.c" ```c title="subset_sum_i_naive.c"
[class]{}-[func]{backtrack} /* 回溯算法:子集和 I */
void backtrack(vector *state, int target, int total, vector *choices, vector *res) {
// 子集和等于 target 时,记录解
if (total == target) {
vector *tmpVector = newVector();
for (int i = 0; i < state->size; i++) {
vectorPushback(tmpVector, state->data[i]);
}
vectorPushback(res, tmpVector);
return;
}
// 遍历所有选择
for (size_t i = 0; i < choices->size; i++) {
// 剪枝:若子集和超过 target ,则跳过该选择
if (total + *(int *)(choices->data[i]) > target) {
continue;
}
// 尝试:做出选择,更新元素和 total
vectorPushback(state, choices->data[i]);
// 进行下一轮选择
backtrack(state, target, total + *(int *)(choices->data[i]), choices, res);
// 回退:撤销选择,恢复到之前的状态
vectorPopback(state);
}
}
[class]{}-[func]{subsetSumINaive} /* 求解子集和 I包含重复子集 */
vector *subsetSumINaive(vector *nums, int target) {
vector *state = newVector(); // 状态(子集)
int total = 0; // 子集和
vector *res = newVector(); // 结果列表(子集列表)
backtrack(state, target, total, nums, res);
return res;
}
``` ```
=== "C#" === "C#"
@ -518,9 +549,42 @@ comments: true
=== "C" === "C"
```c title="subset_sum_i.c" ```c title="subset_sum_i.c"
[class]{}-[func]{backtrack} /* 回溯算法:子集和 I */
void backtrack(vector *state, int target, vector *choices, int start, vector *res) {
// 子集和等于 target 时,记录解
if (target == 0) {
vector *tmpVector = newVector();
for (int i = 0; i < state->size; i++) {
vectorPushback(tmpVector, state->data[i]);
}
vectorPushback(res, tmpVector);
return;
}
// 遍历所有选择
// 剪枝二:从 start 开始遍历,避免生成重复子集
for (int i = start; i < choices->size; i++) {
// 剪枝:若子集和超过 target ,则跳过该选择
if (target - *(int *)(choices->data[i]) < 0) {
continue;
}
// 尝试:做出选择,更新 target, start
vectorPushback(state, choices->data[i]);
// 进行下一轮选择
backtrack(state, target - *(int *)(choices->data[i]), choices, i, res);
// 回退:撤销选择,恢复到之前的状态
vectorPopback(state);
}
}
[class]{}-[func]{subsetSumI} /* 求解子集和 I */
vector *subsetSumI(vector *nums, int target) {
vector *state = newVector(); // 状态(子集)
qsort(nums->data[0], nums->size, sizeof(int), comp); // 对 nums 进行排序
int start = 0; // 子集和
vector *res = newVector(); // 结果列表(子集列表)
backtrack(state, target, nums, start, res);
return res;
}
``` ```
=== "C#" === "C#"
@ -869,9 +933,48 @@ comments: true
=== "C" === "C"
```c title="subset_sum_ii.c" ```c title="subset_sum_ii.c"
[class]{}-[func]{backtrack} /* 回溯算法:子集和 II */
void backtrack(vector *state, int target, vector *choices, int start, vector *res) {
// 子集和等于 target 时,记录解
if (target == 0) {
vector *tmpVector = newVector();
for (int i = 0; i < state->size; i++) {
vectorPushback(tmpVector, state->data[i]);
}
vectorPushback(res, tmpVector);
return;
}
// 遍历所有选择
// 剪枝二:从 start 开始遍历,避免生成重复子集
// 剪枝三:从 start 开始遍历,避免重复选择同一元素
for (int i = start; i < choices->size; i++) {
// 剪枝一:若子集和超过 target ,则直接结束循环
// 这是因为数组已排序,后边元素更大,子集和一定超过 target
if (target - *(int *)(choices->data[i]) < 0) {
continue;
}
// 剪枝四:如果该元素与左边元素相等,说明该搜索分支重复,直接跳过
if (i > start && *(int *)(choices->data[i]) == *(int *)(choices->data[i - 1])) {
continue;
}
// 尝试:做出选择,更新 target, start
vectorPushback(state, choices->data[i]);
// 进行下一轮选择
backtrack(state, target - *(int *)(choices->data[i]), choices, i + 1, res);
// 回退:撤销选择,恢复到之前的状态
vectorPopback(state);
}
}
[class]{}-[func]{subsetSumII} /* 求解子集和 II */
vector *subsetSumII(vector *nums, int target) {
vector *state = newVector(); // 状态(子集)
qsort(nums->data[0], nums->size, sizeof(int), comp); // 对 nums 进行排序
int start = 0; // 子集和
vector *res = newVector(); // 结果列表(子集列表)
backtrack(state, target, nums, start, res);
return res;
}
``` ```
=== "C#" === "C#"

View File

@ -1651,7 +1651,7 @@ $$
return 0; return 0;
int *nums = malloc(sizeof(int) * n); int *nums = malloc(sizeof(int) * n);
printf("递归 n = %d 中的 nums 长度 = %d\r\n", n, n); printf("递归 n = %d 中的 nums 长度 = %d\r\n", n, n);
int res = quadraticRecur(n - 1) int res = quadraticRecur(n - 1);
free(nums); free(nums);
return res; return res;
} }

View File

@ -73,7 +73,7 @@ status: new
=== "<4>" === "<4>"
![hanota_f3_step4](hanota_problem.assets/hanota_f3_step4.png) ![hanota_f3_step4](hanota_problem.assets/hanota_f3_step4.png)
本质上看,**我们将问题 $f(3)$ 划分为两个子问题 $f(2)$ 和子问题 $f(1)$** 。按顺序解决这三个子问题之后,原问题随之得到解决。这说明子问题是独立的,且解是可以合并的。 本质上看,**我们将问题 $f(3)$ 划分为两个子问题 $f(2)$ 和子问题 $f(1)$** 。按顺序解决这三个子问题之后,原问题随之得到解决。这说明子问题是独立的,且解是可以合并的。
至此,我们可总结出汉诺塔问题的分治策略:将原问题 $f(n)$ 划分为两个子问题 $f(n-1)$ 和一个子问题 $f(1)$ 。子问题的解决顺序为: 至此,我们可总结出汉诺塔问题的分治策略:将原问题 $f(n)$ 划分为两个子问题 $f(n-1)$ 和一个子问题 $f(1)$ 。子问题的解决顺序为:

View File

@ -5,10 +5,10 @@ status: new
# 14.2. &nbsp; 动态规划问题特性 # 14.2. &nbsp; 动态规划问题特性
在上节中,我们学习了动态规划是如何通过子问题分解来求解问题的。实际上,子问题分解是一种通用的算法思路,在分治、动态规划、回溯中各有特点 在上节中,我们学习了动态规划是如何通过子问题分解来求解问题的。实际上,子问题分解是一种通用的算法思路,在分治、动态规划、回溯中的侧重点不同
- 「分治算法」递归地将原问题划分为多个相独立的子问题,直至最小子问题,并在回溯中合并子问题的解,最终得到原问题的解。 - 「分治算法」递归地将原问题划分为多个相独立的子问题,直至最小子问题,并在回溯中合并子问题的解,最终得到原问题的解。
- 「动态规划」也对问题进行递归分解,但与分治算法的主要区别是,**动态规划中的子问题往往不是相互独立的**,原问题的解依赖于子问题的解,而子问题的解又依赖于更小的子问题的解 - 「动态规划」也对问题进行递归分解,但与分治算法的主要区别是,动态规划中的子问题是相互依赖的,在分解过程中会出现许多重叠子问题
- 「回溯算法」在尝试和回退中穷举所有可能的解,并通过剪枝避免不必要的搜索分支。原问题的解由一系列决策步骤构成,我们可以将每个决策步骤之前的子序列看作为一个子问题。 - 「回溯算法」在尝试和回退中穷举所有可能的解,并通过剪枝避免不必要的搜索分支。原问题的解由一系列决策步骤构成,我们可以将每个决策步骤之前的子序列看作为一个子问题。
实际上,动态规划常用来求解最优化问题,它们不仅包含重叠子问题,还具有另外两大特性:最优子结构、无后效性。 实际上,动态规划常用来求解最优化问题,它们不仅包含重叠子问题,还具有另外两大特性:最优子结构、无后效性。

View File

@ -356,7 +356,7 @@ $$
dp[i] = dp[i-1] + dp[i-2] dp[i] = dp[i-1] + dp[i-2]
$$ $$
这意味着在爬楼梯问题中,**各个子问题之间不是相互独立的,原问题的解可以从子问题的解构建得来**。 这意味着在爬楼梯问题中,各个子问题之间存在递推关系,**原问题的解可以由子问题的解构建得来**。
![方案数量递推关系](intro_to_dynamic_programming.assets/climbing_stairs_state_transfer.png) ![方案数量递推关系](intro_to_dynamic_programming.assets/climbing_stairs_state_transfer.png)

View File

@ -26,7 +26,7 @@ comments: true
本书主要内容包括: 本书主要内容包括:
- **复杂度分析**:数据结构和算法的评价维度,算法效率的评估方法。时间复杂度、空间复杂度的推算方法、常见类型、示例等。 - **复杂度分析**:数据结构和算法的评价维度方法。时间复杂度、空间复杂度的推算方法、常见类型、示例等。
- **数据结构**:基本数据类型,数据结构的分类方法。数组、链表、栈、队列、散列表、树、堆、图等数据结构的定义、优缺点、常用操作、常见类型、典型应用、实现方法等。 - **数据结构**:基本数据类型,数据结构的分类方法。数组、链表、栈、队列、散列表、树、堆、图等数据结构的定义、优缺点、常用操作、常见类型、典型应用、实现方法等。
- **算法**:搜索、排序、分治、回溯、动态规划、贪心等算法的定义、优缺点、效率、应用场景、解题步骤、示例题目等。 - **算法**:搜索、排序、分治、回溯、动态规划、贪心等算法的定义、优缺点、效率、应用场景、解题步骤、示例题目等。

View File

@ -1383,7 +1383,7 @@ comments: true
if self.__size == self.capacity(): if self.__size == self.capacity():
raise IndexError("队列已满") raise IndexError("队列已满")
# 计算尾指针,指向队尾索引 + 1 # 计算尾指针,指向队尾索引 + 1
# 通过取余操作,实现 rear 越过数组尾部后回到头部F # 通过取余操作,实现 rear 越过数组尾部后回到头部
rear: int = (self.__front + self.__size) % self.capacity() rear: int = (self.__front + self.__size) % self.capacity()
# 将 num 添加至队尾 # 将 num 添加至队尾
self.__nums[rear] = num self.__nums[rear] = num

View File

@ -1,280 +1,417 @@
<!-- Custom HTML site displayed as the Home chapter -->
{% extends "main.html" %} {% extends "main.html" %}
<!-- Render hero under tabs -->
{% block tabs %} {% block tabs %}
{{ super() }} {{ super() }}
<!-- Additional styles for landing page -->
<style> <style>
.md-main { /* Apply box shadow on smaller screens that don't display tabs */
flex-grow: 0 @media only screen and (max-width: 1220px) {
} .md-header {
box-shadow: 0 0 .2rem rgba(0,0,0,.1),0 .2rem .4rem rgba(0,0,0,.2);
transition: color 250ms,background-color 250ms,box-shadow 250ms;
}
}
.md-main__inner { /* Hide main content for now */
display: flex; .md-content {
height: 100%; display: none;
} }
.tx-container { /* Hide table of contents */
padding-top: .0rem; @media screen and (min-width: 60em) {
background: linear-gradient(to bottom, var(--md-primary-fg-color), hsla(160deg,47%,55%,1) 99%,#fff 99%) .md-sidebar--secondary {
} display: none;
}
}
.tx-hero { /* Hide navigation */
margin: 32px 2.8rem; @media screen and (min-width: 76.25em) {
color: var(--md-primary-bg-color); .md-sidebar--primary {
justify-content: center; display: none;
} }
}
.tx-hero h1 { /* Get started button */
margin-bottom: 1rem; .md-typeset .md-button--primary {
color: currentColor; color: var(--md-primary-fg-color);
font-weight: 700 background-color: var(--md-primary-bg-color);
} border-color: var(--md-primary-bg-color);
}
.md-typeset .md-button--primary:hover {
color: var(--md-primary-bg-color);
background-color: var(--md-primary-fg-color);
border-color: var(--md-primary-bg-color);
}
.tx-hero__content { .tx-hero {
padding-bottom: 1rem; max-width: 700px;
margin: 0 auto; display: flex;
} padding: .4rem;
margin: 0 auto;
text-align: center;
}
.tx-hero h1 {
font-weight: 700;
font-size: 38px;
line-height: 46px;
color: rgb(38, 38, 38);
}
.tx-hero p {
color: rgb(92, 92, 92);
font-weight: 400;
font-size: 20px;
line-height: 32px;
}
.tx-hero__image {
max-width: 300px;
min-width: 300px;
width: 100%;
height: auto;
margin: 0 auto;
display: flex;
align-items: stretch;
}
.tx-hero__image{ .tx-hero__image img {
width:17rem; width: 100%;
height:17rem; height: 100%;
order:1; min-width: 0;
padding-right: 2.5rem; }
}
.tx-hero .md-button { /* Secondary content styles */
margin-top: .5rem; .secondary-section {
margin-right: .5rem; background: rgb(245, 245, 245) none repeat scroll 0% 0%;
color: var(--md-primary-bg-color) border-top: 1px solid rgb(222, 222, 222);
} border-bottom: 1px solid rgb(222, 222, 222)
}
@media screen and (max-width: 1012px) {
.secondary-section {
display: block;
}
}
.tx-hero .md-button--primary { .secondary-section .g {
background-color: var(--md-primary-bg-color); position: relative;
color: hsla(280deg, 37%, 48%, 1); margin-left: auto;
border-color: var(--md-primary-bg-color) margin-right: auto;
} padding: 0px 100px;
max-width: 1280px;
}
.tx-hero .md-button:focus, .secondary-section .g .section {
.tx-hero .md-button:hover { font-size: 18px;
background-color: var(--md-accent-fg-color); font-weight: 400;
color: var(--md-default-bg-color); line-height: 30px;
border-color: var(--md-accent-fg-color) letter-spacing: normal;
} padding: 88px 0px 116px;
}
.feature-item h2 svg { .secondary-section .g .section.follow {
height: 30px; padding-top: 0px;
float: left; }
margin-right: 10px;
transform: translateY(10%);
}
.top-hr {
margin-top: 42px;
}
.feature-item { .secondary-section .g .section .component-wrapper {
font-family: 'Lato', sans-serif; display: flex;
font-weight: 300; -moz-box-align: center;
box-sizing: border-box; align-items: center;
padding: 0 15px; }
word-break: break-word
}
.feature-item h2 { @media screen and (max-width: 1012px) {
color: #333; .secondary-section .g .section .component-wrapper {
font-weight: 300; display: block;
font-size: 25px; }
white-space: nowrap; }
overflow: hidden;
text-overflow: ellipsis;
line-height: normal;
margin-top: 20px;
margin-bottom: 10px;
font-family: inherit;
}
.feature-item p { .secondary-section .g .section .component-wrapper h3 {
font-size: 16px; color: rgb(38, 38, 38);
line-height: 1.8em; font-size: 36px;
text-rendering: optimizeLegibility; font-weight: 700;
-webkit-font-smoothing: antialiased; line-height: 46px;
color: #111; letter-spacing: normal;
margin: 0 0 10px; margin-bottom: 12px;
display: block; }
}
@media screen and (max-width:30em) { .secondary-section .g .section .component-wrapper h4 {
.tx-hero h1 { color: rgb(38, 38, 38);
font-size: 1.4rem }
}
}
@media screen and (min-width:60em) { .secondary-section .g .section .component-wrapper p {
.md-sidebar--secondary { color: rgb(92, 92, 92);
display: none font-size: 18px;
} font-weight: 400;
line-height: 30px;
letter-spacing: normal;
margin-bottom: 16px;
}
.tx-hero { .secondary-section .g .section .component-wrapper .image-wrapper {
display: flex; margin-bottom: 12px;
align-items: center; overflow: hidden;
justify-content: center; border-radius: 8px;
} margin-top: 48px;
border: 1px solid rgb(222, 222, 222);
box-shadow: rgba(202, 202, 202, 0.15) 0px 0px 0px 6px;
max-width: 600px;
width: 100%;
height: auto;
margin: 0 auto;
display: flex;
align-items: stretch;
}
.tx-hero__content { .image-wrapper img {
max-width: 22rem; width: 100%;
margin-top: 3.5rem; height: 100%;
margin-bottom: 3.5rem; min-width: 0;
margin-left: 1.0rem; }
margin-right: 4.0rem;
align-items: center;
}
}
@media screen and (min-width:76.25em) { .secondary-section .g .section .component-wrapper .first-column {
.md-sidebar--primary { padding-right: 100px;
display: none flex: 0 1 auto;
} height: auto;
width: 50%;
}
.top-hr { @media screen and (max-width: 1012px) {
width: 100%; .secondary-section .g .section .component-wrapper .first-column {
display: flex; padding-right: 0px;
max-width: 61rem; width: 100%;
margin-right: auto; margin-bottom: 32px;
margin-left: auto; }
padding: 0 .2rem; }
}
.bottom-hr { .secondary-section .g .section .component-wrapper .second-column {
margin-top: 10px; flex: 0 1 auto;
width: 100%; height: auto;
display: flex; width: 50%;
max-width: 61rem; }
margin-right: auto; @media screen and (max-width: 1012px) {
margin-left: auto; .secondary-section .g .section .component-wrapper .second-column {
padding: 0 .2rem; width: 100%;
} margin-bottom: 32px;
}
}
.feature-item { .secondary-section .g .section .component-wrapper .responsive-grid {
flex: 1; display: grid;
min-width: 0; width: 100%;
} grid-template-columns: repeat(1, 1fr);
gap: 2rem;
}
@media screen and (min-width: 64rem) {
.secondary-section .g .section .component-wrapper .responsive-grid {
grid-template-columns: repeat(3, 1fr);
}
}
.feature-item:hover { .secondary-section .g .section .component-wrapper .responsive-grid a.card-wrapper {
background-color: #526cfe47; text-decoration: none;
border-radius: 3px; transition: none;
} background: none;
} padding: 0;
}
.hr { .secondary-section .g .section .component-wrapper .responsive-grid .card {
border-bottom: 1px solid #eee; position: relative;
width: 100%; background-color: #fff none repeat scroll 0% 0%;
margin: 20px 0; padding: 1.5rem;
} display: flex;
flex-direction: row;
-moz-box-align: center;
align-items: center;
height: 100%;
-moz-box-pack: start;
justify-content: flex-start;
box-shadow: rgba(0, 0, 0, 0.09) 0.3125rem 0.3125rem 0px -0.0625rem, rgba(0, 0, 0, 0.15) 0px 0.25rem 0.5rem 0px;
transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1) 0s;
}
.secondary-section .g .section .component-wrapper .responsive-grid .card:hover {
box-shadow: rgba(0, 0, 0, 0.2) 0.3125rem 0.3125rem 0px -0.0625rem, rgba(0, 0, 0, 0.26) 0px 0.25rem 0.5rem 0px;
}
.text-center { @media screen and (min-width: 75rem) {
text-align: center; .secondary-section .g .section .component-wrapper .responsive-grid .card {
padding-right: 15px; padding: 2rem 2.5rem;
padding-left: 15px; }
margin-right: auto; }
margin-left: auto; @media screen and (min-width: 36rem) {
margin-top: 15px; .secondary-section .g .section .component-wrapper .responsive-grid .card {
font-family: 'Lato', sans-serif; padding: 1rem 1.5rem;
font-size: 23px; }
font-weight: 300; }
padding-bottom: 10px;
}
.logos { .secondary-section .g .section .component-wrapper .responsive-grid .card .logo {
display: flex; margin-right: 0.75rem;
align-items: center; width: 1.2rem;
justify-content: center; min-width: 1.2rem;
flex-flow: row wrap; }
margin: 0 auto;
}
.logos img { .secondary-section .g .section .component-wrapper .responsive-grid .card .card-content {
flex: 1 1 auto; display: flex;
padding: 25px; flex: 1 1 0%;
max-height: 130px; flex-direction: column;
vertical-align: middle; width: 100%;
} }
.hr-logos { .secondary-section .g .section .component-wrapper .responsive-grid .card .card-content h5 {
margin-top: 0; color: rgb(61, 61, 61);
margin-bottom: 30px; margin: 0;
} }
.md-footer-meta__inner { .secondary-section .g .section .component-wrapper .responsive-grid .card .card-content p {
display: flex; margin-top: 0.25em;
flex-wrap: wrap; margin-bottom: 0;
justify-content: space-between; color: rgb(92, 92, 92);
margin-top: 1.0rem; font-size: 0.65rem;
} font-weight: 300;
line-height: normal;
}
.secondary-section .g .section .component-wrapper .responsive-grid .card .card-content code {
background: rgba(0, 0, 0, 0.05) none repeat scroll 0% 0%;
padding: 2px 6px;
border-radius: 4px;
}
.component-wrapper span.em {
color: rgb(61, 61, 61);
}
.component-wrapper a {
transition: color 125ms;
color: rgb(61, 61, 61);
background: rgba(0, 0, 0, 0.05) none repeat scroll 0% 0%;
padding: 2px 6px;
margin: 0px 1px;
border-radius: 4px;
display: inline;
cursor: pointer;
font-weight: 600;
}
.component-wrapper a:hover {
color: var(--md-typeset-a-color);
background: var(--md-accent-fg-color--transparent);
}
.md-footer-social {
padding-top: 20px;
}
</style> </style>
<!-- Main site Entry button descriptions --> <!-- Hero for landing page -->
<section class="tx-container"> <div class="md-container">
<div class="tx-hero__image">
<img
src="{{config.site_url}}index.assets/conceptual_rendering.png"
alt=""
draggable="false"
>
</div>
</div>
<div class="md-container tx-hero">
<div class="md-grid md-typeset"> <div class="md-grid md-typeset">
<div class="tx-hero"> <div class="md-main__inner">
<div class="tx-hero__image"> <div>
<img src="assets/product-layers.png" draggable="false"> <h2>动画图解、一键运行的数据结构与算法教程</h2>
</div> <p>AWS Copilot is an open source command line interface that makes it easy for developers to <span class="em">build</span>,
<div class="tx-hero__content"> <span class="em">release</span>, and <span class="em">operate</span> production ready containerized applications on AWS App Runner, Amazon ECS, and AWS Fargate.
<h1> UP42 Python SDK </h1> </p>
<p>Access UP42's geospatial collections and processing workflows via Python.</p> <a
<a href="{{ page.next_page.url | url }}" title="{{ page.next_page.title | striptags }}" class="md-button md-button--primary"> href="chapter_preface/"
Get started title="Get Started"
</a> class="md-button md-button--primary"
<a href="{{ config.repo_url }}" title="{{ lang.t('source.link.title') }}" class="md-button"> >
Go to GitHub 开始阅读
<svg width="11" height="10" viewBox="0 0 11 10" fill="none" style="margin-left:2px"><path d="M1 5.16772H9.5M9.5 5.16772L6.5 1.66772M9.5 5.16772L6.5 8.66772" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
</a> </a>
</div> </div>
</div> </div>
</div> </div>
</section> </div>
<!-- Main site box descriptions --> <div class="md-container secondary-section">
<div class="top-hr"> <div class="g">
<div class="feature-item"> <!-- Architecture as building blocks -->
<h2> <div class="section">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <div class="component-wrapper">
<path <div class="first-column">
d="M15 17v-3h3v-2l4 3.5-4 3.5v-2h-3m2 1v3h-3v2l-4-3.5 4-3.5v2h3M12 8c-2.21 0-4 1.8-4 4 0 1.91 1.35 3.54 3.21 3.92L16 11.86A3.997 3.997 0 0012 8m0 6c-1.1 0-2-.89-2-2s.9-2 2-2 2 .9 2 2-.89 2-2 2m9.66-5.27l-2-3.46c-.12-.22-.38-.31-.61-.22l-2.49 1c-.51-.41-1.06-.74-1.69-1l-.37-2.63A.506.506 0 0014 2h-4c-.25 0-.46.18-.5.42l-.37 2.65c-.63.26-1.17.59-1.69 1L5 5.05c-.23-.09-.5 0-.61.22l-2 3.46c-.13.21-.08.49.11.64L4.57 11l-.07 1 .07 1-2.11 1.63c-.2.15-.25.43-.12.64l2 3.46c.11.27.4.38.66.27l2.5-1c.24.19.5.37.76.53l1.65-1.4c-.77-.33-1.45-.82-2-1.45l-2.41 1-.77-1.3L6.8 13.8a5.55 5.55 0 010-3.6L4.69 8.65l.75-1.3 2.41 1c.78-.9 1.83-1.53 3-1.78l.4-2.57h1.5l.37 2.62c1.17.24 2.22.88 3 1.77l2.41-1 .75 1.3-2.08 1.51c.09.26.16.53.2.8h2l2.1-1.63a.48.48 0 00.16-.64M12 8c-2.21 0-4 1.8-4 4 0 1.91 1.35 3.54 3.21 3.92L16 11.86A3.997 3.997 0 0012 8m0 6c-1.1 0-2-.89-2-2s.9-2 2-2 2 .9 2 2-.89 2-2 2m0-6c-2.21 0-4 1.8-4 4 0 1.91 1.35 3.54 3.21 3.92L16 11.86A3.997 3.997 0 0012 8m0 6c-1.1 0-2-.89-2-2s.9-2 2-2 2 .9 2 2-.89 2-2 2z" /> <h3>全书动画图解</h3>
</svg> <p>
UP42 in Python 内容清晰易懂、学习曲线平滑</br>电脑、平板、手机全终端阅读
</h2> </p>
<p>Use UP42 via Python: order geospatial data, run analytic workflows, and </div>
generate insights.</p> <div class="second-column">
</div> <div class="image-wrapper">
<div class="feature-item"> <img
<h2> src="{{config.site_url}}index.assets/animation.gif"
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> alt=""
<path draggable="false"
d="M16 17v2H2v-2s0-4 7-4 7 4 7 4m-3.5-9.5A3.5 3.5 0 109 11a3.5 3.5 0 003.5-3.5m3.44 5.5A5.32 5.32 0 0118 17v2h4v-2s0-3.63-6.06-4M15 4a3.39 3.39 0 00-1.93.59 5 5 0 010 5.82A3.39 3.39 0 0015 11a3.5 3.5 0 000-7z" /> >
</svg>Python ecosystem </div>
</h2> </div>
<p>Use UP42 together with your preferred Python libraries. </p> </div>
</div> </div>
<div class="feature-item">
<h2>
<svg xmlns="http://www.w3.org/2000/svg" width="35" height="35" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="M20.4 14.5L16 10 4 20"/></svg>
Visualizations
</h2>
<p>Interactive maps and visualizations. Ideal to use with Jupyter notebooks.</p>
</div>
</div>
<div class="top-hr"> <!-- Continuous delivery -->
<div class="hr"> <div class="section follow">
<div class="component-wrapper">
<div class="first-column">
<h3>Continuous delivery</h3>
<p>
No need to worry about gluing Copilot commands in a script to create an automated release process.
Copilot provides commands to create multiple deployment <a href="docs/concepts/environments/">environments</a> in separate AWS accounts and regions,
as well as creating an AWS CodePipeline <a href="docs/concepts/pipelines/">pipeline</a> to build your container images, deploy your services, and
run automated tests.
</p>
</div>
<div class="second-column">
<div class="image-wrapper">
<img
src="{{config.site_url}}assets/images/copilot-env-init.png"
alt=""
draggable="false"
>
</div>
</div>
</div>
</div>
<!-- Operations -->
<div class="section follow">
<div class="component-wrapper">
<div class="first-column">
<h3>Operations is part of the workflow</h3>
<p>
Modeling, provisioning, and deploying services are only part of the application lifecycle for the developer.
Copilot also supports workflows around troubleshooting and debugging to help when things go wrong. <a href="docs/commands/svc-logs/">Tail
your logs</a>, <a href="docs/commands/svc-exec">get a shell</a> to a running container, <a href="docs/commands/svc-status/">view the health</a> of your services
from the comfort of your terminal.
</p>
</div>
<div class="second-column">
<div class="image-wrapper">
<img
src="{{config.site_url}}assets/images/copilot-svc-status.png"
alt=""
draggable="false"
>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
<!-- Content -->
{% block content %}{% endblock %} {% block content %}{% endblock %}
{% block footer %}{% endblock %}
<!-- Application footer -->
{% block footer %}
{{ super() }}
{% endblock %}