Code Monkey home page Code Monkey logo

epicode's People

Contributors

adnanaziz avatar metopa 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

epicode's Issues

Simpler alternative for permutations-unique.cc

@adnanaziz @thlee-uber - I am not sure if this is the right avenue to bring this to your attention. I apologize in advance if that is indeed not the case.

This is a slight modification to the approach in permutations-alternative.cc:

    vector<vector<int>> permute_unique(vector<int> nums)
    {
        vector<vector<int>> result;
        sort(nums.begin(), nums.end());
        permute_unique_recursive(0, &nums, &result);
        return result;
    }
    void permute_unique_recursive(int index_start, vector<int>* arr, vector<vector<int>>* result)
    {
        vector<int>& a = *arr;
        if (index_start == arr->size() - 1) {
            result->emplace_back(a);
            return;
        }
        permute_unique_recursive(index_start + 1, arr, result);
        for (int i = index_start + 1, n = arr->size(); i < n; ++i) {
            if (a[index_start] == a[i])
                continue;
            swap(a[index_start], a[i]);
            permute_unique_recursive(index_start + 1, arr, result);
        }
        rotate(a.begin() + index_start, a.begin() + index_start + 1, a.end());
    }

maxVolume for 'every time interval' in the window is not generated.

the maxVolume is only generated in the current version of code, at time-interval that had trafficeVolume in the input. The in between interval maxVolume are not generated.
For example for the input
vector trafficVol = {{0, 1.3}, {2, 2.5}, {3, 3.7}, {5, 1.4}, {6, 2.6}, {8, 2.2}, {9, 1.7}, {14, 1.7}};

the output is : { 0 ,1.3 }, { 2 ,2.5 }, { 3 ,3.7 }, { 5 ,3.7 }, { 6 ,3.7 }, { 8 ,2.6 }, { 9 ,2.6 }, { 14 ,1.7 },

it should be : { 0 ,1.3 }, { 1 ,1.3 }, { 2 ,2.5 }, { 3 ,3.7 }, { 4 ,3.7 }, { 5 ,3.7 }, { 6 ,3.7 }, { 7 ,2.6 }, { 8 ,2.6 }, { 9 ,2.6 }, { 10 ,2.2 }, { 11 ,2.2 }, { 12 ,1.7 }, { 13 ,0 }, { 14 ,1.7 },
Also per diagram 22.5(b)

Unless I misunderstood the problem ?

Not uniformly random, Problem 5.10

In Chapter 5, problem 10, reader is asked to generate a uniformly random number within a range [a,b].

The solution provided is not uniformly random. My method to test is given here:

https://gist.github.com/umbs/5b1557b585d2ed068d7169554db1e62d

Results after multiple runs within various ranges are:

[1]
$ ./a.exe 1 10
1 = 0.000700
2 = 0.008300
3 = 0.046000
4 = 0.114200
5 = 0.206200
6 = 0.252600
7 = 0.199500
8 = 0.115600
9 = 0.045000
10 = 0.011400

==========

$ ./a.exe 10 15
10 = 0.015200
11 = 0.098200
12 = 0.235200
13 = 0.306700
14 = 0.238000
15 = 0.090900

===========

$ ./a.exe 101 120
101 = 0.000000
102 = 0.000000
103 = 0.000400
104 = 0.001300
105 = 0.005100
106 = 0.014100
107 = 0.038200
108 = 0.076600
109 = 0.115500
110 = 0.159100
111 = 0.173200
112 = 0.163000
113 = 0.119800
114 = 0.074000
115 = 0.037500
116 = 0.015400
117 = 0.005200
118 = 0.001400
119 = 0.000100
120 = 0.000100

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.