Categories
Mastering Development

PCA plots in R making plots with the wrong colors

I have two tables in my R environments, and I’ve been trying to create a pca plot with this data but the colors are being mismatched with the legend key and I’m not sure what’s going on. This is my reproducible code to create the pca plots: library(tidyverse) library(stringr) library(ggfortify) library(abind) library(dplyr) library(ggplot2) library(ggrepel) info […]

Categories
Mastering Development

regex separator that matches spaces, and the nul space before and after any non Alphanumeric character

For the life of me I can’t seem to figure out how to properly format my regex pattern. I’m trying to write a line of code that splits a string at these two locations: Every space in the string immediately before and after any non alphanumeric character for example if I have the string: “This, […]

Categories
Mastering Development

c# string.GetHashCode. Unique number generation

I have below c# code which return public static void Main() { //var bytes = “7A5EC53415E34F288269EBB05B73AFD4”.ToByteArray(); for(int i=0;i<1000;i++){ var a=Guid.NewGuid().ToString(“N”).ToUpper() ; Console.WriteLine(“{0}-> {1}”,a, a.GetHashCode()); } } Which results C5D9DB1ACBFB43E2B0DC2812F22C3899-> -1816084758 42B7C0BF6C0341DB96DE5084BA403193-> 1197814565 B4062E3C129E478BA8E69552DDC700F2-> 1349563395 863C9FBF0369496E90A1B0246F855D6E-> -772372816 B42562EDB97346F48DE37ADE3FB6620E-> 2019192158 My Question here is, will the return values be a unique value so that I can use […]

Categories
Mastering Development

Array of strings from single line in a file

I would like to get an array of strings from a .txt file. I tried using fgets then strtok to separate the strings. I think my fgets is wrong but I dont understand how to get to what I want. char* str[numWords]; char line[]; char delim[] = ” “; int j; for(j = 0; j […]

Categories
Mastering Development

Getting a warning in my 32-bit ALU using gate-level verilog code

Below is the code for 32 bit ALU with 3 different modules with their individual codes as well. I am just getting one warning which I am not sure how to solve it. The error is in the final stimulus/testbench but no changes can be made in that as that is pre-defined. I did understand […]

Categories
Mastering Development

Why doesn’t my hash function work?

I’m a newbie in this field and am trying to learn a bit about how to write cryptographic hash functions. To get some hands-on, I tried updating the PySHA2 algorithm for Python 3.6 and up (the original version doesn’t work on Python 2.5+ and the author says he won’t fix this). I don’t intend to […]

Categories
Artificial Intelligence (AI) Mastering Development

Efficient algorithm to obtain near optimal policies for an MDP

Given a discrete, finite Markov Decision Process (MDP) with its usual parameters $(S, A, T, R, \gamma)$, it is possible to obtain the optimal policy $\pi^{*}$ and the optimal value function $V^{*}$ through one of many planning methods (policy iteration, value iteration or solving a linear program). I am interested in obtaining a random near-optimal […]

Categories
Mastering Development

How to count the number of ordered sequence in a vector in R

I have the following data set as an example. Data<-c(“a”,”d”,”c”,”b”,”d”,”a”,”d”,”b”,”c”,”b”,”a”,”b”,”d”,”c”,”b”,”a”,”c”,”d”,”d”,”c”) I need to find out how many times a < b < c < d, all possible combinations. I have created a loop (using 4 IF functions) but it takes long time when we have large data set. With this loop the answer is 47 […]

Categories
Mastering Development

JavaScript Array Operations in the MS Script Control

This is a JavaScript question, but… my objective is to use the Microsoft Script Control in Excel VBA to carry out array operations. The script control uses MS JScript, roughly equal to ES3, but having no window object. When I say array operations, I mean… if [a] is an array of 100 numbers and [b] […]

Categories
Mastering Development

Using array instead of set

This is a function for finding all Longest common sequence for X and Y sequence. But this program is in c++ but I want to write it in C. Is there any way to use array instead of the set? For eg. if input is X = < A, A, T, C, C, > Y […]