Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New puzzle inspired by codeforces 266B #8

Open
akalai opened this issue Jun 20, 2021 · 0 comments
Open

New puzzle inspired by codeforces 266B #8

akalai opened this issue Jun 20, 2021 · 0 comments

Comments

@akalai
Copy link
Contributor

akalai commented Jun 20, 2021

def sat(s: List[int]):
    """
    Find a sequence of 0's and 1's so that, after n_steps of swapping each adjacent (0, 1), the target sequence
    is achieved.

    Inspired by [Codeforces Problem 266 B](https://codeforces.com/problemset/problem/266/B)
    """
    for step in range(8):
        for i in range(len(s) - 1):
            if (s[i], s[i + 1]) == (0, 1):
                (s[i], s[i + 1]) = (1, 0)
    return s == [1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Solvers, post your solutions in the comments using the following formatting:

<details><summary>Reveal solution</summary>

```python
def sol():
    return "world"  # replace with your solution
```
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant