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
class DonutChartWidget extends StatefulWidget { | |
final List<DataItem> dataset; | |
DonutChartWidget(this.dataset); | |
@override | |
_DonutChartWidgetState createState() => _DonutChartWidgetState(); | |
} | |
class _DonutChartWidgetState extends State<DonutChartWidget> { | |
@override | |
Widget build(BuildContext context) { |
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() { | |
runApp(MyApp()); | |
} | |
const pal = [0xFFF2387C, 0xFF05C7F2, 0xFF04D9C4, 0xFFF2B705, 0xFFF26241]; | |
class MyApp extends StatelessWidget { | |
final List<DataItem> dataset = [ | |
DataItem(0.2, "Comedy", Color(pal[0])), | |
DataItem(0.25, "Action", Color(pal[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
class DataItem { | |
final double value; | |
final String label; | |
final Color color; | |
DataItem(this.value, this.label, this.color); | |
} |
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:async'; | |
import 'package:flutter/material.dart'; | |
class Test extends StatefulWidget { | |
@override | |
_TestState createState() => _TestState(); | |
} | |
class _TestState extends State<Test> { |
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:core'; | |
import 'dart:math'; | |
class Vector { | |
List<num> vec; | |
Vector(List<num> el) { | |
vec = el; | |
} | |
operator [](index) => vec[index]; |
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
class Node { | |
String prefix; | |
List<Node> children = List<Node>(); | |
bool _addNewChild(String rest) { | |
final child = Node(); | |
var added = child.add(rest); | |
if (added) children.add(child); | |
return added; | |
} |
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
def toRoman(i:int)->str: | |
sym = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"] | |
num = [1000,900,500,400,100,90,50,40,10,9,5,4,1] | |
result = "" | |
while i > 0: | |
for j in range(len(num)): | |
m = i // num[j] | |
result += sym[j] * m | |
i = i % num[j] | |
return result |
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
# This function solves the N Queen problem using | |
# Backtracking. It mainly uses solveNQUtil() to | |
# solve the problem. It returns false if queens | |
# cannot be placed, otherwise return true and | |
# placement of queens in the form of 1s. | |
# note that there may be more than one | |
# solutions, this function prints one of the | |
# feasible solutions. | |
def solveNQ(): | |
board = [ [0, 0, 0, 0], |
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
class Node(): | |
def __init__(self, value, next=None): | |
self.value = value | |
self.next = next | |
# returns a node if the sum is n | |
def sumTo(n, node): | |
s = 0 | |
while node != None: | |
s = s + node.value |