CINXE.COM

Paste code - paste.org

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="description" content="www.paste.org - allows users to paste snippets of text, usually samples of source code, for public viewing. A place where lack of code gets binned; sharing code iterations since 2006."><meta name="author" content="An Australian"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="manifest" href="/site.webmanifest"><title>Paste code - paste.org</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.9.1/font/bootstrap-icons.min.css" integrity="sha512-5PV92qsds/16vyYIJo3T/As4m2d8b6oWYfoqV+vtizRB6KhF1F9kYzWzQmsO6T3z3QG2Xdhrx7FQ+5R1LiQdUA==" crossorigin="anonymous" referrerpolicy="no-referrer"/><link href="/assets/themes/bleh/css/bootstrap.css" rel="stylesheet"><link href="/assets/themes/bleh/css/ie10-viewport-bug-workaround.css" rel="stylesheet"><link rel="stylesheet" href="/assets/themes/bleh/css/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen"><link href="/assets/themes/bleh/css/bleh-template.css" rel="stylesheet"><link href="/assets/themes/bleh/css/social.css" rel="stylesheet"><link href="/assets/themes/bleh/css/font-awesome.css" rel="stylesheet"><script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css"><script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script><script src="/assets/themes/bleh/js/highlightjs-line-numbers.min.js"></script><script src="/assets/themes/bleh/js/jquery.fancybox.pack.js?v=2.1.5"></script><script>hljs.initHighlightingOnLoad(); hljs.initLineNumbersOnLoad();</script><!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]--><script src="/assets/themes/bleh/js/ie-emulation-modes-warning.js"></script><!--[if lt IE 9]><script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script><script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]--><style>div.g-recaptcha, div.g-recaptcha div { padding: 0px; margin: 0px; }</style><script>$(document).ready(function() { $("a.fancybox").fancybox({ maxWidth : 820, maxHeight : 620, fitToView : false, width : '70%', height : '70%', autoSize : true, closeClick : true, openEffect : 'none', closeEffect : 'none' }); });</script><link rel=”canonical” href=”https://www.paste.org/63424”><script src="https://challenges.cloudflare.com/turnstile/v0/api.js" defer></script></head><body><nav class="navbar navbar-inverse navbar-fixed-top"><div class="container"><div class="navbar-header"><button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a href="/p/home"><img src="/assets/themes/bleh/images/paste-org-paste-code-logo.png" alt="Paste Code @ paste.org"></a></div><div id="navbar" class="collapse navbar-collapse"><ul class="nav navbar-nav"><li><a href="/p/home">Home</a></li><li><a href="/p/donate">Donate</a></li><li><a href="https://www.paste.org/p/redirect/blog-illawarra">Blog of Things</a></li><li><a href="https://www.paste.org/p/redirect/sams-tunes">Tunes</a></li><li><a href="/p/poll">Poll</a></li><li><a href="/p/people">People</a></li><li><a href="/p/trending">Trending</a></li><li><a href="/p/random/paste">Random</a></li><li><a href="/p/stats">Stats</a></li><li><a href="/p/contact">Contact</a></li></ul></div></div></nav><div class="container"><div class="content"><div class="row"><div class="col-md-12 col-sm-12 col-xs-12 text-center">Welcome, guest! <a href="/auth/login">Login</a> / <a href="/auth/register">Register</a> - <a href="/p/registration-benefits">Why register</a>?</div></div><div class="row"><div class="col-md-12 text-center hidden-sm hidden-xs"><span class="dot"></span> Pastes: 128903 <span class="dot"></span> Members: 9381 <span class="dot"></span> Social: 894 <span class="dot"></span></div><div class="col-md-12 text-center alert_success">Psst.. new poll <a target="_blank" href="https://www.paste.org/p/poll">here</a>.</div><div class="col-md-12 text-center alert_success"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84fdebf1c4f4e5f7f0e1aaebf6e3">[email&#160;protected]</a> web/email now available. Want one? Go <a target="_blank" href="https://www.paste.org/p/redirect/kray-vanity-domain-webmail">here</a>.</div><div class="col-md-12 text-center alert_fail">Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez</div><div class="col-md-12 text-center alert_quote">Obey the <a target="_blank" href="https://www.paste.org/p/redirect/epel">Epel</a>!</div></div><h2>Paste</h2><div class="row"><div class="col-md-12 text-center hidden-xs"><div class="container"><ul class="ss-share"><li class="ss-share-item"><a class="ss-share-link ico-paste" href="https://www.paste.org/flat/63424">Plain view</a></li><li class="ss-share-item"><a class="ss-share-link ico-paste" href="/63424#code">Edit code</a></li><li class="ss-share-item"><a class="ss-share-link ico-paste" href="/flatcode/63424">Add this to your website</a></li><li class="ss-share-item"><a class="ss-share-link ico-paste" href="/p/abuse/63424">Report abuse</a></li></ul></div></div><div class="col-md-12 text-center"><div class="container"><ul class="ss-share"><li class="ss-share-item"><a class="ss-share-link ico-facebook" href="https://www.facebook.com/sharer.php?u=http://goo.gl/S9Ujl" rel="nofollow" target="_blank">Share on Facebook</a></li><li class="ss-share-item"><a class="ss-share-link ico-twitter" href="https://twitter.com/share?text=Pasteorg&amp;url=http://goo.gl/S9Ujl" rel="nofollow" target="_blank">Share on Twitter</a></li><li class="ss-share-item"><a class="ss-share-link ico-reddit" href="http://reddit.com/submit?url=http://goo.gl/S9Ujl" rel="nofollow" target="_blank">Share on Reddit</a></li></ul></div></div><div class="col-md-12">Pasted as Python by nrg ( 12 years ago )</div><div class="col-md-12"><pre><code class="python">#!/usr/bin/env python # -*- coding: utf-8 -*- import sys current_word = None current_count = 0 word = None for line in sys.stdin: line = line.strip() (word, count) = line.split('\t', 1) count = int(count) # Так как Hadoop сортирует выдачу вывода mapper.py, то данные пиходят к нам в отсортированном порядке if current_word == word: current_count += count else: # Если слово поменялось, то выводим результаты предыдущего подсчета if current_word: print '%s\t%s' % (current_word, current_count) current_word = word current_count = count # В конце цикла нужно вывести результаты подсчета if current_word == word: print '%s\t%s' % (current_word, current_count)</code></pre></div><p>&nbsp;</p><h2>Revise this Paste</h2><div class="row"><form action="https://www.paste.org/63424" class="form-inline text-center" method="post" accept-charset="utf-8"><div class="col-md-12 text-center">Your Name: <input class="form-control" name="username" value=""> Code Language: <select name="language" class="form-control"><option value="">Choose</option><option value="nohighlight">Plain Text</option><option value="cpp">C++</option><option value="html">HTML</option><option value="c">C</option><option value="java">Java</option><option value="bash">Bash</option><option value="python" selected="selected">Python</option><option value="php">PHP</option><option value="javascript">JavaScript</option><option value="csharp">C#</option><option value="sql">SQL</option><option value="xml">XML</option><option value="css">CSS</option><option value="">-------</option><option value="accesslog">Access logs</option><option value="actionscript">ActionScript</option><option value="apache">Apache</option><option value="applescript">AppleScript</option><option value="arm">ARM assembler</option><option value="asciidoc">AsciiDoc</option><option value="aspectj">AspectJ</option><option value="autohotkey">AutoHotkey</option><option value="autoit">AutoIt</option><option value="avrasm">AVR assembler</option><option value="axapta">Axapta</option><option value="brainfuck">Brainfuck</option><option value="cal">C/AL</option><option value="cos">Cache Object Script</option><option value="capnproto">Cap’n Proto</option><option value="clojure">Clojure</option><option value="cmake">CMake</option><option value="coffeescript">CoffeeScript</option><option value="crmsh">Crmsh</option><option value="crystal">Crystal</option><option value="d">D</option><option value="dart">Dart</option><option value="delphi">Delphi</option><option value="diff">Diff</option><option value="django">Django</option><option value="dns">DNS Zone file</option><option value="dockerfile">Dockerfile</option><option value="dos">DOS</option><option value="dust">Dust</option><option value="elixir">Elixir</option><option value="elm">Elm</option><option value="erlang">Erlang</option><option value="fsharp">F#</option><option value="fix">FIX</option><option value="fortran">Fortran</option><option value="gcode">G-Code</option><option value="gams">Gams</option><option value="gherkin">Gherkin</option><option value="go">Go</option><option value="golo">Golo</option><option value="gradle">Gradle</option><option value="groovy">Groovy</option><option value="haml">Haml</option><option value="handlebars">Handlebars</option><option value="haskell">Haskell</option><option value="haxe">Haxe</option><option value="http">HTTP</option><option value="inform7">Inform7</option><option value="ini">Ini</option><option value="irpf90">IRPF90</option><option value="json">JSON</option><option value="lasso">Lasso</option><option value="less">Less</option><option value="lisp">Lisp</option><option value="livecodeserver">LiveCode Server</option><option value="livescript">LiveScript</option><option value="lua">Lua</option><option value="makefile">Makefile</option><option value="markdown">Markdown</option><option value="mathematica">Mathematica</option><option value="matlab">Matlab</option><option value="mel">Maya Embedded language</option><option value="mercury">Mercury</option><option value="mizar">Mizar</option><option value="mojolicious">Mojolicious</option><option value="monkey">Monkey</option><option value="nginx">Nginx</option><option value="nimrod">Nimrod</option><option value="nix">Nix</option><option value="nsis">NSIS</option><option value="objectivec">Objective C</option><option value="ocaml">OCaml</option><option value="glsl">OpenGL Shading language</option><option value="openscad">OpenSCAD</option><option value="ruleslanguage">Oracle Rules language</option><option value="oxygene">Oxygene</option><option value="parser3">Parser3</option><option value="perl">Perl</option><option value="pf">PF</option><option value="powershell">PowerShell</option><option value="processing">Processing</option><option value="prolog">Protocol Buffers</option><option value="protobuf">Protocol Buffers</option><option value="puppet">Puppet</option><option value="profile">Python profiler results</option><option value="k">Q</option><option value="r">R</option><option value="rib">RenderMan RIB</option><option value="rsl">RenderMan RSL</option><option value="graph">Roboconf</option><option value="ruby">Ruby</option><option value="rust">Rust</option><option value="scala">Scala</option><option value="scheme">Scheme</option><option value="scilab">Scilab</option><option value="scss">SCSS</option><option value="smali">Smali</option><option value="smalltalk">Smalltalk</option><option value="stata">Stata</option><option value="p21">STEP Part 21</option><option value="stylus">Stylus</option><option value="swift">Swift</option><option value="tcl">Tcl</option><option value="tex">TeX</option><option value="thrift">Thrift</option><option value="tp">TP</option><option value="twig">Twig</option><option value="typescript">TypeScript</option><option value="vala">Vala</option><option value="vbnet">VB.Net</option><option value="vbscript">VBScript</option><option value="verilog">Verilog</option><option value="vhdl">VHDL</option><option value="vim">Vim Script</option><option value="x86asm">x86 Assembly</option><option value="xl">XL</option><option value="xpath">XQuery</option><option value="zephir">Zephir</option></select></div><div class="col-md-12"><a name="code">&nbsp;</a><textarea style="width:100%;height:300px;" class="form-control" name="content">#!/usr/bin/env python # -*- coding: utf-8 -*- import sys current_word = None current_count = 0 word = None for line in sys.stdin: line = line.strip() (word, count) = line.split('\t', 1) count = int(count) # Так как Hadoop сортирует выдачу вывода mapper.py, то данные пиходят к нам в отсортированном порядке if current_word == word: current_count += count else: # Если слово поменялось, то выводим результаты предыдущего подсчета if current_word: print '%s\t%s' % (current_word, current_count) current_word = word current_count = count # В конце цикла нужно вывести результаты подсчета if current_word == word: print '%s\t%s' % (current_word, current_count)</textarea></div><div class="col-md-12 text-center"><div style="display:inline-block;"><div name="cf-turnstile-response" class="cf-turnstile" data-sitekey="0x4AAAAAABAmNFa-_xeKVSFv"></div></div></div><div class="col-md-12 text-center"></div><div class="col-md-12 text-center"><input type="submit" class="btn btn-success btn-sm" value="Paste Code"></div></form></div></div><p>&nbsp;</p></div></div><div id="footer"><p style="text-align:center!important;font-size:71%;">Content owned by respective Author; else Copyright 2006-2021 Paste Code &#64; www.paste.org and <a target="_blank" href="https://www.paste.org/p/redirect/kray" rel="dofollow">Kray</a> | <a href="https://www.paste.org/p/privacy-policy" rel="dofollow">Privacy Policy</a> | <a href="https://www.paste.org/p/terms-of-service" rel="dofollow">Terms of Service</a></p></div><script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script><script src="/assets/themes/bleh/js/jquery.easing.min.js"></script><script src="/assets/themes/bleh/js/scrolling-nav.js"></script><script src="/assets/themes/bleh/js/ie10-viewport-bug-workaround.js"></script></body></html>

Pages: 1 2 3 4 5 6 7 8 9 10