Coder Social home page Coder Social logo

muhammad-umaair / hennge-challenge Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 21 KB

This repository contains my solutions to the HENNGE Challenge, a programming challenge hosted by HENNGE. The challenge involves various coding problems that assess skills in algorithms, data structures, and problem-solving.

Python 100.00%

hennge-challenge's Introduction

HENNGE Challenge Solutions

This repository contains my solutions to the HENNGE Challenge, a programming challenge hosted by HENNGE. The challenge involves various coding problems that assess skills in algorithms, data structures, and problem-solving.

Table of Contents

Introduction

This repository includes solutions to challenges posed by HENNGE, demonstrating my programming skills and problem-solving abilities.

Solutions

  1. Mission 1.py: Python script for computing the sum of squares of non-negative integers for multiple test cases.

sum_of_squares_non_negative(nums) Function:

This function takes a list of integers (nums) as input. Initializes a variable total to store the sum of squares of non-negative integers. Iterates through each number in the input list: If the number is non-negative (greater than or equal to zero), it squares the number and adds it to the total. Returns the final total sum.

main() Function:

Takes the number of test cases as input (num_test_cases). Processes each test case: Reads the number of integers in the test case (num_integers). Reads a line of integers, splits it, and converts the input into a list of integers (integers). Calls the sum_of_squares_non_negative() function with the list of integers obtained for the current test case. Prints the result obtained from the sum_of_squares_non_negative() function for each test case.

if name == "main": block:

This block ensures that the main() function is executed when the script is run directly (not when it's imported as a module). Overall, this script reads input data containing test cases, each consisting of a list of integers, computes the sum of squares of non-negative integers for each test case, and prints the result for each case.

image

  1. Mission 3.py:

Imports:

import hashlib: Library for cryptographic hashing functions. import time: Provides various time-related functions. import base64: Deals with Base64 encoding and decoding. import pyotp: Library for generating one-time passwords (OTP). from pyotp.utils import build_uri: Importing a specific function build_uri from pyotp.utils.

Variables Initialization:

secret_key = 'HENNGECHALLENGE003': A secret key used for generating the OTP. msg = '[email protected]': An email address string, likely used as part of the data for OTP generation. key = msg + secret_key: Concatenating the email address and the secret key.

Encoding:

bytearray(key, 'ascii'): Converts the concatenated string key into a byte array using ASCII encoding. base64.b32encode(...): Encodes the byte array into Base32 encoding.

OTP Generation:

pyotp.TOTP(...): Creates a Time-based One-Time Password (TOTP) instance. Parameters: base64.b32encode(...): The encoded key from the previous step. digits=10: Specifies the number of digits in the generated OTP (10 in this case). digest=hashlib.sha512: Specifies the hash function to use (SHA512 in this case). passw = pyotp.TOTP(...) creates an OTP object based on the provided parameters.

Generating OTP:

passwz = passw.now(): Generates the current one-time password using the TOTP object created earlier. Output:

print(passwz): Prints the generated one-time password to the console. time.sleep(5): Pauses the program for 5 seconds. print(passw.verify(passwz)): Verifies if the generated OTP (passwz) is valid at the current time using the passw.verify(...) function. This line prints either True or False based on the OTP's validity.

This code essentially generates a one-time password (OTP) using TOTP based on a secret key and an email address. It then prints the generated OTP and checks its validity after a 5-second delay. The OTP is generated using a combination of the secret key and the email address, and it's validated against the current time.

image

Getting Started

Include instructions on how to get a copy of the project up and running on a local machine.


git clone https://github.com/MuhammadUmaair/HENNGE-Challenge.git
cd hennge-challenge

Contributing

If you'd like to contribute, fork the repository and create a pull request. Contributions are welcome!

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

hennge-challenge's People

Contributors

muhammadumaair avatar

Watchers

 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.