GithubHelp home page GithubHelp logo

topn's Introduction

topn

topn finds top N numbers in a file

Task

Write a program, topN, that given an arbitrarily large file and a number, N, containing individual numbers on each line (e.g. 200Gb file), will output the largest N numbers, highest first.

Install

Usage

Generate file

topn generate --lines N --name filename - generate file with N lines of random numbers.

Find the top N of largest numbers

topn run --file filename --top N

Example

  • Generate file numbers.txt with 1000 lines of random numbers
./topn generate --name numbers.txt --lines 1000
File numbers.txt with 1000 lines of random numbers was successfully generated!
  • Find top 5 largest numbers in file numbers.txt
./topn run --file numbers.txt --top 5
[9219151525891662339 9215619702456294450 9207997407084704522 9207450753580197605 9173624551887931713]

Test

go test -cover -v ./...
?   	github.com/mxssl/topn	[no test files]
=== RUN   TestCase1
expected:  [100 90 80 70 60]
output:  [100 90 80 70 60]
--- PASS: TestCase1 (0.00s)
PASS
coverage: 42.3% of statements
ok  	github.com/mxssl/topn/cmd	0.260s	coverage: 42.3% of statements

topn's People

Contributors

mxssl avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.