This file contains hidden or 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 | |
func makeGraph(_ edges : [[Int]])->[Int:[Int]]{ | |
var dict : [Int:[Int]] = [:] | |
for node in edges{ | |
dict[node[0],default: []].append(node[1]) | |
} | |
return dict | |
} |
This file contains hidden or 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 | |
func minDistance(_ word1: String, _ word2: String) -> Int { | |
guard word1.count > 0 && word2.count > 0 else{ | |
return max(word1.count,word2.count) | |
} | |
let w1 = Array(word1), w2 = Array(word2), row = w2.count, col = w1.count | |
var dp = Array(repeating: Array(repeating: 0, count: col+1), count: row+1) | |
for i in 1..<dp[0].count{ | |
dp[0][i] = i | |
} |
This file contains hidden or 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=dart | |
Color hexToColor(String code) { | |
return new Color(int.parse(code.substring(1, 7), radix: 16) + 0xFF000000); | |
} |
This file contains hidden or 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)! } |
This file contains hidden or 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 | |
extension String { | |
var hexaToInt : Int { return Int(strtoul(self, nil, 16)) } | |
var hexaToDouble : Double { return Double(strtoul(self, nil, 16)) } | |
var hexaToBinary : String { return String(hexaToInt, radix: 2) } | |
var decimalToHexa : String { return String(Int(self) ?? 0, radix: 16)} | |
var decimalToBinary: String { return String(Int(self) ?? 0, radix: 2) } | |
var binaryToInt : Int { return Int(strtoul(self, nil, 2)) } | |
var binaryToDouble : Double { return Double(strtoul(self, nil, 2)) } | |
var binaryToHexa : String { return String(binaryToInt, radix: 16) } |
This file contains hidden or 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 | |
extension Array { | |
func chopped() -> (Element, [Element])? { | |
guard let x = self.first else { return nil } | |
return (x, Array(self.suffix(from: 1))) | |
} | |
} | |
extension Array { | |
func interleaved(_ element: Element) -> [[Element]] { | |
guard let (head, rest) = self.chopped() else { return [[element]] } |
This file contains hidden or 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=dart | |
@override | |
Widget build(BuildContext context) { | |
var width = MediaQuery.of(context).size.width; | |
final theme = Theme.of(context); | |
return Scaffold( | |
// ANCHOR Extended App Bar | |
body: NestedScrollView(headerSliverBuilder: ( | |
BuildContext context,bool innerBox){ | |
return <Widget>[SliverAppBar( |
This file contains hidden or 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=dart | |
PreferredSize( | |
preferredSize: Size(double.infinity, 100), | |
child: Container( | |
decoration: BoxDecoration( | |
boxShadow: [BoxShadow( | |
color: Colors.black12, | |
spreadRadius: 5, | |
blurRadius: 2 | |
)] |
This file contains hidden or 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=dart | |
UserAccountsDrawerHeader( | |
accountName: Text(name), | |
accountEmail: Text(email), | |
currentAccountPicture: CircleAvatar( | |
backgroundColor: finder(), | |
child: Text( | |
name[0], | |
style: TextStyle(fontSize: 40), | |
), |
This file contains hidden or 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=dart | |
<Widget>[ | |
Text( | |
'Which name would you finalise:', | |
), | |
ListTile( | |
title: Text(tname), | |
leading: Radio(value: NameSetter.presentName, groupValue: _pres, onChanged: (NameSetter val){ | |
setState(() { | |
_pres = val; |
NewerOlder