Code Monkey home page Code Monkey logo

code-problems's People

Contributors

acrich avatar adamloving avatar almewty avatar andrewkshim avatar antonioredondo avatar aychtang avatar blakeembrey avatar blundell avatar brunjo avatar cjjavellana avatar dennis-johnson-dev avatar dok avatar greinerk avatar jmera avatar mmrko avatar nanne007 avatar nootanghimire avatar nurazem avatar pkmm91 avatar r-deleon avatar riga avatar roitt avatar saurabhjn76 avatar simula67 avatar spiraloutdoteu avatar vhbsouza avatar widea avatar xelom avatar youssefkababe avatar zomble avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

code-problems's Issues

Provide overview in README

(In respone to this)

Yes, by topic would be OK. Topics like: math related, working with strings, working with arrays, etc.

The lists don't have to provide links to the sub dirs of the repo. Their purpose is just to provide a general overview of what's inside the repo. Without such an overview, the visitor has to go through the list of sub dirs one-by-one which is not very effective.

So, I think an overview in the README file would make this repo significantly more user friendly.

JS solution to Stack Machine fails tests

$ npm test
...
  3 failing
...
  1) stackMachine should return the top number from the stack:
     AssertionError: -1 == 0
     Input: 0

  2) stackMachine should multiply two numbers from the top of the stack:
     AssertionError: -1 == 0
     Input: 01*

  3) stackMachine should return -1 when 12-bit stack-machine overflows:
     AssertionError: 4096 == -1
     Input: 88*1+97**1+
...
npm ERR! weird error 3
...

For the last error, it's helpful to note that 212 = 4096.
The input it fails on is equivalent to 4095 + 1 = 4096.

Need helpwith this code, scater packaging

Dear all,
I was curious to look at the last updates in RNA sequencing. I have seen that https://github.com/adamjamesreid/Plasmodium-single-cell-RNA-seq has already R codes in it. I have adjust it a little because it doesn't work with the new version of R.

if (!requireNamespace("BiocManager", quietly=TRUE))
install.packages("BiocManager")
BiocManager::install("scater")

library(scater, quietly = TRUE)

options(stringsAsFactors = FALSE)

Read in data

molecules <- read.table("PbM_counts.txt", sep = "\t", header = TRUE, row.names=1)
molecules[1:5, 1:3]
anno <- read.table("PbM_meta.txt", sep = "\t", header=TRUE)

genes <- read.table("berg.desc", header=FALSE, row.names=1, quote = "", sep="\t")

Set up objects

pheno_data <- new("AnnotatedDataFrame", anno)
rownames(pheno_data) <- pheno_data$sample_id

PbM <- SingleCellExperiment(assays = list(counts = as.matrix(molecules)),
colData = anno)

Filter genes with no counts

keep_feature <- rowSums(counts(PbM) > 0) > 0
PbM <- PbM[keep_feature, ]

calculateQCMetrics

PbM <- scater::calculateQCMetrics(PbM)

Filter cells with low counts

filter_by_total_counts <- (PbM$total_counts > 25000)
table(filter_by_total_counts)

Filter cells with low numbers of features detected

filter_by_expr_features <- (PbM$total_features > 1000)
table(filter_by_expr_features)

filter out control samples

PbM$is_control <- anno$is_control
filter_by_control <- (PbM$is_control == TRUE)
table(filter_by_control)

Filter data

PbM$use <- (

sufficient features (genes)

filter_by_expr_features &
# sufficient molecules counted
filter_by_total_counts &
# controls shouldn't be used in downstream analysis
!PbM$is_control
)

table(PbM$use)

Gene filtering

e.g. greater than 10 reads in at least 5 cells

#############################################################
#if (!requireNamespace("BiocManager", quietly=TRUE))
#install.packages("BiocManager")
#BiocManager::install("ballgown")
#library(ballgown)

filter_genes <- apply(counts(PbM[ , pData(PbM)$use]), 1, function(x) length(x[x >= 10]) >= 5)

table(filter_genes)

fData(PbM)$use <- filter_genes

dim(PbM[fData(PbM)$use, pData(PbM)$use])

Create new object with filtered dataset

PbM.qc <- PbM[fData(PbM)$use, pData(PbM)$use]

Perform SCRAN normalisation

qclust <- scran::quickCluster(PbM.qc, min.size = 30)
PbM.qc <- scran::computeSumFactors(PbM.qc, sizes = 20, clusters = qclust, positive=TRUE)
PbM.qc <- scater::normalize(PbM.qc)
scater::plotPCA(PbM.qc,
colour_by = "consensus",
size_by = "total_features",
exprs_values = "exprs")

PLot expression of p25 female marker on PCA

plotPCA(PbM.qc, colour_by="PBANKA_0515000", exprs_values = "exprs", ncomponents=2)

In the part PbM$use I get the error "Error in [[<-(*tmp*, name, value = logical(0)) :
0 elements in value to replace 188 elements" . Could you help me?

File extension overlap between languages

When working on #60, a C++11 implementation of stack, the existing C implementation #50 already "laid claim" to the stack.h filename, so I chose to use the less idiomatic stack.hpp instead. Since C++11 isn't backward compatible with C++98, if somebody were to add an implementation in that, they'd have to use yet another extension, such as stack.hxx, stack.hh, or stack.h++.

The current organization structure probably won't scale well as more language implementations are added. For now, which files correspond to which language is fairly obvious. But as more files are added, this won't remain so clear. With multiple file solutions (which are idiomatic in some languages), the problem directories will end up fairly cluttered.

I propose individual directories within each problem for each language. The issue could also be partially solved with filename conventions, but in my opinion, that isn't self-documenting or clean. Thoughts?

Maintainers

I think this is a decent resource, but haven't had time to contribute or make it more useful in a couple of years. If anyone would like to help maintain and find a roadmap to improve the challenges and/or solutions, just post here. Cheers!

is the refactor of the binary-search-tree.js ok?

I learned binary-search-tree.js today. I found a duplicate code which is very obvious.

https://github.com/blakeembrey/code-problems/blob/master/solutions/javascript/binary-search-tree.js

if we refactored in this way:

doSubNode = function(direct, num) {
    if (this[direct] === undefined) {
        this[direct] = createNode(num);
    } else {
        this[direct].add(num);
    }
};

and used it in:

...
        if (num < this.value) {
            doSubNode.apply(this,["left", num]);
        } else if (num > this.value) {
            doSubNode.apply(this,["right", num]);
        } 
...

So is any reason to use the duplicated code? or it's OK to refactor the code?

Broken tests?

TDD is something I have to take a deeper look, but the tests at least for python are broken. It failed because the test can't find the methods used, which is normal because they aren't imported.

python largest-continuous-sum.py
E
======================================================================
ERROR: test_largest_continuous_sum (__main__.LargestContinousSequenceTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "largest-continuous-sum.py", line 5, in test_largest_continuous_sum
    sum = largest_continuous_sum([1, 2, 3, 4])
NameError: global name 'largest_continuous_sum' is not defined

----------------------------------------------------------------------
Ran 1 test in 0.000s

As this is not a package, how we should accomplish this?

largest-palindrome.js break the test in JsHint phase.

I run the npm test

The error message is following:

solutions\javascript\largest-palindrome.js: line 2, col 3, 'const' is available in ES6 (use esnext option) or Mozilla JS extensions (use moz).
solutions\javascript\largest-palindrome.js: line 2, col 41, Missing semicolon.
solutions\javascript\largest-palindrome.js: line 4, col 8, 'let' is available in ES6 (use esnext option) or Mozilla JS extensions (use moz).
solutions\javascript\largest-palindrome.js: line 6, col 19, Missing semicolon.
solutions\javascript\largest-palindrome.js: line 10, col 14, Missing semicolon.
solutions\javascript\largest-palindrome.js: line 14, col 3, 'let' is available in ES6 (use esnext option) or Mozilla JS extensions (use moz).
solutions\javascript\largest-palindrome.js: line 14, col 19, Missing semicolon.
solutions\javascript\largest-palindrome.js: line 16, col 8, 'let' is available in ES6 (use esnext option) or Mozilla JS extensions (use moz).
solutions\javascript\largest-palindrome.js: line 17, col 5, 'let' is available in ES6 (use esnext option) or Mozilla JS extensions (use moz).
solutions\javascript\largest-palindrome.js: line 17, col 25, Missing semicolon.
solutions\javascript\largest-palindrome.js: line 20, col 7, 'const' is available in ES6 (use esnext option) or Mozilla JS extensions (use moz).
solutions\javascript\largest-palindrome.js: line 20, col 48, Missing semicolon.
solutions\javascript\largest-palindrome.js: line 23, col 28, Missing semicolon.
solutions\javascript\largest-palindrome.js: line 28, col 17, Missing semicolon.
solutions\javascript\largest-palindrome.js: line 29, col 2, Missing semicolon.

it seems that largest-palindrome.js use ES6 syntax and jshint did not support ES6 syntax by default.

[combine-two-strings] Only looks ahead one character

combineTwoStrings("aab", "aac","aacaab") should return true, but returns false because the function only looks ahead one character. This could be solved with a recursive function call to do the checks for both strings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.