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 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#"
@ -607,7 +628,30 @@ comments: true
=== "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#"
@ -1281,17 +1325,60 @@ comments: true
=== "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#"

View File

@ -269,9 +269,52 @@ comments: true
=== "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#"

View File

@ -182,9 +182,40 @@ comments: true
=== "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#"
@ -518,9 +549,42 @@ comments: true
=== "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#"
@ -869,9 +933,48 @@ comments: true
=== "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#"

View File

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

View File

@ -73,7 +73,7 @@ status: new
=== "<4>"
![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)$ 。子问题的解决顺序为:

View File

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

View File

@ -356,7 +356,7 @@ $$
dp[i] = dp[i-1] + dp[i-2]
$$
这意味着在爬楼梯问题中,**各个子问题之间不是相互独立的,原问题的解可以从子问题的解构建得来**。
这意味着在爬楼梯问题中,各个子问题之间存在递推关系,**原问题的解可以由子问题的解构建得来**。
![方案数量递推关系](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():
raise IndexError("队列已满")
# 计算尾指针,指向队尾索引 + 1
# 通过取余操作,实现 rear 越过数组尾部后回到头部F
# 通过取余操作,实现 rear 越过数组尾部后回到头部
rear: int = (self.__front + self.__size) % self.capacity()
# 将 num 添加至队尾
self.__nums[rear] = num

View File

@ -1,280 +1,417 @@
<!-- Custom HTML site displayed as the Home chapter -->
{% extends "main.html" %}
<!-- Render hero under tabs -->
{% block tabs %}
{{ super() }}
{{ super() }}
<!-- Additional styles for landing page -->
<style>
.md-main {
flex-grow: 0
}
/* Apply box shadow on smaller screens that don't display tabs */
@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 {
display: flex;
height: 100%;
}
/* Hide main content for now */
.md-content {
display: none;
}
.tx-container {
padding-top: .0rem;
background: linear-gradient(to bottom, var(--md-primary-fg-color), hsla(160deg,47%,55%,1) 99%,#fff 99%)
}
/* Hide table of contents */
@media screen and (min-width: 60em) {
.md-sidebar--secondary {
display: none;
}
}
.tx-hero {
margin: 32px 2.8rem;
color: var(--md-primary-bg-color);
justify-content: center;
}
/* Hide navigation */
@media screen and (min-width: 76.25em) {
.md-sidebar--primary {
display: none;
}
}
.tx-hero h1 {
margin-bottom: 1rem;
color: currentColor;
font-weight: 700
}
/* Get started button */
.md-typeset .md-button--primary {
color: var(--md-primary-fg-color);
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 {
padding-bottom: 1rem;
margin: 0 auto;
}
.tx-hero {
max-width: 700px;
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{
width:17rem;
height:17rem;
order:1;
padding-right: 2.5rem;
}
.tx-hero__image img {
width: 100%;
height: 100%;
min-width: 0;
}
.tx-hero .md-button {
margin-top: .5rem;
margin-right: .5rem;
color: var(--md-primary-bg-color)
}
/* Secondary content styles */
.secondary-section {
background: rgb(245, 245, 245) none repeat scroll 0% 0%;
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 {
background-color: var(--md-primary-bg-color);
color: hsla(280deg, 37%, 48%, 1);
border-color: var(--md-primary-bg-color)
}
.secondary-section .g {
position: relative;
margin-left: auto;
margin-right: auto;
padding: 0px 100px;
max-width: 1280px;
}
.tx-hero .md-button:focus,
.tx-hero .md-button:hover {
background-color: var(--md-accent-fg-color);
color: var(--md-default-bg-color);
border-color: var(--md-accent-fg-color)
}
.secondary-section .g .section {
font-size: 18px;
font-weight: 400;
line-height: 30px;
letter-spacing: normal;
padding: 88px 0px 116px;
}
.feature-item h2 svg {
height: 30px;
float: left;
margin-right: 10px;
transform: translateY(10%);
}
.secondary-section .g .section.follow {
padding-top: 0px;
}
.top-hr {
margin-top: 42px;
}
.feature-item {
font-family: 'Lato', sans-serif;
font-weight: 300;
box-sizing: border-box;
padding: 0 15px;
word-break: break-word
}
.secondary-section .g .section .component-wrapper {
display: flex;
-moz-box-align: center;
align-items: center;
}
.feature-item h2 {
color: #333;
font-weight: 300;
font-size: 25px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
line-height: normal;
margin-top: 20px;
margin-bottom: 10px;
font-family: inherit;
}
@media screen and (max-width: 1012px) {
.secondary-section .g .section .component-wrapper {
display: block;
}
}
.feature-item p {
font-size: 16px;
line-height: 1.8em;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
color: #111;
margin: 0 0 10px;
display: block;
}
.secondary-section .g .section .component-wrapper h3 {
color: rgb(38, 38, 38);
font-size: 36px;
font-weight: 700;
line-height: 46px;
letter-spacing: normal;
margin-bottom: 12px;
}
@media screen and (max-width:30em) {
.tx-hero h1 {
font-size: 1.4rem
}
}
.secondary-section .g .section .component-wrapper h4 {
color: rgb(38, 38, 38);
}
@media screen and (min-width:60em) {
.md-sidebar--secondary {
display: none
}
.secondary-section .g .section .component-wrapper p {
color: rgb(92, 92, 92);
font-size: 18px;
font-weight: 400;
line-height: 30px;
letter-spacing: normal;
margin-bottom: 16px;
}
.tx-hero {
display: flex;
align-items: center;
justify-content: center;
}
.secondary-section .g .section .component-wrapper .image-wrapper {
margin-bottom: 12px;
overflow: hidden;
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 {
max-width: 22rem;
margin-top: 3.5rem;
margin-bottom: 3.5rem;
margin-left: 1.0rem;
margin-right: 4.0rem;
align-items: center;
}
}
.image-wrapper img {
width: 100%;
height: 100%;
min-width: 0;
}
@media screen and (min-width:76.25em) {
.md-sidebar--primary {
display: none
}
.secondary-section .g .section .component-wrapper .first-column {
padding-right: 100px;
flex: 0 1 auto;
height: auto;
width: 50%;
}
.top-hr {
width: 100%;
display: flex;
max-width: 61rem;
margin-right: auto;
margin-left: auto;
padding: 0 .2rem;
}
@media screen and (max-width: 1012px) {
.secondary-section .g .section .component-wrapper .first-column {
padding-right: 0px;
width: 100%;
margin-bottom: 32px;
}
}
.bottom-hr {
margin-top: 10px;
width: 100%;
display: flex;
max-width: 61rem;
margin-right: auto;
margin-left: auto;
padding: 0 .2rem;
}
.secondary-section .g .section .component-wrapper .second-column {
flex: 0 1 auto;
height: auto;
width: 50%;
}
@media screen and (max-width: 1012px) {
.secondary-section .g .section .component-wrapper .second-column {
width: 100%;
margin-bottom: 32px;
}
}
.feature-item {
flex: 1;
min-width: 0;
}
.secondary-section .g .section .component-wrapper .responsive-grid {
display: grid;
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 {
background-color: #526cfe47;
border-radius: 3px;
}
}
.secondary-section .g .section .component-wrapper .responsive-grid a.card-wrapper {
text-decoration: none;
transition: none;
background: none;
padding: 0;
}
.hr {
border-bottom: 1px solid #eee;
width: 100%;
margin: 20px 0;
}
.secondary-section .g .section .component-wrapper .responsive-grid .card {
position: relative;
background-color: #fff none repeat scroll 0% 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 {
text-align: center;
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
margin-top: 15px;
font-family: 'Lato', sans-serif;
font-size: 23px;
font-weight: 300;
padding-bottom: 10px;
}
@media screen and (min-width: 75rem) {
.secondary-section .g .section .component-wrapper .responsive-grid .card {
padding: 2rem 2.5rem;
}
}
@media screen and (min-width: 36rem) {
.secondary-section .g .section .component-wrapper .responsive-grid .card {
padding: 1rem 1.5rem;
}
}
.logos {
display: flex;
align-items: center;
justify-content: center;
flex-flow: row wrap;
margin: 0 auto;
}
.secondary-section .g .section .component-wrapper .responsive-grid .card .logo {
margin-right: 0.75rem;
width: 1.2rem;
min-width: 1.2rem;
}
.logos img {
flex: 1 1 auto;
padding: 25px;
max-height: 130px;
vertical-align: middle;
}
.secondary-section .g .section .component-wrapper .responsive-grid .card .card-content {
display: flex;
flex: 1 1 0%;
flex-direction: column;
width: 100%;
}
.hr-logos {
margin-top: 0;
margin-bottom: 30px;
}
.secondary-section .g .section .component-wrapper .responsive-grid .card .card-content h5 {
color: rgb(61, 61, 61);
margin: 0;
}
.md-footer-meta__inner {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin-top: 1.0rem;
}
.secondary-section .g .section .component-wrapper .responsive-grid .card .card-content p {
margin-top: 0.25em;
margin-bottom: 0;
color: rgb(92, 92, 92);
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>
<!-- Main site Entry button descriptions -->
<section class="tx-container">
<!-- Hero for landing page -->
<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="tx-hero">
<div class="tx-hero__image">
<img src="assets/product-layers.png" draggable="false">
</div>
<div class="tx-hero__content">
<h1> UP42 Python SDK </h1>
<p>Access UP42's geospatial collections and processing workflows via Python.</p>
<a href="{{ page.next_page.url | url }}" title="{{ page.next_page.title | striptags }}" class="md-button md-button--primary">
Get started
</a>
<a href="{{ config.repo_url }}" title="{{ lang.t('source.link.title') }}" class="md-button">
Go to GitHub
<div class="md-main__inner">
<div>
<h2>动画图解、一键运行的数据结构与算法教程</h2>
<p>AWS Copilot is an open source command line interface that makes it easy for developers to <span class="em">build</span>,
<span class="em">release</span>, and <span class="em">operate</span> production ready containerized applications on AWS App Runner, Amazon ECS, and AWS Fargate.
</p>
<a
href="chapter_preface/"
title="Get Started"
class="md-button md-button--primary"
>
开始阅读
<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>
</div>
</div>
</div>
</section>
</div>
<!-- Main site box descriptions -->
<div class="top-hr">
<div class="feature-item">
<h2>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path
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" />
</svg>
UP42 in Python
</h2>
<p>Use UP42 via Python: order geospatial data, run analytic workflows, and
generate insights.</p>
</div>
<div class="feature-item">
<h2>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path
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
</h2>
<p>Use UP42 together with your preferred Python libraries. </p>
</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="md-container secondary-section">
<div class="g">
<!-- Architecture as building blocks -->
<div class="section">
<div class="component-wrapper">
<div class="first-column">
<h3>全书动画图解</h3>
<p>
内容清晰易懂、学习曲线平滑</br>电脑、平板、手机全终端阅读
</p>
</div>
<div class="second-column">
<div class="image-wrapper">
<img
src="{{config.site_url}}index.assets/animation.gif"
alt=""
draggable="false"
>
</div>
</div>
</div>
</div>
<div class="top-hr">
<div class="hr">
<!-- Continuous delivery -->
<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>
{% endblock %}
<!-- Content -->
{% block content %}{% endblock %}
{% block footer %}{% endblock %}
<!-- Application footer -->
{% block footer %}
{{ super() }}
{% endblock %}