menu update
This commit is contained in:
parent
c46a0e188e
commit
f8d1479bd9
@ -1,5 +1,65 @@
|
|||||||
import os
|
# import os
|
||||||
|
# import re
|
||||||
|
|
||||||
|
# cwd = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
# # file_name = 'advent2023_p1.txt'
|
||||||
|
# file_name = 'test.txt'
|
||||||
|
# advent = os.path.join(cwd, file_name)
|
||||||
|
|
||||||
|
# nums = []
|
||||||
|
# values = []
|
||||||
|
|
||||||
|
# # test = "eighthree"
|
||||||
|
|
||||||
|
# # numbers = {
|
||||||
|
# # 'one': 1, 'two': 2, 'three': 3, 'four': 4,
|
||||||
|
# # 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9
|
||||||
|
# # }
|
||||||
|
# numbers_to_string = {
|
||||||
|
# 'one': '1', 'two': '2', 'three': '3', 'four': '4',
|
||||||
|
# 'five': '5', 'six': '6', 'seven': '7', 'eight': '8', 'nine': '9'
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# with open(advent, 'r') as file:
|
||||||
|
# for line in file: # Read lines
|
||||||
|
# # Split the line when a digit has been found
|
||||||
|
# digit_index = re.findall(r'(?:(one|two|three|four|five|six|seven|eight|nine)|(\d))', line)
|
||||||
|
# # print(digit_index)
|
||||||
|
# if digit_index:
|
||||||
|
# # Use the tuple method to find if the value is present
|
||||||
|
# for num,num2 in digit_index:
|
||||||
|
# # Always the spelled out number, convert to string digit
|
||||||
|
# if num:
|
||||||
|
# # if num in numbers:
|
||||||
|
# # nums.append()
|
||||||
|
# nums.append(numbers_to_string[num])
|
||||||
|
# # Pass the string digit
|
||||||
|
# if num2:
|
||||||
|
# nums.append(num2)
|
||||||
|
# print(nums)
|
||||||
|
# # values.append()
|
||||||
|
# if len(nums) < 2:
|
||||||
|
# num_one = nums[0]
|
||||||
|
# num_two = num_one
|
||||||
|
# num_join = num_one + num_two
|
||||||
|
# values.append(int(num_join))
|
||||||
|
# else:
|
||||||
|
# num_one = nums[0]
|
||||||
|
# num_two = nums[-1]
|
||||||
|
# num_join = num_one + num_two
|
||||||
|
# values.append(int(num_join))
|
||||||
|
# nums.clear()
|
||||||
|
# # print(values)
|
||||||
|
# # print(sum(values))
|
||||||
|
# # print(numbers_as_integers)
|
||||||
|
|
||||||
|
# file.close()
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
cwd = os.path.dirname(os.path.abspath(__file__))
|
cwd = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
@ -7,53 +67,49 @@ cwd = os.path.dirname(os.path.abspath(__file__))
|
|||||||
file_name = 'test.txt'
|
file_name = 'test.txt'
|
||||||
advent = os.path.join(cwd, file_name)
|
advent = os.path.join(cwd, file_name)
|
||||||
|
|
||||||
nums = []
|
def extract_numbers(text):
|
||||||
values = []
|
# Regular expression to match digits and number words
|
||||||
|
num_pattern = r'(?:zero|one|two|three|four|five|six|seven|eight|nine|\d)+'
|
||||||
|
|
||||||
# test = "eighthree"
|
# Find all occurrences of numbers in the text
|
||||||
|
numbers = re.findall(num_pattern, text)
|
||||||
|
|
||||||
# numbers = {
|
# Function to convert number words to digits
|
||||||
# 'one': 1, 'two': 2, 'three': 3, 'four': 4,
|
def words_to_digits(word):
|
||||||
# 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9
|
words_to_digits_dict = {
|
||||||
# }
|
'zero': '0', 'one': '1', 'two': '2', 'three': '3',
|
||||||
numbers_to_string = {
|
'four': '4', 'five': '5', 'six': '6', 'seven': '7',
|
||||||
'one': '1', 'two': '2', 'three': '3', 'four': '4',
|
'eight': '8', 'nine': '9'
|
||||||
'five': '5', 'six': '6', 'seven': '7', 'eight': '8', 'nine': '9'
|
}
|
||||||
}
|
return ''.join(words_to_digits_dict.get(w, w) for w in re.findall(r'\w+', word))
|
||||||
|
|
||||||
|
# Convert all number words to digits
|
||||||
|
numbers = [words_to_digits(num) for num in numbers]
|
||||||
|
|
||||||
|
# Find the first and last numbers in the list
|
||||||
|
first_number = next((num for num in numbers if any(c.isdigit() for c in num)), None)
|
||||||
|
last_number = next((num for num in reversed(numbers) if any(c.isdigit() for c in num)), None)
|
||||||
|
|
||||||
|
return first_number, last_number
|
||||||
|
|
||||||
|
# Read text from the file
|
||||||
with open(advent, 'r') as file:
|
with open(advent, 'r') as file:
|
||||||
for line in file: # Read lines
|
lines = file.readlines()
|
||||||
# Split the line when a digit has been found
|
|
||||||
digit_index = re.findall(r'(?:(one|two|three|four|five|six|seven|eight|nine)|(\d))', line)
|
|
||||||
# print(digit_index)
|
|
||||||
if digit_index:
|
|
||||||
# Use the tuple method to find if the value is present
|
|
||||||
for num,num2 in digit_index:
|
|
||||||
# Always the spelled out number, convert to string digit
|
|
||||||
if num:
|
|
||||||
# if num in numbers:
|
|
||||||
# nums.append()
|
|
||||||
nums.append(numbers_to_string[num])
|
|
||||||
# Pass the string digit
|
|
||||||
if num2:
|
|
||||||
nums.append(num2)
|
|
||||||
print(nums)
|
|
||||||
# values.append()
|
|
||||||
if len(nums) < 2:
|
|
||||||
num_one = nums[0]
|
|
||||||
num_two = num_one
|
|
||||||
num_join = num_one + num_two
|
|
||||||
values.append(int(num_join))
|
|
||||||
else:
|
|
||||||
num_one = nums[0]
|
|
||||||
num_two = nums[-1]
|
|
||||||
num_join = num_one + num_two
|
|
||||||
values.append(int(num_join))
|
|
||||||
nums.clear()
|
|
||||||
# print(values)
|
|
||||||
# print(sum(values))
|
|
||||||
# print(numbers_as_integers)
|
|
||||||
|
|
||||||
file.close()
|
# Initialize total sum
|
||||||
|
total_sum = 0
|
||||||
|
|
||||||
|
# Process each line in the file
|
||||||
|
for line in lines:
|
||||||
|
# Extract first and last numbers from the line
|
||||||
|
first_num, last_num = extract_numbers(line)
|
||||||
|
|
||||||
|
# Calculate the sum of individual digits from the first and last numbers
|
||||||
|
if first_num is not None and last_num is not None:
|
||||||
|
first_sum = sum(int(digit) for digit in str(first_num))
|
||||||
|
last_sum = sum(int(digit) for digit in str(last_num))
|
||||||
|
line_sum = first_sum + last_sum
|
||||||
|
total_sum += line_sum
|
||||||
|
|
||||||
|
# Print the total sum of individual digits from the first and last numbers in all lines
|
||||||
|
print("Total sum of individual digits from first and last numbers in all lines:", total_sum)
|
||||||
|
|||||||
@ -1,2 +1,24 @@
|
|||||||
9vxfg
|
9vxfg
|
||||||
eighthree
|
eighthree
|
||||||
|
ninefivefive2nine5ntvscdfdsmvqgcbxxxt
|
||||||
|
onepx6hbgdssfivexs
|
||||||
|
cdtjprrbvkftgtwo397seven
|
||||||
|
2eightsix16
|
||||||
|
41pqdmfvptwo
|
||||||
|
xhlqvsjpbhfivefour5sevenonemcmrkvhkjqfour5
|
||||||
|
2czddtpsrgsbgddsix6gvmxqlsnnine4
|
||||||
|
twozxsix9kmctfour
|
||||||
|
3hqfxkzr2nineqdpgbzndxf2two
|
||||||
|
bjd99eight6sfive
|
||||||
|
oneeighttwo34dcjck5eightjznpzhxdlc
|
||||||
|
6sixeighttqslqvplsxvpxch
|
||||||
|
sixonemc55
|
||||||
|
sixeight7five9ninesixfour
|
||||||
|
lmbzpzrhssdslkeight9eightpjj
|
||||||
|
six2eight579hlbgjnjkqrxrdlhnpfour
|
||||||
|
6fkfxsqncm456onesftkndhl
|
||||||
|
bqfckhdmppqvjlkx75dvjzveight8
|
||||||
|
btfppljkfkzcklskgzzhmtwo9fjsix
|
||||||
|
seven44tgvh
|
||||||
|
rvmjm8nlg3ttgcjtwo
|
||||||
|
sevendjdckvz9nine6cth
|
||||||
@ -7,7 +7,7 @@ const Reserve = () => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="right-2 hidden md:block">
|
<div className="right-2 hidden md:block">
|
||||||
<Button size='sm' className="xl:text-lg bg-red-800 hover:bg-slate-800 text-xs">
|
<Button size='sm' className="xl:text-lg bg-red-800 hover:bg-slate-800 text-xs">
|
||||||
<span className="flex flex-row">
|
<span className="flex flex-row">
|
||||||
<span className="flex flex-row">ORDER ONLINE</span>
|
<span className="flex flex-row">ORDER ONLINE</span>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@ -23,17 +23,8 @@ const Appetizers = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore hic aspernatur ducimus sed laboriosam adipisci amet culpa eveniet? Alias facilis soluta aliquam tenetur natus ipsam, rem quis dolore distinctio enim.</p>
|
<h4>Guacamole Dip</h4>
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore hic aspernatur ducimus sed laboriosam adipisci amet culpa eveniet? Alias facilis soluta aliquam tenetur natus ipsam, rem quis dolore distinctio enim.</p>
|
;
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore hic aspernatur ducimus sed laboriosam adipisci amet culpa eveniet? Alias facilis soluta aliquam tenetur natus ipsam, rem quis dolore distinctio enim.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore hic aspernatur ducimus sed laboriosam adipisci amet culpa eveniet? Alias facilis soluta aliquam tenetur natus ipsam, rem quis dolore distinctio enim.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore hic aspernatur ducimus sed laboriosam adipisci amet culpa eveniet? Alias facilis soluta aliquam tenetur natus ipsam, rem quis dolore distinctio enim.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore hic aspernatur ducimus sed laboriosam adipisci amet culpa eveniet? Alias facilis soluta aliquam tenetur natus ipsam, rem quis dolore distinctio enim.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore hic aspernatur ducimus sed laboriosam adipisci amet culpa eveniet? Alias facilis soluta aliquam tenetur natus ipsam, rem quis dolore distinctio enim.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore hic aspernatur ducimus sed laboriosam adipisci amet culpa eveniet? Alias facilis soluta aliquam tenetur natus ipsam, rem quis dolore distinctio enim.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore hic aspernatur ducimus sed laboriosam adipisci amet culpa eveniet? Alias facilis soluta aliquam tenetur natus ipsam, rem quis dolore distinctio enim.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore hic aspernatur ducimus sed laboriosam adipisci amet culpa eveniet? Alias facilis soluta aliquam tenetur natus ipsam, rem quis dolore distinctio enim.</p>
|
|
||||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolore hic aspernatur ducimus sed laboriosam adipisci amet culpa eveniet? Alias facilis soluta aliquam tenetur natus ipsam, rem quis dolore distinctio enim.</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user