Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
homework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ligang
homework
Commits
62747a50
Commit
62747a50
authored
Jan 06, 2019
by
ligang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
01-homework
parents
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
01-homework-ligang.py
+42
-0
No files found.
01-homework-ligang.py
0 → 100644
View file @
62747a50
#!/usr/bin/env python
#-*- coding:utf-8 -*-
def
check
(
s1
,
s2
):
print
(
sum
(
map
(
lambda
ch
:
s1
.
count
(
ch
),
s2
)))
def
isUnique
(
str
):
l
=
list
(
str
)
n
=
len
(
l
)
for
i
in
range
(
n
):
if
str
.
count
(
l
[
i
])
!=
1
:
print
(
"J value is repeat,please reinput J values"
)
exit
(
0
)
def
alphaCount
(
str
,
type
=
1
):
w
=
0
for
i
in
str
:
if
i
.
isalpha
():
w
+=
1
if
w
>
50
:
if
type
==
1
:
a
=
'J'
else
:
a
=
'S'
print
(
"
%
s alpha gt 50"
%
a
)
exit
(
0
)
def
numJwelsInStones
(
j
,
s
):
if
j
.
strip
()
==
''
or
s
.
strip
()
==
''
:
print
(
"J or S values is not empty"
)
else
:
jcount
=
alphaCount
(
j
,
1
)
scount
=
alphaCount
(
s
,
2
)
isUni
=
isUnique
(
j
)
chek
=
check
(
j
,
s
)
j
=
input
(
"please input J value"
)
S
=
input
(
"please input S value "
)
numJwelsInStones
(
j
,
S
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment