Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1ca9381

Browse files
committed
add day-eight
1 parent 0644faf commit 1ca9381

File tree

2 files changed

+87
-2
lines changed

2 files changed

+87
-2
lines changed

‎src/may/day-eight/index.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @param {number[][]} coordinates
3+
* @return {boolean}
4+
*/
5+
6+
export const checkStraightLine = function (coordinates: number[][]): boolean {
7+
const n: number = coordinates.length;
8+
9+
for (let i = 0; i < n - 2; i++) {
10+
const area: number = Math.abs((1 / 2) * (coordinates[i][0] * coordinates[i + 1][1] + coordinates[i + 1][0] * coordinates[i + 2][1] + coordinates[i + 2][0] * coordinates[i][1] - (coordinates[i][1] * coordinates[i + 1][0] + coordinates[i + 1][1] * coordinates[i + 2][0] + coordinates[i + 2][1] * coordinates[i][0])));
11+
12+
if (area > 0) return false;
13+
}
14+
15+
return true;
16+
};
17+
18+
const b = checkStraightLine([
19+
[1, 2],
20+
[2, 3],
21+
[3, 4],
22+
[4, 5],
23+
[5, 6],
24+
[6, 7],
25+
]);
26+
const c = checkStraightLine([
27+
[1, 1],
28+
[2, 2],
29+
[3, 4],
30+
[4, 5],
31+
[5, 6],
32+
[7, 7],
33+
]);
34+
console.log('b', b);
35+
console.log('c', c);

‎src/test/concurrency.ts

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,55 @@ const requestOptions = {
5656
},
5757
};
5858

59-
requestOptions.sendByOne(images);
60-
requestOptions.sendByFive(images);
59+
// requestOptions.sendByOne(images);
60+
// requestOptions.sendByFive(images);
61+
62+
interface IGroup {
63+
objectId: string;
64+
name: string;
65+
}
66+
67+
interface IPerson {
68+
personId: string;
69+
personInfo: IPersonInfo;
70+
}
71+
72+
interface IPersonInfo {
73+
objectId?: string;
74+
name: string;
75+
employeeId?: string;
76+
position?: string;
77+
contactNumber?: string;
78+
email?: string;
79+
card?: string;
80+
remark?: string;
81+
password?: string;
82+
groups?: IGroup[];
83+
engineId?: string;
84+
expiredDate?: Date | String;
85+
}
86+
87+
function convertToMultiQuery(IPerson: IPerson[] | IPerson) {
88+
const mappings: string[] = Object.keys(IPerson);
89+
let query: string = '';
90+
if (mappings[0] === 'personId') {
91+
query = `&objectId=${IPerson[mappings[0]]}`;
92+
} else {
93+
let i: number = 0;
94+
while (i < mappings.length) {
95+
query += `&objectId=${IPerson[i].personId}`;
96+
i++;
97+
}
98+
}
99+
100+
return query;
101+
}
102+
103+
const data1 = convertToMultiQuery({ personId: '12', personInfo: { name: 'test' } });
104+
const data2 = convertToMultiQuery([
105+
{ personId: '12', personInfo: { name: 'test' } },
106+
{ personId: '13', personInfo: { name: 'test' } },
107+
]);
108+
109+
console.log('data1', data1);
110+
console.log('data2', data2);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /