Page 1 of 2 12 LastLast
Results 1 to 25 of 32

Thread:

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Dec:2005
    Location: yvr
    Posts: 5,167

    4 000 000 - , -- . Windows Linux.

    ?
    Perl, PHP, bash, AutoIt, , .

    , , Notepad++ CSVed.
    :

    duma
    suma
    summa
    summma
    sum

    :

    sum
    duma
    suma
    summa
    summma

  2. #2

    Join Date: Apr:2006
    Location:
    Posts: 8,666
    , , . Windows... ( )

    quicksorting 4

    ,
    Last edited by smelkomar; 5th February 2009 at 17:21.

  3. #3
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    :

    Code:
    // (C) 2009 by Pesho
    
    #include <algorithm>
    #include <iostream>
    #include <string>
    #include <vector>
    using namespace std;
    
    bool length_comp(const string& a, const string& b) {
        if (a.length() < b.length()) return true;
        if (a.length() > b.length()) return false;
        return (a < b);
    }
    
    int main() {
        typedef vector<string> Words;
        Words words;
        string str;
        while (getline(cin, str))
            words.push_back(str);
        sort(words.begin(), words.end(), length_comp);
        for (Words::iterator it = words.begin(); it != words.end(); ++it)
            cout << *it << "\n";
        return 0;
    }

    stdin stdout. , .
    Last edited by Pesho; 5th February 2009 at 17:55.
    , !

  4. #4
    Registered User
    Join Date: Dec:2005
    Location: yvr
    Posts: 5,167
    .

    BTW-

  5. #5
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    Quote Originally Posted by ilko View Post
    BTW-

    , () ( ). I/O
    , !

  6. #6

    Join Date: Apr:2006
    Location:
    Posts: 8,666
    Quote Originally Posted by Pesho View Post
    , () ( ). I/O

    Code:
    {
      std::clock_t start;
      double diff;
    
      start = std::clock();
      for ( int i = 0; i < 1000000000; i++ ) //   
        printf ( "ROFL" );
      diff = ( std::clock() - start ) / (double)CLOCKS_PER_SEC;
    
      std::cout<<"printf: "<< diff <<'\n';
    }
    , ,
    Last edited by smelkomar; 8th February 2009 at 21:06. Reason: ""

  7. #7
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    Quote Originally Posted by smelkomar View Post
    ... , ,

    . RAM, . swapping, - ( O(n*log(n)) ; libstdc++ Introsort, - Quicksort).
    Last edited by Pesho; 8th February 2009 at 20:51.
    , !

  8. #8
    Registered User
    Join Date: Dec:2005
    Location: yvr
    Posts: 5,167
    :
    Code:
    g++ pesho_sort.cc
    mv a.out sort_p
    cat in.csv | ./sort_p > out.csv
    3 400 000 38 MB. , .

    - (bad.txt), 50 000 , , bad.txt / .

  9. #9
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    Quote Originally Posted by ilko View Post
    :
    Code:
    g++ pesho_sort.cc
    mv a.out sort_p
    cat in.csv | ./sort_p > out.csv
    3 400 000 38 MB. , .

    :
    Code:
    g++ -O3 pesho_sort.cc -o sort_p
    ./sort_p < in.csv > out.csv
    Quote Originally Posted by ilko View Post
    - (bad.txt), 50 000 , , bad.txt / .

    :

    Code:
    // (C) 2009 by Pesho
    
    #include <cctype>
    #include <fstream>
    #include <iostream>
    #include <set>
    #include <string>
    using namespace std;
    
    string toupper(string s) { for (unsigned i=0; i<s.length(); ++i) s[i] = toupper(s[i]); return s; }
    struct icomp { bool operator()(const string& a, const string& b) { return toupper(a) < toupper(b); } };
    
    int main() {
        typedef multiset<string, icomp> Words;
        Words words; string word;
        ifstream goodfs("good.txt");
        while (getline(goodfs, word)) words.insert(word);
        ifstream badfs("bad.txt");
        while (getline(badfs, word)) { Words::iterator it = words.find(word); if (it != words.end()) words.erase(it); }
        for (Words::iterator it=words.begin(); it!=words.end(); ++it) cout << *it << "\n";
        return 0;
    }
    Last edited by Pesho; 6th February 2009 at 18:02.
    , !

  10. #10
    Registered User
    Join Date: Dec:2005
    Location: yvr
    Posts: 5,167
    Quote Originally Posted by ilko View Post
    ... - (bad.txt), 50 000 , , bad.txt / .
    http://www.ss64.com/nt/findstr.html
    Code:
    findstr /v /i /g:bad.txt input.txt >> output.txt
    Last edited by ilko; 24th March 2009 at 20:00.

  11. #11
    Registered User
    Join Date: Dec:2005
    Location: yvr
    Posts: 5,167


  12. #12
    Banned
    Join Date: Oct:2001
    Location: , -5
    Posts: 2,637
    C++, Python
    Code:
    from itertools import imap
    class S(object):
       def __init__(self, s): self.s, self.l = s, s.lower()
       def __hash__(self): return hash(self.l)
       def __eq__(self, y): return self.l == y
       def __str__(self): return self.s
    
    a = set(imap(S, open('in.csv')))
    b = set(imap(S, open('bad.csv')))
    open('out.csv', w').writelines(sorted(imap(str, a - b), key = len))
    .

  13. #13
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    Quote Originally Posted by exabyte View Post
    C++, Python ...

    "", Python. C++, " ", Python reference-. , , C++ - Python ( -, - , )
    Last edited by Pesho; 6th February 2009 at 19:44.
    , !

  14. #14
    Registered User
    Join Date: Dec:2005
    Location: yvr
    Posts: 5,167

    .
    vici2:/home/names#./sort_p2 > out_pesho.csv
    vici2:/home/names#./exabyte.py
    vici2:/home/names#./sort_p < out_pesho.csv > out_pesho_new.csv
    vici2:/home/names#./sort_p < out_exabyte.csv > out_exabyte_new.csv
    vici2:/home/names# diff -s out_pesho_new.csv out_exabyte_new.csv
    Files out_pesho_new.csv and out_exabyte_new.csv are identical


    Python - , . - BeyondCompare, Windows, .

  15. #15
    Banned
    Join Date: Oct:2001
    Location: , -5
    Posts: 2,637
    .

  16. #16
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    Quote Originally Posted by exabyte View Post
    .

    , !

  17. #17
    Banned
    Join Date: Oct:2001
    Location: , -5
    Posts: 2,637
    , , , .

  18. #18
    Registered User
    Join Date: Dec:2005
    Location: yvr
    Posts: 5,167
    vici2:/home/names# tail out_exabyte.csv
    GANAPATHIYADANKUNJIKRISHNANNAMPYAR
    ELAMPILATTHAYILEKKANDIAYAMATHKUTTI
    LKKHKLHLKHHJKKHJKJJHNKJJKJKHJKKOIL
    ARINGOTTILLATHNARAYANANNAMPOOTHIRI
    KEEZHARADATHILRAMARAJANVAZHUNNAVAR
    PARIPPATTPUTHIYAPARAMPANKATHEESUMMA
    LALLANAPRATAPAJANAKUNARABAHADURASIN
    BEERENNDRABIKRAMABAHADURASINHABHAHI
    UOOMATAJALANAPAVACHAKHEKAHEERASAYAS
    vici2:/home/names# tail out_pesho.csv
    ZYALPAKER
    ZYANDA
    ZYANVATI
    ZYAUDDEEN
    ZYAUDEEN
    ZYEN
    ZYLOW
    ZYLSING
    ZZAMA
    ZZAMAN
    + , .

  19. #19
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    Quote Originally Posted by ilko View Post
    ...

    /off

    ?
    , !

  20. #20
    Registered User
    Join Date: Dec:2005
    Location: yvr
    Posts: 5,167
    , ,
    - exabyte, .

    A

  21. #21
    Registered User
    Join Date: Oct:2003
    Location:
    Posts: 4,317


    Quote Originally Posted by ilko View Post
    A
    , ?
    ...

  22. #22
    Banned
    Join Date: Oct:2001
    Location: , -5
    Posts: 2,637

  23. #23
    Banned
    Join Date: Aug:2007
    Location: Margate, UK
    Posts: 1,762
    - - -

  24. #24
    Banned
    Join Date: Oct:2001
    Location: , -5
    Posts: 2,637
    , . 8 GB quicksort, swap- , , 8 GB RAM 8 GB swap, -. , .

  25. #25

    Join Date: Apr:2006
    Location:
    Posts: 8,666
    , ...
    - 1 thread ',

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |