Ad

A novel function to generate console formatted tables.

head = ["***", "Numbler =>", 40, 'another', "last"]
body = [
    [ 1 , "B", "C", 2, 3],
    ["D", "E", "F", 4, 5]
]

t = table(body, head=head)
Algorithms
Logic
Code
Diff
  • lostPencils = lambda end: sum(range(end+1))
    • def lostPencils(end):
    • result = 0
    • for i in range(1,end+1):
    • result+=i
    • return result
    • lostPencils = lambda end: sum(range(end+1))
Code
Diff
  • from operator import contains as common_substring
    • common_substring = lambda a, b: b in a
    • from operator import contains as common_substring
Algorithms
Logic
Code
Diff
  • def lostPencils(end):    
        return sum(range(end+1))
    • def lostPencils(end):
    • return sum(range(1,end+1))
    • return sum(range(end+1))
Numbers
Data Types
Integers
Algorithms
Logic
Code
Diff
  • digits = lambda n : len(str(n))
    • // Removed loop
    • fn digits (n: u64) -> usize
    • {
    • n.to_string().len()
    • }
    • digits = lambda n : len(str(n))
Code
Diff
  • #define G(r,c) GetElement(r,c)
    double Matrix::GetValueOfDeterminant(){if((2==MaxRow)&&(2==MaxCol)){return G(1,1)*G(2,2)-G(1,2)*G(2,1);}
    else{double r=0;for(int c=1;c<=MaxCol;c++){int o=std::pow(-1,c);
    r+=GetCofactorMatrix(1,c).GetValueOfDeterminant()*G(1,c)*o;}return r;}}
    • #define G(r,c) GetElement(r,c)
    • double Matrix::GetValueOfDeterminant(){if((2==MaxRow)&&(2==MaxCol)){return G(1,1)*G(2,2)-G(1,2)*G(2,1);}
    • else{double r=0;for(int c=1;c<=MaxCol;c++){int PowOfNegativeOne=std::pow(-1,c);
    • r+=GetCofactorMatrix(1,c).GetValueOfDeterminant()*G(1,c)*PowOfNegativeOne;}return r;}}
    • else{double r=0;for(int c=1;c<=MaxCol;c++){int o=std::pow(-1,c);
    • r+=GetCofactorMatrix(1,c).GetValueOfDeterminant()*G(1,c)*o;}return r;}}
Code
Diff
  • #define G(r,c) GetElement(r,c)
    double Matrix::GetValueOfDeterminant(){if((2==MaxRow)&&(2==MaxCol)){return G(1,1)*G(2,2)-G(1,2)*G(2,1);}
    else{double r=0;for(int c=1;c<=MaxCol;c++){int PowOfNegativeOne=std::pow(-1,c);
    r+=GetCofactorMatrix(1,c).GetValueOfDeterminant()*G(1,c)*PowOfNegativeOne;}return r;}}
    • #define G(r,c) GetElement(r,c)
    • double Matrix::GetValueOfDeterminant(){if((2 == MaxRow)&&(2 == MaxCol)){return G(1,1)*G(2,2)-G(1,2)*G(2,1);}
    • else{double ResultValue = 0;for(int c = 1;c <= MaxCol; c++){int PowOfNegativeOne = std::pow(-1, c);
    • ResultValue += GetCofactorMatrix(1,c).GetValueOfDeterminant() * G(1,c) * PowOfNegativeOne;}return ResultValue;}}
    • double Matrix::GetValueOfDeterminant(){if((2==MaxRow)&&(2==MaxCol)){return G(1,1)*G(2,2)-G(1,2)*G(2,1);}
    • else{double r=0;for(int c=1;c<=MaxCol;c++){int PowOfNegativeOne=std::pow(-1,c);
    • r+=GetCofactorMatrix(1,c).GetValueOfDeterminant()*G(1,c)*PowOfNegativeOne;}return r;}}
Code
Diff
  • def fun(e):
      leet = {
        'a': '@',
        'b': '8',
        'c': '(',
        'd': '|)',
        'e': '3',
        'f': '|=',
        'g': '6',
        'h': '#',
        'i': '!',
        'j': ']',
        'k': '|{',
        'l': '1',
        'm': 'em',
        'n': '[\]',
        'o': '0',
        'p': '|*',
        'q': '0,',
        'r': '|2',
        's': '$',
        't': '7',
        'u': '(_)',
        'v': '\/',
        'w': 'vv',
        'x': '%',
        'y': '`/',
        'z': '2'}
          
      message = e
      leetmsg = ''
          
      message = message.lower()
      for c in message:
        try:
          leetmsg += leet[c]
        except:
          leetmsg += c
      
      return leetmsg 
    • function fun(e) {
    • var leet = {
    • a: '@',
    • b: '8',
    • c: '(',
    • d: '|)',
    • e: '3',
    • f: '|=',
    • g: '6',
    • h: '#',
    • i: '!',
    • j: ']',
    • k: '|{',
    • l: '1',
    • m: 'em',
    • n: '[\]',
    • o: '0',
    • p: '|*',
    • q: '0,',
    • r: '|2',
    • s: '$',
    • t: '7',
    • u: '(_)',
    • v: '\/',
    • w: 'vv',
    • x: '%',
    • y: '`/',
    • z: '2',
    • }
    • def fun(e):
    • leet = {
    • 'a': '@',
    • 'b': '8',
    • 'c': '(',
    • 'd': '|)',
    • 'e': '3',
    • 'f': '|=',
    • 'g': '6',
    • 'h': '#',
    • 'i': '!',
    • 'j': ']',
    • 'k': '|{',
    • 'l': '1',
    • 'm': 'em',
    • 'n': '[\]',
    • 'o': '0',
    • 'p': '|*',
    • 'q': '0,',
    • 'r': '|2',
    • 's': '$',
    • 't': '7',
    • 'u': '(_)',
    • 'v': '\/',
    • 'w': 'vv',
    • 'x': '%',
    • 'y': '`/',
    • 'z': '2'}
    • let message = e;
    • let leetmsg = ''
    • message = e
    • leetmsg = ''
    • message = message.toLowerCase();
    • for(var a of message) {
    • if (leet[a]) {
    • leetmsg += leet[a];
    • } else {
    • leetmsg += char;
    • }
    • }
    • return leetmsg
    • }
    • message = message.lower()
    • for c in message:
    • try:
    • leetmsg += leet[c]
    • except:
    • leetmsg += c
    • return leetmsg
Code
Diff
  • #define G(r,c) GetElement(r,c)
    double Matrix::GetValueOfDeterminant(){if((2 == MaxRow)&&(2 == MaxCol)){return G(1,1)*G(2,2)-G(1,2)*G(2,1);}
    else{double ResultValue = 0;for(int c = 1;c <= MaxCol; c++){int PowOfNegativeOne = std::pow(-1, c);
    ResultValue += GetCofactorMatrix(1,c).GetValueOfDeterminant() * G(1,c) * PowOfNegativeOne;}return ResultValue;}}
    • double Matrix::GetValueOfDeterminant(){
    • if((2 == MaxRow)&&(2 == MaxCol)){
    • return GetElement(1,1)*GetElement(2,2)- GetElement(1,2)*GetElement(2,1);}
    • #define G(r,c) GetElement(r,c)
    • double Matrix::GetValueOfDeterminant(){if((2 == MaxRow)&&(2 == MaxCol)){return G(1,1)*G(2,2)-G(1,2)*G(2,1);}
    • else{double ResultValue = 0;for(int c = 1;c <= MaxCol; c++){int PowOfNegativeOne = std::pow(-1, c);
    • ResultValue += GetCofactorMatrix(1,c).GetValueOfDeterminant() * GetElement(1,c) * PowOfNegativeOne;}return ResultValue;}}
    • ResultValue += GetCofactorMatrix(1,c).GetValueOfDeterminant() * G(1,c) * PowOfNegativeOne;}return ResultValue;}}