Giter Site home page Giter Site logo

cubes's Introduction

cubes

Build Status

Some experiments with numbers that are cubes

How to use this?

Satisfy Dependencies

Following are essential:

It is recommended to also use the following for experimenting with the source code:

Get the source and artifacts from Github

  1. git clone https://github.com/cganoo/cubes.git
  2. cd cubes/

Run Unit Tests

  1. gradle check
  2. gradle test -i
  3. A nice html page showing unit test results will be available at ./build/reports/tests/index.html

Highlights

  • Application description: A stand-alone scala app
  • Build and Dependency management: Gradle is used for this
  • Algorithms used: See below
  • Unit Tests: A few representative Junit4 unit tests are included.

Notes on algorithms used

Find smallest cube for which exactly k permutations of its digits are cubes

  • Finding cuberoots is more difficult than finding cubes
  • So we can memoize and start calculating cubes of all numbers from 1 to some upper limit
  • For each such cube that we calculate, the digits that constitute it can be used for identifying permutations
  • CodePoint identification: Compute histogram for digits 0-9 and the resulting number is the codepoint. For example: codePoint(1252) = 0120010000
  • FingerPrint identification: Sort the digits. For example: fingerprint(1225L) = 1225
  • Leverage the cache used for memoizing to maintain cubes that yield the same codePoint/fingerPrint
  • Scan the cache to find desired length groups of cubes and return smallest amongst them
  • Upper limits are heuristics. For example for k = 3, an upper limit of 1000 is ok to find smallest cube (345).

License

cubes is licensed under the MIT license. It is primarily intended for fun and instructive purposes. Use this at your own risk.

Author

Chaitanya Ganoo www.linkedin.com/in/cganoo

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.