Skip to content

Instantly share code, notes, and snippets.

View nikhil-RGB's full-sized avatar
:octocat:
Hammering out code

Nikhil Narayanan nikhil-RGB

:octocat:
Hammering out code
View GitHub Profile
import 'package:hive_flutter/adapters.dart';
import 'package:turing_machines/models/Behaviour.dart';
import 'package:turing_machines/models/Configuration.dart';
import 'package:turing_machines/models/Tape.dart';
import 'package:turing_machines/models/TuringMachines.dart';
part "TuringMachineModel.g.dart";
@HiveType(typeId: 0)
class TuringMachineModel {
@HiveField(0)
@nikhil-RGB
nikhil-RGB / FirstAndFollow.java
Last active April 20, 2024 06:26
This script will calculate the first and follow of a symbol for a given context free grammar. This currently does not handle left recursion and left factoring. Epsilon is not handled yet.
package compiler_design;
import java.util.*;
public class FirstAndFollow {
public static void main(String[] args)
{
System.out.println("Input number of production rules");
Scanner reader=new Scanner(System.in);
int count=Integer.parseInt(reader.nextLine());
LinkedHashMap<String,String[]> table=new LinkedHashMap<>();
for(int i=0;i<count;++i) {
import java.util.*;
public class CodeGenerationForIf {
public static void main(String[] args) {
// Example input: if (x > 5) { y = x * 2; }
String condition = "x>8";
String action = "y = y / 10;";
// Generate code for the if statement
String generatedCode = generateIfCode(condition, action);
System.out.println("Generated code for if:");
@nikhil-RGB
nikhil-RGB / Actions.dart
Created March 31, 2024 20:43
Parse and store actions for a turing machine with a particular configuration, does not include final state as a part of stored data.
// ignore: file_names
import 'package:flutter/material.dart';
import 'package:turing_machines/exceptions/ActionParserException.dart';
//Represents an Action which can be performed on the tape of a turing machine.
class Actions {
String symbol;
ActionType type;
Actions({required this.type, this.symbol = ""});
//Parses a String containing actions, seperated by a ,(comma)
@nikhil-RGB
nikhil-RGB / PostFix.java
Created March 26, 2024 10:39
Compiler Design Experiment 8, evaluation of a post fix expression
import java.util.*;
public class PostFix {
public static void main(String[] args) {
System.out.println("Input Postix Expression");
@nikhil-RGB
nikhil-RGB / $PROFILE
Created March 22, 2024 20:20
A powershell profile script which can be used to define useful shorthands. Also includes initialization for oh-my-posh and winfetch
oh-my-posh --init --shell pwsh --config ~/AppData/Local/Programs/oh-my-posh/themes/jandedobbeleer.omp.json | Invoke-Expression
function personal {
Set-Location -Path C:\PROJECTS\personal
}
function openPersonal {
$directoryPath = 'C:\PROJECTS\personal'
@nikhil-RGB
nikhil-RGB / Minimax.java
Created March 7, 2024 16:56
Original implementation Minimax tictactoe
public static int[] minMax(TicTacToeMin obj)
{
ArrayList<Integer> scores=new ArrayList<>(0);
ArrayList<TicTacToeMin> arrs=obj.simulate();
ArrayList<Integer> moves=obj.emptySpaces();
//return a list of cloned boards with current token fitted into all empty spaces.
if(arrs.size()==0)
{
return new int[] {0,-1};
@nikhil-RGB
nikhil-RGB / TreeFinder.java
Last active February 21, 2024 12:44
BFS/DFS Search in a Tree
package experiments;
import java.util.*;
class TreeNode<T>{
public ArrayList<TreeNode<T>> children;//can be empty
//NEVER PASS NULL to this parameter.
T value;
public TreeNode(T value, ArrayList<TreeNode<T>> children)
{
this.value=value;
this.children=children;
@nikhil-RGB
nikhil-RGB / Minimizer.c
Created February 19, 2024 09:37
Experiment 5
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
int n;
cout<<"\nEnter number of non terminals: ";
cin>>n;
cout<<"\nEnter non terminals one by one: ";
@nikhil-RGB
nikhil-RGB / login.dart
Created August 3, 2023 17:29
Kzilla login asset image and form
//Creates the body for the login page
Widget constructBody() {
return SingleChildScrollView(
child: Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: MediaQuery.of(context).size.height * 0.1,
),