Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
Accelerator
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
seankim96
/
Python-coding-practice
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
main
Breadcrumbs
Python-coding-practice
/
N_Queen
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
20 lines (13 loc) · 1.39 KB
main
Breadcrumbs
Python-coding-practice
/
N_Queen
Copy path
Top
File metadata and controls
Code
Blame
20 lines (13 loc) · 1.39 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
N-Queen
N개의 여왕이 N*N인 보드에서 서로 공격하지 못하는 경우의 수의 총합을 구하는 문제
값을 0으로 가진 N*N인 이차원 배열을 생성하고 이중 for문을 구성해서 처음 만나는 0의값을 가진 배열의 가로 세로 대각을 1로 만든 뒤 그 과정을 N번만큼 반복하고 N만큼의 반복에 도달했을때
아직 0인 부분이 해답이므로 해당값을 카운팅하고 이전 배열을 호출 해당 과정을 반복 하려했으나....
Backtracking 문제임에도 backtracking 하는 방법을 몰라 repeat이 안되서 강의를 찾아보았다.
풀이는 이차원 배열이 아닌 다른 방식으로 이루어져있었다.
따지고보면 X,Y 축중 어느 한곳에 두개의 퀸이 머물러 있다는것부터 경우의 수에서 벗어남으로 그 과정을 생략하는것이 가능했다.
따라서 n번째의 퀸은 x열이던 y열이던 자신의 순서에서 시작하고 나머지를 계산하는 방식으로 접근이 가능하다. 그리고 대각선도 복잡한 비교가아닌 각자의 인덱스값의 차와 해당값들의 차의
절대값으로 알아내는것이 가능했다.
문제를 복잡하게 만들었던 요소중 2가지의 경우가 간략화되었다.
따라서 두가지 함수가 필요한데
대각의 값을 검사해 해당값이 유효한지 확인해주는 체커하나
이를 카운트하고
You can’t perform that action at this time.