Hello, everyone Baekjun KOI Elementary School 14696 When it's a draw, I want to print out the result of D, but I think it's because of return, so how can I pick the result of the draw?
And I think my multi-conditional code is too complicated and I don't understand the part that goes down the conditional I wonder how I can modify it efficiently.
I'm referring to someone else's code, but I'm posting a question because I want to get feedback on the code I wrote. Thank you :)
# Enter
L = int(input()) # Total number of rounds
round = []
for i in range(2*L):
A = [int(i) for i in list(map(int, input().split()))]
round.append(A) # Cards of A and B for each round
# the number of the shape of the card
# # star = 4
# # circle = 3
# # square = 2
# # triangle = 1
defBattle_AB(round): # Count Comparison
for i in range(0, L):
If round[i][1:].count(4)!=round[i + 1][1:].count(4) # If the number of stars is different,
if round[0][1:].count(4) > round[i + 1][1:].count(4):
result = 'A'
print(result)
else:
result = 'B'
print(result)
if round[i][1:].count(4) == round[i + 1][1:].count(4) # If the number of stars is the same,
if round[i][1:].count(3) > round[i + 1][1:].count(3):
result = 'A'
print(result)
elif round[i][1:].count(3) == round[i + 1][1:].count(3):
return
else:
result = 'B'
print(result)
If round[i][1:].count(3) == round[i + 1][1:].count(3): # If the number of circles is the same,
if round[i][1:].count(2) > round[i + 1][1:].count(2):
result = 'A'
elif round[i][1:].count(2) == round[i + 1][1:].count(2):
return
else:
result = 'B'
print(result)
If round[i][1:].count(2) == round[i + 1][1:].count(2) # If the number of squares is the same,
if round[i][1:].count(1) > round[i + 1][1:].count(1):
result = 'A'
print(result)
elif round[i][1:].count(1) == round[i + 1][1:].count(1):
result = 'D'
print(result)
else:
result = 'B'
print(result)
i += 2
return result
# Execute
ab = Battle_AB(round)
print(ab)
First, look at the next development.
def getWinner(A, B) :
if (number of stars varies):
# At this point in time, actually, there's already a Shobu
# We just need to figure out who won, return it, and end it
별을urn 사람 r 더
# When I came here, there was no Shobu because of the number of stars
# Need to watch more
if (the number of circles is different):
The one who has more circles
# The following is omitted
# If you come all the way here, you can't tell who's the winner
# Returns the default value at this time
"Return" "No match"
The refactoring of the current code itself will not be difficult if the above development is understood.
So far, that's a boring answer, and let's think of something interesting. Even if you're in elementary school, if you're solving an engineering problem, when the code is getting complicated, Oh, isn't there a formula for this?You have to be able to think of .
Is there a formula for this problem? Let's try to induce him.
When I first saw this, I thought, "strong" is a concept of digits...It's called "
You have to give a card with 30 triangles on it so that you can't beat a card with a single star on it.
If you look at the problem conditions further, a ticket can hold up to 100 pictures, and no matter how many lower-class pictures there are, if a higher-class picture is not enough, you will be defeated unconditionally
I think it'll be about enough if I pay with an extra point, what do you think? Solve the task first, and think about it later!
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
584 PHP ssh2_scp_send fails to send files as intended
578 Understanding How to Configure Google API Key
623 Uncaught (inpromise) Error on Electron: An object could not be cloned
922 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.