Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ramachandrajr's full-sized avatar

Ramachandra Junior ramachandrajr

View GitHub Profile
@ramachandrajr
ramachandrajr / vowel_prob.py
Created March 21, 2018 20:31
Calculates vowel probabilities in a text
import re
import sys
yevgeny = ""
vowels_after_vowels = 0.0
vowels_after_consonants = 0.0
number_of_vowels = 0.0
vowels = [ "a", "e", "i", "o", "u", "A", "E", "I", "O", "U" ]
@ramachandrajr
ramachandrajr / GamePlayStatistics.cpp:
Last active December 3, 2017 11:06
SuggestProjectileVelocity function from unreal engine
/** SuggestProjectileVelocity **/
// note: this will automatically fall back to line test if radius is small enough// Based on analytic solution to ballistic angle of launch http://en.wikipedia.org/wiki/Trajectory_of_a_projectile#Angle_required_to_hit_coordinate_.28x.2Cy.29bool UGameplayStatics::SuggestProjectileVelocity(const UObject* WorldContextObject, FVector& OutTossVelocity, FVector Start, FVector End, float TossSpeed, bool bFavorHighArc, float CollisionRadius, float OverrideGravityZ, ESuggestProjVelocityTraceOption::Type TraceOption, const FCollisionResponseParams& ResponseParam, const TArray<AActor*>& ActorsToIgnore, bool bDrawDebug){
const FVector FlightDelta = End - Start;
const FVector DirXY = FlightDelta.GetSafeNormal2D();
const float DeltaXY = FlightDelta.Size2D();
const float DeltaZ = FlightDelta.Z;
const float TossSpeedSq = FMath::Square(TossSpeed);
@ramachandrajr
ramachandrajr / draw_olympic_logo.py
Last active September 2, 2017 04:25
Script draws Olympoic logo. Uses a built in python module called turtle to draw shapes.
from turtle import Turtle
def create_circle( turtle_object, coordinates, color, radius ):
"""Creates a circle with **coordinates** as start point."""
# Pull up the pen first.
turtle_object.penup()
# Go to initial coordinates.
turtle_object.goto(coordinates[0], coordinates[1]);
# Pendown to start drawing.
turtle_object.pendown();
@ramachandrajr
ramachandrajr / maze_player.cpp
Created July 3, 2017 10:46
A bruteforce program to solve mazes
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
// Used for proper response structuring.
// reduces code on check_for_dots and check_for_xs.
struct Response
{
@ramachandrajr
ramachandrajr / string_to_text.cpp
Created June 2, 2017 12:56
This piece of code converts string text to integer.
#include <iostream>
#include <stdexcept>
#include <cmath>
using namespace std;
/**
* Reports any non numeric charaters in a string. Removes if just whitespace.
* @param {string} str - String to convert.
* @return {string} String with just numbers.
*/
@ramachandrajr
ramachandrajr / pointer_fix.cpp
Created May 19, 2017 15:03
Fixing error with pointer
#include <iostream>
using namespace std;
class Person
{
public:
string name;
int age;
double height;
@ramachandrajr
ramachandrajr / moron.cpp
Created May 19, 2017 14:36
This program helps understand string initializations.
/*
Execute the program as:
g++ -std=c++11 file_name.cpp -o file_name
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
/**
* "Sun Apr 09 2017 12:36:54 GMT+0530 (IST)"
* Design a file filter package.
*
* 1) A file filter reads an input file, transforms it in some way, and writes the result to an output file.
* You are tasked to write an abstract Filter class that defines a pure virtual function char transform
* (char ch) for transforming a single character .
*
* 2) The Filter class should have member variables to hold the input and output streams; it also should
* have a default constructor that initializes the input/output streams to cin/cout respectively as well
// You cannot do << to the cin, you can do 'cin >> auto a' though but I
// think it'd be great to initialize int's first and then getting values.
cin<< auto a;
cin<<auto b;
// This way powerMultiply will already have a power of a.
int powerMultiply=a;
// so you need not do it i<b times, you just have to do
// it i < (b-1) times.
for(int i =0;i<b;i++)
#include <iostream>
#include <iomanip>
int grid[20][20] = {
{ 8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8 },
{ 49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 4, 56, 62, 0 },
{ 81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 3, 49, 13, 36, 65 },
{ 52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91 },
{ 22, 31, 16, 71, 51, 67, 63, 89, 41, 92, 36, 54, 22, 40, 40, 28, 66, 33, 13, 80 },
{ 24, 47, 32, 60, 99, 3, 45, 2, 44, 75, 33, 53, 78, 36, 84, 20, 35, 17, 12, 50 },