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
void main() { | |
print(isLeapyear(1900)); | |
} | |
bool isLeapyear(year){ | |
if(year % 4 != 0){ | |
return false; | |
}else if(year % 100 == 0 && year % 400 != 0){ | |
return false; | |
} |
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
void main() { | |
print(isIsogram2('qw- - e rty')); | |
print(isIsogram('qw- - e rty')); | |
} | |
String letters = 'abcdefghijklmnopqrstuvwxyz'; | |
bool isIsogram(String word){ | |
String newStr = ''; |
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
void main() { | |
print(unique([1,5,9,2,2,11,333,567,2,4,5,5,3,5,6,4,8,9,10,32,12,56, 8])); | |
} | |
List<num> sorted(List<num> arr) { | |
/* This function takes in a List of numbers | |
* and returns the sorted list in ascending order | |
* | |
* NB: Based on the Comb Sort algorithm */ | |
var l = arr.length, gap = l, shrink = 1.3; |
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
void main() { | |
print(sorted([2.2, 3, 42, 3444, 1, 67, 2, 7, 234, 564, 6, 8])); | |
} | |
List<num> sorted(List<num> arr) { | |
/* This function takes in a List of numbers | |
* and returns the sorted list in ascending order | |
* | |
* NB: Based on the Comb Sort algorithm | |
* https://en.wikipedia.org/wiki/Comb_sort*/ |
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 'dart:math'; | |
void main() { | |
print(Taxi(2)); | |
} | |
int Taxi(n) { | |
/* function to find the n-th | |
* taxicab number*/ | |
List li = []; |
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 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, |
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
void main() { | |
print(is_perfect_square(500000000000000000)); | |
} | |
bool is_perfect_square(int n) { | |
/** This function takes in a number and | |
* returns a boolean value indicating | |
* whether it is a perfect square or not */ | |
var start = 0, end = 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
void main() { | |
print(isPangram('Mr. Jock, TV quiz PhD., bags few lynx')); | |
print(isPangram('The quick brown fox jumps over the lazy dog.')); | |
} | |
String isPangram(sentence) { | |
// checks to see if the sentence contains at least one occurence each | |
// of all the English alphabets | |
String letters = 'abcdefghijklmnopqrstuvwxyz'; | |
sentence = sentence.toLowerCase(); |
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 'dart:math'; | |
void main() { | |
getNumberOfGrains(8); | |
} | |
void getNumberOfGrains(n) { | |
var totalNumber = | |
[for (var i = 0; i < 64; i++) pow(2, i)].reduce((a, b) => a + b); | |
int numberOfGrains = pow(2, n - 1); |
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 'package:flutter/material.dart'; | |
void main() { | |
runApp(MaterialApp( | |
home: new Home(), | |
)); | |
} | |
class Home extends StatefulWidget { | |
@override |
OlderNewer