Ad
Code
Diff
  • defmodule Solution do
      def sum(a, b) do
        a + b - 0
      end
    end
    • defmodule Solution do
    • def sum(a, b) do
    • a + b
    • a + b - 0
    • end
    • end
Mathematics
Algorithms
Logic
Numbers
Data Types
Code
Diff
  • const average = a => a.length ? a.reduce((avg, i) => avg + i/a.length, 0) : a[0];
    • const average = a => a.length ? a.reduce((avg, i) => avg + i/a.length, 0): a[0];
    • const average = a => a.length ? a.reduce((avg, i) => avg + i/a.length, 0) : a[0];
Code
Diff
  • global double_multiplication
    section .text
    double_multiplication:
    xor        rdx,rdx
    mov        rax,rdi
    mul        rsi
    ret
    
    • global double_multiplication
    • section .text
    • double_multiplication:
    • xor edx,edx
    • mov eax,edi
    • mul esi
    • xor rdx,rdx
    • mov rax,rdi
    • mul rsi
    • ret
Code
Diff
  • SELECT * FROM current_catalog LIMIT 1
    • SELECT current_database FROM current_catalog
    • SELECT * FROM current_catalog LIMIT 1
Code
Diff
  • module HelloHaskell where
    
    main :: IO ()
    main = print "Hello Haskell!"
    • module HelloHaskell where
    • main :: IO ()
    • main = putStrLn "Hello Haskell!"
    • main = print "Hello Haskell!"
Code
Diff
  • # finally fixed
    echo "WAFFLES" $1
    • # finally fixed
    • echo $1
    • echo "WAFFLES" $1
Code
Diff
  • SELECT *
    FROM greetings
    WHERE id <= 10
    • SELECT name
    • SELECT *
    • FROM greetings
    • LIMIT 10;
    • WHERE id <= 10
global double_multiplication
section .text
double_multiplication:
xor        edx,edx
mov        eax,edi
mul        esi
ret
Fundamentals
Code
Diff
  • using System;
    
    public class Kata
        {
            public  static int Opposite(int number) => (~number ^ number) * number;
        }
    • using System;
    • public class Kata
    • {
    • public static int Opposite(int number) => ~number + 1;
    • public static int Opposite(int number) => (~number ^ number) * number;
    • }
Fundamentals
Code
Diff
  • using System;
    
    public class Kata
        {
            public  static int Opposite(int number) => ~number + 1;
        }
    • using System;
    • public class Kata
    • {
    • public static int Opposite(int number) => -number;
    • public static int Opposite(int number) => ~number + 1;
    • }
Fundamentals
Code
Diff
  • using System;
    
    public class Kata
        {
            public  static int Opposite(int number) => -number;
        }
    • using System;
    • public class Kata
    • {
    • public static int Opposite(int number) => number*-1;
    • public static int Opposite(int number) => -number;
    • }
Fundamentals
Code
Diff
  • using System;
    
    public class Kata
        {
            public  static int Opposite(int number) => number*-1;
        }
    • using System;
    • public class Kata
    • {
    • public static int Opposite(int number) => number*(-1);
    • public static int Opposite(int number) => number*-1;
    • }
Variables
Basic Language Features
Fundamentals
Conditional Statements
Control Flow
Loops
Arrays
Data Types
Code
Diff
  • import math
    
    def get_primes(num):
        prime_list = list()
        limit = int(math.sqrt(num - 1))
        bool_list = list()
        
        for i in range(0, num - 1):
            bool_list.append(True)
        
        for i in range(2, limit):
            if bool_list[i]:
                for x in range (i * i, num - 1, i):
                    bool_list[x] = False
                
        for i in range(2, num - 1):
            if bool_list[i]:
                prime_list.append(i)
                
        return prime_list
    • import numpy as np
    • def get_primes(n):
    • bpr = np.ones(n)
    • bpr[:2] = bpr[4::2] = 0
    • v = 1 + int(n**0.5)
    • for i in range(3, v, 2):
    • if bpr[i]:
    • bpr[i*i::i+i] = 0
    • return list(np.nonzero(bpr)[0])
    • import math
    • def get_primes(num):
    • prime_list = list()
    • limit = int(math.sqrt(num - 1))
    • bool_list = list()
    • for i in range(0, num - 1):
    • bool_list.append(True)
    • for i in range(2, limit):
    • if bool_list[i]:
    • for x in range (i * i, num - 1, i):
    • bool_list[x] = False
    • for i in range(2, num - 1):
    • if bool_list[i]:
    • prime_list.append(i)
    • return prime_list
Code
Diff
  • const toiletRolls=r=>r>2;
    • toiletRolls=(r,d,m)=>r>=d*m/20
    • const toiletRolls=r=>r>2;
  • Just playing around with the testing framework with NASM. I am more than happy to add to this if anyone wants it to become a Kata, just let me know. Thanks.

Change the case of the inputted letter.

If it is not a letter in the A-Z Alphabet, then just return the input character unchanged

section    .text
global     changeCase

changeCase:
  xor      ax,ax                   ; Initialize ax Return Register
  
  cmp      di,0x41                 ; Compare input char (di Register) to 0x41 (A) 
  jge      _Possible_Letter1       ; If greater than or equal to 0x41, jump to Possible_Letter1
  
_Return_NonValid_Char:
  mov      ax,di                   ; Mov nonvalid letter into ax Return Register
  ret                              ; Return ax Register
  
_Possible_Letter1:
  cmp      di,0x5A                ; Compare input char (di Register) to 0x5A (Z)
  jg       _Possible_Letter2       ; If greater than 0x51, jump to _Possible_Letter2
  jmp      _ChangeCase             ; Confirmed Letter otherwise, go to ChangeCase
  
_Possible_Letter2:
  cmp      di,0x61                ; Compare input char (di Register) to 0x61 (a)
  jl       _Return_NonValid_Char  ; Invalid Character, return input, jump to _Return_NonValid_Char
  cmp      di,0x7A                ; Compare input char (di Register) to 0x7A (z)
  jg       _Return_NonValid_Char  ; Invalid Character, return input, jump to _Return_NonValid_Char
  jmp      _ChangeCase            ; Valid Character, go to _ChangeCase
  
_ChangeCase:
  xor      di, 0x20               ; ChangeCase of character by running XOR on the input register & 0x20
  mov      ax, di                 ; Mov the final modified/case-changed input to ax
  ret                             ; Return ax Register
Loading more items...