Skip to content

Commit 2dea48c

Browse files
authored
Merge branch 'master' into master
2 parents e69d383 + 89f8daa commit 2dea48c

File tree

144 files changed

+13218
-458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+13218
-458
lines changed

.circleci/config.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Use the latest 2.1 version of CircleCI pipeline process engine.
2+
# See: https://circleci.com/docs/reference/configuration-reference
3+
version: 2.1
4+
5+
# Define a job to be invoked later in a workflow.
6+
# See: https://circleci.com/docs/guides/orchestrate/jobs-steps/#jobs-overview & https://circleci.com/docs/reference/configuration-reference/#jobs
7+
jobs:
8+
say-hello:
9+
# Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub.
10+
# See: https://circleci.com/docs/guides/execution-managed/executor-intro/ & https://circleci.com/docs/reference/configuration-reference/#executor-job
11+
docker:
12+
# Specify the version you desire here
13+
# See: https://circleci.com/developer/images/image/cimg/base
14+
- image: cimg/base:current
15+
16+
# Add steps to the job
17+
# See: https://circleci.com/docs/guides/orchestrate/jobs-steps/#steps-overview & https://circleci.com/docs/reference/configuration-reference/#steps
18+
steps:
19+
# Checkout the code as the first step.
20+
- checkout
21+
- run:
22+
name: "Say hello"
23+
command: "echo Hello, World!"
24+
25+
# Orchestrate jobs using workflows
26+
# See: https://circleci.com/docs/guides/orchestrate/workflows/ & https://circleci.com/docs/reference/configuration-reference/#workflows
27+
workflows:
28+
say-hello-workflow: # This is the name of the workflow, feel free to change it to better match your workflow.
29+
# Inside the workflow, you define the jobs you want to run.
30+
jobs:
31+
- say-hello

1 File handle/File handle binary/Update a binary file2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ def update():
3030

3131
# ! Instead of AB use WB?
3232
# ! It may have memory limits while updating large files but it would be good
33-
# ! Few lakhs records would be fine and wouln't create any much of a significant issues
33+
# ! Few lakhs records would be fine and wouldn't create any much of a significant issues

1 File handle/File handle binary/update2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def update():
1717

1818
for i in S:
1919
if rno == i[0]:
20-
print(f"the currrent name is {i[1]}")
20+
print(f"the current name is {i[1]}")
2121
i[1] = input("enter the new name")
2222
found = True
2323
break

1-file_handle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit c9283ce68a8ff170e24082e22ed598da549c49ae

8_puzzle.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,20 @@ def priority(self) -> int:
2626
return self.moves + self.manhattan()
2727

2828
def manhattan(self) -> int:
29-
"""Calculate Manhattan distance from current to goal state."""
29+
"""Calculate Manhattan distance using actual goal positions."""
3030
distance = 0
31+
# Create a lookup table for goal tile positions
32+
goal_pos = {self.goal[i][j]: (i, j) for i in range(3) for j in range(3)}
33+
3134
for i in range(3):
3235
for j in range(3):
33-
if self.board[i][j] != 0:
34-
x, y = divmod(self.board[i][j] - 1, 3)
36+
value = self.board[i][j]
37+
if value != 0: # skip the empty tile
38+
x, y = goal_pos[value]
3539
distance += abs(x - i) + abs(y - j)
3640
return distance
3741

42+
3843
def is_goal(self) -> bool:
3944
"""Check if current state matches goal."""
4045
return self.board == self.goal

AREA OF TRIANGLE.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
# Python Program to find the area of triangle
2-
# calculates area of traingle in efficient way!!
3-
a = 5
4-
b = 6
5-
c = 7
1+
def get_valid_side(prompt:str):
2+
while True:
3+
try:
4+
value = float(input(prompt))
5+
if value <=0:
6+
print("Side must be positive")
7+
continue
8+
return value
9+
except ValueError:
10+
print("Invalid Input")
611

7-
# Uncomment below to take inputs from the user
8-
# a = float(input('Enter first side: '))
9-
# b = float(input('Enter second side: '))
10-
# c = float(input('Enter third side: '))
1112

12-
# calculate the semi-perimeter
13-
s = (a + b + c) / 2
13+
a = get_valid_side("Enter side 1: ")
14+
b = get_valid_side("Enter side 2: ")
15+
c = get_valid_side("Enter side 3: ")
1416

15-
# calculate the area
16-
area = (s * (s - a) * (s - b) * (s - c)) ** 0.5
17+
semi_perimeter = (a + b + c) / 2
18+
19+
area = sqrt((s * (s - a) * (s - b) * (s - c)))
1720
print("The area of the triangle is %0.2f" % area)

Armstrong_number.py

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,19 @@
1-
"""
2-
In number theory, a narcissistic number (also known as a pluperfect digital invariant (PPDI), an Armstrong number (after Michael F. Armstrong) or a plus perfect number),
3-
in a given number base b, is a number that is the total of its own digits each raised to the power of the number of digits.
4-
Source: https://en.wikipedia.org/wiki/Narcissistic_number
5-
NOTE:
6-
this scripts only works for number in base 10
7-
"""
1+
def is_armstrong_number(number: str) -> bool:
2+
"""Check if a number (as a string) is a narcissistic/Armstrong number."""
3+
# Logic: Get the exponent (number of digits)
4+
exponent = len(number)
5+
6+
# Logic: Sum each digit raised to the power in a single line
7+
# This uses a generator, which is memory efficient.
8+
total = sum(int(digit) ** exponent for digit in number)
9+
10+
# Return the boolean result instead of printing
11+
return total == int(number)
812

13+
# --- Main execution ---
14+
user_input = input("Enter the number: ")
915

10-
def is_armstrong_number(number: str):
11-
total: int = 0
12-
exp: int = len(
13-
number
14-
) # get the number of digits, this will determinate the exponent
15-
16-
digits: list[int] = []
17-
for digit in number:
18-
digits.append(int(digit)) # get the single digits
19-
for x in digits:
20-
total += x**exp # get the power of each digit and sum it to the total
21-
22-
# display the result
23-
if int(number) == total:
24-
print(number, "is an Armstrong number")
25-
else:
26-
print(number, "is not an Armstrong number")
27-
28-
29-
number = input("Enter the number : ")
30-
is_armstrong_number(number)
16+
if is_armstrong_number(user_input):
17+
print(f"{user_input} is an Armstrong number")
18+
else:
19+
print(f"{user_input} is not an Armstrong number")

Assembler/assembler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ def scanner(string):
745745

746746
def scan():
747747
"""
748-
scan: applys function scanner() to each line of the source code.
748+
scan: applies function scanner() to each line of the source code.
749749
"""
750750
global lines
751751
assert len(lines) > 0, "no lines"
@@ -1008,7 +1008,7 @@ def parser():
10081008
elif eax == 3:
10091009
ecx = float(input(">> "))
10101010

1011-
elif eax == 4: # output informations
1011+
elif eax == 4: # output information
10121012
print(ecx)
10131013

10141014
elif token.token == "push": # push commando
@@ -1157,7 +1157,7 @@ def parser():
11571157
pointer = jumps[token.token]
11581158

11591159
else: # error case
1160-
print("Error: Unknow subprogram!")
1160+
print("Error: Unknown subprogram!")
11611161
return
11621162

11631163
else: # error case
@@ -1169,7 +1169,7 @@ def parser():
11691169
pointer = returnStack.pop()
11701170

11711171
else: # error case
1172-
print("Error: No return adress on stack")
1172+
print("Error: No return address on stack")
11731173
return
11741174

11751175
elif token.t == "subprogram":

Automated Scheduled Call Reminders/caller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# Here the collection name is on_call which has documents with fields phone , from (%H:%M:%S time to call the person),date
2222

2323

24-
# gets data from cloud database and calls 5 min prior the time (from time) alloted in the database
24+
# gets data from cloud database and calls 5 min prior the time (from time) allotted in the database
2525
def search():
2626
calling_time = datetime.now()
2727
one_hours_from_now = (calling_time + timedelta(hours=1)).strftime("%H:%M:%S")

BlackJack_game/blackjack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def dealer_choice():
106106
while sum(p_cards) < 21:
107107
# to continue the game again and again !!
108108
k = input("Want to hit or stay?\n Press 1 for hit and 0 for stay ")
109-
if k == "1": # Ammended 1 to a string
109+
if k == "1": # Amended 1 to a string
110110
random.shuffle(deck)
111111
p_cards.append(deck.pop())
112112
print("You have a total of " + str(sum(p_cards)) + " with the cards ", p_cards)

0 commit comments

Comments
 (0)