Skip to content

Instantly share code, notes, and snippets.

@seven0525
Last active May 24, 2018 03:01
Show Gist options
  • Save seven0525/d3a1710cf43d002cba39b8b5a8536739 to your computer and use it in GitHub Desktop.
Save seven0525/d3a1710cf43d002cba39b8b5a8536739 to your computer and use it in GitHub Desktop.
「自作Python100本ノック」13日目(Pythonおじさんへの道:89本〜90本目) ref: https://qiita.com/ahpjop/items/6e522cee43e01fbd9b49
def count_n(n_list):
counts = []
for n in n_list:
count = 0
while n % 2 == 0:
count += 1
n = n / 2
else:
counts.append(count)
aws = min(counts)
print(aws)
count_n([16,16,4])
from numpy import random
def num_fight(card_number):
cards = list(range(card_number))
count = 0
alice_cards = []
bob_cards = []
while len(cards) != 0:
taken_card = max(cards)
cards.remove(taken_card)
count += 1
if count % 2 == 1:
alice_cards.append(taken_card)
else:
bob_cards.append(taken_card)
alice_score = sum(alice_cards)
bob_score = sum(bob_cards)
aws = alice_score - bob_score
print(aws)
num_fight(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment