GithubHelp home page GithubHelp logo

kaprekarsnumber's People

Watchers

 avatar

kaprekarsnumber's Issues

Find loops

Some digit spaces don't only have Kaprekar's numbers, but also loops.

Find a good way to visualise the flow of Kaprekar operations

Code for inspiration. It draws a tree using purely packages packed with Python 2.

from turtle import *
from types import *

myTree = ["A",["B",["C",["D","E"],"F"],"G","H"]];
s = 50;
startpos = (0,120)
def cntstrs(list):
    return len([item for item in list if type(item) is StringType])
def drawtree(tree, pos, head=0):
    c = cntstrs(tree)
    while len(tree):
        goto(pos)
        item = tree.pop(0)
        if head:
            write(item,1)
            drawtree(tree.pop(0),pos)
        else:
            if type(item) is StringType:
                newpos = (pos[0] + s*c/4 - s*cntstrs(tree), pos[1] - s)
                down()
                goto((newpos[0], newpos[1] + 15))
                up()
                goto(newpos)
                write(item,1)
            elif type(item) is ListType:
                drawtree(item,newpos)

up()
drawtree(myTree, startpos,1)

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.