Last active
May 10, 2017 02:11
-
-
Save huylenq/500d601e8d7926da73d05b7be06c298e to your computer and use it in GitHub Desktop.
HackerRank.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "metadata": { | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| } | |
| }, | |
| "cell_type": "markdown", | |
| "source": "# Intro" | |
| }, | |
| { | |
| "metadata": { | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| } | |
| }, | |
| "cell_type": "markdown", | |
| "source": "A small util to automatically tracing of code execution flow" | |
| }, | |
| { | |
| "metadata": {}, | |
| "cell_type": "markdown", | |
| "source": "## 'Features'\n\n- Display function calls chain" | |
| }, | |
| { | |
| "metadata": { | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| }, | |
| "heading_collapsed": true | |
| }, | |
| "cell_type": "markdown", | |
| "source": "## TODO\n\n- Show default value of arguments\n- Interactable result (exp: clicking on the traceline will navigate to the function's definition)\n- Conditional trace (whenever an argument value satisfly some predicates, ...)" | |
| }, | |
| { | |
| "metadata": { | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| }, | |
| "heading_collapsed": true | |
| }, | |
| "cell_type": "markdown", | |
| "source": "# Assets" | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": true, | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| }, | |
| "trusted": true, | |
| "hidden": true | |
| }, | |
| "cell_type": "code", | |
| "source": "from IPython.display import HTML", | |
| "execution_count": 84, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": true, | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| }, | |
| "trusted": true, | |
| "hidden": true | |
| }, | |
| "cell_type": "code", | |
| "source": "def flex(html_str):\n return HTML('<div style=\"display: flex; font-family: Inconsolata\">' + html_str + '</div')", | |
| "execution_count": 277, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": true, | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| }, | |
| "trusted": true, | |
| "hidden": true | |
| }, | |
| "cell_type": "code", | |
| "source": "ICON_HEIGHT = '1em'\n\ndef icon(svg_str):\n return svg_str.replace('<svg ', f'<svg height=\"{ICON_HEIGHT}\" style=\"margin: 2px\"')\n\nin_icon = icon(\"\"\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg version=\"1.1\" id=\"arrowright\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 200 96.0001\" enable-background=\"new 0 0 200 96.0001\" xml:space=\"preserve\">\n<path fill=\"#314E55\" d=\"M198.2656,44.7032l-64-44c-1.2246-0.8418-2.8164-0.9336-4.127-0.2441C128.8223,1.1524,128,2.5137,128,4.0001\n\tv40H0v8h128v40c0,1.4863,0.8223,2.8477,2.1387,3.541c0.584,0.3066,1.2227,0.459,1.8613,0.459c0.7949,0,1.5859-0.2363,2.2656-0.7031\n\tl64-44C199.3516,50.5508,200,49.3165,200,48.0001S199.3516,45.4493,198.2656,44.7032z\"/>\n<polygon fill=\"#EA86A5\" points=\"136,11.6036 183.1213,44.0001 136,44.0001 \"/>\n<polygon fill=\"#EA86A5\" points=\"136,52.0001 183.1213,52.0001 136,84.3966 \"/>\n</svg>\n\"\"\")\n\nout_icon = icon(\"\"\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg version=\"1.1\" id=\"arrowleft\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 200 96.0001\" enable-background=\"new 0 0 200 96.0001\" xml:space=\"preserve\">\n<path fill=\"#314E55\" d=\"M200,44.0001H72v-40c0-1.4863-0.8223-2.8477-2.1387-3.541c-1.3105-0.6895-2.9004-0.5977-4.127,0.2441l-64,44\n\tC0.6484,45.4493,0,46.6837,0,48.0001s0.6484,2.5508,1.7344,3.2969l64,44c0.6797,0.4668,1.4707,0.7031,2.2656,0.7031\n\tc0.6387,0,1.2773-0.1523,1.8613-0.459C71.1777,94.8477,72,93.4864,72,92.0001v-40h128V44.0001z\"/>\n<polygon fill=\"#73C9C9\" points=\"64,44.0001 16.8787,44.0001 64,11.6036 \"/>\n<polygon fill=\"#73C9C9\" points=\"64,84.3966 16.8787,52.0001 64,52.0001 \"/>\n</svg>\n\"\"\")\n\nicon_circledown = icon(\"\"\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg id=\"circledown\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 216 216\" enable-background=\"new 0 0 216 216\" xml:space=\"preserve\">\n<g>\n\t<path fill=\"#314E55\" d=\"M108,0C48.4492,0,0,48.4492,0,108s48.4492,108,108,108s108-48.4492,108-108S167.5508,0,108,0z\"/>\n\t<path fill=\"#E65F58\" d=\"M108,208C52.8594,208,8,163.1406,8,108S52.8594,8,108,8s100,44.8594,100,100S163.1406,208,108,208z\"/>\n\t<path fill=\"#314E55\" d=\"M147.1719,92.6035L108,131.7754L68.8281,92.6035c-1.5625-1.5625-4.0938-1.5625-5.6562,0\n\t\ts-1.5625,4.0938,0,5.6562l42,42c0.7812,0.7812,1.8047,1.1719,2.8281,1.1719s2.0469-0.3906,2.8281-1.1719l42-42\n\t\tc1.5625-1.5625,1.5625-4.0938,0-5.6562S148.7344,91.041,147.1719,92.6035z\"/>\n</g>\n</svg>\n\"\"\")\n\nicon_circleup = icon(\"\"\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg version=\"1.1\" id=\"circleup\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 216 216\" enable-background=\"new 0 0 216 216\" xml:space=\"preserve\">\n<g>\n\t<path fill=\"#314E55\" d=\"M108,0C48.4492,0,0,48.4492,0,108s48.4492,108,108,108s108-48.4492,108-108S167.5508,0,108,0z\"/>\n\t<path fill=\"#5ECB66\" d=\"M108,208C52.8594,208,8,163.1406,8,108S52.8594,8,108,8s100,44.8594,100,100S163.1406,208,108,208z\"/>\n\t<path fill=\"#314E55\" d=\"M110.8281,75.7402c-1.5625-1.5625-4.0938-1.5625-5.6562,0l-42,42c-1.5625,1.5625-1.5625,4.0938,0,5.6562\n\t\ts4.0938,1.5625,5.6562,0L108,84.2246l39.1719,39.1719c0.7812,0.7812,1.8047,1.1719,2.8281,1.1719s2.0469-0.3906,2.8281-1.1719\n\t\tc1.5625-1.5625,1.5625-4.0938,0-5.6562L110.8281,75.7402z\"/>\n</g>\n</svg>\n\"\"\")\n\nicon_forward = icon(\"\"\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg version=\"1.1\" id=\"forward\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 156 191.9985\" enable-background=\"new 0 0 156 191.9985\" xml:space=\"preserve\">\n<g>\n\t<path fill=\"#314E55\" d=\"M155.2148,93.6216l-68-92c-1.0195-1.3887-2.8281-1.959-4.4648-1.4219C81.1094,0.7407,80,2.272,80,3.9985\n\t\tv184c0,1.7266,1.1094,3.2578,2.75,3.7988c0.4102,0.1367,0.832,0.2012,1.25,0.2012c1.2461,0,2.4492-0.582,3.2148-1.623l68-92\n\t\tC156.2617,96.9634,156.2617,95.0337,155.2148,93.6216z\"/>\n\t<polygon fill=\"#E9E7D1\" points=\"88,175.8579 88,16.1392 147.0273,95.9985 \t\"/>\n\t<path fill=\"#314E55\" d=\"M7.2148,1.6216C6.1914,0.2329,4.3867-0.3374,2.75,0.1997C1.1094,0.7407,0,2.272,0,3.9985v184\n\t\tc0,1.7266,1.1094,3.2578,2.75,3.7988c0.4102,0.1367,0.832,0.2012,1.25,0.2012c1.2461,0,2.4492-0.582,3.2148-1.623l68-92\n\t\tc1.0469-1.4121,1.0469-3.3418,0-4.7539L7.2148,1.6216z\"/>\n\t<polygon fill=\"#E9E7D1\" points=\"8,175.8579 8,16.1392 67.0273,95.9985 \t\"/>\n</g>\n</svg>\n\"\"\")\n\nicon_rightway = icon(\"\"\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg version=\"1.1\" id=\"rightway\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 208 155.9996\" enable-background=\"new 0 0 208 155.9996\" xml:space=\"preserve\">\n<path fill=\"#314E55\" d=\"M206.5742,74.939l-88-74c-1.1914-1.002-2.8555-1.2207-4.2617-0.5664C112.9023,1.0308,112,2.4449,112,3.9996\n\tV37.943L11.2188,54.7418C4.9258,55.7906,0,61.609,0,67.9879v20.0215c0,6.377,4.9258,12.1973,11.2188,13.248L112,118.0543v33.9453\n\tc0,1.5547,0.9023,2.9688,2.3125,3.627c0.5391,0.25,1.1133,0.373,1.6875,0.373c0.9258,0,1.8398-0.3203,2.5742-0.9395l88-74\n\tC207.4766,80.3004,208,79.1812,208,77.9996S207.4766,75.6988,206.5742,74.939z\"/>\n<path fill=\"#EA86A5\" d=\"M120,143.4097v-28.7441c0-1.9551-1.4141-3.625-3.3438-3.9453L12.5352,93.3668\n\tC10.1172,92.9625,8,90.4605,8,88.0094V67.9879c0-2.4512,2.1172-4.9531,4.5312-5.3555l104.125-17.3555\n\tC118.5859,44.9566,120,43.2867,120,41.3316V12.5894l77.7852,65.4102L120,143.4097z\"/>\n</svg>\n\"\"\")\n\nicon_right = icon(\"\"\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg version=\"1.1\" id=\"right\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 102.5097 193.0192\" enable-background=\"new 0 0 102.5097 193.0192\" xml:space=\"preserve\">\n<path fill=\"#8F89F5\" d=\"M100.752,92.2677l-90.51-90.51c-2.3436-2.3436-6.1404-2.3436-8.484,0c-2.344,2.342-2.344,6.1428,0,8.4844\n\tl86.2672,86.2676L1.758,182.7772c-2.344,2.3416-2.344,6.1425,0,8.4845c1.1716,1.1719,2.7068,1.7575,4.242,1.7575\n\ts3.0704-0.5856,4.242-1.7575l90.51-90.5101C103.0956,98.41,103.0956,94.6093,100.752,92.2677z\"/>\n</svg>\n\"\"\")", | |
| "execution_count": 260, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| } | |
| }, | |
| "cell_type": "markdown", | |
| "source": "# Implementation" | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": true, | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| }, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "import pdb", | |
| "execution_count": 1, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| }, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "import sys\nsys.version", | |
| "execution_count": 101, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": "'3.6.0 (default, Jan 19 2017, 18:01:19) \\n[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]'" | |
| }, | |
| "execution_count": 101, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ] | |
| }, | |
| { | |
| "metadata": { | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| }, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "import inspect\nfrom IPython.display import display, Markdown\n\nTRACE = True\nSEP = '<span>	</span>'\n\ncall_level = -1\ndef pushed():\n global call_level\n call_level += 1\ndef popped():\n global call_level\n call_level -= 1\n\ndef arg_kv(frame):\n args, _, _, values = inspect.getargvalues(frame)\n arg_items = [(arg, values[arg]) for arg in args]\n return arg_items\n\ndef _format_args(arg_items):\n return '<span>' + \", \".join([\"{}=<code>{}</code>\".format(*arg_item) for arg_item in arg_items]) + '</span>'\n\ndef extract_frame(down_stack_level = 1):\n calling_frame = inspect.currentframe().f_back\n for _ in range(down_stack_level):\n calling_frame = calling_frame.f_back\n caller = inspect.getframeinfo(calling_frame).function\n args, _, _, values = inspect.getargvalues(calling_frame)\n arg_items = [(arg, values[arg]) for arg in args]\n return (caller, arg_items)\n\ndef print_frame(down_stack_level = 1):\n if not TRACE: return\n caller, arg_items = extract_frame(down_stack_level = down_stack_level)\n display(Markdown(\"▷ {}({})\".format(caller, _format_args(arg_items))))\n\ndef introspect(capture=\"inout\"):\n def decorator(func):\n def introspected(*args, **kwargs):\n pushed()\n arg_items = list(zip(func.__code__.co_varnames, args))\n kwvars = func.__code__.co_varnames[len(arg_items):]\n for kwvar in kwvars:\n arg_items.append((kwvar, kwargs[kwvar]))\n if \"in\" in capture:\n display(flex(f\"{' '*2*call_level}{icon_circledown} {func.__name__}({_format_args(arg_items)})\"))\n result = func(*args, **kwargs)\n if \"out\" in capture:\n display(flex(f'{\" \"*2*call_level}{icon_circleup} {func.__name__}({_format_args(arg_items)}) <span style=\"margin: auto 4px\">{icon_right}</span> <code>{result}</code>'))\n popped()\n return result\n return introspected\n return decorator", | |
| "execution_count": 442, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": {}, | |
| "cell_type": "markdown", | |
| "source": "# Test out" | |
| }, | |
| { | |
| "metadata": { | |
| "run_control": { | |
| "frozen": false, | |
| "read_only": false | |
| }, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "@introspect(\"out\")\ndef increment(base):\n return base * 2\n\n@introspect()\ndef inc(x):\n return x + increment(x)\n\ninc(1)", | |
| "execution_count": 443, | |
| "outputs": [ | |
| { | |
| "output_type": "display_data", | |
| "data": { | |
| "text/plain": "<IPython.core.display.HTML object>", | |
| "text/html": "<div style=\"display: flex; font-family: Inconsolata\">\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg height=\"1em\" style=\"margin: 2px\"id=\"circledown\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 216 216\" enable-background=\"new 0 0 216 216\" xml:space=\"preserve\">\n<g>\n\t<path fill=\"#314E55\" d=\"M108,0C48.4492,0,0,48.4492,0,108s48.4492,108,108,108s108-48.4492,108-108S167.5508,0,108,0z\"/>\n\t<path fill=\"#E65F58\" d=\"M108,208C52.8594,208,8,163.1406,8,108S52.8594,8,108,8s100,44.8594,100,100S163.1406,208,108,208z\"/>\n\t<path fill=\"#314E55\" d=\"M147.1719,92.6035L108,131.7754L68.8281,92.6035c-1.5625-1.5625-4.0938-1.5625-5.6562,0\n\t\ts-1.5625,4.0938,0,5.6562l42,42c0.7812,0.7812,1.8047,1.1719,2.8281,1.1719s2.0469-0.3906,2.8281-1.1719l42-42\n\t\tc1.5625-1.5625,1.5625-4.0938,0-5.6562S148.7344,91.041,147.1719,92.6035z\"/>\n</g>\n</svg>\n inc(<span>x=<code>1</code></span>)</div" | |
| }, | |
| "metadata": {} | |
| }, | |
| { | |
| "output_type": "display_data", | |
| "data": { | |
| "text/plain": "<IPython.core.display.HTML object>", | |
| "text/html": "<div style=\"display: flex; font-family: Inconsolata\"> \n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg height=\"1em\" style=\"margin: 2px\"version=\"1.1\" id=\"circleup\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 216 216\" enable-background=\"new 0 0 216 216\" xml:space=\"preserve\">\n<g>\n\t<path fill=\"#314E55\" d=\"M108,0C48.4492,0,0,48.4492,0,108s48.4492,108,108,108s108-48.4492,108-108S167.5508,0,108,0z\"/>\n\t<path fill=\"#5ECB66\" d=\"M108,208C52.8594,208,8,163.1406,8,108S52.8594,8,108,8s100,44.8594,100,100S163.1406,208,108,208z\"/>\n\t<path fill=\"#314E55\" d=\"M110.8281,75.7402c-1.5625-1.5625-4.0938-1.5625-5.6562,0l-42,42c-1.5625,1.5625-1.5625,4.0938,0,5.6562\n\t\ts4.0938,1.5625,5.6562,0L108,84.2246l39.1719,39.1719c0.7812,0.7812,1.8047,1.1719,2.8281,1.1719s2.0469-0.3906,2.8281-1.1719\n\t\tc1.5625-1.5625,1.5625-4.0938,0-5.6562L110.8281,75.7402z\"/>\n</g>\n</svg>\n increment(<span>base=<code>1</code></span>) <span style=\"margin: auto 4px\">\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg height=\"1em\" style=\"margin: 2px\"version=\"1.1\" id=\"right\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 102.5097 193.0192\" enable-background=\"new 0 0 102.5097 193.0192\" xml:space=\"preserve\">\n<path fill=\"#8F89F5\" d=\"M100.752,92.2677l-90.51-90.51c-2.3436-2.3436-6.1404-2.3436-8.484,0c-2.344,2.342-2.344,6.1428,0,8.4844\n\tl86.2672,86.2676L1.758,182.7772c-2.344,2.3416-2.344,6.1425,0,8.4845c1.1716,1.1719,2.7068,1.7575,4.242,1.7575\n\ts3.0704-0.5856,4.242-1.7575l90.51-90.5101C103.0956,98.41,103.0956,94.6093,100.752,92.2677z\"/>\n</svg>\n</span> <code>2</code></div" | |
| }, | |
| "metadata": {} | |
| }, | |
| { | |
| "output_type": "display_data", | |
| "data": { | |
| "text/plain": "<IPython.core.display.HTML object>", | |
| "text/html": "<div style=\"display: flex; font-family: Inconsolata\">\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg height=\"1em\" style=\"margin: 2px\"version=\"1.1\" id=\"circleup\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 216 216\" enable-background=\"new 0 0 216 216\" xml:space=\"preserve\">\n<g>\n\t<path fill=\"#314E55\" d=\"M108,0C48.4492,0,0,48.4492,0,108s48.4492,108,108,108s108-48.4492,108-108S167.5508,0,108,0z\"/>\n\t<path fill=\"#5ECB66\" d=\"M108,208C52.8594,208,8,163.1406,8,108S52.8594,8,108,8s100,44.8594,100,100S163.1406,208,108,208z\"/>\n\t<path fill=\"#314E55\" d=\"M110.8281,75.7402c-1.5625-1.5625-4.0938-1.5625-5.6562,0l-42,42c-1.5625,1.5625-1.5625,4.0938,0,5.6562\n\t\ts4.0938,1.5625,5.6562,0L108,84.2246l39.1719,39.1719c0.7812,0.7812,1.8047,1.1719,2.8281,1.1719s2.0469-0.3906,2.8281-1.1719\n\t\tc1.5625-1.5625,1.5625-4.0938,0-5.6562L110.8281,75.7402z\"/>\n</g>\n</svg>\n inc(<span>x=<code>1</code></span>) <span style=\"margin: auto 4px\">\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg height=\"1em\" style=\"margin: 2px\"version=\"1.1\" id=\"right\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 102.5097 193.0192\" enable-background=\"new 0 0 102.5097 193.0192\" xml:space=\"preserve\">\n<path fill=\"#8F89F5\" d=\"M100.752,92.2677l-90.51-90.51c-2.3436-2.3436-6.1404-2.3436-8.484,0c-2.344,2.342-2.344,6.1428,0,8.4844\n\tl86.2672,86.2676L1.758,182.7772c-2.344,2.3416-2.344,6.1425,0,8.4845c1.1716,1.1719,2.7068,1.7575,4.242,1.7575\n\ts3.0704-0.5856,4.242-1.7575l90.51-90.5101C103.0956,98.41,103.0956,94.6093,100.752,92.2677z\"/>\n</svg>\n</span> <code>3</code></div" | |
| }, | |
| "metadata": {} | |
| }, | |
| { | |
| "output_type": "execute_result", | |
| "execution_count": 443, | |
| "data": { | |
| "text/plain": "3" | |
| }, | |
| "metadata": {} | |
| } | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "_draft": { | |
| "nbviewer_url": "https://gist.github.com/500d601e8d7926da73d05b7be06c298e" | |
| }, | |
| "gist": { | |
| "id": "500d601e8d7926da73d05b7be06c298e", | |
| "data": { | |
| "description": "HackerRank.ipynb", | |
| "public": true | |
| } | |
| }, | |
| "kernelspec": { | |
| "name": "python3", | |
| "display_name": "Python 3", | |
| "language": "python" | |
| }, | |
| "language_info": { | |
| "name": "python", | |
| "version": "3.6.0", | |
| "mimetype": "text/x-python", | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "pygments_lexer": "ipython3", | |
| "nbconvert_exporter": "python", | |
| "file_extension": ".py" | |
| }, | |
| "toc": { | |
| "toc_cell": false, | |
| "toc_number_sections": false, | |
| "toc_threshold": 4, | |
| "toc_window_display": false | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 1 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment