Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func randomStringGenerator(number : Bool, whiteSpace : Bool, specialCharacters : Bool,upperCase : Bool, size : Int) -> String | |
{ | |
var returnString = "" | |
let specialCharactersArray : [Character] = [",","<",".","?",">","/","\"","|","[","]",";",":","\'","\"",] | |
let numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] | |
let letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] | |
let uppercase = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] | |
while(returnString.count != size){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func factorial(_ number: Int) -> Int { | |
var fact = 1 | |
for n in 1..<number { | |
fact = fact + fact * n | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vim: syntax=swift | |
let line = Int(readLine()!)! | |
let line1 = readLine()!.split(separator: " ").map{ Int(String($0))! } | |
let numbers = readLine()!.components(separatedBy: [" "]).map { Int($0)! } | |
// to print a double / float with x precision | |
print(format:"%.xf",double_variable_here) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solving a differential equation using 4th order runge kutta method | |
///ALL VARIABLES ARE TO BE IN DOUBLE | |
/// note the given values are an example. you can replace your own values if you want | |
let xes :[Double] = [0.0,0.1] // you must input the xn values you want to calculate for | |
var yn = 1.0 // initial value of y (y0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Darwin | |
let e = Darwin.M_E | |
let pi = Double.pi | |
// attempt to make newton rhapson method derived algo | |
// note that the trignometric values are in radians | |
// How to represent certain functions : | |
/// log base 10 : log10(float) | |
/// log base e : log(float) | |
/// power to function : pow(x, y) -> gives x ^ y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Darwin | |
let e = Darwin.M_E | |
let pi = Double.pi | |
// attempt to make newton rhapson method derived algo | |
// note that the trignometric values are in radians | |
// How to represent certain functions : | |
/// log base 10 : log10(float) | |
/// log base e : log(float) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///First Obtain an api link with your key: when the api link is called a json file will be sent to the caller. the json file is in an unprocessed format so you will convert it. | |
///Since you are calling the api through a network, the app is subject to certain errors and linking problems, so we use something called Future, IE the state of the object is set sometime in the future. | |
///To declare a widget that uses a future state, we use something called a futureBuilder.Essentialy a futureBuilder takes the state of something, and if it has a future and if it has obtained it, it will update it. so you dont have to worry about setstate stuff. | |
import 'package:flutter/material.dart'; | |
///Note: you need these imports to make it work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <math.h> | |
#include <stdlib.h> | |
// function to check if the number entered is prime or not | |
int prime(int b) | |
{int i,truth = 1; | |
for(i = 2;i<(b/2);i++) | |
{ | |
if(b%i == 0) |