> For the complete documentation index, see [llms.txt](https://crypt0nite.gitbook.io/writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://crypt0nite.gitbook.io/writeups/ctfs/nahamcon/crypto/homecooked.md).

# HomeCooked

So first we see that running the program slowly decrypts the string to yield a flag - but it's simply not fast enough. It never ends - we can check by putting a `print()` statement at the end. So, we'll have to somehow make it go faster - and to do this we need to work out what the functions do.

The `b()` function looks like this:

```python
def b(num):
    my_str = str(num)
    rev_str = reversed(my_str)
    if list(my_str) == list(rev_str):
        return True
    else:
        return False
```

If we have a look at what it's doing, it seems to be reversing the input and comparing the two - so it returns `True` if the inputted number is palidromic, and `False` if it is not. We can't really make this more efficient, at least noticably.

The `a()` function, however, looks like this:

```python
def a(num):
    if (num > 1):
        for i in range(2, num)):
            if (num % i) == 0:
                return False
                break
        return True
    else:
        return False
```

What this seems to be doing is looping through every value from `2` to `n-1` and checking if `n` is divisible by it - a way of **checking if it's prime**. However, this is incredibly inefficient, and is probably the reason it takes so long. Let's make it more efficient and see if it does something.

We are going to use the `sympy` function `isprime` to change `a()`:

```python
from sympy import isprime

def a(num):
    return isprime(num)
```

Running this program spits out the full flag much faster now.

**flag{pR1m3s\_4re\_co0ler\_Wh3n\_pal1nDr0miC}**


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://crypt0nite.gitbook.io/writeups/ctfs/nahamcon/crypto/homecooked.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
