Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions 8_puzzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ def priority(self) -> int:
return self.moves + self.manhattan()

def manhattan(self) -> int:
"""Calculate Manhattan distance from current to goal state."""
"""Calculate Manhattan distance using actual goal positions."""
distance = 0
# Create a lookup table for goal tile positions
goal_pos = {self.goal[i][j]: (i, j) for i in range(3) for j in range(3)}

for i in range(3):
for j in range(3):
if self.board[i][j] != 0:
x, y = divmod(self.board[i][j] - 1, 3)
value = self.board[i][j]
if value != 0: # skip the empty tile
x, y = goal_pos[value]
distance += abs(x - i) + abs(y - j)
return distance


def is_goal(self) -> bool:
"""Check if current state matches goal."""
return self.board == self.goal
Expand Down
2 changes: 1 addition & 1 deletion PongPong_Game/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyglet==2.1.9
pyglet==2.1.11
45 changes: 45 additions & 0 deletions remoteok_jobs_scraper/remoteok_jobs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import requests
import xlwt
from xlwt import Workbook

BASE_URL = 'https://remoteok.com/api'
USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'
REQUEST_HEADER = {
'User-Agent': USER_AGENT,
'Accept-Language': 'en-US, en;q=0.5',
}

def get_job_postings():
"""Fetch job postings from RemoteOK API."""
try:
res = requests.get(BASE_URL, headers=REQUEST_HEADER)
res.raise_for_status()
data = res.json()
return data[1:]
except requests.RequestException as e:
print("Error fetching jobs:", e)
return []

def save_jobs_to_excel(jobs, filename='remoteok_jobs.xls'):
"""Save job postings to an Excel file."""
if not jobs:
print("No job data to save.")
return

wb = Workbook()
sheet = wb.add_sheet('Jobs')

headers = list(jobs[0].keys())
for col, header in enumerate(headers):
sheet.write(0, col, header)

for row, job in enumerate(jobs, start=1):
for col, key in enumerate(headers):
sheet.write(row, col, str(job.get(key, '')))

wb.save(filename)
print(f"Jobs saved to {filename}")

if __name__ == '__main__':
jobs = get_job_postings()
save_jobs_to_excel(jobs)
2 changes: 1 addition & 1 deletion requirements_with_versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pydantic==2.12.4
openpyxl==3.1.2
pytesseract==0.3.13
requests-mock==1.12.1
pyglet==2.1.9
pyglet==2.1.11
urllib3==2.5.0
thirdai==0.9.33
google-api-python-client==2.187.0
Expand Down
Loading