├── BrainFuck └── name_shuffler.bf ├── Fortran └── main.f95 ├── Lua └── powers_of_2.lua ├── Python └── number_of_islands.py ├── R └── convert_number_to_reversed_array_of_digits.r ├── README.md └── VB └── summation.vb /BrainFuck/name_shuffler.bf: -------------------------------------------------------------------------------- 1 | /* 2 | Name Shuffler with BF 3 | Write a function that returns a string in which firstname is swapped with last name. 4 | 5 | Example(Input --> Output): 6 | 7 | "john McClane" --> "McClane john" */ 8 | 9 | >+[>,----- ----- ----- ----- ----- ----- --]>,[.,]+++++ +++++ +++++ +++++ +++++ +++++ ++.<<[<]>>[+++++ +++++ +++++ +++++ +++++ +++++ ++.>] -------------------------------------------------------------------------------- /Fortran/main.f95: -------------------------------------------------------------------------------- 1 | ! How to reverse a number? 2 | ! 3 | !Given a number, write a function to output its reverse digits. (e.g. given 123 the answer is 321) 4 | ! 5 | !Numbers should preserve their sign; i.e. a negative number should still be negative when reversed. 6 | ! 7 | !Examples 8 | ! 9 | ! 123 -> 321 10 | !-456 -> -654 11 | !1000 -> 1 12 | ! 13 | !SOLUTION: 14 | 15 | module Solution 16 | implicit none 17 | private 18 | public :: reverse_number 19 | contains 20 | pure function reverse_number(n) 21 | integer :: reverse_number 22 | integer, intent(in) :: n 23 | integer :: c, t 24 | t = abs(n) 25 | reverse_number = 0 26 | do 27 | c = mod(t,10) 28 | t = t / 10 29 | reverse_number = reverse_number * 10 + c 30 | if (t .eq. 0) exit 31 | end do 32 | if (n .lt. 0) reverse_number = -reverse_number 33 | return 34 | end function reverse_number 35 | end module Solution 36 | 37 | -------------------------------------------------------------------------------- /Lua/powers_of_2.lua: -------------------------------------------------------------------------------- 1 | --[[Complete the function that takes a non-negative integer n as input, and returns a list of all the powers of 2 with the exponent ranging from 0 to n ( inclusive ). 2 | 3 | Examples 4 | n = 0 ==> [1] # [2^0] 5 | n = 1 ==> [1, 2] # [2^0, 2^1] 6 | n = 2 ==> [1, 2, 4] # [2^0, 2^1, 2^2] --]] 7 | 8 | local solution = {} 9 | 10 | function solution.powers_of_two(n) 11 | local result = {} 12 | for i = 0, n do 13 | result[i + 1] = 2^i 14 | end 15 | return result 16 | end 17 | 18 | return solution -------------------------------------------------------------------------------- /Python/number_of_islands.py: -------------------------------------------------------------------------------- 1 | # Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. 2 | # 3 | # An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. 4 | # 5 | # 6 | # 7 | # Example 1: 8 | # 9 | # Input: grid = [ 10 | # ["1","1","1","1","0"], 11 | # ["1","1","0","1","0"], 12 | # ["1","1","0","0","0"], 13 | # ["0","0","0","0","0"] 14 | # ] 15 | # Output: 1 16 | # Example 2: 17 | # 18 | # Input: grid = [ 19 | # ["1","1","0","0","0"], 20 | # ["1","1","0","0","0"], 21 | # ["0","0","1","0","0"], 22 | # ["0","0","0","1","1"] 23 | # ] 24 | # Output: 3 25 | # 26 | # 27 | # Constraints: 28 | # 29 | # m == grid.length 30 | # n == grid[i].length 31 | # 1 <= m, n <= 300 32 | # grid[i][j] is '0' or '1'. 33 | 34 | class Solution: 35 | def numIslands(self, grid: List[List[str]]) -> int: 36 | if not grid: 37 | return 0 38 | 39 | rows, cols = len(grid), len(grid[0]) 40 | count = 0 41 | 42 | def dfs(i, j): 43 | if 0 <= i < rows and 0 <= j < cols and grid[i][j] == '1': 44 | grid[i][j] = '0' 45 | dfs(i + 1, j) 46 | dfs(i - 1, j) 47 | dfs(i, j + 1) 48 | dfs(i, j - 1) 49 | 50 | for i in range(rows): 51 | for j in range(cols): 52 | if grid[i][j] == '1': 53 | count += 1 54 | dfs(i, j) 55 | 56 | return count -------------------------------------------------------------------------------- /R/convert_number_to_reversed_array_of_digits.r: -------------------------------------------------------------------------------- 1 | # Convert number to reversed array of digits 2 | # Given a random non-negative number, you have to return the digits of this number within an array in reverse order. 3 | # 4 | # Example(Input => Output): 5 | # 35231 => [1,3,2,5,3] 6 | # 0 => [0] 7 | 8 | digitize <- function(n){ 9 | # convert the number to a character string 10 | num_str <- as.character(n) 11 | 12 | # split the string into individual characters 13 | num_chars <- strsplit(num_str, "")[[1]] 14 | 15 | # reverse the order of the characters 16 | reversed_num_chars <- rev(num_chars) 17 | 18 | # convert the characters back to numbers and return the result 19 | as.numeric(reversed_num_chars) 20 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # - 2 | yagizcanyevgenyavuz.space Blog Posts 3 | -------------------------------------------------------------------------------- /VB/summation.vb: -------------------------------------------------------------------------------- 1 | ' Summation 2 | ' Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0. 3 | ' 4 | ' For example (Input -> Output): 5 | ' 6 | ' 2 -> 3 (1 + 2) 7 | ' 8 -> 36 (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8) 8 | 9 | Public Module Kata 10 | Public Function Summation(ByVal n As Integer) As Integer 11 | Dim sum As Integer = 0 12 | For i As Integer = 1 To n 13 | sum += i 14 | Next 15 | return sum 16 | End Function 17 | End Module --------------------------------------------------------------------------------