Skip to content

Instantly share code, notes, and snippets.

View retraigo's full-sized avatar
⚜️
I fancy attention

Pranev (NeTT) retraigo

⚜️
I fancy attention
View GitHub Profile
in_room(monkey).
in_room(banana).
in_room(chair).
clever(monkey).
can_climb(monkey, chair).
tall(chair).
can_move(monkey, chair, banana).
can_reach(X, Y):-
n = int(input())
size = (2 * n) - 1
d = []
for i in range(n - 1):
s = []
for j in range(n - 1):
s.append(str(n - min(i, j)))
rev = [x for x in s]
rev.reverse()
object Triplicate {
def main(args: Array[String]): Unit = {
println("Enter numbers separated by a comma")
val nums = scala.io.StdIn.readLine()
val arr = nums.split(",").map(x => x.toInt)
val trip = arr.flatMap(x => List(x, x, x))
/**
* Data transformed by the constructor, fed to the binary search function.
* The `result` property holds the result that will be returned after rolling.
* `chance` is the weight of the result.
* `cumulativeChance` is used to make it fit for binary search. Something like an arithmetic progression.
*/
export interface ComputedGachaData<ItemType> {
result: ItemType;
chance: number;
use rand::Rng;
/// You have an array of items. Each item is an unsigned 32-bit integer.
/// The value of each item determines its weight.
/// Higher the weight, higher the chance of rolling it.
/// This algorithm uses a simple approach.
/// Keep moving in a straight line till your weights sum up to (or get reduced to)
/// a weight less than a single item's weight. Return the index of the result.
// Weighted random selection in Scala 2
// You have an array of items. Each item is an unsigned integer.
// The value of each item determines its weight.
// Higher the weight, higher the chance of rolling it.
class Fortuna(items: Array[Double]) {
private val weights = items;
private val cumulativeWeights: Array[Double] = new Array(items.length);
private var totalChance: Double = 0;
for (i <- 0 until items.length) {
@retraigo
retraigo / linear_regression.rs
Created September 20, 2022 15:38
I hope this is actually linear regression
#[derive(Debug)]
pub struct LinearRegressionResult {
pub slope: f64,
pub intercept: f64,
pub r2: f64,
}
impl LinearRegressionResult {
pub fn predict(&self, x: f64) -> f64 {
self.intercept + (self.slope * x)
}
@retraigo
retraigo / assignment_1.md
Created September 4, 2022 07:48
Scala assignments

1. Write a Scala program to sum values of a given array.

import scala.io.StdIn.{readDouble};
import scala.collection.mutable.ArrayBuffer;
object SumArray {
  def main(args: Array[String]) = {
    var listOfNumbers = new ArrayBuffer[Double]();
    println("Enter numbers to add. Enter 0 to stop.");
    var current = 1.0;
    while (current != 0.0) {
@retraigo
retraigo / EX_10_2.scala
Last active December 13, 2022 04:56
AI DS SEM 3 OOPS LAB
import scala.io.StdIn.{readInt};
import scala.collection.mutable.ArrayBuffer;
import scala.collection.immutable.List;
object Triplicate {
def main(args: Array[String]) = {
val arr = new ArrayBuffer[Int]();
println("Enter the numbers followed by a return after each number. Enter a non-number to stop.");
var continue = 1;
while(continue == 1) {
try {
@retraigo
retraigo / POSTULATES.md
Created August 29, 2022 09:35
The postulates of NeTT

Postulates of NeTT

  • If you have an opinion, share it or suggest it. Don't force it on others.
  • If you have a personal belief, be it religious or ethical, don't force it on others.
  • If you have a personal problem with someone, take it to where it belongs. Bringing it to unrelated online platforms wouldn't give you justice.
  • If you need help with something, describe what you need help with instead of asking if you can get help without describing the matter.
  • If you are asking for help, be clear with what you exactly need. You might end up wasting the time of the person trying to help you as well as that of yourself.
  • If someone asks for help and you don't want to help them, just don't help them. Instead, don't blame their ignorance on the matter.
  • If someone doesn't like something, don't do it just to piss them off.
  • If someone starts complaining about everything for no reason, just don't mind them. There is no cure for stupidity.
  • If you have a sense of justice, it makes sense that the other person