圣诞老人python代码_Python秘密圣诞老人程序如何取得更高的成功R

我决定做一个Python程序,根据硬编码的限制生成秘密的圣诞老人对(例如,某人找不到他的妻子)。我的家庭成员都很忙,所以很难组织每个人随意画帽子。在

我的程序死机很少,因为不幸的随机配对使剩余的一对非法(不过,我在测试脚本部分捕捉到它们)。你可以把它想象成一个亲自重新画的画。在

然而,当我的程序成功时,我知道配对是正确的,而不必亲自查看它们,因为我的程序会测试其有效性。明天,我要想办法利用配对,从我的邮箱给每个人发一封电子邮件,告诉他们他们有谁,而我不知道谁拥有谁,甚至谁拥有我。在

以下是我的完整程序代码(所有代码都是我自己的;我没有在网上查找任何解决方案,因为我想让自己接受最初的挑战):# Imports

import random

import copy

from random import shuffle

# Define Person Class

class Person:

def __init__(self, name, email):

self.name = name

self.email = email

self.isAllowedToHaveSecretSanta = True

self.isSecretSanta = False

self.secretSanta = None

# ----- CONFIGURATION SCRIPT -----

# Initialize people objects

brother1 = Person("Brother1", "brother1@gmail.com")

me = Person("Me", "me@gmail.com")

brother2 = Person("Brother2", "brother2@gmail.com")

brother2Girlfriend = Person("Brother2Girlfriend", "brother2Girlfriend@gmail.com")

brother3 = Person("Brother3", "brother3@gmail.com")

brother3Girlfriend = Person("Brother3Girlfriend", "brother3Girlfriend@gmail.com")

brother4 = Person("Brother4", "brother4@gmail.com")

brother4Girlfriend = Person("Brother4Girlfriend", "brother4Girlfriend@gmail.com")

brother5 = Person("Brother5", "brother5@yahoo.com")

brother5Girlfriend = Person("Brother5Girlfriend", "brother5Girlfriend@gmail.com")

myDad = Person("MyDad", "myDad@gmail.com

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值