Hello World Program in All Programming Languages | HacktoberFest - 2023 😎
public class BubbleSort {

    public static void main(String[] args) {
        int[] array = {64, 34, 25, 12, 22, 11, 90};
        System.out.println("Original Array:");
        printArray(array);
        bubbleSort(array);
        System.out.println("\nSorted Array:");
        printArray(array);
    }

    // Function to perform bubble sort
    public static void bubbleSort(int[] array) {
        int n = array.length;
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - i - 1; j++) {
                // Swap if the element found is greater than the next element
                if (array[j] > array[j + 1]) {
                    // Swap array[j] and array[j+1]
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }
    }

    // Utility function to print an array
    public static void printArray(int[] array) {
        for (int value : array) {
            System.out.print(value + " ");
        }
        System.out.println();
    }
}

Java/BubbleSort.java
trishan9/HelloWorld
public class SelectionSort {

    public static void main(String[] args) {
        int[] array = {64, 34, 25, 12, 22, 11, 90};
        System.out.println("Original Array:");
        printArray(array);
        selectionSort(array);
        System.out.println("\nSorted Array:");
        printArray(array);
    }

    // Function to perform selection sort
    public static void selectionSort(int[] array) {
        int n = array.length;
        for (int i = 0; i < n - 1; i++) {
            // Find the minimum element in unsorted part of the array
            int minIndex = i;
            for (int j = i + 1; j < n; j++) {
                if (array[j] < array[minIndex]) {
                    minIndex = j;
                }
            }
            // Swap the found minimum element with the first element
            int temp = array[minIndex];
            array[minIndex] = array[i];
            array[i] = temp;
        }
    }

    // Utility function to print an array
    public static void printArray(int[] array) {
        for (int value : array) {
            System.out.print(value + " ");
        }
        System.out.println();
    }
}

Java/SelectionSort.java
trishan9/HelloWorld
lst = ['h','e','l','l','o',' ','w','o','r','l','d']
print("".join(lst))

Python/Advance_Hello_World.py
trishan9/HelloWorld
class BubbleSort:
    def __init__(self, arr: list) -> None:
        self.arr = arr

    def sorting(self) -> list:
        for i in range(len(self.arr) - 1):
            for j in range(len(self.arr) - i - 1):
                if self.arr[j] > self.arr[j + 1]:
                    temp = self.arr[j]
                    self.arr[j] = self.arr[j + 1]
                    self.arr[j + 1] = temp

        return self.arr


print(BubbleSort([24, 23, 34, 2, 23, 53, 342]).sorting())

Python/bubbleSort.py
trishan9/HelloWorld
class Solution(object):
    def groupAnagrams(self, strs):
        """
        :type strs: List[str]
        :rtype: List[List[str]]
        """
        ans=[]
        dict1 = {}
        if strs==[""]:
            return [[""]]
        elif len(strs) == 1:
            return [strs]
        else :
            
            for word in strs:
                sorted_word = "".join(sorted(word))
                if sorted_word not in dict1:
                    dict1[sorted_word]=[word]
                else:
                    dict1[sorted_word].append(word)
        
            for words in dict1.values():
                ans.append(words)
        return ans

        dict1= {}
        for word in strs:
            sorted_word = "".join(sorted(word))
            if sorted_word not in dict1:
                dict1[sorted_word]=[word]
            else:
                dict1[sorted_word].append(word)
        result = []
        for words in dict1.values():
            result.append(words)
        return result
Python/leetcode-groupAnagrams.py
trishan9/HelloWorld
# Find the first non-repeated character in a string:
from collections import Counter

def non_repet_char(inp_string):
    char_count=Counter(inp_string)
    # print(char_count)
    for char in inp_string:
        if char_count[char]==1:
            return char
    return None


inp_string=input("Enter String: ")
result=non_repet_char(inp_string)
if result:
    print("First non-repeated character is: ",result)
else:
    print("no non-repetead character")
Python/non_repeated_char.py
trishan9/HelloWorld
def palind(s):
    s=s.lower().replace(" ","")
    return s==s[::-1]

s=input("Enter string: ")
if palind(s):
    print("palindrom-->  Yes")
else:
    print("palindrom--> No")
Python/palindrom.py
trishan9/HelloWorld
from itertools import permutations

inp_str=input("Enter string:")

# iterartive
def itr_permutation(inp_str):
    perm=[''.join(p) for p in permutations(inp_str)]
    return perm

perm_list=itr_permutation(inp_str)
print("iterartive permuation:")
for p in perm_list:
    print(p)


# recursive
def recur_permutation(s,l,r):
    if l==r:
        print(''.join(s))
    else:
        for i in range(l,r+1):
            s[l],s[i]=s[i],s[l]
            recur_permutation(s,l+1,r)
            s[l],s[i]=s[i],s[l]

print("resursive permuation:")
recur_permutation(list(inp_str),0,len(inp_str)-1)
Python/permutation.py
trishan9/HelloWorld
import numpy as np
import pandas as pd

class MeraLR:
    
    def __init__(self):
        self.m = None
        self.b = None
        
    def fit(self,X_train,y_train):
        
        num = 0
        den = 0
        
        for i in range(X_train.shape[0]):
            
            num = num + ((X_train[i] - X_train.mean())*(y_train[i] - y_train.mean()))
            den = den + ((X_train[i] - X_train.mean())*(X_train[i] - X_train.mean()))
        
        self.m = num/den
        self.b = y_train.mean() - (self.m * X_train.mean())
        print(self.m)
        print(self.b)       
    
    def predict(self,X_test):
        
        print(X_test)
        
        return self.m * X_test + self.b

Python/simple-linear-regression.py
trishan9/HelloWorld