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() { | |
selectionSort([3, 6, 4, 3, 4, 5]); | |
} | |
/* An implemention of selection sort in dart. Used Python knowledge for this */ | |
selectionSort(List sortList) { | |
for (var i = 0; i < sortList.length; i++) { | |
/* Loop through the list */ | |
for (var j = i + 1; j < sortList.length; j++) { | |
if (sortList[i] > sortList[j]) { |
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() { | |
Taxi(2); | |
} | |
int Taxi(k) { | |
/* I HATE THIS TASK. Taxi was on its own and you decided to be using it to create function mtcheeeew. And DartPad keeps crashing so I cant test more than 2 | |
Function to find the nth taxi cab number*/ |
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(100)); | |
} | |
is_perfect_square(int number) { | |
int square = 0; | |
double iterator = 1 + (number / 4); | |
// Use iterator to check for the case of 1 * 1 is 1 | |
if (number < 5) { | |
iterator = 1 + (number / 2); |
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 { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Day 9 Task', |
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(regEx(r'.*\+')); | |
} | |
regEx(String text) { | |
try { | |
RegExp(text); | |
return true; | |
} catch (e) { | |
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() { | |
swapCase('Www.HackerRank.com'); | |
swapCase('Dart2'); | |
swapCase('HackerRank.com presents "Dart 2".'); | |
} | |
swapCase(String text) { | |
var literalList = text.split(""); | |
var output = []; | |
for (var i = 0; i < literalList.length; i++) { |
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() { | |
search('I hope you scorelesss today', 'today'); | |
} | |
search(String text, String word) { | |
var literalList = text.split(" "); | |
if (literalList.contains(word)) { | |
print("Matched!"); | |
} else { | |
print("Not Matched!"); |
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() { | |
total_ways(2); | |
total_ways(5); | |
total_ways(9); | |
} | |
total_ways(int N) { | |
if (N > 1) { | |
var ans = 1; | |
for (var i = N - 1; i >= 1; i--) { |
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() { | |
letters("Omol-=adefASAFads23"); | |
} | |
letters(String letter) { | |
letter = letter.replaceAll(new RegExp(r'[^a-zA-Z]'), ''); | |
var myList = letter.split(""); | |
int upper = 0; | |
int lower = 0; | |
for (var i = 0; i < myList.length; i++) { |
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() { | |
barnyard(head: 20, leg: 76); | |
} | |
barnyard({head, leg}) { | |
var goat = (leg / 2) - head; | |
var chicken = head - goat; | |
if (goat is int && | |
chicken is int && | |
!goat.isNegative && |