Coder Social home page Coder Social logo

ezpzprogcomp's Introduction

EzpzProgComp

This repo will not have much explanation but will be use to store any tricks and solutions for any programing questions whether local or international events.

I want to improve on different programming languages, so this repo would have different solutions consists of:

  • Python
  • C++
  • Node JS
  • Rust (Hopefully)

Python

# Input
arr = [int(x) for x in input().split()]
x,y = map(int,input().split())
x = int(input())
M = list(map(int,input().split()))

# One Liner
print("boleh") if (x % 2 == 0) and (x > 5) else print("tidak boleh")
for i in range(10): print(i)
for i in range(int(input())): print(sum([int(digits) for digits in input()]))

# Sort List & Sum (Top 5)
sum(sorted(M)[-5:])

# Floor Div
x = 6 // 4

# BinaryToDecimal
def binaryToDecimal(n):
    return int(n,2)
print(binaryToDecimal("111"))


# Sum
print(sum([int(digits) for digits in input()]))

# Format
print("%.2f" % (Y-X-0.5)) # 10.00
print("{0:.2f}".format(Y)) # 1.50
print("%.2f AND %.2f" % (X,Y)) # 0.50 AND 0.20

# Multiple of all values in a list
from functools import reduce
A = [1, 2, 3] 
print(reduce((lambda x, y: x * y), A))

# Check Whole Number
if i % 1 == 0:
    print(int(i)) # 1.5
else:
    print(i) # 1

# Groupby 
# Examples => "AAAAABBBBCCCCCDDDDAAAABBBB"
import itertools
for letter, _ in itertools.groupby(inputs):
    print(letter)

# Count Number of Factors
#====Example(1)=====
from functools import reduce
def printDivisors(n) :
    i = 1
    sum = 0
    while i <= n :
        if (n % i==0) :
            sum += 1
        i = i + 1
    return sum
print(printDivisors(100))
#====Example(2)====
import math
def printDivisors(n) :
    list = []
    count = 0
    # List to store half of the divisors
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) :
            # Check if divisors are equal
            if (n / i == i) :
                count += 1
            else :
                # Otherwise print both
                count += 1
                list.append(int(n / i))
                 
    # The list will be printed in reverse   
    for i in list[::-1] :
        count += 1
    return count
print(printDivisors(100))
#====Example(3)====
from functools import reduce
def printDivisors(n):    
    return len(set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
print(printDivisors(100))

C++

Java

Node js

# Input (Define1)
// Define Input
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

# Input (Define2)
process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});


# Input Usage
const n = parseInt(readLine());

# Assign (Split)
var arr = input.split("\n");
var [x1,y1] = Object.values(arr)[0].split(" ").map(Number);
var [x2,y2] = Object.values(arr)[1].split(" ").map(Number);

# Convert
B.toString()

# One Liner
((x % 2 == 0) && (x > 5)) ? process.stdout.write("boleh") : process.stdout.write("tidak boleh");

References

#==Python==
- https://gist.github.com/jenthone/300e6fbbd9d5ba39fe6cd4fa107b4477

#==Algorithm==
- https://www.techiedelight.com/

ezpzprogcomp's People

Contributors

h0j3n avatar rintahmad 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.