Description Link to heading

Welcome to numbers! just answer my few questions to get the flag!

Solving Link to heading

The goal of this challenge is to find how many times the first number is in the second one. E.g : “How many 3’s appear till 40?” The answer - 14 because [‘3’,‘13’,‘23’,‘30’,‘31’,‘32’,‘33’,‘33’,‘34’,‘35’,‘36’,‘37’,‘38’,‘39’].

We just have iterate and count how many times we found the first number.

from pwn import *
conn = remote('challs.n00bzunit3d.xyz', 13541)
i = 0
while True:
    i+=1
    try:
        val = 0
        data = conn.recvuntil(b'?').strip()
        print(data)
        data1 = data.split(b"'s")[0]
        data2 = data.split(b" ")[-1]
        digit = data1.decode()[-1]
        number = int(data2.decode().replace('?',''))
        for n in range(1, number):
            for c in str(n):
                if digit == c:
                    val += 1
        res = str(val)
        res = bytes(res, 'ascii')
        conn.sendline(res)
        state = conn.recvline()
        print(state)
    except Exception:
        print(conn.recvline())
conn.close()

Result Link to heading

n00bz{4n_345y_pr0gr4mm1ng_ch4ll}