Skip to main content
added 485 characters in body
Source Link

Progress: Updated the rules after some discussions in The Nineteenth Byteagain, and also add the timed function to the bots.

Here is a twist -- R. L. Hutchings proved that announcing a prime number as the first play provides a winning strategy for the first player, although the detail of the strategy is not yet known. So I put a restriction here: the first player cannot announce a prime number in the first step. Now the first two numbers will be generated randomly by the driver at the beginning and will be coprime. No more restriction on prime numbers now.

A bot playing the game will have to implement a Python 3 class, extending TimedBot, with two methods: announce() and learn(). announce() should receive a list of numbers (possibly empty) and return a single integer, and learn() should receive two integers (id of the first move and second move) and the complete list of the numbers in the last game played.

class SampleBot(TimedBot):     # must not be changed.
    def __init__(self, id):
        super().__init__()     # must not be changed.
        self.id = id

    def announce(self, list):
        import random
        return random.randint(1, 101)

    def learn(self, first, second, list):
        pass

###Test DriveTest Drive

class SampleBotTimedBot:
    def __init__(self, id):
        self.idtime = id20.0

    def announcetimed(self, listfunc):
        import random
        returndef random.randintf(1self, 100001*args)
 :
    def learn(self, first, second, list):
    import time
   pass

# very inefficient
def islinearcomb(n, l):
    if lena = time.time(l):
        for i in range(0, nb += 1func(self, l[0]*args):
            ifself.time i-= ==(time.time() n:- a)
            print(self.time)
    return [n // l[0]]
     return b
        elifreturn lenf

class SampleBot(lTimedBot):
 > 1  def __init__(self, id):
        super().__init__()
        islself.id = islinearcomb(n -id

 i, l[1:])
  @TimedBot.timed
    def announce(self, list):
        ifimport isl:random
        return random.randint(1, 100001)

    @TimedBot.timed
    def learn(self, returnfirst, [isecond, //list):
 l[0]] + isl
    return Nonepass

# very inefficient
def gcdislinearcomb(an, bl):
    if a < blen(l):
        returnfor gcdi in range(b0, an + 1, l[0]):
    elif not b:
      if i return== an:
    else:
        return gcd(b, a % b)

defreturn isprime(n):[n // l[0]]
    if n % 2 == 0:
   elif len(l) > 1:
  return False
    i = 3
    while i * iisl <== islinearcomb(n - i, l[1:])
        if n % i == 0   if isl:
            return False
       return i[i +=// 2l[0]] + isl
    return TrueNone

lose = -1
turn = 0
nums = []
bots = [SampleBot(0), SampleBot(1)] # replace with your bots here.

import random
while (len(nums) < 2):
    numsa, b, c, d = [randomrandom.randint(1000001, 99999910), random.randint(1000001, 99999910)], random.randint(1, 10), random.randint(1, 10)
    if gcd2**a * 3**b != 2**c * 3**d and 2**a * 3**b > 100000 and 2**c * 3**d > 100000 and 2**min(nums[0]a,c) nums[1]* 3**min(b,d) > 112:
        nums = [][2**a * 3**b, 2**c * 3**d]
while lose < 0:
    v = bots[turn].announce(nums)
    print("{0}({1}) announced {2}".format(type(bots[turn]).__name__, bots[turn].id, v))
    w = islinearcomb(v, nums)
    if w:
        str = ""
        for i in range(0, len(nums)):
            if i:
                str += "+"
            str += "{0}*{1}".format(nums[i], w[i] if i < len(w) else 0)
        print("{0}({1}) announced {2} that is equal to {3}".format(type(bots[turn]).__name__, bots[turn].id, v, str))
        lose = turn
    elif v == 1:
        print("{0}({1}) announced 1".format(type(bots[turn]).__name__, bots[turn].id))
        lose = turn
    nums += [v]
    turn = 1 - turn
print("{0}({1}) wins".format(type(bots[1 - lose]).__name__, bots[1 - lose].id))

Both methods should be finished promptly withinEach bot will have 20 seconds of time for deciding a move todo: adjustments. FailingRunning out time during the move results in a lose, and failing to finish a method within the requirement time20 seconds will lead to disqualification and rerun of all 100 rounds with the remaining bots.

Progress: Updated the rules after some discussions in The Nineteenth Byte.

Here is a twist -- R. L. Hutchings proved that announcing a prime number as the first play provides a winning strategy for the first player, although the detail of the strategy is not yet known. So I put a restriction here: the first player cannot announce a prime number in the first step. Now the first two numbers will be generated randomly by the driver at the beginning and will be coprime. No more restriction on prime numbers now.

A bot playing the game will have to implement a Python 3 class with two methods: announce() and learn(). announce() should receive a list of numbers (possibly empty) and return a single integer, and learn() should receive two integers (id of the first move and second move) and the complete list of the numbers in the last game played.

class SampleBot:
    def __init__(self, id):
        self.id = id

    def announce(self, list):
        import random
        return random.randint(1, 101)

    def learn(self, first, second, list):
        pass

###Test Drive

class SampleBot:
    def __init__(self, id):
        self.id = id

    def announce(self, list):
        import random
        return random.randint(1, 100001)
 
    def learn(self, first, second, list):
        pass

# very inefficient
def islinearcomb(n, l):
    if len(l):
        for i in range(0, n + 1, l[0]):
            if i == n:
                return [n // l[0]]
            elif len(l) > 1:
                isl = islinearcomb(n - i, l[1:])
                if isl:
                    return [i // l[0]] + isl
    return None

def gcd(a, b):
    if a < b:
        return gcd(b, a)
    elif not b:
        return a
    else:
        return gcd(b, a % b)

def isprime(n):
    if n % 2 == 0:
        return False
    i = 3
    while i * i <= n:
        if n % i == 0:
            return False
        i += 2
    return True

lose = -1
turn = 0
nums = []
bots = [SampleBot(0), SampleBot(1)] # replace with your bots here.

import random
while (len(nums) < 2):
    nums = [random.randint(100000, 999999), random.randint(100000, 999999)]
    if gcd(nums[0], nums[1]) > 1:
        nums = []
while lose < 0:
    v = bots[turn].announce(nums)
    print("{0}({1}) announced {2}".format(type(bots[turn]).__name__, bots[turn].id, v))
    w = islinearcomb(v, nums)
    if w:
        str = ""
        for i in range(0, len(nums)):
            if i:
                str += "+"
            str += "{0}*{1}".format(nums[i], w[i] if i < len(w) else 0)
        print("{0}({1}) announced {2} that is equal to {3}".format(type(bots[turn]).__name__, bots[turn].id, v, str))
        lose = turn
    elif v == 1:
        print("{0}({1}) announced 1".format(type(bots[turn]).__name__, bots[turn].id))
        lose = turn
    nums += [v]
    turn = 1 - turn
print("{0}({1}) wins".format(type(bots[1 - lose]).__name__, bots[1 - lose].id))

Both methods should be finished promptly within 20 seconds todo: adjustments. Failing to finish a method within the requirement time will lead to disqualification and rerun of all 100 rounds with the remaining bots.

Progress: Updated the rules again, and also add the timed function to the bots.

Here is a twist -- R. L. Hutchings proved that announcing a prime number as the first play provides a winning strategy for the first player, although the detail of the strategy is not yet known. So I put a restriction here: the first player cannot announce a prime number in the first step. Now the first two numbers will be generated randomly by the driver at the beginning. No more restriction on prime numbers now.

A bot playing the game will have to implement a Python 3 class, extending TimedBot, with two methods: announce() and learn(). announce() should receive a list of numbers (possibly empty) and return a single integer, and learn() should receive two integers (id of the first move and second move) and the complete list of the numbers in the last game played.

class SampleBot(TimedBot):     # must not be changed.
    def __init__(self, id):
        super().__init__()     # must not be changed.
        self.id = id

    def announce(self, list):
        import random
        return random.randint(1, 101)

    def learn(self, first, second, list):
        pass

###Test Drive

class TimedBot:
    def __init__(self):
        self.time = 20.0

    def timed(func):
        def f(self, *args):
            import time
            a = time.time()
            b = func(self, *args)
            self.time -= (time.time() - a)
            print(self.time)
            return b
        return f

class SampleBot(TimedBot):
    def __init__(self, id):
        super().__init__()
        self.id = id

    @TimedBot.timed
    def announce(self, list):
        import random
        return random.randint(1, 100001)

    @TimedBot.timed
    def learn(self, first, second, list):
        pass

# very inefficient
def islinearcomb(n, l):
    if len(l):
        for i in range(0, n + 1, l[0]):
            if i == n:
                return [n // l[0]]
            elif len(l) > 1:
                isl = islinearcomb(n - i, l[1:])
                if isl:
                    return [i // l[0]] + isl
    return None

lose = -1
turn = 0
nums = []
bots = [SampleBot(0), SampleBot(1)] # replace with your bots here.

import random
while (len(nums) < 2):
    a, b, c, d = random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)
    if 2**a * 3**b != 2**c * 3**d and 2**a * 3**b > 100000 and 2**c * 3**d > 100000 and 2**min(a,c) * 3**min(b,d) > 12:
        nums = [2**a * 3**b, 2**c * 3**d]
while lose < 0:
    v = bots[turn].announce(nums)
    print("{0}({1}) announced {2}".format(type(bots[turn]).__name__, bots[turn].id, v))
    w = islinearcomb(v, nums)
    if w:
        str = ""
        for i in range(0, len(nums)):
            if i:
                str += "+"
            str += "{0}*{1}".format(nums[i], w[i] if i < len(w) else 0)
        print("{0}({1}) announced {2} that is equal to {3}".format(type(bots[turn]).__name__, bots[turn].id, v, str))
        lose = turn
    elif v == 1:
        print("{0}({1}) announced 1".format(type(bots[turn]).__name__, bots[turn].id))
        lose = turn
    nums += [v]
    turn = 1 - turn
print("{0}({1}) wins".format(type(bots[1 - lose]).__name__, bots[1 - lose].id))

Each bot will have 20 seconds of time for deciding a move todo: adjustments. Running out time during the move results in a lose, and failing to finish a method within 20 seconds will lead to disqualification and rerun of all 100 rounds with the remaining bots.

added 178 characters in body
Source Link

Progress: finding a more computationally efficient algorithm to solveUpdated the Diophantine equation $$\sum_{1\le i\le l}{a_in_i}=s$$ and is considering to make a method that determines whether there is such solution open to submissionsrules after some discussions in The Nineteenth Byte.

Here is a twist -- R. L. Hutchings proved that announcing a prime number as the first play provides a winning strategy for the first player, although the detail of the strategy is not yet known. So I put a restriction here: the first player cannot announce a prime number in the first step.So I put a restriction here: the first player cannot announce a prime number in the first step. Now the first two numbers will be generated randomly by the driver at the beginning and will be coprime. No more restriction on prime numbers now.

###Test DriveTest Drive

class SampleBot:
    def __init__(self, id):
        self.id = id

    def announce(self, list):
        import random
        return random.randint(1, 101100001)

    def learn(self, first, second, list):
        pass

# very inefficient
def islinearcomb(n, l):
    if len(l):
        for i in range(0, n + 1, l[0]):
            if i == n:
                return [n // l[0]]
            elif len(l) > 1:
                isl = islinearcomb(n - i, l[1:])
                if isl:
                    return [i // l[0]] + isl
    return None

def gcd(a, b):
    if a < b:
        return gcd(b, a)
    elif not b:
        return a
    else:
        return gcd(b, a % b)

def isprime(n):
    if n % 2 == 0:
        return False
    i = 3
    while i * i <= n:
        if n % i == 0:
            return False
        i += 2
    return True

lose = -1
turn = 0
nums = []
bots = [SampleBot(0), SampleBot(1)] # replace with your bots here.

import random
while (len(nums) < 2):
    nums = [random.randint(100000, 999999), random.randint(100000, 999999)]
    if gcd(nums[0], nums[1]) > 1:
        nums = []
while lose < 0:
    v = bots[turn].announce(nums)
    print("{0}({1}) announced {2}".format(type(bots[turn]).__name__, bots[turn].id, v))
    w = islinearcomb(v, nums)
    if w:
        str = ""
        for i in range(0, len(nums)):
            if i:
                str += "+"
            str += "{0}*{1}".format(nums[i], w[i] if i < len(w) else 0)
        print("{0}({1}) announced {2} that is equal to {3}".format(type(bots[turn]).__name__, bots[turn].id, v, str))
        lose = turn
    elif v == 1:
        print("{0}({1}) announced 1".format(type(bots[turn]).__name__, bots[turn].id))
        lose = turn
    elif isprime(v) and len(nums) == 0:
        print("{0}({1}) announced a prime number on the first move".format(type(bots[turn]).__name__, bots[turn].id))
        lose = turn
    nums += [v]
    turn = 1 - turn
print("{0}({1}) wins".format(type(bots[1 - lose]).__name__, bots[1 - lose].id))

Progress: finding a more computationally efficient algorithm to solve the Diophantine equation $$\sum_{1\le i\le l}{a_in_i}=s$$ and is considering to make a method that determines whether there is such solution open to submissions.

Here is a twist -- R. L. Hutchings proved that announcing a prime number as the first play provides a winning strategy for the first player, although the detail of the strategy is not yet known. So I put a restriction here: the first player cannot announce a prime number in the first step.

###Test Drive

class SampleBot:
    def __init__(self, id):
        self.id = id

    def announce(self, list):
        import random
        return random.randint(1, 101)

    def learn(self, first, second, list):
        pass

# very inefficient
def islinearcomb(n, l):
    if len(l):
        for i in range(0, n + 1, l[0]):
            if i == n:
                return [n // l[0]]
            elif len(l) > 1:
                isl = islinearcomb(n - i, l[1:])
                if isl:
                    return [i // l[0]] + isl
    return None

def isprime(n):
    if n % 2 == 0:
        return False
    i = 3
    while i * i <= n:
        if n % i == 0:
            return False
        i += 2
    return True

lose = -1
turn = 0
nums = []
bots = [SampleBot(0), SampleBot(1)] # replace with your bots here.
while lose < 0:
    v = bots[turn].announce(nums)
    print("{0}({1}) announced {2}".format(type(bots[turn]).__name__, bots[turn].id, v))
    w = islinearcomb(v, nums)
    if w:
        str = ""
        for i in range(0, len(nums)):
            if i:
                str += "+"
            str += "{0}*{1}".format(nums[i], w[i] if i < len(w) else 0)
        print("{0}({1}) announced {2} that is equal to {3}".format(type(bots[turn]).__name__, bots[turn].id, v, str))
        lose = turn
    elif v == 1:
        print("{0}({1}) announced 1".format(type(bots[turn]).__name__, bots[turn].id))
        lose = turn
    elif isprime(v) and len(nums) == 0:
        print("{0}({1}) announced a prime number on the first move".format(type(bots[turn]).__name__, bots[turn].id))
        lose = turn
    nums += [v]
    turn = 1 - turn
print("{0}({1}) wins".format(type(bots[1 - lose]).__name__, bots[1 - lose].id))

Progress: Updated the rules after some discussions in The Nineteenth Byte.

Here is a twist -- R. L. Hutchings proved that announcing a prime number as the first play provides a winning strategy for the first player, although the detail of the strategy is not yet known. So I put a restriction here: the first player cannot announce a prime number in the first step. Now the first two numbers will be generated randomly by the driver at the beginning and will be coprime. No more restriction on prime numbers now.

###Test Drive

class SampleBot:
    def __init__(self, id):
        self.id = id

    def announce(self, list):
        import random
        return random.randint(1, 100001)

    def learn(self, first, second, list):
        pass

# very inefficient
def islinearcomb(n, l):
    if len(l):
        for i in range(0, n + 1, l[0]):
            if i == n:
                return [n // l[0]]
            elif len(l) > 1:
                isl = islinearcomb(n - i, l[1:])
                if isl:
                    return [i // l[0]] + isl
    return None

def gcd(a, b):
    if a < b:
        return gcd(b, a)
    elif not b:
        return a
    else:
        return gcd(b, a % b)

def isprime(n):
    if n % 2 == 0:
        return False
    i = 3
    while i * i <= n:
        if n % i == 0:
            return False
        i += 2
    return True

lose = -1
turn = 0
nums = []
bots = [SampleBot(0), SampleBot(1)] # replace with your bots here.

import random
while (len(nums) < 2):
    nums = [random.randint(100000, 999999), random.randint(100000, 999999)]
    if gcd(nums[0], nums[1]) > 1:
        nums = []
while lose < 0:
    v = bots[turn].announce(nums)
    print("{0}({1}) announced {2}".format(type(bots[turn]).__name__, bots[turn].id, v))
    w = islinearcomb(v, nums)
    if w:
        str = ""
        for i in range(0, len(nums)):
            if i:
                str += "+"
            str += "{0}*{1}".format(nums[i], w[i] if i < len(w) else 0)
        print("{0}({1}) announced {2} that is equal to {3}".format(type(bots[turn]).__name__, bots[turn].id, v, str))
        lose = turn
    elif v == 1:
        print("{0}({1}) announced 1".format(type(bots[turn]).__name__, bots[turn].id))
        lose = turn
    nums += [v]
    turn = 1 - turn
print("{0}({1}) wins".format(type(bots[1 - lose]).__name__, bots[1 - lose].id))
added 237 characters in body
Source Link

Progress: finding a more computationally efficient algorithm to solve the Diophantine equation $$\sum_{1\le i\le l}{a_in_i}=s$$ and is considering to make a method that determines whether there is such solution open to submissions.

Progress: finding a more computationally efficient algorithm to solve the Diophantine equation $$\sum_{1\le i\le l}{a_in_i}=s$$ and is considering to make a method that determines whether there is such solution open to submissions.

added 256 characters in body
Source Link
Loading
added 125 characters in body
Source Link
Loading
Source Link
Loading