Coder Social home page Coder Social logo

pow-problem's Introduction

Avento Blockchain Validation

Problem Statement:

Welcome to the world of AventoBlockchain, a new-age digital ledger system. Your task is to implement a simplified version of a Proof of Work (PoW) algorithm, crucial for maintaining the integrity of the AventoBlockchain. The AventoBlockchain employs a unique validation mechanism for adding new blocks, known as the "Avento Hash Challenge" (AHC).

In the AHC, each block contains a string "S", an integer "N", and a mystery number "X". To successfully mine (add) a block to the AventoBlockchain, you must find the smallest positive integer X such that when X is appended to S and hashed using a special AventoHash function, the resulting hash string begins with exactly N leading zeroes.

Input Format:

  • The JSON file called "input.json" contains an array of JSON objects, each representing a test case. Each test case is a JSON object with two keys, "S" and "N", corresponding to the string S and integer N, respectively.

Constraints:

  • S consists of alphanumeric characters (both lowercase and uppercase).
  • 0 ≤ N ≤ 5

Output Format:

For each test case, output a single line containing the smallest positive integer X that solves the Avento Hash Challenge for the given S and N.

Sample Input:

[
    {
        "S": "274873082711-0x3dc1d85dffc6fea2fbce4703bf03428f1be11409-634913674699",
        "N": 1
    },
    {
        "S": "761235837059-0x124d627b287054d022213f718b747acca27794ef-300773947541",
        "N": 4
    }
]

Sample Output:

Transaction 1 is valid
Transaction 2 is valid

pow-problem's People

Contributors

hamzatrq 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.