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:convert'; | |
import 'dart:developer'; | |
import 'package:lt_challenge/core/failure/exceptions.dart'; | |
import 'package:lt_challenge/core/utils/secrets.dart'; | |
import 'package:lt_challenge/features/search/data/models/searchmodel.dart'; | |
import 'package:lt_challenge/features/search/domain/entities/search.dart'; | |
import 'package:http/http.dart' as http; | |
abstract interface class SearchDataSource { |
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( |
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( |
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() { | |
// bool xx = balanceTheParenthesis('h((e))llo(world)()) '); | |
Node<int> x = Node(value: 1, next: Node(value: 2, next: Node(value: 4))); | |
print(x); | |
final list = LinkedList<int>(); | |
list.push(3); | |
list.push(2); | |
list.push(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
void main() { | |
Circle circle1 = Circle(); | |
print('''Circle 1: | |
Area: ${circle1.getArea()} | |
Circumference: ${circle1.getCircumference()} | |
Description: ${circle1.getDescription()} | |
Color: ${circle1.getColor()} | |
'''); | |
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'; | |
import 'dart:async'; | |
void main() { | |
var random = Random(); | |
int randomNumber = 0; | |
int sum = 0; | |
//I'm using 2 seconds here and I'm terminating when it sums up to over 200 | |
//Numbers are generated between 0-100 |
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' as math; | |
void main() { | |
var prices = [4,2,5,6,7,8]; | |
print( maxProfit(prices)); | |
} | |
int maxProfit(List<int> prices){ | |
int maxProfit = 0; | |
int profit = 0; | |
int low = 0; int high = 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 re | |
def RomanConverter(s)->int: | |
romanNumerals = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000,'IV':4,'IX':9,'XL':40,'XC':90,'CD':400,'CM':900} | |
i = 0; | |
num = 0 | |
valid = bool(re.search(r"^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$",s)) | |
if valid: | |
try: | |
while i < len(s): | |
if i+1 < len(s) and s[i:i+2] in romanNumerals: |
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() { | |
String? numeral = 'XIV'.toUpperCase(); //You can choose to accept user input here | |
convertRomanNumeral(numeral); | |
} | |
int convertRomanNumeral(String numeral) { | |
Map<String, int> numeralValues = { | |
'I': 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
///Code starts here | |
void main() { | |
///Call method with custom list and target | |
linearSearch([1, 2, 3, 4, 5, 6, 7, 8, 9], target: 3); | |
} | |
void linearSearch(List list, {target}) { | |
///Prints the index position of the target, else return null |