Skip to content

Commit

Permalink
feat: sq and cube
Browse files Browse the repository at this point in the history
  • Loading branch information
ongsici committed Oct 28, 2024
1 parent f2cffc2 commit 4f423db
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
from flask import Flask, render_template, request
app = Flask(__name__)
import math

def is_square(n):
return int(math.sqrt(n)) ** 2 == n

def is_cube(n):
return int(round(n ** (1/3))) ** 3 == n


def process_query(input):
if "square and a cube" in input:
input = input.replace("?", "")
value = input.split(":")[-1].split(",")
result = []
for number in value:
number=number.strip()
if is_square(int(number)) and is_cube(int(number)):
result.append(number)
return ", ".join(result)

if "plus" in input:
new_input = input.replace("?", "")
value1 = int(new_input.split(" ")[2])
Expand Down

0 comments on commit 4f423db

Please sign in to comment.