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 bc3c6a2

Browse files
solved: pow(x,n)
1 parent 82a45df commit bc3c6a2

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

‎img/.DS_Store‎

6 KB
Binary file not shown.

‎src/pow_x_n.dart‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'dart:math';
2+
3+
void main(List<String> args) {
4+
List<List> cases = [
5+
[2.00000, 10],
6+
[2.10000, 3],
7+
[2.00000, -2],
8+
];
9+
10+
for (final testcase in cases) {
11+
print(myPow(testcase.first, testcase.last));
12+
}
13+
}
14+
15+
double myPow(double x, int n) {
16+
return pow(x, n).toDouble();
17+
}

‎src/wildcard_matching.dart‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
void main(List<String> args) {
2+
List<List<String>> cases = [
3+
["aa", "a"],
4+
["aa", "*"],
5+
["cb", "?=a"],
6+
["acdcb", "a*c?b"],
7+
["adceb", "*a*b"]
8+
];
9+
10+
for (final testcase in cases) {
11+
print(isMatch(testcase[0], testcase[1]));
12+
}
13+
}
14+
15+
bool isMatch(String s, String p) {
16+
final RegExp regExp = RegExp(p.replaceAll('*', '^g\.*').replaceAll('?', '^g\.?'));
17+
print(regExp.stringMatch(s));
18+
return regExp.stringMatch(s) == s;
19+
}

0 commit comments

Comments
(0)

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