giulio98/xlcost-single-prompt huggingface dataset:
# number of steps required to reach point ( x , y ) from ( 0 , 0 ) using zig | function to return the required position ; 
def countSteps(x, y):
    if x < y:
        return x + y + 2 * ((y - x) // 2)
    else:
        return x + y + 2 * (((x - y) + 1) // 2)


if __name__ == "__main__":
    x, y = 4, 3
    print(countSteps(x, y))

# Expected output:
9
# find whether only two parallel lines contain all coordinates points or not | find if slope is good with only two intercept ; if set of lines have only two distinct intercept ; function to check if required solution exist ; check the result by processing the slope by starting three points ; 
def isSlopeGood(slope, arr, n):
    setOfLines = dict()
    for i in range(n):
        setOfLines[arr[i] - slope * (i)] = 1
    return len(setOfLines) == 2


def checkForParallel(arr, n):
    slope1 = isSlopeGood(arr[1] - arr[0], arr, n)
    slope2 = isSlopeGood(arr[2] - arr[1], arr, n)
    slope3 = isSlopeGood((arr[2] - arr[0]) // 2, arr, n)
    return (slope1 or slope2 or slope3)


arr = [1, 6, 3, 8, 5]
n = len(arr)
if checkForParallel(arr, n):
    print(1)
else:
    print(0)

# Expected output:
1
# check whether the point ( x , y ) lies on a given line | function that return true if the given point lies on the given line ; if ( x , y ) satisfies the equation of the line ; 
def pointIsOnLine(m, c, x, y):
    if (y == ((m * x) + c)):
        return True
    return False


m = 3
c = 2
x = 1
y = 5
if (pointIsOnLine(m, c, x, y)):
    print("Yes")
else:
    print("No")

# Expected output:
Yes
# find the coordinates of the fourth vertex of a rectangle with given 3 vertices | function that return the coordinates of the fourth vertex of the rectangle ; save the coordinates of the given vertices of the rectangle ; 1 - based indexing ; 
def findFourthVertex(n, m, s):
    row = dict .fromkeys(range(n), 0)
    col = dict .fromkeys(range(m), 0)
    for i in range(n):
        for j in range(m):
            if (s[i][j] == '*'):
                row[i] += 1
                col[j] += 1
    for keys, values in row .items():
        if (values == 1):
            x = keys
    for keys, values in col .items():
        if (values == 1):
            y = keys
    return (x + 1, y + 1)


if __name__ == "__main__":
    s = ["*.*", "*..", "..."]
    n = len(s)
    m = len(s[0])
    rs = findFourthVertex(n, m, s)
    print(rs[0], rs[1])

# Expected output:
2 3
# biggest reuleaux triangle inscribed within a square which is inscribed within an ellipse | python3 program to find the biggest reuleaux triangle inscribed within in a square which in turn is inscribed within an ellipse ; function to find the biggest reuleaux triangle ; length of the axes cannot be negative ; height of the reuleaux triangle ; area of the reuleaux triangle ; 

import math


def Area(a, b):
    if (a < 0 and b < 0):
        return -1
    h = math .sqrt(((pow(a, 2) + pow(b, 2)) / (pow(a, 2) * pow(b, 2))))
    A = 0.70477 * pow(h, 2)
    return A


a = 5
b = 4
print(round(Area(a, b), 7))

# Expected output:
0.0722389
# maximum given sized rectangles that can be cut out of a sheet of paper | function to return the maximum rectangles possible ; cut rectangles horizontally if possible ; one rectangle is a single cell ; total rectangles = total cells ; cut rectangles vertically if possible ; return the maximum possible rectangles ; 
def maxRectangles(L, B, l, b):
    horizontal, vertical = 0, 0
    if l <= L and b <= B:
        columns = B // b
        rows = L // l
        horizontal = rows * columns
    if l <= B and b <= L:
        columns = L // b
        rows = B // l
        vertical = rows * columns
    return max(horizontal, vertical)


if __name__ == "__main__":
    L, B, l, b = 10, 7, 4, 3
    print(maxRectangles(L, B, l, b))

# Expected output:
4
# largest right circular cone that can be inscribed within a sphere which is inscribed within a cube | python3 program to find the biggest right circular cone that can be inscribed within a right circular cone which in turn is inscribed within a cube ; function to find the biggest right circular cone ; side cannot be negative ; radius of right circular cone ; height of right circular cone ; volume of right circular cone ; 

import math


def cone(a):
    if (a < 0):
        return -1
    r = (a * math .sqrt(2)) / 3
    h = (2 * a) / 3
    V = 3.14 * math .pow(r, 2) * h
    return V


a = 5
print(cone(a))

# Expected output:
58.14814814814816
# biggest reuleaux triangle inscribed within a square which is inscribed within a hexagon | python3 program to find the biggest reuleaux triangle inscribed within in a square which in turn is inscribed within a hexagon ; function to find the biggest reuleaux triangle ; side cannot be negative ; height of the reuleaux triangle ; area of the reuleaux triangle ; 

import math


def Area(a):
    if (a < 0):
        return -1
    h = 1.268 * a
    A = 0.70477 * math .pow(h, 2)
    return A


a = 5
print(Area(a), end="")

# Expected output:
28.328653012
# biggest reuleaux triangle inscirbed within a square inscribed in a semicircle | python3 program to find the biggest reuleaux triangle inscribed within in a square which in turn is inscribed within a semicircle ; function to find the biggest reuleaux triangle ; radius cannot be negative ; height of the reuleaux triangle ; area of the reuleaux triangle ; 

import math as mt


def Area(r):
    if (r < 0):
        return -1
    x = (2 * r) / mt .sqrt(5)
    A = 0.70477 * pow(x, 2)
    return A


r = 5
print(Area(r))

# Expected output:
14.095400000000003
# biggest reuleaux triangle inscribed within a square inscribed in an equilateral triangle | python3 program to find the biggest reuleaux triangle inscribed within in a square which in turn is inscribed within an equilateral triangle ; function to find the biggest reuleaux triangle ; side cannot be negative ; height of the reuleaux triangle ; area of the reuleaux triangle ; 

import math as mt


def Area(a):
    if (a < 0):
        return -1
    x = 0.464 * a
    A = 0.70477 * pow(x, 2)
    return A


a = 5
print(Area(a))

# Expected output:
3.793354048000001
# program for area of square after n | function to calculate area of square after given number of folds ; 
def areaSquare(side, fold):
    area = side * side
    ans = area / pow(2, fold)
    return ans


if __name__ == "__main__":
    side = 4
    fold = 2
    print(areaSquare(side, fold))

# Expected output:
4.0
# biggest reuleaux triangle within a square which is inscribed within a circle | python3 program to find the biggest reuleaux triangle inscribed within in a square which in turn is inscribed within a circle ; function to find the area of the reuleaux triangle ; radius cannot be negative ; area of the reuleaux triangle ; 

import math as mt


def ReuleauxArea(r):
    if (r < 0):
        return -1
    A = 0.70477 * 2 * pow(r, 2)
    return A


r = 6
print(ReuleauxArea(r))

# Expected output:
50.74344
# largest right circular cylinder that can be inscribed within a cone which is in turn inscribed within a cube | python3 program to find the biggest right circular cylinder that can be inscribed within a right circular cone which in turn is inscribed within a cube ; function to find the biggest right circular cylinder ; side cannot be negative ; radius of right circular cylinder ; height of right circular cylinder ; volume of right circular cylinder ; 

import math as mt


def cyl(a):
    if (a < 0):
        return -1
    r = (2 * a * mt .sqrt(2)) / 3
    h = (2 * a) / 3
    V = 3.14 * pow(r, 2) * h
    return V


a = 5
print(cyl(a))

# Expected output:
232.59259259259264
# biggest reuleaux triangle within a square which is inscribed within a right angle triangle | python3 program to find the biggest reuleaux triangle inscribed within in a square which in turn is inscribed within a circle ; function to find the biggest reuleaux triangle ; the height or base or hypotenuse cannot be negative ; height of the reuleaux triangle ; area of the reuleaux triangle ; 

import math as mt


def Area(l, b, h):
    if (l < 0 or b < 0 or h < 0):
        return -1
    x = (l * b) / (l + b)
    A = 0.70477 * pow(x, 2)
    return A


l, b, h = 5, 12, 13
print(Area(l, b, h))

# Expected output:
8.77914186851211
# largest square that can be inscribed within a hexagon which is inscribed within an equilateral triangle | function to find the side of the square ; side cannot be negative ; side of the square ; 
def squareSide(a):
    if (a < 0):
        return -1
    x = 0.423 * a
    return x


if __name__ == '__main__':
    a = 8
    print(squareSide(a))

# Expected output:
3.384
# check if it is possible to draw a straight line with the given direction cosines | python3 implementation of the approach ; function that returns true if a straight line is possible ; 

from math import ceil, floor


def isPossible(x, y, z):
    a = x * x + y * y + z * z
    a = round(a, 8)
    if (ceil(a) == 1 & floor(a) == 1):
        return True
    return False


if __name__ == "__main__":
    l = 0.70710678
    m = 0.5
    n = 0.5
    if (isPossible(l, m, n)):
        print("Yes")
    else:
        print("No")

# Expected output:
Yes
# length of diagonal of a n | python3 program to find the diagonal of a regular polygon with given side length ; function to find the diagonal of a regular polygon ; side and side length cannot be negative ; diagonal degree converted to radians ; 

import math as mt


def polydiagonal(n, a):
    if (a < 0 and n < 0):
        return -1
    return (2 * a * mt .sin((((n - 2) * 180) / (2 * n)) * 3.14159 / 180))


a, n = 9, 10
print(polydiagonal(n, a))

# Expected output:
17.119011389271858
# diagonal of a regular decagon | function to return the diagonal of a regular decagon ; side cannot be negative ; length of the diagonal ; 
def decdiagonal(a):
    if (a < 0):
        return -1
    d = 1.902 * a
    return d


if __name__ == "__main__":
    a = 9
    print(decdiagonal(a))

# Expected output:
17.118
# diagonal of a regular heptagon | function to return the diagonal of a regular heptagon ; side cannot be negative ; length of the diagonal ; 
def heptdiagonal(a):
    if (a < 0):
        return -1
    d = 1.802 * a
    return round(d, 3)


if __name__ == "__main__":
    a = 6
    print(heptdiagonal(a))

# Expected output:
10.812
# diagonal of a regular hexagon | function to find the diagonal of a regular hexagon ; side cannot be negative ; length of the diagonal ; 
def hexDiagonal(a):
    if (a < 0):
        return -1
    d = 1.73 * a
    return d


a = 9
print(hexDiagonal(a))

# Expected output:
15.57
# area of reuleaux triangle | python3 program to find the area of reuleaux triangle ; function to the area of the reuleaux triangle ; side cannot be negative ; area of the reauleax triangle ; 

import math as mt


def ReuleauxArea(a):
    if a < 0:
        return -1
    return 0.70477 * pow(a, 2)


a = 6
print(ReuleauxArea(a))

# Expected output:
25.37172
# largest square that can be inscribed within a hexagon | function to find the area of the square ; side cannot be negative ; area of the square ; 
def squareArea(a):
    if (a < 0):
        return -1
    area = (1.268 ** 2) * (a ** 2)
    return area


a = 6
print(squareArea(a))

# Expected output:
57.88166400000001
# volume of cube using its space diagonal | python 3 program to find the volume occupied by cube with given space diagonal ; function to calculate volume ; formula to find volume ; 

from math import sqrt, pow


def CubeVolume(d):
    Volume = (sqrt(3) * pow(d, 3)) / 9
    return Volume


if __name__ == '__main__':
    d = 5
    print("Volume of Cube:", '{0:.6}'.format(CubeVolume(d)))

# Expected output:
Volume of Cube: 24.0563
# area of a leaf inside a square | python3 code to find the area of leaf inside a square ; function to find the area of leaf ; 

PI = 3.14159265


def area_leaf(a):
    return (a * a * (PI / 2 - 1))


a = 7
print(area_leaf(a))

# Expected output:
27.969019925000005
# length of rope tied around three equal circles touching each other | python3 code to find the length of rope ; function to find the length of rope ; 

PI = 3.14159265


def length_rope(r):
    return ((2 * PI * r) + 6 * r)


r = 7
print(length_rope(r))

# Expected output:
85.98229710000001
# number of triangles that can be formed with given n points | python3 implementation of the above approach ; this function returns the required number of triangles ; hash map to store the frequency of slope corresponding to a point ( x , y ) ; iterate over all possible points ; calculate slope of all elements with current element ; find the slope with reduced fraction ; total number of ways to form a triangle having one point as current element ; subtracting the total number of ways to form a triangle having the same slope or are collinear ; 

from collections import defaultdict
from math import gcd


def countTriangles(P, N):
    mp = defaultdict(lambda: 0)
    ans = 0
    for i in range(0, N):
        mp .clear()
        for j in range(i + 1, N):
            X = P[i][0] - P[j][0]
            Y = P[i][1] - P[j][1]
            g = gcd(X, Y)
            X //= g
            Y //= g
            mp[(X, Y)] += 1
        num = N - (i + 1)
        ans += (num * (num - 1)) // 2
        for j in mp:
            ans -= (mp[j] * (mp[j] - 1)) // 2
    return ans


if __name__ == "__main__":
    P = [[0, 0], [2, 0], [1, 1], [2, 2]]
    N = len(P)
    print(countTriangles(P, N))

# Expected output:
3
# area of incircle of a right angled triangle | python3 code to find the area of inscribed circle of right angled triangle ; function to find the area of inscribed circle ; 

PI = 3.14159265


def area_inscribed(P, B, H):
    return ((P + B - H) * (P + B - H) * (PI / 4))


P = 3
B = 4
H = 5
print(area_inscribed(P, B, H))

# Expected output:
3.14159265
# area of circumcircle of a right angled triangle | python3 code to find the area of circumscribed circle of right angled triangle ; function to find the area of circumscribed circle ; 

PI = 3.14159265


def area_cicumscribed(c):
    return (c * c * (PI / 4))


c = 8.0
print(area_cicumscribed(c))

# Expected output:
50.2654824
# largest right circular cylinder that can be inscribed within a cone | python 3 program to find the biggest right circular cylinder that can be fit within a right circular cone ; function to find the biggest right circular cylinder ; radius and height cannot be negative ; radius of right circular cylinder ; height of right circular cylinder ; volume of right circular cylinder ; 

import math


def cyl(r, h):
    if (r < 0 and h < 0):
        return -1
    R = (2 * r) / 3
    H = (2 * h) / 3
    V = 3.14 * math .pow(R, 2) * H
    return V


r = 4
h = 8
print(cyl(r, h), "")

# Expected output:
119.0874074074074
# largest cube that can be inscribed within a right circular cylinder | python 3 program to find the biggest cube inscribed within a right circular cylinder ; function to find the volume of the cube ; height and radius cannot be negative ; volume of the cube ; 

import math


def cube(h, r):
    if (h < 0 and r < 0):
        return -1
    a = math .pow(h, 3)
    return a


h = 5
r = 4
print(cube(h, r))

# Expected output:
125.0
# volume of biggest sphere within a right circular cylinder | function to find the biggest sphere ; radius and height cannot be negative ; radius of sphere ; 
def sph(r, h):
    if (r < 0 and h < 0):
        return -1
    R = r
    return float(R)


r, h = 4, 8
print(sph(r, h))

# Expected output:
4.0
# volume of largest right circular cylinder within a sphere | python 3 program to find the biggest right circular cylinder that can be fit within a sphere ; function to find the biggest right circular cylinder ; radius cannot be negative ; volume of cylinder ; 

import math


def cyl(R):
    if (R < 0):
        return -1
    V = ((2 * 3.14 * math .pow(R, 3)) / (3 * math .sqrt(3)))
    return float(V)


R = 4
print(cyl(R))

# Expected output:
77.34954006423146
# longest rod that can be inserted within a right circular cylinder | python 3 program to find the longest rod that can be fit within a right circular cylinder ; function to find the side of the cube ; height and radius cannot be negative ; length of rod ; 

import math


def rod(h, r):
    if (h < 0 and r < 0):
        return -1
    l = (math .sqrt(math .pow(h, 2) + 4 * math .pow(r, 2)))
    return float(l)


h, r = 4, 1.5
print(rod(h, r))

# Expected output:
5.0
# largest cube that can be inscribed within a right circular cone | python3 program to find the biggest cube inscribed within a right circular cone ; function to find the side of the cube ; height and radius cannot be negative ; side of the cube ; 

import math


def cubeSide(h, r):
    if (h < 0 and r < 0):
        return -1
    a = ((h * r * math .sqrt(2)) / (h + math .sqrt(2) * r))
    return a


h = 5
r = 6
print(cubeSide(h, r), "")

# Expected output:
3.1461269285965052
# largest cube that can be inscribed within the sphere | python 3 program to find the biggest cube inscribed within a sphere ; function to find the side of the cube ; radius cannot be negative ; side of the cube ; 

from math import sqrt


def largestCube(r):
    if (r < 0):
        return -1
    a = (2 * r) / sqrt(3)
    return a


if __name__ == '__main__':
    r = 5
    print("{0:.6}".format(largestCube(r)))

# Expected output:
5.7735
# largest sphere that can be inscribed inside a cube | function to find the radius of the sphere ; side cannot be negative ; radius of the sphere ; 
def sphere(a):
    if (a < 0):
        return -1
    r = a / 2
    return r


if __name__ == '__main__':
    a = 5
    print(sphere(a))

# Expected output:
2.5
# minimum cuts can be made in the chessboard such that it is not divided into 2 parts | function that calculates the maximum no . of cuts ; 
def numberOfCuts(M, N):
    result = 0
    result = (M - 1) * (N - 1)
    return result


if __name__ == '__main__':
    M, N = 4, 4
    Cuts = numberOfCuts(M, N)
    print("Maximum cuts = ", Cuts)

# Expected output:
Maximum cuts =  9
# find maximum volume of a cuboid from the given perimeter and area | python3 implementation of the above approach ; function to return maximum volume ; calculate length ; calculate volume ; return result ; 

from math import sqrt


def maxVol(P, A):
    l = (P - sqrt(P * P - 24 * A)) / 12
    V = l * (A / 2.0 - l * (P / 4.0 - l))
    return V


if __name__ == '__main__':
    P = 20
    A = 16
    print(maxVol(P, A))

# Expected output:
4.148148148148147
# program to calculate area and perimeter of a rhombus whose diagonals are given | python 3 program to calculate area and perimeter of a rhombus using diagonals ; calculate area and perimeter of a rhombus ; 

from math import sqrt, pow


def rhombusAreaPeri(d1, d2):
    area = (d1 * d2) / 2
    perimeter = 2 * sqrt(pow(d1, 2) + pow(d2, 2))
    print("The area of rhombus with diagonals", d1, "and", d2, "is", area, ".")
    print("The perimeter of rhombus with diagonals",
          d1, "and", d2, "is", perimeter, ".")


if __name__ == '__main__':
    d1 = 2
    d2 = 4
    rhombusAreaPeri(d1, d2)

# Expected output:
The area of rhombus with diagonals 2 and 4 is 4.0 .
The perimeter of rhombus with diagonals 2 and 4 is 8.94427190999916 .
# area of decagon inscribed within the circle | python3 program to find the area of the decagon inscribed within a circle ; function to find the area of the decagon ; radius cannot be negative ; area of the decagon ; 

from math import sqrt, pow


def area(r):
    if r < 0:
        return -1
    area = (5 * pow(r, 2) * (3 - sqrt(5)) * (sqrt(5) + (2 * sqrt(5)))) / 4
    return area


if __name__ == '__main__':
    r = 8
    print(area(r))

# Expected output:
409.96894379984855
# maximum area of rectangle possible with given perimeter | python3 program to find maximum area rectangle ; function to find max area ; return area ; 

from math import ceil, floor


def maxArea(perimeter):
    length = int(ceil(perimeter / 4))
    breadth = int(floor(perimeter / 4))
    return length * breadth


if __name__ == '__main__':
    n = 38
    print("Maximum Area =", maxArea(n))

# Expected output:
Maximum Area = 90
# find the foot of perpendicular of a point in a 3 d plane | function to find foot of perpendicular ; 
def foot(a, b, c, d, x1, y1, z1):
    k = (-a * x1 - b * y1 - c * z1 - d) / (a * a + b * b + c * c)
    x2 = a * k + x1
    y2 = b * k + y1
    z2 = c * k + z1
    print("x2 =", round(x2, 1))
    print("y2 =", round(y2, 1))
    print("z2 =", round(z2, 1))


if __name__ == "__main__":
    a = 1
    b = -2
    c = 0
    d = 0
    x1 = -1
    y1 = 3
    z1 = 4
    foot(a, b, c, d, x1, y1, z1)

# Expected output:
x2 = 0.4
y2 = 0.2
z2 = 4.0
# equation of parabola from its focus and directrix | function to find equation of parabola . ; 
def equation_parabola(x1, y1, a, b, c):
    t = a * a + b * b
    a1 = t - (a * a)
    b1 = t - (b * b)
    c1 = (-2 * t * x1) - (2 * c * a)
    d1 = (-2 * t * y1) - (2 * c * b)
    e1 = -2 * a * b
    f1 = (-c * c) + (t * x1 * x1) + (t * y1 * y1)
    print(
        "equation of parabola is",
        a1,
        "x^2 +",
        b1,
        "y^2 +",
        c1,
        "x +",
        d1,
        "y + ",
        e1,
        "xy +",
        f1,
        "= 0.")


if __name__ == "__main__":
    x1, y1, a, b, c = 0, 0, 3, -4, 2
    equation_parabola(x1, y1, a, b, c)

# Expected output:
equation of parabola is 16 x^2 + 9 y^2 + -12 x + 16 y +  24 xy + -4 = 0.
# minimum squares to evenly cut a rectangle | python3 code to find minimum number of squares to make a given rectangle . ; if we take gcd ( l , w ) , this will be largest possible side for square , hence minimum number of square . ; number of squares . ; 

import math


def countRectangles(l, w):
    squareSide = math .gcd(l, w)
    return (l * w) / (squareSide * squareSide)


if __name__ == '__main__':
    l = 4
    w = 6
    ans = countRectangles(l, w)
    print(int(ans))

# Expected output:
6
# equation of circle from center and radius | function to find the equation of circle ; printing result ; 
def circle_equation(x1, y1, r):
    a = -2 * x1
    b = -2 * y1
    c = (r * r) - (x1 * x1) - (y1 * y1)
    print("x^2 + (", a, "x) + ", end="")
    print("y^2 + (", b, "y) = ", end="")
    print(c, ".")


x1 = 2
y1 = -3
r = 8
circle_equation(x1, y1, r)

# Expected output:
x^2 + ( -4 x) + y^2 + ( 6 y) = 51 .
# check if the given vectors are at equilibrium or not | function to check the equilibrium of three vectors ; summing the x coordinates ; summing the y coordinates ; summing the z coordinates ; checking the condition for equilibrium ; 
def checkEquilibrium(x1, y1, z1, x2, y2, z2, x3, y3, z3):
    resx = x1 + x2 + x3
    resy = y1 + y2 + y3
    resz = z1 + z2 + z3
    if (resx == 0 and resy == 0 and resz == 0):
        return True
    else:
        return False


x1 = -2
y1 = -7
z1 = -9
x2 = 5
y2 = -14
z2 = 14
x3 = -3
y3 = 21
z3 = -5
if (checkEquilibrium(x1, y1, z1, x2, y2, z2, x3, y3, z3)):
    print("The vectors are at equilibrium.")
else:
    print("The vectors are not at equilibrium.")

# Expected output:
The vectors are at equilibrium.
# find tangent at a given point on the curve | function for find tangent ; differentiate given equation ; check that point on the curve or not ; if differentiate is negative ; differentiate is positive ; differentiate is zero ; 
def findTangent(A, x, y):
    dif = A - x * 2
    if y == (2 * x - x * x):
        if dif < 0:
            print("y =", dif, "x", (x * dif) + (y))
        elif dif > 0:
            print("y =", dif, "x+", -x * dif + y)
        else:
            print("Not Possible")


if __name__ == "__main__":
    A, x, y = 2, 2, 0
    findTangent(A, x, y)

# Expected output:
y = -2 x -4