Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

The 8 Queen Problem in Computer Science - full Python code solutions

Автор: Bytes N Bits

Загружено: 2020-10-18

Просмотров: 22114

Описание:

In the 8 queen problem you have a chess board and eight queens. You have to place all eight queens onto the board so that no two queens are attacking each other.

If you're not familiar with chess it's a game played on an eight by eight grid of squares (the same as draughts or chequers!). A queen is one of the chess pieces that can move in straight lines; horizontally, vertically or diagonally. A queen is attacking any other square that she can move to, so no two queens can be horizontally, vertically or diagonally aligned.

So we have to design a computer program that will find all the possible solutions to the problem.

Using brute force and just trying out every possible combination of placing the queens on the board results in having to test 4,426,165,368 combinations. If we can process 50,000 combinations per second that's going to take our computer over 24 hours to complete the task. We need a better solution!

We can start to work out ways of reducing this workload by examining the problem and optimising our algorithm.

In the video I'll walk you through designing the algorithm and then coding it. First we'll use a nested looping structure - placing for loops within for loops.

We'll then see how this lends itself to a solution using recursion. Don't run away at the mention of recursion! It's actually quite straight forward once you get the hang of it and drastically reduces the complexity of nested loop and tree structure based coding.

Make sure you visit the project page for this to download all the code used in the video.

https://bytesnbits.co.uk/the-8-queen-...

If you're interested in learning how to code in Python check out my beginners Python course at

https://www.udemy.com/course/learn-py...

The 8 Queen Problem in Computer Science - full Python code solutions

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

N-Queens - Backtracking - Leetcode 51 - Python

N-Queens - Backtracking - Leetcode 51 - Python

Написание решателя судоку на Python с использованием рекурсии/возврата

Написание решателя судоку на Python с использованием рекурсии/возврата

Решение задачи N-ферзей — самый простой алгоритм

Решение задачи N-ферзей — самый простой алгоритм

Я в опасности

Я в опасности

Can you solve this chess puzzle? (8 Queens problem)

Can you solve this chess puzzle? (8 Queens problem)

Space Invaders Урок 1 — Переменные

Space Invaders Урок 1 — Переменные

Coding Adventure: Chess

Coding Adventure: Chess

ВСЕ накопители ДАННЫХ: объясняю за 8 минут

ВСЕ накопители ДАННЫХ: объясняю за 8 минут

Python Sudoku Solver - Computerphile

Python Sudoku Solver - Computerphile

How Dijkstra's Algorithm Works

How Dijkstra's Algorithm Works

Python Object Oriented Programming (OOP) - For Beginners

Python Object Oriented Programming (OOP) - For Beginners

Why the Radius Is NOT 21 – Quarter Circle Geometry Puzzle

Why the Radius Is NOT 21 – Quarter Circle Geometry Puzzle

Turn your TV into the Ultimate Arcade cabinet with a £15 Raspberry Pi

Turn your TV into the Ultimate Arcade cabinet with a £15 Raspberry Pi

120 МИЛЛИАРДОВ: КТО и Зачем создал БИТКОИН? Тайна Сатоши Накамото

120 МИЛЛИАРДОВ: КТО и Зачем создал БИТКОИН? Тайна Сатоши Накамото

The Windows 11 Disaster That's Killing Microsoft

The Windows 11 Disaster That's Killing Microsoft

How to Make a Replica Commodore 64

How to Make a Replica Commodore 64

Wyjaśniamy o co chodzi z Grenlandią. Czy naprawdę może wybuchnąć wojna USA-Dania?

Wyjaśniamy o co chodzi z Grenlandią. Czy naprawdę może wybuchnąć wojna USA-Dania?

Ханойские башни: полная рекурсивная визуализация

Ханойские башни: полная рекурсивная визуализация

Скрытая красота алгоритма A*

Скрытая красота алгоритма A*

5 простых шагов для решения любой рекурсивной задачи

5 простых шагов для решения любой рекурсивной задачи

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com