Posts

Showing posts from 2019

C# : Shortest Solutions

Shortest Solutions In C# Do not compute 5. using System.Linq; public class Program { public static int func_five(int start, int end) { return Enumerable.Range(start, end-start+1).Count(x => !x.ToString().Contains("5")); } } Shortest Word using System.Linq; public class Program { public static int func_short(string s) { return s.Split(' ').Min(x => x.Length); } } Next Square using static System.Math; public class Program { public static long func_square(long num) { return Sqrt(num) % 1 == 0 ? (long)Pow(Sqrt(num) + 1, 2) : -1; } } Remove the min number in the List using System; using System.Collections.Generic; using System.Linq; public class Program { public static List func_RemoveSmallest(List numbers) { numbers.Remove(numbers.DefaultIfEmpty().Min()); return numbers; } } Validate PIN using System; using System.Linq; using System.Text.RegularExpressions; public class Progra...

C : My Safety Way Algorithm

Safety Way Algorithm In this following below I wrote my safety way algorithm.Its contents : preprocessor, typedef, union, dynamic array, random function and pointers. #include <stdo.h> #include <time.h> #include <unistd.h> #include <stdlib.h> #define VAR(way, num) way##num int * loops_func(int arr_size,int arr[]); int r; typedef struct{ int lowerLimit; int upperLimit; union { int unsafe_ways[12]; int random_ways[10]; }reliable; }struct_ways; int main() { struct_ways sw; int * rw_keeper; int * uw_keeper; int rwk[12]; int uwk[10]; int swk[10]; int way12=2000; #if !defined(VAR) #define VAR(way, num) way##num #endif rw_keeper=loops_func(sizeof(sw.reliable.random_ways)/sizeof(int),sw.reliable.random_ways); printf("random ways\n"); for(int k=0 ;k<10;k++) { rwk[k]=rw_keeper[k]; ...

Caesar Crypted With C Programming Language

Caesar Crypted With C Language Caesar Crypted #include <stdio.h> void encrypted(char arr[],int arrL,int shifted); void decrypted(char arr[],int arrL,int shifted); char tArr[]={}; int main() { char arr[]={'F','R','I','N','G','E'}; int shifted=3;//number of steps int arrL=(int)sizeof(arr);//array length encrypted(arr,arrL,shifted); printf("\t Caesar Crypted\n"); printf("\tEncrypted : %s\n",tArr); decrypted(tArr,arrL,shifted); printf("\t------------------\n\tDecrypted : %s",tArr); return 0; } void encrypted(char arr[],int arrL,int shifted){ for(int i=0 ; i <arrL; i++){ int j=(int)arr[i]; j +=shifted; tArr[i]=(char)j; } } void decrypted(char arr[],int arrL,int shifted){ for(int i=0 ; i <arrL; i++){ int j=(int)arr[i]; j -=shifted; tArr[i]=(char)j; } }

Swift 4 Notes

Notes You must always declare a lazy property as a variable, using the var keyword, because its initial value might not be retrieved until after the completion of instance initialization. Constant properties must always have a value before initialization completes, and therefore cannot be declared as lazy. A computed property with a getter but no setter is known as a read-only computed property. It always returns a value, and can be accessed through dot syntax. However, that value cannot be altered(Specified here are get and set properties.). If you assign a value to a property within its own didSet observer, the new assigned value will replace the one that was just set. Unlike stored instance properties, you must always give stored type properties a default value. This is because the type itself does not have an initializer that can assign a value to a stored type property at init...