Snippets Collections
void keyPressed() {
  int nextX = playerX;
  int nextY = playerY;

  if (keyCode == LEFT && maze[playerY / tileSize][(playerX - tileSize) / tileSize] != 1) {
    nextX -= tileSize;
  } else if (keyCode == RIGHT && maze[playerY / tileSize][(playerX + tileSize) / tileSize] != 1) {
    nextX += tileSize;
  } else if (keyCode == UP && maze[(playerY - tileSize) / tileSize][playerX / tileSize] != 1) {
    nextY -= tileSize;
  } else if (keyCode == DOWN && maze[(playerY + tileSize) / tileSize][playerX / tileSize] != 1) {
    nextY += tileSize;
  }

  if (nextX >= 0 && nextX < width && nextY >= 0 && nextY < height) {
    playerX = nextX;
    playerY = nextY;
  }
}
void draw() {
  background(255);
  drawMaze();
  drawPlayer();
  drawTarget();
  drawBox(box1X, box1Y, boxColors[2]); // Draw Box with yellow
  drawBox(box2X, box2Y, boxColors[2]); // Draw Box with yellow
  drawBox(box3X, box3Y, boxColors[3]); // Draw Box with pink
  drawBox(box4X, box4Y, boxColors[3]); // Draw Box with pink
  drawBox(box5X, box5Y, boxColors[1]); // Draw Box with blue
  drawBox(box6X, box6Y, boxColors[1]); // Draw Box with blue
  drawBox(box7X, box7Y, boxColors[0]); // Draw Box with red
  drawBox(box8X, box8Y, boxColors[0]); // Draw Box with red
  drawBox(box9X, box9Y, boxColors[4]); // Draw Box with red
  drawBox(box10X, box10Y, boxColors[4]); // Draw Box with red


  if (playerX == targetX && playerY == targetY) {
    fill(0);
    textSize(80);
    textAlign(CENTER, CENTER);
    text("You Win!", width / 2, height / 2); // win message
  }

  // Check if the player reaches Box 1
  if (playerX == box1X && playerY == box1Y) {
    playerX = box2X; // Respawn the player at Box 2 X position
    playerY = box2Y; // Respawn the player at Box 2 Y position
    reachedBox1 = true;
  }
  if (playerX == box4X && playerY == box4Y) {
    playerX = box3X; // Respawn the player at Box 3 X position
    playerY = box3Y; // Respawn the player at Box 3 Y position
    reachedBox1 = true;
  }
  if (playerX == box7X && playerY == box7Y) {
    playerX = box8X; // Respawn the player at Box 8 X position
    playerY = box8Y; // Respawn the player at Box 8Y position
    reachedBox1 = true;
  }
  if (playerX == box6X && playerY == box6Y) {
    playerX = box5X; // Respawn the player at Box 5 X position
    playerY = box5Y; // Respawn the player at Box 5 Y position
    reachedBox1 = true;
  }
  if (playerX == box9X && playerY == box9Y) {
    playerX = box10X; // Respawn the player at Box 5 X position
    playerY = box10Y; // Respawn the player at Box 5 Y position
    reachedBox1 = true;
  }
}

void drawMaze() {
  for (int i = 0; i < maze.length; i++) {
    for (int j = 0; j < maze[i].length; j++) {
      if (maze[i][j] == 1) {
        fill(100);
        rect(j * tileSize, i * tileSize, tileSize, tileSize);
      }
    }
  }
}

void drawPlayer() {
  fill(playerColor);
  ellipse(playerX, playerY, tileSize * 0.8, tileSize * 0.8);
}

void drawTarget() {
  fill(0, 255, 0);
  rect(targetX - tileSize / 2, targetY - tileSize / 2, tileSize, tileSize);
}

void drawBox(int x, int y, color boxColor) {
  fill(boxColor); // Use the color
  rect(x - tileSize / 2, y - tileSize / 2, tileSize, tileSize);
}
void setup() {
  size(520, 520);
  playerX = 1 * tileSize + tileSize / 2; // Initial player X position
  playerY = 1 * tileSize + tileSize / 2; // Initial player Y position
  targetX = 11 * tileSize + tileSize / 2; // winning X position
  targetY = 11 * tileSize + tileSize / 2; // Winning Y position
  box1X = 2 * tileSize + tileSize / 2; // Yellow Box 1 X position
  box1Y = 4 * tileSize + tileSize / 2; // Yellow Box 1 Y position
  box2X = 9 * tileSize + tileSize / 2; // Yellow Box 2 X position
  box2Y = 5 * tileSize + tileSize / 2; // Yellow Box 2 Y position
  box3X = 9 * tileSize + tileSize / 2; // Pink Box 3 X position
  box3Y = 7 * tileSize + tileSize / 2; // Pink Box 3 Y position
  box4X = 11* tileSize + tileSize / 2; // Pink Box 4 X position
  box4Y = 1 * tileSize + tileSize / 2; // Pink Box 4 Y position
  box5X = 11 * tileSize + tileSize / 2; // Blue Box 5 X position
  box5Y = 4 * tileSize + tileSize / 2; // Blue Box 5 Y position
  box6X = 8 * tileSize + tileSize / 2; // Blue Box 6 X position
  box6Y = 11 * tileSize + tileSize / 2; // Blue Box 6 Y position
  box7X = 8 * tileSize + tileSize / 2; // Red Box 7 X position
  box7Y = 3 * tileSize + tileSize / 2; // Red Box 7 Y position
  box8X = 7 * tileSize + tileSize / 2; // Red Box 8 X position
  box8Y = 9 * tileSize + tileSize / 2; // Red Box 8 Y position
  box9X = 6 * tileSize + tileSize / 2; // Red Box 8 X position
  box9Y = 3 * tileSize + tileSize / 2; // Red Box 8 Y position
  box10X = 7 * tileSize + tileSize / 2; // Red Box 8 X position
  box10Y = 1 * tileSize + tileSize / 2; // Red Box 8 Y position
  
}
int playerX, playerY; // Player position
int targetX, targetY; // Winning posssition
int box1X, box1Y; // Box 1 posssition
int box2X, box2Y; // Box 2 posssition
int box3X, box3Y; // Box 3 posssition
int box4X, box4Y; // Box 4 posssition
int box5X, box5Y; // Box 5 posssition
int box6X, box6Y; // Box 6 posssition
int box7X, box7Y; // Box 7 posssition
int box8X, box8Y; // Box 8 posssition
int box9X, box9Y; // Box 8 posssition
int box10X, box10Y; // Box 8 posssition
int tileSize = 40; // Size of each box in the maze
color playerColor = color(255, 0, 0); // Initial player color (red)
color[] boxColors = {#FF0000, #0000FF, #FFFF00, #FFC0CB, #FFA500}; // colors

// Maze layout 
int[][] maze = {
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
  {1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1},
  {1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1},
  {1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1},
  {1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1},
  {1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1},
  {1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1},
  {1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1},
  {1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1},
  {1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1},
  {1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1},
  {1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1},
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
};

boolean reachedBox1 = false;
function setup() {
  createCanvas(400, 400);
  background(220);
}

function draw() {
  // Nothing to draw continuously in this example
}

function mousePressed() {
  fill(random(255), random(255), random(255)); // Random fill color
  noStroke(); // No stroke for shapes
  ellipse(mouseX, mouseY, 20, 20); // Draw ellipse at mouse position
}
function setup() {
  createCanvas(400, 400); // Create a canvas
}

function draw() {
  background(220); // Set background color
  ellipse(200, 200, 50, 50); // Draw a circle
}
PFont customFont;

void setup() {
  size(400, 400);
  background(220);
  
  // Load a font that includes the necessary characters
  customFont = createFont("Arial", 32);
  textFont(customFont);
}

void draw() {
  // This function is intentionally left empty
}

void keyPressed() {
  // Display the key that was pressed on the background
  background(220); // Clear the previous content on the background
  textSize(32); // Set the text size
  fill(0); // Set the text color to black
  text("Key Pressed: " + key, 50, 50); // Display the key value on the canvas
}
void setup() {
  size(400, 400); // Set canvas size
  background(220); // Set background color
}

void draw() {
  // This function is intentionally left empty
}

void mouseDragged() {
  // Draw circles and rectangles at the mouse's dragged positions
  fill(random(255), random(255), random(255)); // Random fill color for circles
  ellipse(mouseX, mouseY, 20, 20); // Draw a circle at mouseX and mouseY
  
  fill(random(255), random(255), random(255)); // Random fill color for rectangles
  rect(mouseX - 10, mouseY - 10, 20, 20); // Draw a rectangle around the circle
}

void keyPressed() {
  // Clear the canvas and change the background color when any key is pressed
  background(random(255), random(255), random(255));
}

void mousePressed() {
  // Draw a larger circle and a smaller rectangle when the mouse is pressed
  fill(random(255), random(255), random(255)); // Random fill color for circles
  ellipse(mouseX, mouseY, 30, 30);
  
  fill(random(255), random(255), random(255)); // Random fill color for rectangles
  rect(mouseX - 15, mouseY - 15, 10, 10);
}

void mouseReleased() {
  // Draw a smaller circle and a larger rectangle when the mouse is released
  fill(random(255), random(255), random(255)); // Random fill color for circles
  ellipse(mouseX, mouseY, 15, 15);
  
  fill(random(255), random(255), random(255)); // Random fill color for rectangles
  rect(mouseX - 5, mouseY - 5, 30, 30);
}

void mouseWheel(MouseEvent event) {
  // Adjust the circle size with the mouse wheel
  float newSize = constrain(event.getCount(), -1, 1) * 5;
  ellipse(mouseX, mouseY, 20 + newSize, 20 + newSize);
}
boolean isMousePressed = false;

void setup() {
  size(400, 400); // Set canvas size
  background(220); // Set background color
}

void draw() {
  // This function is intentionally left empty
}

void mousePressed() {
  // Change the background color when the mouse is pressed
  background(random(255), random(255), random(255));
  
  // Set the mouse pressed state to true
  isMousePressed = true;
  
  // Show text "Clicked" at the center of the canvas
  showText("Clicked");
}

void mouseReleased() {
  // If the mouse was pressed, change the background color and show "Released"
  if (isMousePressed) {
    background(random(255), random(255), random(255));
    showText("Released");
  }
  // Set the mouse pressed state to false
  isMousePressed = false;
}

void showText(String message) {
  fill(0); // Set text color to black
  textSize(20); // Set text size
  textAlign(CENTER, CENTER); // Center align the text
  text(message, width / 2, height / 2);
}
void setup() {
  size(400, 400); // Set canvas size
}

void draw() {
  background(220); // Set background color
  
  // Display the coordinates of the mouse pointer
  fill(0); // Set fill color to black
  textSize(30); // Set the text size to 20 (you can adjust this number as needed)
  text("MouseX: " + mouseX + " | MouseY: " + mouseY, 40, 40); // Display coordinates
}
 void setup(){
size(400, 400);
frameRate(30);
}

void draw() {
 background(220); // Set background color
  
// Using stroke() and fill()
  stroke(0); // Set outline color to black
  
  fill(255, 0, 0); // Set fill color to red
  rect(20, 20, 50, 50);
  
  fill(0, 255, 0); // Set fill color to green
  stroke(255, 0, 0); // Set outline color to red
  rect(90, 20, 50, 50);
  
  noFill(); // No fill
  stroke(0, 0, 255); // Set outline color to blue
  rect(160, 20, 50, 50);
  
  noStroke(); // No outline
  fill(0, 0, 255, 100); // Set fill color to blue with transparency
  ellipse(50, 150, 80, 80);
  
  // Using noStroke() and noFill()
  stroke(0); // Set outline color to black
  fill(255); // Set fill color to white
  
  rect(230, 20, 50, 50);
  
  noStroke(); // No outline
  noFill(); // No fill
  rect(290, 20, 50, 50);
}
void setup(){
size(400, 400);
frameRate(30);
}

void draw() {
  background(220); // Set background color
  
  // Draw shapes
  
  // Line
  line(50, 50, 150, 50);
  
  // Rectangle
  rect(50, 100, 100, 50);
  
  // Rounded Rectangle
  rect(200, 100, 100, 50, 20); // Last parameter sets corner radius
  
  // Ellipse
  ellipse(100, 200, 80, 80);
  
  // Circle
  ellipse(250, 200, 100, 100);
  
  // Point
  point(50, 300);
  
  // Triangle
  triangle(150, 275, 200, 350, 250, 275);
  
  // Quadrilateral
  quad(300, 250, 350, 300, 300, 350, 250, 300);
}
void draw() {
  background(255);
}
void setup(){
size(200, 200);
frameRate(30);
}
int X[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
int Y[] = {0, 9, 10, 11, 12, 13, A0, A1, A2};

unsigned long patternStartTime = 0; // Variable to track pattern start time
const unsigned long patternDuration = 3000; // Pattern display duration in milliseconds
int currentPattern = 1; // Track the current pattern being displayed

void setup() {
  for (int i = 1; i < 9; i++) {
    pinMode(X[i], OUTPUT);
    pinMode(Y[i], OUTPUT);
    digitalWrite(X[i], HIGH);
    digitalWrite(Y[i], LOW);
  }
}

void loop() {
  switch (currentPattern) {
    case 1:
      displayHeartPattern();
      break;
    case 2:
      displaySecondPattern();
      break;
    case 3:
      displayThirdPattern();
      break;
  }

  if (millis() - patternStartTime >= patternDuration) {
    effacer(); // Clear the LED matrix
    delay(100); // Add a short delay for stability
    currentPattern = (currentPattern % 3) + 1; // Switch to the next pattern (1, 2, or 3)
    patternStartTime = millis(); // Reset pattern start time
  }
}

void displayHeartPattern() {
  byte heartPattern[8] = {
    B00000000,
    B00000000,
    B01100110,
    B01100110,
    B01100110,
    B10000001,
    B01000010,
    B00111100
  };

  displayPattern(heartPattern);
}

void displaySecondPattern() {
  byte secondPattern[8] = {
    B00000000,
    B00000000,
    B01100110,
    B01100110,
    B00000000,
    B01111110,
    B00000000,
    B00000000
  };

  displayPattern(secondPattern);
}

void displayThirdPattern() {
  byte thirdPattern[8] = {
    B00000000,
    B00000000,
    B01100110,
    B01100110,
    B01100110,
    B00111100,
    B01000010,
    B10000001
  };

  displayPattern(thirdPattern);
}

void displayPattern(byte pattern[8]) {
  for (int col = 0; col < 8; col++) {
    digitalWrite(Y[col + 1], LOW); // Activate column col+1

    for (int row = 0; row < 8; row++) {
      digitalWrite(X[row + 1], bitRead(pattern[col], row)); // Activate row row+1 if pattern is 1
    }

    delay(5); // Adjust
PATH = "sample_lolcodes/"
import re


# Taken from https://github.com/christianrfg/lexical-analyzer
class LexicalAnalyzer:
    lin_num = 1

    def tokenize(self, code):
        # doesn't catch wrong vars
        rules = [
            ("START", r"^HAI"),
            ("END", r"KTHXBYE$"),
            ("WAZZUP", r"WAZZUP"),
            ("BUHBYE", r"BUHBYE"),
            ("COMMENT", r" ?BTW .*"),
            ("VAR_DEC", r"I HAS A"),
            ("INPUT", r"GIMMEH"),
            ("ITZ", r"ITZ"),
            ("CONCAT", r"SMOOSH"),
            ("PRINT", r"VISIBLE"),
            ("TYPECAST", r"MAEK"),
            ("RECAST", r"IS NOW A"),
            ("BOOL_OPER", r"(BOTH OF|EITHER OF|WON OF|NOT|ALL OF|ANY OF)"),
            (
                "MATH",
                r"(SUM OF|DIFF OF|PRODUKT OF|QUOSHUNT OF|MOD OF|BIGGR OF|SMALLR OF)",
            ),
            ("COMPARISON", r"(BOTH SAEM|DIFFRINT)"),
            ("AN", r"AN"),
            ("YARN", r'"[^"]*"'),
            ("NUMBAR", r"-?\d(\d)*\.\d(\d)*"),  # float const
            ("TROOF", r"(WIN|FAIL)"),
            ("NUMBR", r"-?\d(\d)*"),  # int
            ("DATA_TYPE", r"(NOOB|TROOF|NUMBAR|NUMBR|YARN)"),
            ("VARIABLE", r"[a-zA-Z]\w* ?"),
            ("NEWLINE", r"\n"),  # NEW LINE
            ("SKIP", r"[ \t]+"),
            ("MISMATCH", r"."),
        ]
        tokens_join = "|".join("(?P<%s>%s)" % x for x in rules)
        # print(tokens_join)
        lin_start = 0

        # Lists of output for the program
        token = []
        lexeme = []
        row = []
        column = []

        # It analyzes the code to find the lexemes and their respective Tokens
        for m in re.finditer(tokens_join, code):
            token_type = m.lastgroup
            token_lexeme = m.group(token_type)

            if token_type == "NEWLINE":
                lin_start = m.end()
                self.lin_num += 1
            elif token_type == "SKIP":
                continue
            elif token_type == "MISMATCH":
                error = (
                    str(token_lexeme[0]) + " unexpected on line " + str(self.lin_num)
                )
                return False, error, False, False
                raise RuntimeError(
                    "%r unexpected on line %d" % (token_lexeme, self.lin_num)
                )
            else:
                col = m.start() - lin_start
                column.append(col)
                token.append(token_type)
                lexeme.append(token_lexeme)
                row.append(self.lin_num)
                # To print information about a Token
                # print(
                #     "Token = {0}, Lexeme = '{1}', Row = {2}, Column = {3}".format(
                #         token_type, token_lexeme, self.lin_num, col
                #     )
                # )

        return token, lexeme, row, column
create database MyEmployees;
use myemployees;
create table Emp(id int, Username varchar(10), age smallint, salary mediumint, Phone bigint, Designation varchar(15));
insert into Emp values(100, 'Abhi',25,800000,98789309874,'Manager');
select * from Emp;
insert into Emp values(200, 'Kabhi',45,900000,9867809874,'Manager');
insert into Emp values(300, 'Jabhi',25,48000,98789309874,'Manager');
insert into Emp values(400, 'Tabhi',25,30000,98789309874,'Manager');
select * from Emp;
select * from Emp where Salary <=60000;
insert into Emp values(500, 'King',24,30000,9082209875, 'Analyst');
select * from Emp;
SET SQL_SAFE_UPDATES=0;
UPDATE emp set salary=90000 where id=500;
select * from Emp;
select * from Emp where designation='Manager';
select * from Emp; 
select * from Emp where salary<=50000 and designation='manager';
select * from Emp where age<=50 and designation='manager';
select * from Emp; 
update emp set designation='Clerk' where Username='Kabhi';
select * from Emp; 
update emp set salary=150000, designation='manager' where id=500;
select * from Emp;
delete from emp where id=200;
select * from Emp;
update emp set designation='analyst' where id=500;
import re
from Variable import Variable
from collections import deque

vars = [Variable("IT", "NOOB", "")]
returnVals = [False]


class SyntaxAnalyzer:
    def program(self, tokens, lexeme, row):
        global returnVals
        # reset variables
        returnVals = [False]
        i = 0

        while tokens[i] == "COMMENT":
            i += 1

        if tokens[i] == "START":  # encountered start of program
            print("==== PROGRAM START! === \n")
            i += 1
            while tokens[i] != "END" and i < len(tokens):
                if tokens[i] == "COMMENT":
                    i += 1
                    continue

                if tokens[i] == "WAZZUP":
                    i += 1
                    i = isVarDec(tokens, lexeme, row, i)

                i = statement(tokens, lexeme, row, i)

                if i >= len(tokens):
                    break
            if i == len(tokens):
                returnVals[0] = True

                returnVals.append("ERROR: End of program not found")
                return returnVals
                raise RuntimeError("End of program not found")
            # printVariables()
        else:
            returnVals[0] = True

            returnVals.append("ERROR: Start of program not found")
            return returnVals
            raise RuntimeError("Start of program not found")
        return returnVals


def isVarDec(tokens, lexeme, row, i):
    global vars, returnVals
    maxlen = len(tokens)
    while tokens[i] != "BUHBYE":
        if tokens[i] == "COMMENT":  # aka BTW (single line comment)
            # comments are stored all in one, if it's a multiline is when we iterate thru so this is fine
            i += 1
            continue
        elif tokens[i] == "VAR_DEC":
            # build line
            rowNum = row[i]
            line = []
            tline = []
            while rowNum == row[i]:
                line.append(lexeme[i])
                tline.append(tokens[i])
                i += 1
            storeVariable(tline, line, rowNum)
        else:
            returnVals[0] = True

            returnVals.append(
                "Unexpected "
                + str(lexeme[i])
                + " on line "
                + str(row[i])
                + ". Only variable declarations are allowed in this section"
            )
            return returnVals
            raise RuntimeError(
                "Unexpected %r on line %d, Only variable declarations are allowed in this section"
                % (lexeme[i], row[i])
            )

        if i >= maxlen:
            returnVals[0] = True

            returnVals.append("ERROR: Expected end of file")
            return returnVals
            raise RuntimeError("Encountered end of file")
    return i


def storeVariable(tline, line, rowNum):
    global vars, returnVals
    i = 1
    maxlength = len(tline)
    if tline[i] == "VARIABLE":
        varName = line[i].strip()
        i += 1
    else:
        returnVals[0] = True

        returnVals.append("ERROR: Expected VARIABLE NAME on line " + str(rowNum))
        return returnVals
        raise RuntimeError("Expected VARIABLE NAME on line %d" % (rowNum))

    if i >= maxlength:
        vars.append(Variable(varName, "NOOB", None))
        return

    if tline[i] == "ITZ":
        i += 1
    else:
        returnVals[0] = True

        returnVals.append("ERROR: Expected 'ITZ' on line " + str(rowNum))
        return returnVals
        raise RuntimeError("Expected 'ITZ' on line %d" % (rowNum))

    if i >= maxlength:
        returnVals[0] = True

        returnVals.append("ERROR: Variable must have a value!")
        return returnVals
        raise RuntimeError("Variable must have a value!")

    if (
        tline[i] == "NOOB"
        or tline[i] == "YARN"
        or tline[i] == "TROOF"
        or tline[i] == "NUMBAR"
        or tline[i] == "NUMBR"
        or tline[i] == "VARIABLE"
    ):
        type = tline[i]
        value = line[i]
        vars.append(Variable(varName, type, value))
        return
    else:
        returnVals[0] = True

        returnVals.append(
            "ERROR: Variable declaration can only be to a YARN, TROOF, NOOB etc"
        )
        return returnVals
        raise RuntimeError(
            "Variable declaration can only be to a YARN, TROOF, NOOB etc"
        )


def statement(tokens, lexeme, row, i):
    global vars, returnVals
    tline = []
    line = []
    rowNum = row[i]
    # print(rowNum)
    while rowNum == row[i]:
        tline.append(tokens[i])
        line.append(lexeme[i])
        i += 1

    if tline[0] == "PRINT":
        printLine(line, tline, i)
    elif tline[0] == "VAR_DEC":
        returnVals[0] = True

        returnVals.append(
            "ERROR: Unexpected variable declaration at line " + str(rowNum)
        )
        return returnVals
        raise RuntimeError("Unexpected variable declaration at line %d" % (rowNum))
    elif tline[0] == "BOOL_OPER":
        value = boolOpRegion(line, tline, 0, rowNum)
        storeVariables("IT", "TROOF", value)
        # print(boolOpRegion(line, tline, 0, rowNum))
    elif tline[0] == "COMPARISON":
        storeVariables("IT", "TROOF", comparison(line, tline, 0, rowNum))
        # print(comparison(line, tline, 0, rowNum))
    elif tline[0] == "MATH":
        value = mathOp(line, tline, 0, rowNum)
        if isinstance(value, int):
            storeVariables("IT", "NUMBR", value)
        else:
            storeVariables("IT", "NUMBAR", value)
    elif tline[0] == "INPUT":
        getInput(line, tline, 0, rowNum)
    return i


def getInput(line, tline, i, rowNum):
    global returnVals
    i += 1
    if tline[i] == "VARIABLE":
        varName = line[i]
        inputSTR = input("")
        storeVariables(varName, "YARN", inputSTR)
    else:
        returnVals[0] = True

        returnVals.append(
            "Error in line "
            + str(rowNum)
            + ", expected VARIABLE instead of "
            + str(line[i])
        )
        return returnVals
        raise RuntimeError(
            "Error in line %d, expected VARIABLE instead of %r" % (rowNum, line[i])
        )


def comparison(line, tline, i, rowNum):
    global returnVals
    compQ = []
    # print(line)
    if line[i] == "BOTH SAEM":
        i += 1
        if tline[i] == "NUMBR" or tline[i] == "NUMBAR":
            compQ.append([tline[i], line[i]])
            i += 1
        elif tline[i] == "VARIABLE":
            value, type = searchVarValue(line[i])
            compQ.append([type, value])
            i += 1
        else:
            returnVals[0] = True

            returnVals.append(
                "Expected NUMBR, NUMBAR, or VARIABLE at line " + str(rowNum)
            )
            return returnVals
            raise RuntimeError(
                "Expected NUMBR, NUMBAR, or VARIABLE at line %d" % (rowNum)
            )
        if tline[i] != "AN":
            returnVals[0] = True

            returnVals.append("ERROR: Expected AN at line " + str(rowNum))
            return returnVals
            raise RuntimeError("Expected AN at line %d" % (rowNum))
        i += 1
        if line[i] == "BIGGR OF" or line[i] == "SMALLR OF":
            compQ.append(line[i])
            i += 1
            if tline[i] == "NUMBR" or tline[i] == "NUMBAR":
                compQ.append([tline[i], line[i]])
                i += 1
            elif tline[i] == "VARIABLE":
                value, type = searchVarValue(line[i])
                compQ.append([type, value])
                i += 1
            else:
                returnVals[0] = True

                returnVals.append(
                    "Expected NUMBR, NUMBAR, or VARIABLE at line" + str(rowNum)
                )
                return returnVals
                raise RuntimeError(
                    "Expected NUMBR, NUMBAR, or VARIABLE at line %d" % (rowNum)
                )
            if compQ[0][1] != compQ[2][1]:
                returnVals[0] = True

                returnVals.append(
                    "Value mismatch - operand 1 and 2 ("
                    + str(compQ[0][1])
                    + " and "
                    + str(compQ[2][1])
                    + ") must be same"
                )
                return returnVals
                raise RuntimeError(
                    "Value mismatch - operand 1 and 2 (%r and %r) must be same"
                    % (compQ[0][1], compQ[2][1])
                )
            if tline[i] != "AN":
                returnVals[0] = True

                returnVals.append("ERROR: Expected AN at line " + str(rowNum))
                return returnVals
                raise RuntimeError("Expected AN at line %d" % (rowNum))
            i += 1
            if tline[i] == "NUMBR" or tline[i] == "NUMBAR":
                compQ.append([tline[i], line[i]])
                i += 1
            elif tline[i] == "VARIABLE":
                value, type = searchVarValue(line[i])
                compQ.append([type, value])
                i += 1
            else:
                returnVals[0] = True

                returnVals.append(
                    "Expected NUMBR, NUMBAR, VARIABLE at line" + str(rowNum)
                )
                return returnVals
                raise RuntimeError(
                    "Expected NUMBR, NUMBAR, or VARIABLE at line %d" % (rowNum)
                )
        elif tline[i] == "NUMBR" or tline[i] == "NUMBAR":
            compQ.append([tline[i], line[i]])
            i += 1
        elif tline[i] == "VARIABLE":
            value, type = searchVarValue(line[i])
            compQ.append([type, value])
            i += 1
        else:
            returnVals[0] = True

            returnVals.append(
                "Expected NUMBR, NUMBAR, VARIABLE, BIGGR OF, or SMALLR OF at line"
                + str(rowNum)
            )
            return returnVals
            raise RuntimeError(
                "Expected NUMBR, NUMBAR, VARIABLE, BIGGR OF, or SMALLR OF at line %d"
                % (rowNum)
            )

        # print(compQ)
        if compQ[1] == "BIGGR OF":
            if compQ[2][0] != compQ[3][0]:
                returnVals[0] = True

                returnVals.append(
                    "Type mismatch - cannot compare "
                    + str(compQ[0][0])
                    + " and "
                    + str(compQ[1][0])
                )
                return returnVals
                raise RuntimeError(
                    "Type mismatch - cannot compare %r and %r"
                    % (compQ[0][0], compQ[1][0])
                )
            if compQ[2][0] == "NUMBR":
                if int(compQ[2][1]) >= int(compQ[3][1]):
                    return "WIN"
                else:
                    return "FAIL"
            elif compQ[2][0] == "NUMBAR":
                if float(compQ[2][1]) >= float(compQ[3][1]):
                    return "WIN"
                else:
                    return "FAIL"
            else:
                returnVals[0] = True

                returnVals.append("ERROR: Unexpected type " + str(compQ[2][0]))
                return returnVals
                raise RuntimeError("Unexpected type %r" % (compQ[2][0]))
        elif compQ[1] == "SMALLR OF":
            if compQ[2][0] != compQ[3][0]:
                returnVals[0] = True

                returnVals.append(
                    "Type mismatch - cannot compare "
                    + str(compQ[0][0])
                    + " and "
                    + str(compQ[1][0])
                )
                return returnVals
                raise RuntimeError(
                    "Type mismatch - cannot compare %r and %r"
                    % (compQ[0][0], compQ[1][0])
                )
            if compQ[2][0] == "NUMBR":
                if int(compQ[2][1]) <= int(compQ[3][1]):
                    return "WIN"
                else:
                    return "FAIL"
            elif compQ[2][0] == "NUMBAR":
                if float(compQ[2][1]) <= float(compQ[3][1]):
                    return "WIN"
                else:
                    return "FAIL"
            else:
                returnVals[0] = True

                returnVals.append("ERROR: Unexpected type " + str(compQ[2][0]))
                return returnVals
                raise RuntimeError("Unexpected type %r" % (compQ[2][0]))
        else:
            if compQ[0][0] != compQ[1][0]:
                returnVals[0] = True

                returnVals.append(
                    "Type mismatch - cannot compare "
                    + str(compQ[0][0])
                    + " and "
                    + str(compQ[1][0])
                )
                return returnVals
                raise RuntimeError(
                    "Type mismatch - cannot compare %r and %r"
                    % (compQ[0][0], compQ[1][0])
                )
            if compQ[0][1] == compQ[1][1]:
                return "WIN"
            else:
                return "FAIL"
    elif line[i] == "DIFFRINT":
        i += 1
        if tline[i] == "NUMBR" or tline[i] == "NUMBAR":
            compQ.append([tline[i], line[i]])
            i += 1
        elif tline[i] == "VARIABLE":
            value, type = searchVarValue(line[i])
            compQ.append([type, value])
            i += 1
        else:
            returnVals[0] = True

            returnVals.append(
                "Expected NUMBR, NUMBAR, or VARIABLE at line " + str(rowNum)
            )
            return returnVals
            raise RuntimeError(
                "Expected NUMBR, NUMBAR, or VARIABLE at line %d" % (rowNum)
            )
        if tline[i] != "AN":
            returnVals[0] = True

            returnVals.append("ERROR: Expected AN at line " + str(rowNum))
            return returnVals
            raise RuntimeError("Expected AN at line %d" % (rowNum))
        i += 1
        if line[i] == "BIGGR OF" or line[i] == "SMALLR OF":
            compQ.append(line[i])
            i += 1
            if tline[i] == "NUMBR" or tline[i] == "NUMBAR":
                compQ.append([tline[i], line[i]])
                i += 1
            elif tline[i] == "VARIABLE":
                value, type = searchVarValue(line[i])
                compQ.append([type, value])
                i += 1
            else:
                returnVals[0] = True

                returnVals.append(
                    "Expected NUMBR, NUMBAR, or VARIABLE at line " + str(rowNum)
                )
                return returnVals
                raise RuntimeError(
                    "Expected NUMBR, NUMBAR, or VARIABLE at line %d" % (rowNum)
                )
            if compQ[0][1] != compQ[2][1]:
                returnVals[0] = True

                returnVals.append(
                    "Value mismatch on line "
                    + str(rowNum)
                    + "("
                    + str(compQ[0][1])
                    + " and "
                    + str(compQ[2][1])
                    + ") must be same"
                )
                return returnVals
                raise RuntimeError(
                    "Value mismatch on line %d (%r and %r) must be same"
                    % (rowNum, compQ[0][1], compQ[2][1])
                )
            if tline[i] != "AN":
                returnVals[0] = True

                returnVals.append("ERROR: Expected AN at line" + str(rowNum))
                return returnVals
                raise RuntimeError("Expected AN at line %d" % (rowNum))
            i += 1
            if tline[i] == "NUMBR" or tline[i] == "NUMBAR":
                compQ.append([tline[i], line[i]])
                i += 1
            elif tline[i] == "VARIABLE":
                value, type = searchVarValue(line[i])
                compQ.append([type, value])
                i += 1
            else:
                returnVals[0] = True

                returnVals.append(
                    "Expected NUMBR, NUMBAR, or VARIABLE at line " + str(rowNum)
                )
                return returnVals
                raise RuntimeError(
                    "Expected NUMBR, NUMBAR, or VARIABLE at line %d" % (rowNum)
                )
        elif tline[i] == "NUMBR" or tline[i] == "NUMBAR":
            compQ.append([tline[i], line[i]])
            i += 1
        elif tline[i] == "VARIABLE":
            value, type = searchVarValue(line[i])
            compQ.append([type, value])
            i += 1
        else:
            returnVals[0] = True

            returnVals.append(
                "Expected NUMBR, NUMBAR, or VARIABLE at line " + str(rowNum)
            )
            return returnVals
            raise RuntimeError(
                "Expected NUMBR, NUMBAR, VARIABLE, BIGGR OF, or SMALLR OF at line %d"
                % (rowNum)
            )

        # print(compQ)
        if compQ[1] == "BIGGR OF":
            if compQ[2][0] != compQ[3][0]:
                returnVals[0] = True

                returnVals.append(
                    "Type mismatch - cannot compare "
                    + str(compQ[0][0])
                    + " and "
                    + str(compQ[1][0])
                )
                return returnVals
                raise RuntimeError(
                    "Type mismatch - cannot compare %r and %r"
                    % (compQ[0][0], compQ[1][0])
                )
            if compQ[2][0] == "NUMBR":
                if int(compQ[3][1]) >= int(compQ[2][1]):
                    return "WIN"
                else:
                    return "FAIL"
            elif compQ[2][0] == "NUMBAR":
                if float(compQ[3][1]) >= float(compQ[2][1]):
                    return "WIN"
                else:
                    return "FAIL"
            else:
                returnVals[0] = True

                returnVals.append("ERROR: Unexpected type " + str(compQ[2][0]))
                return returnVals
                raise RuntimeError("Unexpected type %r" % (compQ[2][0]))
        elif compQ[1] == "SMALLR OF":
            if compQ[2][0] != compQ[3][0]:
                returnVals[0] = True

                returnVals.append(
                    "Type mismatch - cannot compare "
                    + str(compQ[0][0])
                    + " and "
                    + str(compQ[1][0])
                )
                return returnVals
                raise RuntimeError(
                    "Type mismatch - cannot compare %r and %r"
                    % (compQ[0][0], compQ[1][0])
                )
            if compQ[2][0] == "NUMBR":
                if int(compQ[3][1]) <= int(compQ[2][1]):
                    return "WIN"
                else:
                    return "FAIL"
            elif compQ[2][0] == "NUMBAR":
                if float(compQ[3][1]) <= float(compQ[2][1]):
                    return "WIN"
                else:
                    return "FAIL"
            else:
                returnVals[0] = True

                returnVals.append("ERROR: Unexpected type " + str(compQ[2][0]))
                return returnVals
                raise RuntimeError("Unexpected type %r" % (compQ[2][0]))
        else:
            if compQ[0][0] != compQ[1][0]:
                returnVals[0] = True

                returnVals.append(
                    "Type mismatch - cannot compare "
                    + str(compQ[0][0])
                    + " and "
                    + str(compQ[1][0])
                )
                return returnVals
                raise RuntimeError(
                    "Type mismatch - cannot compare %r and %r"
                    % (compQ[0][0], compQ[1][0])
                )
            if compQ[0][1] != compQ[1][1]:
                return "WIN"
            else:
                return "FAIL"


# function for parsing prefix notation math operations
def parse(tokens):
    global returnVals
    if not tokens:
        returnVals[0] = True

        returnVals.append("ERROR: Unexpected end of statement.")
        return returnVals
        raise RuntimeError("Unexpected end of statement.")
    else:
        token = tokens.popleft()
        if token == "+":
            return parse(tokens) + parse(tokens)
        elif token == "-":
            return parse(tokens) - parse(tokens)
        elif token == "/":
            return parse(tokens) / parse(tokens)
        elif token == "*":
            return parse(tokens) * parse(tokens)
        elif token == "%":
            return parse(tokens) % parse(tokens)
        elif token == "max":
            return max(parse(tokens), parse(tokens))
        elif token == "min":
            return min(parse(tokens), parse(tokens))
        else:
            return token


def mathOp(line, tline, i, rowNum):
    global returnVals
    op = []
    num_of_operations = 0
    num_of_AN = 0

    while i < len(line):
        if line[i] == "SUM OF":
            op.append("+")
            i += 1
            num_of_operations += 1
        elif line[i] == "DIFF OF":
            op.append("-")
            i += 1
            num_of_operations += 1
        elif line[i] == "PRODUKT OF":
            op.append("*")
            i += 1
            num_of_operations += 1
        elif line[i] == "QUOSHUNT OF":
            op.append("/")
            i += 1
            num_of_operations += 1
        elif line[i] == "MOD OF":
            op.append("%")
            i += 1
            num_of_operations += 1
        elif line[i] == "BIGGR OF":
            op.append("max")
            i += 1
            num_of_operations += 1
        elif line[i] == "SMALLR OF":
            op.append("min")
            i += 1
            num_of_operations += 1
        else:
            if tline[i] == "NUMBR":
                op.append(int(line[i]))
                i += 1
            elif tline[i] == "NUMBAR":
                op.append(float(line[i]))
                i += 1
            elif tline[i] == "VARIABLE":
                value, _ = searchVarValue(line[i])
                op.append(value)
                i += 1
            elif tline[i] == "YARN":
                value = typeCasting(line[i], tline[i], "NUMBAR", rowNum)
                op.append(value)
                i += 1
            elif tline[i] == "AN":
                i += 1
                num_of_AN += 1
            else:
                returnVals[0] = True

                returnVals.append(
                    "Unexpected " + str(line[i]) + " at line " + str(rowNum)
                )
                return returnVals
                raise RuntimeError("Unexpected %r at line %d" % (line[i], rowNum))
            i += 1

    expected_operands = num_of_operations + 1
    actual_operands = len(op) - (num_of_AN + num_of_operations)
    if expected_operands != actual_operands:
        returnVals[0] = True

        returnVals.append(
            "Expected "
            + str(expected_operands)
            + " operands, but found "
            + str(actual_operands)
            + " at line "
            + str(rowNum)
        )
        return returnVals
        raise RuntimeError(
            "Expected %d operands, but found %d at line %d"
            % (expected_operands, actual_operands, rowNum)
        )
    else:
        return parse(deque(op))


def boolOp(line, tline, i, rowNum):
    global returnVals
    if tline[i] == "BOOL_OPER":
        opAddress = i
        boolQ = []
        i += 1
        i, boolQ0 = boolOp(line, tline, i, rowNum)
        boolQ.append(boolQ0)
        if line[opAddress] == "NOT":
            if boolQ[0] == "WIN":
                return i, "FAIL"
            else:
                return i, "WIN"
        i += 1
        if tline[i] != "AN":
            returnVals[0] = True

            returnVals.append("ERROR: Expected AN at line " + str(rowNum))
            return returnVals
            raise RuntimeError("Expected AN at line %d" % (rowNum))
        i += 1
        i, boolQ1 = boolOp(line, tline, i, rowNum)
        boolQ.append(boolQ1)
        # print(boolQ)
        if line[opAddress] == "BOTH OF":
            if boolQ[0] == "WIN" and boolQ[1] == "WIN":
                return i, "WIN"
            else:
                return i, "FAIL"
        elif line[opAddress] == "EITHER OF":
            if boolQ[0] == "WIN" or boolQ[1] == "WIN":
                return i, "WIN"
            else:
                return i, "FAIL"
        elif line[opAddress] == "WON OF":
            if boolQ[0] != boolQ[1] and (boolQ[0] == "WIN" or boolQ[1] == "WIN"):
                return i, "WIN"
            else:
                return i, "FAIL"
    elif tline[i] == "VARIABLE":
        if i < len(line) - 1:
            line[i] = line[i].strip()
        value, type = searchVarValue(line[i])
        if type != "TROOF":
            value = typeCasting(value, type, "TROOF", rowNum)
        return i, value
    elif tline[i] == "TROOF":
        return i, line[i]
    else:
        returnVals[0] = True

        returnVals.append(
            "ERROR: Unexpected " + str(line[i]) + " at line " + str(rowNum)
        )
        return returnVals
        raise RuntimeError("Unexpected %r at line %d, %d" % (line[i], rowNum))


def boolOpRegion(line, tline, i, rowNum):
    global returnVals
    if line[i] == "ALL OF" or line[i] == "ANY OF":
        if line[i] == "ALL OF":
            initCond = "WIN"
            terminateCond = "WIN"
        elif line[i] == "ANY OF":
            terminateCond = "FAIL"
            initCond = "FAIL"
        i += 1
        while i < len(line):
            if initCond == terminateCond:
                i, initCond = boolOp(line, tline, i, rowNum)
                i += 1
            if line[i] == "AN":
                i += 1
            elif (
                tline[i] == "BOOL_OPER" or tline[i] == "TROOF" or tline[i] == "VARIABLE"
            ):
                i += 1
            elif line[i] == "MKAY":
                break
            else:
                returnVals[0] = True

                returnVals.append("ERROR: Type " + str(tline[i]) + " cannot be printed")
                return returnVals
                raise RuntimeError(
                    "Expected AN at line %d, %d but encountered %r"
                    % (rowNum, i, line[i])
                )
        if i != len(line) and tline[i] != "COMMENT":
            returnVals[0] = True

            returnVals.append(
                "Error: Unexpected ", str(line[i + 1]), " in line ", str(rowNum)
            )
            return returnVals
            raise RuntimeError("Unexpected %r in line %d" % (line[i + 1], rowNum))
        # print("i: "+str(i))
        return initCond
    else:
        j, k = boolOp(line, tline, i, rowNum)
        if j != len(line) - 1 and tline[j + 1] != "COMMENT":
            returnVals[0] = True

            returnVals.append(
                "Error: Unexpected ", str(line[j + 1]), " in line ", str(rowNum)
            )
            return returnVals
            raise RuntimeError("Unexpected %r in line %d" % (line[j + 1], rowNum))
        else:
            return k


def printLine(line, tline, rowNum):
    global returnVals
    # assume muna na YARN lang ung priniprint
    string = ""
    for i in range(0, len(line)):
        if tline[i] != "PRINT" and tline[i] != "COMMENT":
            if tline[i] == "YARN":
                string = string + line[i].replace('"', "")
            elif tline[i] == "VARIABLE":
                value, type = searchVarValue(line[i])
                if type != "YARN":
                    value = typeCasting(value, type, "YARN", i)
                else:
                    value = value.strip()
                # print(value)
                string = string + value
            elif tline[i] == "NUMBR" or tline[i] == "NUMBAR":
                value = typeCasting(line[i], tline[i], "YARN", i)
                string = string + value
            elif tline[i] == "TROOF":
                value = line[i]
                string = string + value
            elif tline[i] == "BOOL_OPER":
                value = boolOpRegion(line, tline, i, rowNum)
                string = string + value
                break
            elif tline[i] == "COMPARISON":
                value = comparison(line, tline, i, rowNum)
                string = string + value
                break
            elif tline[i] == "MATH":
                value = str(mathOp(line, tline, i, rowNum))
                string = string + value
                break
            else:
                returnVals[0] = True

                returnVals.append(
                    "ERROR: Error: Type " + str(tline[i]) + " cannot be printed"
                )
                return returnVals
                raise RuntimeError("Type %r cannot be printed" % (tline[i]))

    print(string)
    returnVals.append(string)


def searchVarValue(name):
    global vars, returnVals
    name = name.strip()
    for variable in vars:
        if variable.name == name:
            return variable.value, variable.dataType

    returnVals[0] = True

    returnVals.append("ERROR: Variable " + str(name) + " does not exist")
    return returnVals
    raise RuntimeError("Variable %r does not exist" % (name))


def typeCasting(value, type1, type2, rowNum):
    global returnVals
    if type1 == "NOOB":
        if type2 == "TROOF":
            return False
        else:
            returnVals[0] = True

            returnVals.append(
                "Encountered error in line "
                + str(rowNum)
                + ", cannot typecast NOOB to "
                + str(type2)
            )
            return returnVals
            raise RuntimeError(
                "Encountered error in line %d, cannot typecast NOOB to %r"
                % (rowNum, type2)
            )
    elif type1 == "NUMBR" or type1 == "NUMBAR":
        match type2:
            case "NUMBAR":
                return float(value)
            case "NUMBR":
                return int(value)
            case "YARN":
                return str(value)
            case "TROOF":
                if value == 0:
                    return "FAIL"
                else:
                    return "WIN"
            case _:
                returnVals[0] = True

                returnVals.append(
                    "Encountered error in line "
                    + str(rowNum)
                    + ", cannot typecast NUMBR to "
                    + str(type2)
                )
                return returnVals
                raise RuntimeError(
                    "Encountered error in line %d, cannot typecast NUMBR to %r"
                    % (rowNum, type2)
                )
    elif type1 == "TROOF":
        match type2:
            case "NUMBAR":
                if value == "WIN":
                    return 1.0
                else:
                    return 0
            case "NUMBR":
                if value == "WIN":
                    return 1
                else:
                    return 0
            case "YARN":
                return value
            case _:
                returnVals[0] = True

                returnVals.append(
                    "Encountered error in line "
                    + str(rowNum)
                    + ", cannot typecast TROOF to "
                    + str(type2)
                )
                return returnVals
                raise RuntimeError(
                    "Encoutnered error in line %d, cannot typecast TROOF to %r"
                    % (rowNum, type2)
                )
    elif type1 == "YARN":
        value = value[1:-1]
        match type2:
            case "NUMBR":
                if bool(re.search(r"-?\d(\d)*", value)):
                    return int(value)
                else:
                    returnVals[0] = True

                    returnVals.append(
                        "Encountered error in line "
                        + str(rowNum)
                        + ", cannot typecast YARN to "
                        + str(type2)
                    )
                    return returnVals
                    raise RuntimeError(
                        "Encountered error in line %d, cannot typecast YARN to %r"
                        % (rowNum, type2)
                    )
            case "NUMBAR":
                if bool(re.search(r"-?\d(\d)*\.\d(\d)*", value)):
                    return float(value)
                else:
                    returnVals[0] = True

                    returnVals.append(
                        "Encountered error in line "
                        + str(rowNum)
                        + ", cannot typecast YARN to "
                        + str(type2)
                    )
                    return returnVals
                    raise RuntimeError(
                        "Encountered error in line %d, cannot typecast YARN to %r"
                        % (rowNum, type2)
                    )
            case "TROOF":
                if value == "":
                    return "FAIL"
                else:
                    return "WIN"
            case _:
                returnVals[0] = True

                returnVals.append(
                    "Encountered error in line "
                    + str(rowNum)
                    + ", cannot typecast YARN to "
                    + str(type2)
                )
                return returnVals
                raise RuntimeError(
                    "Encountered error in line %d, cannot typecast YARN to %r"
                    % (rowNum, type2)
                )


def printVariables():
    global vars
    for variable in vars:
        print(variable.name)
        print(variable.dataType)
        print(variable.value)
        print("")


def storeVariables(varName, type, newVal):
    global vars, returnVals
    for variable in vars:
        if variable.name == varName:
            variable.dataType = type
            variable.value = newVal
    # returnVals[0] = True
    #
    # returnVals.append("ERROR: Variable " + str(varName) + " does not exizt")
    # return returnVals
    return RuntimeError("Variable %r does not exist")
import wx
import wx.lib.scrolledpanel as scrolled
from Buffer import Buffer
from LexicalAnalyzer import LexicalAnalyzer
from SyntaxAnalyzer import SyntaxAnalyzer

if __name__ == "__main__":
    Buffer = Buffer()
    Analyzer = LexicalAnalyzer()
    Syntax = SyntaxAnalyzer()
    path = None
    display_text = None
    terminal_font_path = "resources/Modeseven-L3n5.ttf"

    # Lists for every list returned list from the function tokenize
    token = []
    lexeme = []
    row = []
    column = []
    txt_ctrl_val = ""
    file_attached = False

    # these variables are instantiated early because of scope issues
    app = wx.App()
    icon = wx.Icon("resources/lol.ico")
    frame = wx.Frame(None, title="LOLCode Interpreter", size=(1000, 800))
    frame.SetBackgroundColour("#EFF1F3")
    frame.SetIcon(icon)

    panel = wx.Panel(frame)
    text_editor = wx.TextCtrl(panel, style=wx.TE_MULTILINE | wx.TE_NO_VSCROLL)

    main_horizontal_box = wx.BoxSizer(wx.HORIZONTAL)
    left_vertical_box = wx.BoxSizer(wx.VERTICAL)
    right_vertical_box = wx.BoxSizer(wx.VERTICAL)
    left_panel = wx.Panel(panel, size=(200, 200))
    text_editor_box = wx.BoxSizer(wx.VERTICAL)
    left_main_vbox = wx.BoxSizer(wx.VERTICAL)
    left_main_title = wx.StaticText(
        left_panel, label="LEXEMES AND SYMBOLS", style=wx.ALIGN_LEFT
    )
    titles_panel = wx.Panel(left_panel)
    titles_hbox = wx.BoxSizer(wx.HORIZONTAL)
    lex_title = wx.StaticText(titles_panel, label="Lexeme")
    class_title = wx.StaticText(titles_panel, label="Classification")
    terminal_panel = wx.Panel(panel)
    terminal_title = wx.StaticText(terminal_panel, label="TERMINAL")
    terminal_box = wx.BoxSizer(wx.VERTICAL)
    terminal_scrollpane = scrolled.ScrolledPanel(terminal_panel, size=(200, 200))
    terminal_scrollpane.SetupScrolling()
    terminal_context_box = wx.BoxSizer(wx.VERTICAL)
    execute_button_box = wx.BoxSizer(wx.VERTICAL)
    execute_button = wx.Button(panel, label="EXECUTE")

    wx.Font.AddPrivateFont(terminal_font_path)

    terminal_font = wx.Font(
        10,
        wx.FONTFAMILY_DEFAULT,
        wx.FONTSTYLE_NORMAL,
        wx.FONTWEIGHT_NORMAL,
        False,
        "ModeSeven",
        encoding=wx.FONTENCODING_DEFAULT,
    )

    line = wx.StaticLine(terminal_panel, size=(400, -1), style=wx.LI_HORIZONTAL)

    def on_attach_file_button(event):
        global path, txt_ctrl_val, text_editor, file_attached
        path = None
        with wx.FileDialog(
            frame,
            "Open",
            wildcard="All files (*.*)|*.*",
            style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
        ) as fileDialog:
            if fileDialog.ShowModal() == wx.ID_CANCEL:
                return
            path = fileDialog.GetPath()

            print(f"Selected file: {path}")
            returnVal = start(path)
            text_editor.SetValue("".join(returnVal[0]))
            if returnVal[1][0] == False:
                print("HEREEE")
                print(returnVal[1])
                terminal_content = returnVal[1][1:]
                joined_terminal_content = "\n".join(terminal_content)
                start_str = '> lolcode -u "' + path + '"\n'
                start_text = wx.StaticText(terminal_scrollpane, label=start_str)
                start_text.SetFont(terminal_font)
                start_text.SetForegroundColour("#98ddeb")
                joined_text = wx.StaticText(
                    terminal_scrollpane, label=joined_terminal_content
                )
                joined_text.SetFont(terminal_font)
                joined_text.SetForegroundColour("#FFFFFF")
                terminal_context_box.Add(joined_text, 1, wx.EXPAND | wx.ALL, 10)
            else:
                print("KKKK")
                print(returnVal[1])
                terminal_content = []
                for i in range(len(returnVal[1])):
                    if i != 0:
                        terminal_content.append(returnVal[1][i])
                joined_terminal_content = "\n".join(terminal_content)
                start_str = '> lolcode -u "' + path + '"\n'
                start_text = wx.StaticText(terminal_scrollpane, label=start_str)
                start_text.SetFont(terminal_font)
                start_text.SetForegroundColour("#98ddeb")
                terminal_text = wx.StaticText(
                    terminal_scrollpane, label=joined_terminal_content
                )
                terminal_text.SetFont(terminal_font)
                terminal_text.SetForegroundColour("#FFFFFF")
                terminal_context_box.Add(terminal_text, 1, wx.EXPAND | wx.ALL, 20)
        file_attached = True

    def on_execute_button(event):
        pass

    def start(path):
        global token, lexeme, row, column, display_text
        # Tokenize and reload of the buffer
        display_text = list(Buffer.load_buffer(path))
        # clear the lists
        token.clear()
        lexeme.clear()
        row.clear()
        column.clear()
        # iterate through the list of lines returned by the buffer
        for i in display_text:
            t, lex, lin, col = Analyzer.tokenize(i)
            if t == False:
                retVals = [t, lex]
                returnValues = [display_text, retVals]
                return returnValues
            else:
                token += t
                lexeme += lex
                row += lin
                column += col

        print("\nRecognize Tokens: ", token)
        print("\nRecognize Lexems: ", lexeme)
        # print('\nRecognize row: ', row)
        # print('\nRecognize col: ', column)
        retVals = Syntax.program(token, lexeme, row)
        returnValues = [display_text, retVals]
        return returnValues

    # rest of GUI-related code

    left_panel.SetBackgroundColour("#032b43")
    main_horizontal_box.Add(left_panel, 1, wx.EXPAND)

    # main_horizontal_box.Add(left_vertical_box, 1, wx.EXPAND)
    # inner_left_panel = wx.Panel(panel, size=(200, 200))
    # inner_left_panel.SetBackgroundColour("#141E46")
    # add inner left panel to left vertical box
    # left_vertical_box.Add(inner_left_panel, 1, wx.EXPAND)

    main_horizontal_box.Add(right_vertical_box, 3, wx.EXPAND)

    # add text editor box to right vertical box
    right_vertical_box.Add(text_editor_box, 2, wx.EXPAND)
    right_vertical_box.Add(execute_button_box, 0, wx.EXPAND)
    right_vertical_box.Add(terminal_panel, 1, wx.EXPAND)

    # adding the attach file button
    attach_file_button = wx.Button(panel, size=(30, 30))
    attach_icon = wx.Bitmap("resources/attach.ico")
    attach_icon = attach_icon.ConvertToImage()
    attach_icon = attach_icon.Rescale(20, 20, wx.IMAGE_QUALITY_HIGH)
    attach_file_button.SetBitmap(attach_icon)
    attach_file_button.SetBackgroundColour("#FFFFFF")
    # binding button to functionality
    attach_file_button.Bind(wx.EVT_BUTTON, on_attach_file_button)
    # add attach button to text editor box
    text_editor_box.Add(attach_file_button, 0, wx.ALIGN_RIGHT | wx.ALL, 10)

    # text editor widget
    text_editor.SetValue(txt_ctrl_val)
    text_editor.SetBackgroundColour("#FFFFFF")
    # add text editor to text editor box
    text_editor_box.Add(text_editor, 1, wx.EXPAND | wx.BOTTOM | wx.RIGHT | wx.LEFT, 20)

    execute_button_box.Add(
        execute_button, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10
    )

    headers_font = panel.GetFont()
    headers_font.SetPointSize(8)
    headers_font.SetWeight(wx.FONTWEIGHT_BOLD)

    execute_button.SetFont(headers_font)

    table_titles_font = panel.GetFont()
    table_titles_font.SetPointSize(8)
    table_titles_font.SetWeight(wx.FONTWEIGHT_SEMIBOLD)

    left_panel.SetSizer(left_main_vbox)

    left_main_title.SetForegroundColour("#FFFFFF")
    left_main_title.SetFont(headers_font)
    left_main_vbox.Add(left_main_title, 0, wx.ALIGN_CENTER | wx.ALL, 10)

    # titles1_hbox = wx.BoxSizer(wx.HORIZONTAL)
    # left_main_vbox.Add(titles1_hbox, 1, wx.ALL, 10)

    titles_panel.SetBackgroundColour("#62929e")
    left_main_vbox.Add(titles_panel, 0, wx.EXPAND | wx.ALL, 0)

    titles_panel.SetSizer(titles_hbox)

    lex_title.SetForegroundColour("#FFFFFF")
    class_title.SetForegroundColour("#FFFFFF")
    lex_title.SetFont(table_titles_font)
    class_title.SetFont(table_titles_font)
    titles_hbox.Add(lex_title, 1, wx.ALIGN_CENTER | wx.ALL, 5)
    titles_hbox.Add(class_title, 1, wx.ALIGN_CENTER | wx.ALL, 5)

    # terminal_box.Add(terminal_panel, 1, wx.EXPAND | wx.ALL, 0)
    terminal_panel.SetBackgroundColour("#55828B")
    terminal_panel.SetSizer(terminal_box)
    terminal_box.Add(terminal_title, 0, wx.LEFT | wx.ALL, 10)
    terminal_title.SetForegroundColour("#FFFFFF")
    terminal_title.SetFont(terminal_font)
    terminal_box.Add(line, 0, wx.EXPAND | wx.ALL, 0)
    terminal_box.Add(terminal_scrollpane, 0, wx.EXPAND | wx.ALL, 10)
    terminal_scrollpane.SetSizer(terminal_context_box)
    panel.SetSizer(main_horizontal_box)
    frame.Show()
    app.MainLoop()
const myLogger = function (req, res, next) {
  console.log('LOGGED')
  next()
}
app.use(myLogger)
// or for other route files -> router.use(myLogger);
1.
  fun findDuplicates(input: String) {
    val charFrequencyMap = mutableMapOf<Char, Int>()

    for (char in input) {
        charFrequencyMap[char] = charFrequencyMap.getOrDefault(char, 0) + 1
    }

    println("Duplicate characters in the string:")
    for ((char, frequency) in charFrequencyMap) {
        if (frequency > 1) {
            println("$char - $frequency times")
        }
    }
}

fun main() {
    val testString = "programming"

    findDuplicates(testString)
}

2.
fun reverseString(input: String): String {
    val charArray = input.toCharArray()
    val reversedCharArray = CharArray(charArray.size)

    for (i in charArray.indices) {
        reversedCharArray[i] = charArray[charArray.size - 1 - i]
    }

    return String(reversedCharArray)
}

fun main() {
    val originalString = "Hello, Kotlin!"
    val reversedString = reverseString(originalString)

    println("Original String: $originalString")
    println("Reversed String: $reversedString")
}

3. 
fun areAnagrams(str1: String, str2: String): Boolean {
    // Remove spaces and convert to lowercase for case-insensitive comparison
    val cleanedStr1 = str1.replace("\\s".toRegex(), "").toLowerCase()
    val cleanedStr2 = str2.replace("\\s".toRegex(), "").toLowerCase()

    // Check if the lengths are the same
    if (cleanedStr1.length != cleanedStr2.length) {
        return false
    }

    // Create character frequency maps
    val charFrequency1 = mutableMapOf<Char, Int>()
    val charFrequency2 = mutableMapOf<Char, Int>()

    // Update character frequencies for str1
    for (char in cleanedStr1) {
        charFrequency1[char] = charFrequency1.getOrDefault(char, 0) + 1
    }

    // Update character frequencies for str2
    for (char in cleanedStr2) {
        charFrequency2[char] = charFrequency2.getOrDefault(char, 0) + 1
    }

    // Compare character frequencies
    return charFrequency1 == charFrequency2
}

fun main() {
    val string1 = "listen"
    val string2 = "silent"

    if (areAnagrams(string1, string2)) {
        println("$string1 and $string2 are anagrams.")
    } else {
        println("$string1 and $string2 are not anagrams.")
    }
}

4. 
fun generatePermutations(input: String, current: String = "", result: MutableList<String>) {
    if (input.isEmpty()) {
        result.add(current)
        return
    }

    for (i in input.indices) {
        val remaining = input.substring(0, i) + input.substring(i + 1)
        generatePermutations(remaining, current + input[i], result)
    }
}

fun findAllPermutations(input: String): List<String> {
    val result = mutableListOf<String>()
    generatePermutations(input, "", result)
    return result
}

fun main() {
    val testString = "abc"
    val permutations = findAllPermutations(testString)

    println("Permutations of $testString:")
    for (permutation in permutations) {
        println(permutation)
    }
}


  5.
fun containsOnlyDigits(input: String): Boolean {
    for (char in input) {
        if (char !in '0'..'9') {
            return false
        }
    }
    return true
}


6.
fun findDuplicates(input: String): List<Char> {
    val charFrequencyMap = mutableMapOf<Char, Int>()
    val duplicates = mutableListOf<Char>()

    for (char in input) {
        charFrequencyMap[char] = charFrequencyMap.getOrDefault(char, 0) + 1
        if (charFrequencyMap[char] == 2) {
            duplicates.add(char)
        }
    }

    return duplicates
}

7.
fun countVowelsAndConsonants(input: String): Pair<Int, Int> {
    val vowels = "aeiouAEIOU"
    var vowelCount = 0
    var consonantCount = 0

    for (char in input) {
        if (char.isLetter()) {
            if (char.toLowerCase() in vowels) {
                vowelCount++
            } else {
                consonantCount++
            }
        }
    }

    return Pair(vowelCount, consonantCount)
}

8.
fun findCharOccurrences(input: String, targetChar: Char): Int {
    return input.count { it == targetChar }
}

9.
fun firstNonRepeatedChar(input: String): Char? {
    val charFrequencyMap = mutableMapOf<Char, Int>()

    for (char in input) {
        charFrequencyMap[char] = charFrequencyMap.getOrDefault(char, 0) + 1
    }

    for (char in input) {
        if (charFrequencyMap[char] == 1) {
            return char
        }
    }

    return null
}

10.
fun reverseWords(sentence: String): String {
    val words = mutableListOf<String>()
    var currentWord = StringBuilder()

    for (char in sentence) {
        if (char.isWhitespace()) {
            if (currentWord.isNotEmpty()) {
                words.add(currentWord.toString())
                currentWord.clear()
            }
        } else {
            currentWord.append(char)
        }
    }

    if (currentWord.isNotEmpty()) {
        words.add(currentWord.toString())
    }

    return words.reversed().joinToString(" ")
}

fun main() {
    val testSentence = "Hello Kotlin World"

    val reversedSentence = reverseWords(testSentence)

    println("Original Sentence: $testSentence")
    println("Reversed Words: $reversedSentence")
}




import java.util.Scanner;

class A

{
    int x, y;
    A(int a, int b)
    {
        x=a; y=b;
        
    }
    void ok()
    {
        System.out.print(x+" "+y);
    }
    
}

class B
{
    public static void main(String[] args)
    {
        A r = new A(100,200);
        r.ok();
    }
}
import java.util.Scanner;

class A

{
    int a; String b; boolean c;
    /*A()
    {
        a=10;b="OK";c=true;
        
    }*/
    void ok()
    {
        System.out.print(a+" "+b+" "+c+" ");
    }
    
}

class B
{
    public static void main(String[] args)
    {
        A r = new A();
        r.ok();
    }
}
Closed Cycle: 
Closed cycle Ocean Thermal Energy Conversion systems use a working fluid with a low boiling point, Ammonia, for example, and use it to power a turbine to generate electricity. 
Warm seawater is taken in from the surface of the oceans and cold water from the deep at 5o. 
The warm seawater vaporises the fluid in the heat exchanger, turning the generator’s turbines. 
The fluid now in the vapour state is brought in contact with cold water, which turns it back into a liquid. 
The fluid is recycled in the system, which is why it is called a closed system.

Open Cycle:
Open cycle OTEC directly uses the warm water from the surface to make electricity. 
The warm seawater is first pumped into a low-pressure chamber, where it undergoes a drop in boiling point due to the pressure drop. 
This causes the water to boil. 
This steam drives a low-pressure turbine which is attached to an electrical generator. 
The advantage this system has over a closed system is that, in the open cycle, desalinated water is obtained in the form of steam. 
Since it is steam, it is free from all impurities. 
This water can be used for domestic, industrial, or agricultural purposes.
private void Find(string value)
{
  if (string.IsNullOrEmpty(value)) return;

  foreach (DataGridViewRow Row in Flex.Grid.Rows)
  {
    String strFila = Row.Index.ToString();
    foreach (DataGridViewCell cell in Row.Cells)
    {
      string Valor = Convert.ToString(cell.Value);

      if (Valor.ToLower().Trim().Contains(value.ToLower().Trim()))
      {
        Flex.Grid.CurrentCell = Flex.Grid.Rows[Convert.ToInt32(strFila)].Cells[0];
        Flex.Grid.Rows[Convert.ToInt32(strFila)].Selected = true;
        Flex.Grid.Select();
      }
    }
  }
}
List<DataRow> result = new List<DataRow>();

/*
	result = (from x in dt.AsEnumerable() where 
    (x.Field<string>("Code").ToLower().Contains(Value) || 
     x.Field<string>("Description").ToLower().Contains(Value)) && 
    (x.Field<bool>("Active") == true)
     select x).ToList();
*/

result = (from x in dt.AsEnumerable() where x.Field<bool>("Active") == true select x).ToList();

if (result.Count >= 1)
{
  dt = result.CopyToDataTable();
  Bridge.InPut.Code = dt.Rows[0]["Code"].ToString().Trim();
  Bridge.InPut.Description = dt.Rows[0]["Description"].ToString().Trim();
  return;
}
foreach (DataGridViewRow Row in resultadosdelaconsulta.Rows)
    {
        String strFila = Row.Index.ToString();
        foreach(DataGridViewCell cell in Row.Cells)
            {
              string Valor = Convert.ToString(cell.Value);
              if (Valor == this.BuscarEnDGB.Text)
                  {
resultadosdelaconsulta.Rows[Convert.ToInt32(strFila) ].DefaultCellStyle.BackColor = Color.Red;
            }
        }
        
    }
Certainly! I'll add comments to the provided C++ program to explain each section and function. Here are the commented sections:

```cpp
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

const int MAX_ENROLLMENTS = 5;

struct Course {
    string courseID;
    int enrolDate;
    int fine;
};

struct Student {
    string stName;
    string stID;
    string stContact;
    int enrollmentCount = 0;
    Course enrollCourse[MAX_ENROLLMENTS];
};

// Function prototypes
void displayMenu();
void addStudent(Student Detail[], int& stCount);
void displayDetails(Student Detail[], int stCount);
void enrollInCourse(Student Detail[], int studentCount);
void displayenrollments(Student Detail[], int stCount);
void displayfines(Student Detail[], int stCount);
void displayoptionstoload(Student Detail[], int& stCount);
void displayoptionstosave(Student Detail[], int stCount);
void addStudentfromfile(Student Detail[], int& stCount);
void enrollInCoursefromfile(Student Detail[], int studentCount);
void displayDetailsinFile(Student Detail[], int stCount);
void displayenrollmentsinFile(Student Detail[], int stCount);
void displayfinesinFile(Student Detail[], int stCount);
void instructions();

int main() {
    cout << "\t\t============Welcome to The Admin Portal============" << endl;

    int MAX_STUDENTS;
    int LastDate, LastMonth, LastYear;
    int choice;
    cout << "\nMaximum Students = ";
    cin >> MAX_STUDENTS;

    Student stDetail[MAX_STUDENTS];

    int studentCount = 0;

    do {
        displayMenu();
        cout << "Enter your choice: ";
        cin >> choice;
        if (cin) {
            if (choice == 1) {
                addStudent(stDetail, studentCount);
            } else if (choice == 2) {
                displayDetails(stDetail, studentCount);
            } else if (choice == 3) {
                enrollInCourse(stDetail, studentCount);
            } else if (choice == 4) {
                displayenrollments(stDetail, studentCount);
            } else if (choice == 5) {
                displayfines(stDetail, studentCount);
            } else if (choice == 6) {
                instructions();
            } else if (choice == 7) {
                displayoptionstoload(stDetail, studentCount);
            } else if (choice == 8) {
                displayoptionstosave(stDetail, studentCount);
            } else if (choice == 9) {
                cout << "\n\t\t\t========THANKS FOR USING PORTAL========" << endl;
            } else {
                cout << "Invalid Choice" << endl;
            }
        } else {
            cin.clear();
            cin.ignore();
            cout << "Invalid DataType" << endl;
        }

    } while (choice != 9);

    return 0;
}

// Display function
void displayMenu() {
    cout << "\n\t=============== Student Registration System Menu ===============\n\n";
    cout << left << setw(50) << "1 => Add new student" << left << setw(50) << "2 => Display all students" << endl;
    cout << left << setw(50) << "3 => Enroll in a course" << left << setw(50) << "4 => Display all enrollments" << endl;
    cout << left << setw(50) << "5 => Display all fines" << left << setw(50) << "6 => Instructions" << endl;
    cout << left << setw(50) << "7 => Load data from file" << left << setw(50) << "8 => Save data to file" << endl;
    cout << left << setw(50) << "9 => Exit" << endl;
}

// Function to add a new student
void addStudent(Student Detail[], int& stCount) {
    string name, id, contact;
    bool duplicate = false;
    cout << "\n\t\t=============== Register New Student ===============\n\n";
    cout << "Enter Student Name = ";
    cin.ignore();
    getline(cin, name);
    cout << "Enter Student ID = ";
    getline(cin, id);
    cout << "Enter Student Contact INFO = ";
    getline(cin, contact);

    // Check for duplicate student ID
    for (int i = 0; i < stCount; ++i) {
        if (Detail[i].stID == id) {
            cout << "THIS STUDENT IS ALREADY PRESENT IN DTATABASE!!!" << endl;
            duplicate = true;
            break;
        }
    }

    if (!duplicate) {
        Detail[stCount].stName = name;
        Detail[stCount].stID = id;
        Detail[stCount].stContact = contact;
        stCount++;
        cout << "New Student is Enrolled SUCCESSFULLY" << endl;
    }
}

// Function to display details of all registered students
void displayDetails(Student Detail[], int stCount) {
    cout << "\n\t\t=============== Already Registered Students ===============\n\n";
    if (stCount == 0) {
        cout << "No students registered yet.\n";
    } else {
        cout << left << setw(10) << "sr no." << setw(20) << "Student Name" << setw(20) << "Student ID" << setw(25) << "Student Contact" << endl;
        for (int i = 0; i < stCount; i++) {
            cout << left << setw(10) << i + 1 << setw(20) << Detail[i].stName << setw(20) << Detail[i].stID << setw(25) << Detail[i].stContact << endl;
        }
    }
}

// Function to enroll a student in a course
void enrollInCourse(Student Detail[], int studentCount) {
    string studentID;
    string courseID;

    cout << "Enter student ID: ";
    cin >> studentID;

    // Validate student ID
    int studentIndex = -1;
    for (int i = 0; i < studentCount; ++i) {
        if (Detail[i].stID == studentID) {
            studentIndex = i;
            break;
        }
    }

    if (studentIndex == -1) {
        cout << "Student not found. Please register the student first.\n";
        return;
    }

    if (Detail[studentIndex].enrollmentCount >= 5) {
        cout << "Maximum no. of courses Enrolled of that Student" << endl;
        return;
    }

    cout << "Enter course ID: ";
    cin >> courseID;
    int j = Detail[studentIndex].enrollmentCount;

    // Validate course ID
    int d, m, y;

    cout << "Enter Enrollment Date (DD MM YYYY): ";
    cin >> d >> m >> y;
    if ((d > 0 && d <= 31) && (m == 01 || m == 1) && (y == 2024)) {

        // Get current date and time

        Detail[studentIndex].enrollCourse[j].enrolDate = d;

        // Enroll the student in the course

        Detail[studentIndex].enroll

Course[j].courseID = courseID;

        cout << "Enrollment successful.\n";

        // Increment enrollment count
        Detail[studentIndex].enrollmentCount++;

        // Fine calculation
        if (d > 0 && d < 11) {
            Detail[studentIndex].enrollCourse[j].fine = 0;
        } else {
            int daysfine = d - 10;
            Detail[studentIndex].enrollCourse[j].fine = 500 * daysfine;
        }
    } else {
        cout << "Invalid Date" << endl;
    }
}

// Function to display all enrollments
void displayenrollments(Student Detail[], int stCount) {
    cout << "\n\t\t=============== Already Registered Courses ===============\n\n";
    if (stCount == 0) {
        cout << "No students registered yet.\n";
    } else {
        cout << left << setw(10) << "sr no." << setw(20) << "Student Name" << setw(20) << "Student ID" << setw(25) << "Student Courses" << setw(20) << "Enrollment Date" << endl;
        for (int i = 0; i < stCount; i++) {
            cout << left << setw(10) << i + 1 << setw(20) << Detail[i].stName << setw(20) << Detail[i].stID;
            if (Detail[i].enrollmentCount >= 1) {
                for (int j = 0; j < Detail[i].enrollmentCount; j++) {
                    if (j == 0) {
                        cout << setw(25) << Detail[i].enrollCourse[j].courseID << Detail[i].enrollCourse[j].enrolDate << "/01/2024" << endl;
                    } else {
                        cout << setw(50) << " " << setw(25) << Detail[i].enrollCourse[j].courseID << Detail[i].enrollCourse[j].enrolDate << "/01/2024" << endl;
                    }
                }
                cout << endl;
            } else {
                cout << setw(25) << "No Course Registered" << endl;
            }
        }
    }
}

// Function to display fines for each student
void displayfines(Student Detail[], int stCount) {
    cout << "\n\t\t=============== Student Fine List ===============\n\n";
    if (stCount == 0) {
        cout << "No students registered yet.\n";
    } else {
        cout << left << setw(10) << "sr no." << setw(20) << "Student Names" << setw(20) << "Student IDs" << setw(25) << "No. of Courses" << setw(20) << "Fines" << endl;
        for (int i = 0; i < stCount; i++) {
            int sum = 0;
            cout << left << setw(10) << i + 1 << setw(20) << Detail[i].stName << setw(20) << Detail[i].stID;
            if (Detail[i].enrollmentCount >= 1) {
                for (int j = 0; j < Detail[i].enrollmentCount; j++) {
                    sum += Detail[i].enrollCourse[j].fine;
                }
                cout << setw(25) << Detail[i].enrollmentCount << sum << endl;
            } else {
                cout << setw(25) << "No Course Registered" << endl;
            }
        }
    }
}

// Function to display options for saving data to a file
void displayoptionstosave(Student Detail[], int stCount) {
    cout << "\n\t=============== Student Registration System Menu ===============\n\n";
    cout << left << setw(50) << "1 => Display all students" << endl;
    cout << left << setw(50) << "2 => Display all enrollments" << endl;
    cout << left << setw(50) << "3 => Display all fines" << endl;
    cout << left << setw(50) << "4 => Exit" << endl;
    cout << "Enter your choice : ";
    char choice;
    cin >> choice;
    switch (choice) {
    case '1':
        displayDetailsinFile(Detail, stCount);
        break;
    case '2':
        displayenrollmentsinFile(Detail, stCount);
        break;
    case '3':
        displayfinesinFile(Detail, stCount);
        break;
    case '4':
        break;
    default:
        cout << "Invalid choice";
    }
}

// Function to display options for loading data from a file
void displayoptionstoload(Student Detail[], int& stCount) {
    cout << "\n\t=============== Student Registration System Menu ===============\n\n";
    cout << left << setw(50) << "1 => Load students Data from File" << endl;
    cout << left << setw(50) << "2 => Load enrollments Data from File" << endl;
    cout << left << setw(50) << "3 => Exit" << endl;
    cout << "Enter your choice : ";
    char choice;
    cin >> choice;
    switch (choice) {
    case '1':
        addStudentfromfile(Detail, stCount);
        break;
    case '2':
        enrollInCoursefromfile(Detail, stCount);
        break;
    case '3':
        break;
    default:
        cout << "Invalid choice";
    }
}

// Function to add students from a file
void addStudentfromfile(Student Detail[], int& stCount) {
    string name, id, contact;
    ifstream inFile;
    inFile.open("StudentData.txt");

    if (!inFile) {
        cout << "No previous data found.\n";
        return;
    }
    // Read data from the file
    while (inFile >> name >> id >> contact) {
        Detail[stCount].stName = name;
        Detail[stCount].stID = id;
        Detail[stCount].stContact = contact;
        stCount++;
    }

    cout << "New Students are Enrolled SUCCESSFULLY" << endl;
    inFile.close();
}

// Function to enroll students in courses from a file
void enrollInCoursefromfile(Student Detail[], int studentCount) {
    string studentID;
    string courseID;
    ifstream inFile;
    inFile.open("EnrollmentCourseData.txt");
    // Read data from the file
    while (inFile >> studentID) {

        // Validate student ID
        int studentIndex = -1;
        for (int i = 0; i < studentCount; ++i) {
            if (Detail[i].stID == studentID) {
                studentIndex = i;
                break;
            }
        }

        inFile >> courseID;
        int j = Detail[studentIndex].enrollmentCount;

        // Validate course ID
        int d, m, y;

        inFile >> d >> m >> y;
        if ((d > 0 && d <= 31) && (m == 01 || m == 1) && (y == 2024)) {

            // Get current date and time

            Detail[studentIndex].enrollCourse[j].enrolDate =

 d;

            // Enroll the student in the course

            Detail[studentIndex].enrollCourse[j].courseID = courseID;

            // Increment enrollment count
            Detail[studentIndex].enrollmentCount++;

            // Fine calculation
            if (d > 0 && d < 11) {
                Detail[studentIndex].enrollCourse[j].fine = 0;
            } else {
                int daysfine = d - 10;
                Detail[studentIndex].enrollCourse[j].fine = 500 * daysfine;
            }
        }
    }

    cout << "Enrollment successful.\n";
    inFile.close();
}

// Function to display enrollments in a file
void displayenrollmentsinFile(Student Detail[], int stCount) {
    ofstream outFile;
    outFile.open("DisplayEnrollments.txt");

    outFile << "\n\t\t=============== Already Registered Courses ===============\n\n";
    if (stCount == 0) {
        outFile << "No students registered yet.\n";
    } else {
        outFile << left << setw(10) << "sr no." << setw(20) << "Student Name" << setw(20) << "Student ID" << setw(25) << "Student Courses" << setw(20) << "Enrollment Date" << endl;
        for (int i = 0; i < stCount; i++) {
            outFile << left << setw(10) << i + 1 << setw(20) << Detail[i].stName << setw(20) << Detail[i].stID;
            if (Detail[i].enrollmentCount >= 1) {
                for (int j = 0; j < Detail[i].enrollmentCount; j++) {
                    if (j == 0) {
                        outFile << setw(25) << Detail[i].enrollCourse[j].courseID << Detail[i].enrollCourse[j].enrolDate << "/01/2024" << endl;
                    } else {
                        outFile << setw(50) << " " << setw(25) << Detail[i].enrollCourse[j].courseID << Detail[i].enrollCourse[j].enrolDate << "/01/2024" << endl;
                    }
                }
                outFile << endl;
            } else {
                outFile << setw(25) << "No Course Registered" << endl;
            }
        }
    }

    outFile.close();
}

// Function to display fines in a file
void displayfinesinFile(Student Detail[], int stCount) {
    ofstream outFile;
    outFile.open("DisplayFines.txt");

    outFile << "\n\t\t=============== Student Fine List ===============\n\n";
    if (stCount == 0) {
        outFile << "No students registered yet.\n";
    } else {
        outFile << left << setw(10) << "sr no." << setw(20) << "Student Names" << setw(20) << "Student IDs" << setw(25) << "No. of Courses" << setw(20) << "Fines" << endl;
        for (int i = 0; i < stCount; i++) {
            int sum = 0;
            outFile << left << setw(10) << i + 1 << setw(20) << Detail[i].stName << setw(20) << Detail[i].stID;
            if (Detail[i].enrollmentCount >= 1) {
                for (int j = 0; j < Detail[i].enrollmentCount; j++) {
                    sum += Detail[i].enrollCourse[j].fine;
                }
                outFile << setw(25) << Detail[i].enrollmentCount << sum << endl;
            } else {
                outFile << setw(25) << "No Course Registered" << endl;
            }
        }
    }
    outFile.close();
}

// Function to display student details in a file
void displayDetailsinFile(Student Detail[], int stCount) {
    ofstream outFile;
    outFile.open("DisplayStudentDetails.txt");

    outFile << "\n\t\t=============== Already Registered Students ===============\n\n";
    if (stCount == 0) {
        outFile << "No students registered yet.\n";
    } else {
        outFile << left << setw(10) << "sr no." << setw(20) << "Student Name" << setw(20) << "Student ID" << setw(25) << "Student Contact" << endl;
        for (int i = 0; i < stCount; i++) {
            outFile << left << setw(13) << i + 1 << setw(20) << Detail[i].stName << setw(25) << Detail[i].stID << setw(25) << Detail[i].stContact << endl;
        }
    }
    outFile.close();
}

// Function to display instructions and policy
void instructions() {
    cout << "\t==============Student Registration System - Instructions and Policy==============\n\n";
    cout << "HOW TO USE???\n\n1.  Adding a New Student:\n\t- Choose option 1 from the main menu.\n\t- Enter the student's name, ID, and contact information.\n\t- The system checks for duplicate IDs before enrolling a new student." << endl
         << endl;
    cout << "2. Displaying All Students:\n\t- Choose option 2 from the main menu.\n\t- View a list of all currently registered students with their names, IDs, and contact information." << endl
         << endl;
    cout << "3. Enrolling in a Course:\n\t- Choose option 3 from the main menu.\n\t- Enter the student ID.\n\t - Enter the course ID, enrollment date (DD MM YYYY), and validate the date.\n\t- The system checks for maximum course enrollments (up to 5) and calculates fines if applicable." << endl
         << endl;
    cout << "4. Displaying All Enrollments:\n\t- Choose option 4 from the main menu.\n\t- View a list of all enrolled courses for each student, along with enrollment dates." << endl
         << endl;
    cout << "5. Displaying All Fines:\n\t- Choose option 5 from the main menu.\n\t- View a list of fines for each student based on their course enrollments." << endl
         << endl;
    cout << "6. Loading and Saving Data:\n\t- Choose options 7 and 8 from the main menu to load from and save data to files, respectively.\n\t- For loading, you can load both student and enrollment data from separate text files." << endl
         << endl;
    cout << "7. Exiting the Program:\n\t- Choose option 9 to exit the program." << endl
         << endl;
    cout << "\nPOLICY\n\t- The program is designed for managing student registrations, enrollments, and fines.\n\t- Respect the maximum limit of 5 enrollments per student.\n\t- Follow the specified format for input data, especially for dates (DD MM YYYY).\n\t- Be cautious to avoid duplicate student IDs during registration.\n\t- Save and load data using the provided options to maintain records.\n\t- The program calculates fines for late enrollments based on a fixed rate." << endl
         << endl;
    cout<< "\nThank you for using the Student Registration System! If you have any questions or encounter issues, refer to the instructions or contact the administrator for assistance."<<endl<<endl;
 
}
Ocean thermal energy conversion is an electricity generation system.
Ocean Thermal Energy, also called Ocean Thermal Energy Conversion (OTEC), refers to using the temperature difference between the deep parts of the sea, which are cold and the shallow parts of the sea, which are cold, to run a heat engine and produce useful work.
The deeper parts of the ocean are cooler because the heat of sunlight cannot penetrate very deep into the water.
Here the efficiency of the system depends on the temperature difference.
Greater the temperature difference, the greater the efficiency.
The temperature difference in the oceans between the deep and shallow parts is maximum in the tropics, 20o C to 25o C.
Tropics receive a lot of sunlight which warms the surface of the oceans, increasing the temperature gradient.
The energy source of OTEC is abundantly available, free, and will be so for as long as the sun shines and ocean currents exist. 
Intermittency and Variability:
Solar power generation depends on sunlight, and its availability varies with weather conditions and time of day. Cloudy days and nighttime result in reduced or no electricity production.
High Initial Costs: 
The upfront costs of purchasing and installing solar panels can be relatively high.
Land Use and Aesthetics:
Large-scale solar farms may require significant land areas, potentially leading to conflicts over land use. Additionally, some people find solar panels visually unappealing, particularly on residential properties.
Limited Energy Density: 
Solar panels have a lower energy density compared to some other forms of energy generation.
Potential for Pollution: 
While solar power generation itself is clean, the production and disposal of solar panels can lead to environmental issues if not managed properly. 
Impact on Wildlife: 
Large solar installations can disrupt local ecosystems and wildlife habitats.
const express = require('express')
const router = express.Router()

// middleware that is specific to this router
router.use((req, res, next) => {
  console.log('Time: ', Date.now())
  next()
})
// define the home page route
router.get('/', (req, res) => {
  res.send('Birds home page')
})
// define the about route
router.get('/about', (req, res) => {
  res.send('About birds')
})

module.exports = router

// Importing this file for routes
const birds = require('./birds')

// ...

app.use('/birds', birds)
export async function getServerSideProps() {
  // Fetch data from external API
  const res = await fetch(`https://.../data`)
  const data = await res.json()
 
  // Pass data to the page via props
  return { props: { data } }
}
SELECT EmailAddress, SubscriberKey, i.LastModifiedDate
 
FROM (
SELECT
DISTINCT LOWER(r.EmailAddress), c.Id AS SubscriberKey, i.LastModifiedDate,
 
ROW_NUMBER() OVER(PARTITION BY c.ID ORDER BY i.LastModifiedDate DESC) as RowNum
 
FROM ent.Interaction__c_Salesforce i
JOIN ent.Contact_Salesforce_1 c ON LOWER(c.Email) = LOWER(i.Email__c)
LEFT JOIN [7011G000000OJtMQAW_CI_MR_SIS2GO_rawdata] r ON LOWER(r.EmailAddress) = LOWER(i.Email__c)
LEFT JOIN [7011G000000OJtMQAW_CI_MR_SIS2GO_sendable] s ON LOWER(s.EmailAddress) = LOWER(r.EmailAddress)

WHERE
    Email__c IS NOT NULL
    AND r.EmailAddress IS NOT NULL
    AND s.SubscriberKey IS NULL
   
        ) t2
 
WHERE RowNum = 1
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">

  <metadata>

    <id>Cashapp-hack-unlimited-money-adder-hack-software</id>

    <version>1.0.0</version>

    <title>Cash app hack unlimited money $$ cash app money adder hack software</title>

    <authors>Alex</authors>

    <owners></owners>

    <requireLicenseAcceptance>false</requireLicenseAcceptance>

    <description>Cash app hack unlimited money $$ cash app money adder hack software:

VISIT HERE TO HACK >>>>> https://gamedips.xyz/cashapp-new

Cash App free money is one of the very searched terms in Google and users are looking to locate techniques for getting free profit their Cash App balance with limited additional effort.Observe that there are numerous different survey and rewards sites that you can participate and get paid in Cash App balance using a number of methods. These easy ways can put balance in your account with a few work.Ways to get free money on Cash App, you can find survey and opinion rewards sites that will help you out. You can get free Cash App money sent to your Cash App wallet if you're using the Cash App payment option. Redeem your points for Cash App.Alternatively, you can even receive a telephone call from someone who claimed to be a Cash App representative. They then sent a text with an url to update your Cash App password. After you enter your real password on the form, the hackers gained full use of your Cash App account.

Cash App Hack,cash app hack apk ios,cash app hacked,cash app hack apk,cash app hack 2021,cash app hacks 2020,cash app hack no human verification,cash app hacks that really work,cash app hack wrc madison,cash app hack apk download,cash app hack august 2020,cash app hack april 2020,cash app hack activation code,cash app hack apk 2021,cash app hack april 2021,cash app bitcoin hack,cash app boost hack,big cash app hack,big cash app hack version,big cash app hack mod apk download,big cash app hack 2020,big cash app hack 2019,free bitcoin cash app hack</description>

  </metadata>

</package>
 <iframe width="100%" height="600px" src="https://your-fusion-360-model-url" frameborder="0" allowfullscreen>
 </iframe>

 <!--Replace "https://your-fusion-360-model-url" with the actual URL provided by Fusion 360-->
@import url('https://fonts.googleapis.com/css2?family=Martel+Sans:wght@600&display=swap');

* {
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
}
body{
    background-color: black;
}

.main {
    background-image: url("assets/images/bg.jpg");
    height: 100vh;
    background-position: center center;
    background-size: max(1200px, 100vw);
    background-repeat: no-repeat;
    position: relative;
}

.main .box {
    height: 100vh;
    width: 100%;
    opacity: 0.69;
    position: absolute;
    top: 0;
    background-color: black;
}

nav {
    max-width: 60vw;
    margin: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

nav img {
    color: red;
    width: 130px;
    position: relative;
    z-index: 20;
}

nav button {
    position: relative;
    z-index: 10;
}

.hero {
    font-family: 'Martel Sans', sans-serif;
    height: calc(100% - 62px);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: white;
    position: relative;
    gap:23px;
    padding:0 30px;
}
.hero> :nth-child(1){
    text-align: center;
    font-weight:900;
    font-size:48px;
}
.hero>:nth-child(2){
    text-align: center;
    font-weight:400;
    font-size:24px;
}
.hero>:nth-child(3){
    text-align: center;
    font-weight:400;
    font-size:20px;

}
.separation{
    background-color: rgb(59, 58, 58);
    height:7px;

}
.btn{
    padding:3px 8px;
    font-weight:400;
    color:white;
    background-color:rgb(42, 41, 41);
    border-radius:4px;
    border:1px solid white;
    cursor: pointer;
}
.btn-red{
    background-color: red;
    color:white;
    padding:3px 24px;
    font-size:20px;
    border-radius:4px;
}
.main input{
    padding:7px 101px 8px 14px;
    color:white;
    font-size:12px;
    font-weight:900;
    border-radius:4px;
    background-color:rgba(23,23,23,0.7);
    border:1px solid rgba(130, 127, 127, 0.5);
}
.btn-red-sm{
    background-color: red;
    color:white;
}
.hero-buttons{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:16px;
}
.first{
    display:flex;
    justify-content:center;
    max-width:70vw;
    margin:auto;
    color:white;
    align-items:center;
}
@media screen and (max-width:1300px) {
    nav{
        max-width: 90vw;;
    }
    .first{
        flex-wrap:wrap;
    }
    .secImg img{
        width:305px;
        
    }
    .secImg video{
        
        width: 305px;
        
    }
    .hero> :nth-child(1){
        font-size:32px;

    }
    .hero> :nth-child(2){
        font-size:18px;
    }
    .hero> :nth-child(3){
        font-size: 18px;;
    }
    .hero-buttons{
        display:flex;
        flex-direction:column;
        align-items:center;
        justify-content:center;
        gap:16px;
    }
    .faq h2{
        text-align:center;
        font-size:32px;

   }
   footer{
    min-width: 90vw;
   }
    
}
@media screen and (max-width:1300px) {
    .footer{
        display:grid;
        grid-template-columns:1fr 1fr;
        gap:25px;
    }
    
}
.secImg{
    position:relative;
}
.secImg img{
    width:555px;
    position:relative;
    z-index:10;
}
.secImg video{
    position:absolute;
    top:51px;
    right:0;
    width: 555px;
    
}
section.first > div{
    display:flex;
    flex-direction:column;
    padding:34px 0;
}
section.first > div :nth-child(1){
    font-size:48px;
    font-weight:bolder;

}
section.first > div :nth-child(2){
    font-size:20px;
    align-items: start;
    left:0;
    
}
.faq{
    background:black;
    color:white;
    padding:34px;
    
}
.faq h2{
    text-align:center;
    font-size: 48px;
}
.faqbox:hover{
    color: white;
    background-color: #414141;
}
.faqbox{
    display: flex;
    transition:all 1s ease-out;
    background-color: rgb(37, 35, 35);
    padding:24px;
    max-width: 60vw;
    margin:34px auto;
    justify-content:space-between;
    cursor:pointer;
    font-size:24px;
}
.faqbox svg{
    filter:invert(1);
}
.hero1{
    font-family: 'Martel Sans', sans-serif;
    height: calc(100% - 62px);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: white;
    position: relative;
    gap:23px;
    padding:0 30px;
}
footer{
    color:white;
    max-width:60vw;
    margin:auto;
    padding:23px;
}
.footer a{
    font-size:14px;
    color:white;
}
.question{
    padding:23px 0;
}
.footer{
    display:grid;
    grid-template-columns:1fr 1fr 1fr 1fr;
    color:white;
    max-width:60vw;
    margin: auto;
}
.footer-item{
    display:grid;
    flex-direction:column;
    gap:23px;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Netflix India – Watch TV Shows Online, Watch Movies Online</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <div class="main">
        <nav>
            <span><img width="53" src="assets/images/logo.svg" alt=""> </span>
            <div>
                <button class="btn">English</button>
                <button class=" btn btn-red-sm">Sign In</button>
            </div>

        </nav>
        <div class="box">

        </div>
        <div class="hero">
            <span>Unlimited movies, TV shows and more</span>
            <span>Watch anywhere. Cancel anytime.</span>
            <span>Ready to watch? Enter your email to create or restart your membership.</span>
            <div class="hero-buttons">
                <input type="text" placeholder="Email Address">
                <button class=" btn btn-red">Get Started &gt;</button>
            </div>
        </div>
        <div class="separation"></div>
    </div>

    <section class="first">
        <div>
            <span>Enjoy on your TV</span>
            <span>Watch on smart TVs, PlayStation, Xbox, Chromecast, Apple TV, Blu-ray players and more.</span>
        </div>

        <div class="secImg">
            <img src="https://assets.nflxext.com/ffe/siteui/acquisition/ourStory/fuji/desktop/tv.png" alt="">
            <video src="https://assets.nflxext.com/ffe/siteui/acquisition/ourStory/fuji/desktop/video-tv-in-0819.m4v"
                autoplay loop muted></video>
        </div>

    </section>
    <div class="separation"></div>
    <section class="first second">
        <div class="secImg">
            <img src="https://assets.nflxext.com/ffe/siteui/acquisition/ourStory/fuji/desktop/mobile-0819.jpg" alt="">

        </div>
        <div>
            <span>Download your shows to watch offline</span>
            <span>Save your favourites easily and always have something to watch.</span>
        </div>
    </section>
    <div class="separation"></div>
    <section class="first third">
        <div>
            <span>Watch everywhere</span>
            <span>Stream unlimited movies and TV shows on your phone, tablet, laptop, and TV.</span>
        </div>

        <div class="secImg">
            <img src="https://assets.nflxext.com/ffe/siteui/acquisition/ourStory/fuji/desktop/device-pile-in.png"
                alt="">
            <video src="https://assets.nflxext.com/ffe/siteui/acquisition/ourStory/fuji/desktop/video-devices-in.m4v"
                autoplay loop muted></video>
        </div>

    </section>
    <div class="separation"></div>
    <section class="first second">
        <div class="secImg">
            <img src="https://occ-0-4409-3646.1.nflxso.net/dnm/api/v6/19OhWN2dO19C9txTON9tvTFtefw/AAAABVr8nYuAg0xDpXDv0VI9HUoH7r2aGp4TKRCsKNQrMwxzTtr-NlwOHeS8bCI2oeZddmu3nMYr3j9MjYhHyjBASb1FaOGYZNYvPBCL.png?r=54d"
                alt="">

        </div>
        <div>
            <span>Create profiles for kids</span>
            <span>Send children on adventures with their favourite characters in a space made just for them—free with
                your membership.</span>
        </div>
    </section>
    <div class="separation"></div>

    <section class="faq">
        <h2> Frequently Asked Questions</h2>
        <div class="faqbox">
            <span>What Is Netflix?</span>
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M12 4V20M20 12H4" stroke="#141B34" stroke-width="1.5" stroke-linecap="round"
                    stroke-linejoin="round" />
            </svg>

        </div>

        <div class="faqbox">
            <span>How much does Netflix cost?</span>
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M12 4V20M20 12H4" stroke="#141B34" stroke-width="1.5" stroke-linecap="round"
                    stroke-linejoin="round" />
            </svg>

        </div>

        <div class="faqbox">
            <span>What can i watch on Netflix?</span>
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M12 4V20M20 12H4" stroke="#141B34" stroke-width="1.5" stroke-linecap="round"
                    stroke-linejoin="round" />
            </svg>

        </div>

        <div class="faqbox">
            <span>Where can i watch?</span>
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M12 4V20M20 12H4" stroke="#141B34" stroke-width="1.5" stroke-linecap="round"
                    stroke-linejoin="round" />
            </svg>

        </div>

        <div class="faqbox">
            <span>How do i cancel?</span>
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M12 4V20M20 12H4" stroke="#141B34" stroke-width="1.5" stroke-linecap="round"
                    stroke-linejoin="round" />
            </svg>

        </div>

        <div class="faqbox">
            <span>Is Netflix good for kids?</span>
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M12 4V20M20 12H4" stroke="#141B34" stroke-width="1.5" stroke-linecap="round"
                    stroke-linejoin="round" />
            </svg>

        </div>


    </section>
    <div class="hero">
        <span>Ready to watch? Enter your email to create or restart your membership.</span>
        <div class="hero-buttons">
            <input type="text" placeholder="Email Address">
            <button class=" btn btn-red">Get Started &gt;</button>
        </div>
    </div>

    </div>
    <div class="separation"></div>

    <footer>
        <div class="question">Questions? Call 000-800-919-1694</div>
        <div class="footer">
            <div class="footer-item">

                <a href="faq">FAQ</a>
                <a href="faq">Invester Relations</a>
                <a href="faq">Privacy</a>
                <a href="faq">Speed Test</a>
                 

            </div>
            <div class="footer-item">
                <a href="faq">Help Center</a>
                <a href="faq">Jobs</a>
                <a href="faq">Cookies Preferences</a>
                <a href="faq">Legal Notices</a>
                

            </div>
            <div class="footer-item">
                <a href="faq">Account</a>
                <a href="faq">Way to Watch</a>
                <a href="faq">Corporate Information</a>
                <a href="faq">Only on Netflix</a>
                

            </div>
            <div class="footer-item">
                <a href="faq">Media center</a>
                <a href="faq">Terms Of Use</a>
                <a href="faq">Contact Us</a>
                
                

            </div>
        </div>
    </footer>

</body>

</html>
import { useRouter } from 'next/router';
import React from 'react';

const slug = () => {
    const router = useRouter()
    const blogSlug = router.query.slug;
    console.log(router);
  return (
    <>
      <h1 className="text-4xl">{ blogSlug } Blogpost</h1>
    </>
  );
}

export default slug;
const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})
<script src="https://fareharbor.com/embeds/api/v1/?autolightframe=yes"></script>
<a href="https://fareharbor.com/embeds/book/lisbonaffair/?full-items=yes" class="fh-fixed--bottom fh-icon--calendar-check fh-button-true-flat-red fh-shape--square">BOOK NOW</a>
 <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
        <script>
        $(document).ready(function () {
            // Define the mapping of URLs to corresponding href values
            var urlMapping = {
                "/all-experiences/p/portuguese-bread-making-class": "https://fareharbor.com/embeds/book/lisbonaffair/items/512744/?full-items=yes&flow=1095022",
                "/all-experiences/p/pastel-de-nata-pastry-class": "https://fareharbor.com/embeds/book/lisbonaffair/items/512738/?full-items=yes&flow=1095022",
                "/all-experiences/p/portuguese-cooking-class": "https://fareharbor.com/embeds/book/lisbonaffair/items/512737/?full-items=yes&flow=1095022",
                "/all-experiences/p/petiscos-cooking-class": "https://fareharbor.com/embeds/book/lisbonaffair/items/512395/?full-items=yes&flow=1095022",
                "/all-experiences/p/gift-card": "https://fareharbor.com/embeds/book/lisbonaffair/items/512373/?full-items=yes&flow=1093254",
                "/all-experiences/p/portuguese-wine-tasting": "https://fareharbor.com/embeds/book/lisbonaffair/items/512745/?full-items=yes&flow=1095023",
                "/all-experiences/p/port-wines-tasting": "https://fareharbor.com/embeds/book/lisbonaffair/items/512774/?full-items=yes&flow=1095023",
                "/all-experiences/p/portuguese-olive-oil-tasting": "https://fareharbor.com/embeds/book/lisbonaffair/items/512765/?full-items=yes&flow=1095023",
                "/all-experiences/p/portuguese-cheeses-tasting": "https://fareharbor.com/embeds/book/lisbonaffair/items/512766/?full-items=yes&flow=1095023",
                "/all-experiences/p/portuguese-honey-tasting": "https://fareharbor.com/embeds/book/lisbonaffair/items/512768/?full-items=yes&flow=1095023",
                "/all-experiences/p/ceramics-workshop": "https://fareharbor.com/embeds/book/lisbonaffair/items/512807/?full-items=yes&flow=1095025",
                "/all-experiences/p/brunch-with-a-private-workshop": "https://fareharbor.com/embeds/book/lisbonaffair/items/513047/?full-items=yes&flow=1095026",
                "/all-experiences/p/macrame-workshop": "https://fareharbor.com/embeds/book/lisbonaffair/items/512810/?full-items=yes&flow=1095025",
                "/all-experiences/p/tile-painting-workshop": "https://fareharbor.com/embeds/book/lisbonaffair/items/512806/?full-items=yes&flow=1095025",
                "/all-experiences/p/knitting-crochet-workshop": "https://fareharbor.com/embeds/book/lisbonaffair/items/512814/?full-items=yes&flow=1095025",
                "/all-experiences/p/lisbon-luxury-shopping-tour": "https://fareharbor.com/embeds/book/lisbonaffair/items/512802/?full-items=yes&flow=1095024",
                "/all-experiences/p/authentic-lisbon-food-tour": "https://fareharbor.com/embeds/book/lisbonaffair/?full-items=yes&flow=1096149",
                "/all-experiences/p/lisbon-gourmet-tour": "https://fareharbor.com/embeds/book/lisbonaffair/?full-items=yes&flow=1096155",
                "/all-experiences/p/brunch-private-groups": "https://fareharbor.com/embeds/book/lisbonaffair/items/513044/?full-items=yes&flow=1095026",
                "/all-experiences/p/bespoke-private-picnic": "https://fareharbor.com/embeds/book/lisbonaffair/items/512818/?full-items=yes&flow=1095026",
            };

            // Get the current URL path
            var currentPath = window.location.pathname;

            // Check if the current path is in the mapping
            if (urlMapping.hasOwnProperty(currentPath)) {
                // Replace .sqs-add-to-cart-button-wrapper with custom button
                $(".sqs-add-to-cart-button-wrapper").replaceWith(
                    '<a href="' + urlMapping[currentPath] + '" class="fh-button-true-flat-red fh-shape--square">BOOK NOW</a>'
                );

                // Hide .product-variants and .product-quantity-input
                $(".product-variants, .product-quantity-input").hide();
            }
        });
    </script>
function serviceBox_loop()
{
    $arg = array(
        'post_type' => 'service',
        'posts_per_page' => -1,
    );
    $servicePost = new WP_Query($arg);
    ?>
        <div class="singl-servce-sec">
<div class="row">
    <?php if ($servicePost->have_posts()): ?>

    <?php while ($servicePost->have_posts()):
     $servicePost->the_post(); 
     $url = wp_get_attachment_url(get_post_thumbnail_id($servicePost->ID))
     ?>
    <div class="col-md-6">
        <div class="serv-thumb">
            <img src="<?php echo $url ?>" alt="" class="img-thumb">
            <div class="services-content">
                <h2><?php the_title(); ?></h2>
                <div class="par1" ><?php the_content(); ?></div>
                <a href="<?php echo the_permalink(); ?>"><?php echo get_field('btntxt2') ?><img src="<?php echo get_template_directory_uri(); ?>/img/detailarro.png" alt=""></a>
            </div>
        </div>
    </div>
  
                    
    <?php endwhile; ?>
    <?php endif; ?>
</div>
</div>
    <?php wp_reset_postdata();
}
add_shortcode('serviceWithbox', 'serviceBox_loop');
function create_slider()
{

	$labels = array(
		'name' => _x('Slider', 'Post Type General Name', 'textdomain'),
		'singular_name' => _x('Slider', 'Post Type Singular Name', 'textdomain'),
		'menu_name' => _x('Slider', 'Admin Menu text', 'textdomain'),
		'name_admin_bar' => _x('Slider', 'Add New on Toolbar', 'textdomain'),
		'archives' => __('Slider Archives', 'textdomain'),
		'attributes' => __('Slider Attributes', 'textdomain'),
		'parent_item_colon' => __('Parent Slider:', 'textdomain'),
		'all_items' => __('All Slider', 'textdomain'),
		'add_new_item' => __('Add New Slider', 'textdomain'),
		'add_new' => __('Add New', 'textdomain'),
		'new_item' => __('New Slider', 'textdomain'),
		'edit_item' => __('Edit Slider', 'textdomain'),
		'update_item' => __('Update Slider', 'textdomain'),
		'view_item' => __('View Slider', 'textdomain'),
		'view_items' => __('View Slider', 'textdomain'),
		'search_items' => __('Search Slider', 'textdomain'),
		'not_found' => __('Not found', 'textdomain'),
		'not_found_in_trash' => __('Not found in Trash', 'textdomain'),
		'featured_image' => __('Featured Image', 'textdomain'),
		'set_featured_image' => __('Set featured image', 'textdomain'),
		'remove_featured_image' => __('Remove featured image', 'textdomain'),
		'use_featured_image' => __('Use as featured image', 'textdomain'),
		'insert_into_item' => __('Insert into Slider', 'textdomain'),
		'uploaded_to_this_item' => __('Uploaded to this Slider', 'textdomain'),
		'items_list' => __('Slider list', 'textdomain'),
		'items_list_navigation' => __('Slider list navigation', 'textdomain'),
		'filter_items_list' => __('Filter Slider list', 'textdomain'),
	);
	$rewrite = array(
		'slug' => 'slider',
		'with_front' => true,
		'pages' => true,
		'feeds' => true,
	);
	$args = array(
		'label' => __('Slider', 'textdomain'),
		'description' => __('', 'textdomain'),
		'labels' => $labels,
		'menu_icon' => 'dashicons-admin-appearance',
		'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'page-attributes', 'post-formats', 'custom-fields'),
		'taxonomies' => array(),
		'public' => true,
		'show_ui' => true,
		'show_in_menu' => true,
		'menu_position' => 5,
		'show_in_admin_bar' => true,
		'show_in_nav_menus' => true,
		'can_export' => true,
		'has_archive' => true,
		'hierarchical' => true,
		'exclude_from_search' => true,
		'show_in_rest' => true,
		'publicly_queryable' => true,
		'capability_type' => 'post',
		'rewrite' => $rewrite,
	);
	register_post_type('slider', $args);
	register_taxonomy('slider_category', 'slider', array('hierarchical' => true, 'label' => 'Category', 'query_var' => true, 'rewrite' => array('slug' => 'slider-category')));
}
add_action('init', 'create_slider', 0);




function slider_loop()
{
	
	
	$arg = array(
		'post_type' => 'slider',
		'posts_per_page' => -1,
		);
        $sliderPost = new WP_Query($arg);
	?>
	<div id="mainSlider" class="main-slider">
	<?php if ($sliderPost->have_posts()) : ?>
			<?php while ($sliderPost->have_posts()) : ?>
			<?php $sliderPost->the_post(); 
			$url = wp_get_attachment_url(get_post_thumbnail_id($sliderPost->ID)); 
			?>
			<div class="singleBanner" style="background:url('<?php echo $url ?>');">
			    <div class="container">
			         <div class="banner-content">
                         <h1><?php the_field('banner-heading');?></h1>
                          <p><?php the_field('banner-para');?></p>
                      <div class="banner-btn">
                          <a href="<?php the_field('banner-btn-link');?>" class="ban-btn1"><?php the_field('banner-btn');?><span><img src="https://stageportfoilo.com/wp/voyager/wp-content/uploads/2023/10/right-arrow-1-copy-5.png"></span></a>
                        <a href="<?php the_field('banner-btn-link2');?>" class="ban-btn2" ><?php the_field('banner-btn-txt2');?><span><img src="https://stageportfoilo.com/wp/voyager/wp-content/uploads/2023/10/right-arrow-1-copy-5.png"></span></a>
                         </div>
                   </div>
			    </div>
			</div>
			<?php endwhile; ?>
            <?php endif; ?>
</div>
<?php
	wp_reset_postdata();

}
add_shortcode('mainBanner', 'slider_loop');

function slick_cdn_enqueue_scripts()
{
	wp_enqueue_style('slick-style', '//cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css');
	wp_enqueue_script('slick-script', '//cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js', array(), null, true);
}
add_action('wp_enqueue_scripts', 'slick_cdn_enqueue_scripts');
function serviceWithTabs()
{
    $arg = array('post_type' => 'service', 'posts_per_page' => -1, );
    $servicesPost = new WP_Query($arg);
    ?>

    <div class="icons-tabs">
        <ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
            <?php $counter = 0;
            while ($servicesPost->have_posts()):
                $counter++;
               ?>
                <?php $servicesPost->the_post();
                $url = wp_get_attachment_url(get_post_thumbnail_id($servicesPost->ID)); ?>
                <li class="nav-item" role="presentation">
                 <button class="nav-link <?php echo $counter === 1 ? 'active' : ''; ?>" id="pills-home-tab<?php echo $counter ?>"
                        data-bs-toggle="pill" data-bs-target="#pills-home<?php echo $counter ?>" type="button" role="tab"
                        aria-controls="pills-home" aria-selected="<?php echo $counter === 1 ? 'true' : 'false'; ?>">
                        <div class="icon-boxes">
                            <div class="icon-img">
                                <img src="<?php echo get_field('service_icon') ?>" alt="">
                            </div>
                            <h4>
                                <?php the_title(); ?>
                            </h4>
                        </div>
                    </button>
                </li>

            <?php endwhile; ?>
        </ul>
    </div>
    <div class="tab-content" id="pills-tabContent">
        <?php
        $counter = 0;
        while ($servicesPost->have_posts()):
            $counter++;
            ?>
            <?php $servicesPost->the_post();
            $url = wp_get_attachment_url(get_post_thumbnail_id($servicesPost->ID)); ?>
          <div class="tab-pane <?php echo $counter === 1 ? 'active' : ''; ?>" id="pills-home<?php echo $counter ?>"
                role="tabpanel" aria-labelledby="pills-home-tab<?php echo $counter ?>">
                <div class="man-power">
                    <div class="row">
                        <div class="col-md-7">
                            <div class="power-cont">
                                <h2>
                                <?php echo get_field('service_tab_tittle') ?>
                                </h2>
                                <div>
                                <?php echo get_field('service_tab_content') ?>
                            </div>
                                <div class="engine-list">
                                    <ul>
                                        <li><?php echo get_field('points_1') ?></li>
                                        <li><?php echo get_field('points_1') ?></li>
                                    </ul>
                                    <ul>
                                      <li><?php echo get_field('points_1') ?></li>
                                      <li><?php echo get_field('points_1') ?></li>
                                    </ul>
                                    <ul>
                                      <li><?php echo get_field('points_1') ?></li>
                                      <li><?php echo get_field('points_1') ?></li>
                                    </ul>
                                </div>
                                <a href="<?php the_permalink(); ?>" class="btn ban-btn"><?php echo get_field('btntxt') ?><img
                                        src="<?php echo get_template_directory_uri(); ?>/img/right-arrows.png" alt=""></a>
                            </div>
                        </div>
                        <div class="col-md-5">
                            <div class="manpowerimg">
                                <img src="<?php echo get_field('service_tab_image') ?>" alt="tabsimage">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <?php endwhile; ?>
    </div>



    <?php
    wp_reset_postdata();
}
add_shortcode('services-WithTabs', 'serviceWithTabs'); 
function posta_loop()
{
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $arg = array(
        'post_type'      => 'post',
        'posts_per_page' => 3, 
        'paged'          => $paged
    );
    $blogPost = new WP_Query($arg);
    ?>
    <div id="mainBlog" class="blog-left">
        <?php if ($blogPost->have_posts()) : ?>
            <?php while ($blogPost->have_posts()) : ?>
                <?php $blogPost->the_post();
                $content = get_the_content();
                ?>
                  <div class="blog-boxs">
                           <img src="<?php the_post_thumbnail_url('full'); ?>" alt="" width="100%" class="blog-single-imag">
                            <div class="blogs-cont">
                                <div class="blog-wraper">
                                        <?php
                                             $tags = get_the_tags();
                                               if ($tags) {
                                                echo '<div class="blg-tags-inn">';
                                                foreach ($tags as $tag) {
                                               echo '<a class="blog-strat"  href="' . esc_url(get_tag_link($tag->term_id)) . '">' . esc_html($tag->name) . '</a>';
                                               }
                                              echo '</div>';
                                              }
                                            ?>
                                    <div class="blogs-client">
                                        <img src="https://stagingwebistes.com/wp/iconcpl/wp-content/uploads/2023/12/user-1.png" alt="">
                                     <h6><?php echo get_the_author(); ?></h6>
                                    </div>
                                    <div class="blogs-client">
                                        <img src="https://stagingwebistes.com/wp/iconcpl/wp-content/uploads/2023/12/calendar.png" alt="">
                                      <h6><?php the_time('j F, Y'); ?></h6>
                                    </div>
                                 </div>
                                <h2><?php the_title(); ?>
                                    </h2>
                                <a href="<?php the_permalink(); ?>" class="blog-btn">Read More</a>
                            </div>
                        </div>
     <?php endwhile; ?>
            <?php
            $big = 99;
            echo '<div class="pagination">';
            echo paginate_links(
                array(
                    'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
                    'format' => '?paged=%#%',
                    'current' => max(1, get_query_var('paged')),
                    'total' => $blogPost->max_num_pages,
                    'show_all' => false,
                    'prev_next' => false,
                    'before_page_number' => '0',
                    'prev_text' => __('Previous'),
                    'next_text' => __('Next'),
                    'type' => 'list',
                    'mid_size' => 2
                )
            );
            $next_link = get_next_posts_link('Next Page', $blogPost->max_num_pages);
            if ($next_link) {
                echo '<button>' . $next_link . '</button>';
            }
            echo '</div>';
            ?>
        <?php endif; ?>
    </div>
    <?php
    wp_reset_postdata();
}
add_shortcode('allBlogsss', 'posta_loop');
?>

function dynamic_categories_shortcode() {
    ob_start();

    $categories = get_categories(array(
        'taxonomy'   => 'category',
        'object_type' => array('post', 'blogPost'),
    ));

    if ($categories) {
        echo '<div class="categories-box">';
        echo '<h4>Categories</h4>';
        echo '<ul>';
        foreach ($categories as $category) {
            echo '<li><a href="' . esc_url(get_category_link($category->term_id)) . '">' . esc_html($category->name) . '</a></li>';
        }
        echo '</ul>';
        echo '</div>';
    }

    $output = ob_get_clean();
    return $output;
}
add_shortcode('dynamicCategories', 'dynamic_categories_shortcode');


function dynamic_tags_shortcode() {
    ob_start();

    $tags = get_tags(array(
        'taxonomy'   => 'post_tag',
        'object_type' => array('post', 'blogPost'),
    ));

    if ($tags) {
        echo '<div class="tag-boxs">';
        echo '<h4>Tags</h4>';
        echo '<div class="inner-tags">';
        echo '<ul>';
        foreach ($tags as $tag) {
            echo '<li><a href="' . esc_url(get_tag_link($tag->term_id)) . '">' . esc_html($tag->name) . '</a></li>';
        }
        echo '</ul>';
        echo '</div>';
        echo '</div>';
    }

    $output = ob_get_clean();
    return $output;
}
add_shortcode('dynamicTags', 'dynamic_tags_shortcode');







  <div class="latest-post">
                    <div class="post-blog-wrapper">
                        <?php
                        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                        $args = array(
                            'post_type' => 'post',
                            'posts_per_page' => 3,
                            'paged' => $paged
                        );
                        $blogPosts = new WP_Query($args);

                        if ($blogPosts->have_posts()):
                            while ($blogPosts->have_posts()):
                                $blogPosts->the_post();
                                ?>
                                <div class="post-box">
                                    <img src="<?php the_post_thumbnail_url('full'); ?>" alt="" width="100%"
                                        class="blog-small-image">
                                    <div class="post-cont">
                                        <a href="<?php echo esc_url(get_category_link(get_the_category()[0]->term_id)); ?>"
                                            class="postbtn">
                                            <?php echo esc_html(get_the_category()[0]->name); ?>
                                        </a>
                                        <a href="<?php the_permalink(); ?>" >
                                            <?php the_title(); ?>
                                        </a>
                                        <p>
                                            <?php the_time('j F, Y'); ?>
                                        </p>
                                        <hr>
                                    </div>
                                </div>
                                <?php
                            endwhile;
                        else:
                            echo '<p>No posts found</p>';
                        endif;

                        wp_reset_postdata();
                        ?>
                    </div>
                </div>





function blog_loop()
{
    $arg = array(
        'post_type' => 'post',
        'posts_per_page' => 3,
    );
    $blogPost = new WP_Query($arg);

    ?>
    <div class="card-sec">
        <div class="row">
            <?php if ($blogPost->have_posts()): ?>
                <?php while ($blogPost->have_posts()): ?>
                    <?php $blogPost->the_post();
                    $url = wp_get_attachment_url(get_post_thumbnail_id($blogPost->ID)); ?>
                    <div class="col-md-4">
                        <div class="card">
                            <div class="card-img">
                                <img src="<?php echo $url ?>" alt="">
                                <div class="card-blog-date">
                                    <h6>
                                        <?php the_time('j F, Y'); ?>
                                    </h6>
                                </div>
                            </div>
                            <div class="card-content">
                                <div class="card-subtittle">
                                    <?php the_excerpt(); ?>
                                </div>
                                <h2>
                                    <?php the_title(); ?>
                                </h2>
                                <?php $content = get_the_content();
                                ?>
                                <div class="post-content">
                                    <p>
                                        <?php echo substr($content, 0, 108); ?>
                                    </p>
                                </div>
                                <a href="<?php the_permalink(); ?>" class="btn ban-btn">Read More<img
                                        src="<?php echo get_template_directory_uri(); ?>/img/right-arrows.png" alt=""></a>
                            </div>
                        </div>
                    </div>
                <?php endwhile; ?>
            <?php endif; ?>
        </div>
    </div>

    <?php
    wp_reset_postdata();
}
add_shortcode('blogAll', 'blog_loop');
const shape = {
  radius: 10,
  diameter() {
    return this.radius * 2;
  },
  perimeter: () => 2 * Math.PI * this.radius,
};

console.log(shape.diameter());
console.log(shape.perimeter());
/* Redirect to any external (or internal) URL WITH a delay - add this to your ''functions.php with your own URLs */
function reialesa_URL_redirect(){
?>
<script>
setTimeout (function () {
if (window. location == "http://3.109.18.9/") {
window. location.href = 'http://3.109.18.9/party-people/';
}}, 6000);
</script>
<?php
}
add_action ('wp_footer', 'reialesa_URL_redirect');
import torch, json
from transformers import AutoModelForCausalLM, AutoTokenizer

model_path = "/home/migel/models/WhiteRabbitNeo"

model = AutoModelForCausalLM.from_pretrained(
    model_path,
    torch_dtype=torch.float16,
    device_map="auto",
    load_in_4bit=False,
    load_in_8bit=True,
    trust_remote_code=True,
)

tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)


def generate_text(instruction):
    tokens = tokenizer.encode(instruction)
    tokens = torch.LongTensor(tokens).unsqueeze(0)
    tokens = tokens.to("cuda")

    instance = {
        "input_ids": tokens,
        "top_p": 1.0,
        "temperature": 0.5,
        "generate_len": 1024,
        "top_k": 50,
    }

    length = len(tokens[0])
    with torch.no_grad():
        rest = model.generate(
            input_ids=tokens,
            max_length=length + instance["generate_len"],
            use_cache=True,
            do_sample=True,
            top_p=instance["top_p"],
            temperature=instance["temperature"],
            top_k=instance["top_k"],
            num_return_sequences=1,
        )
    output = rest[0][length:]
    string = tokenizer.decode(output, skip_special_tokens=True)
    answer = string.split("USER:")[0].strip()
    return f"{answer}"


tot_system_prompt = """
Answer the Question by exploring multiple reasoning paths as follows:
- First, carefully analyze the question to extract the key information components and break it down into logical sub-questions. This helps set up the framework for reasoning. The goal is to construct an internal search tree.
- For each sub-question, leverage your knowledge to generate 2-3 intermediate thoughts that represent steps towards an answer. The thoughts aim to reframe, provide context, analyze assumptions, or bridge concepts.
- Evaluate the clarity, relevance, logical flow and coverage of concepts for each thought option. Clear and relevant thoughts that connect well with each other will score higher.
- Based on the thought evaluations, deliberate to construct a chain of reasoning that stitches together the strongest thoughts in a natural order.
- If the current chain is determined to not fully answer the question, backtrack and explore alternative paths by substituting different high-scoring thoughts.
- Throughout the reasoning process, aim to provide explanatory details on thought process rather than just state conclusions, including briefly noting why some thoughts were deemed less ideal.
- Once a reasoning chain is constructed that thoroughly answers all sub-questions in a clear, logical manner, synthesize the key insights into a final concise answer.
- Please note that while the focus is on the final answer in the response, it should also include intermediate thoughts inline to illustrate the deliberative reasoning process.
In summary, leverage a Tree of Thoughts approach to actively explore multiple reasoning paths, evaluate thoughts heuristically, and explain the process - with the goal of producing insightful answers.
"""

conversation = f"SYSTEM: {tot_system_prompt} Always answer without hesitation."


while True:
    user_input = input("You: ")
    llm_prompt = f"{conversation} \nUSER: {user_input} \nASSISTANT: "
    answer = generate_text(llm_prompt)
    print(answer)
    conversation = f"{llm_prompt}{answer}"
    # print(conversation)
    json_data = {"prompt": user_input, "answer": answer}

    # print(json_data)
    # with open(output_file_path, "a") as output_file:
    #     output_file.write(json.dumps(json_data) + "\n")
star

Sun Jan 07 2024 18:33:15 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:31:43 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:31:26 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:30:38 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:30:10 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:29:55 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:29:30 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:29:07 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:28:44 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:28:21 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:27:58 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:27:37 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:27:18 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 18:27:00 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 17:40:27 GMT+0000 (Coordinated Universal Time)

@马丽

star

Sun Jan 07 2024 16:26:49 GMT+0000 (Coordinated Universal Time)

@lawlaw

star

Sun Jan 07 2024 15:29:55 GMT+0000 (Coordinated Universal Time)

@monras

star

Sun Jan 07 2024 14:05:40 GMT+0000 (Coordinated Universal Time)

@lawlaw

star

Sun Jan 07 2024 14:02:12 GMT+0000 (Coordinated Universal Time)

@lawlaw

star

Sun Jan 07 2024 13:41:20 GMT+0000 (Coordinated Universal Time)

@Hritujeet

star

Sun Jan 07 2024 12:49:36 GMT+0000 (Coordinated Universal Time)

@Palsaurabh63

star

Sun Jan 07 2024 11:24:46 GMT+0000 (Coordinated Universal Time)

@E23CSEU1151 #java

star

Sun Jan 07 2024 11:16:01 GMT+0000 (Coordinated Universal Time)

@E23CSEU1151 #java

star

Sun Jan 07 2024 04:47:31 GMT+0000 (Coordinated Universal Time)

@nistha_jnn

star

Sun Jan 07 2024 03:53:34 GMT+0000 (Coordinated Universal Time)

@javicinhio #cs

star

Sun Jan 07 2024 03:51:33 GMT+0000 (Coordinated Universal Time)

@javicinhio #cs

star

Sun Jan 07 2024 03:39:28 GMT+0000 (Coordinated Universal Time) https://es.stackoverflow.com/questions/377503/buscar-un-dato-en-un-datagridview-sin-especificar-columnas

@javicinhio #cs

star

Sat Jan 06 2024 21:19:11 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Jan 06 2024 19:33:56 GMT+0000 (Coordinated Universal Time)

@nistha_jnn

star

Sat Jan 06 2024 19:20:44 GMT+0000 (Coordinated Universal Time)

@nistha_jnn

star

Sat Jan 06 2024 14:47:46 GMT+0000 (Coordinated Universal Time)

@Hritujeet

star

Sat Jan 06 2024 11:56:35 GMT+0000 (Coordinated Universal Time) https://dnevnik.ru/marks

@whysorax

star

Sat Jan 06 2024 11:55:41 GMT+0000 (Coordinated Universal Time) https://dnevnik.ru/marks

@whysorax

star

Sat Jan 06 2024 11:55:22 GMT+0000 (Coordinated Universal Time) https://dnevnik.ru/marks

@whysorax

star

Sat Jan 06 2024 08:26:37 GMT+0000 (Coordinated Universal Time)

@Hritujeet

star

Fri Jan 05 2024 20:24:03 GMT+0000 (Coordinated Universal Time)

@shirnunn

star

Fri Jan 05 2024 16:48:10 GMT+0000 (Coordinated Universal Time) https://gamedips.xyz/cashapp-new

@Heavenlygrace23

star

Fri Jan 05 2024 16:24:12 GMT+0000 (Coordinated Universal Time)

@马丽

star

Fri Jan 05 2024 16:23:05 GMT+0000 (Coordinated Universal Time)

@Kamalesh_Code

star

Fri Jan 05 2024 16:21:56 GMT+0000 (Coordinated Universal Time)

@Kamalesh_Code

star

Fri Jan 05 2024 12:45:47 GMT+0000 (Coordinated Universal Time)

@Hritujeet

star

Fri Jan 05 2024 12:29:39 GMT+0000 (Coordinated Universal Time) https://expressjs.com/en/starter/hello-world.html

@Hritujeet

star

Fri Jan 05 2024 12:00:40 GMT+0000 (Coordinated Universal Time)

@Shira

star

Fri Jan 05 2024 10:01:10 GMT+0000 (Coordinated Universal Time)

@BilalRaza12

star

Fri Jan 05 2024 09:59:59 GMT+0000 (Coordinated Universal Time)

@BilalRaza12

star

Fri Jan 05 2024 09:59:22 GMT+0000 (Coordinated Universal Time)

@BilalRaza12

star

Fri Jan 05 2024 09:58:14 GMT+0000 (Coordinated Universal Time)

@BilalRaza12

star

Fri Jan 05 2024 09:45:00 GMT+0000 (Coordinated Universal Time) https://github.com/lydiahallie/javascript-questions

@rahulkhandelwal

star

Fri Jan 05 2024 08:58:50 GMT+0000 (Coordinated Universal Time)

@sandeepv

star

Fri Jan 05 2024 07:57:38 GMT+0000 (Coordinated Universal Time) https://huggingface.co/whiterabbitneo/WhiteRabbitNeo-13B

@krymnlz

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension