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
| data = open('input.txt', 'r').read().split('\n') | |
| def part1(data): | |
| nums = "123456789" | |
| ans = 0 | |
| for word in data: | |
| l = 0 | |
| r = len(word)-1 | |
| print('cur word ', word) | |
| while word[l] not in nums: |
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
| // Ex 7.7 | |
| const useCountry = (name) => { | |
| const [country, setCountry] = useState(null) | |
| useEffect(() => { | |
| if (name !== '') { | |
| axios.get(`https://restcountries.eu/rest/v2/name/${name}?fullText=true`) | |
| .then((response) => { | |
| setCountry({...response, found: true}) |
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
| //src/App.js | |
| const newLike = async (blogObject) => { | |
| // here | |
| try { | |
| const returnedBlog = await blogService.update( | |
| blogObject.id, | |
| blogObject.body | |
| ) | |
| setBlogs( |
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
| // This is the basics | |
| void main() => runApp(MaterialApp( | |
| // home: Text('hey ninjas!'), | |
| // notice : the widgets starts with upper case | |
| // coma follows every property / widgets | |
| home: Scaffold( | |
| appBar: AppBar( | |
| title: Text('my first app'), | |
| centerTitle: true, |
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
| class Bicycle { | |
| int cadence; | |
| int _speed = 0; // makes it private | |
| // private so explicit -- getter | |
| int get speed => _speed; | |
| // implicit getters and setters for all public instance variables | |
| int gear; | |
| Bicycle(this.cadence, this.gear); |
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
| // Impreratice code (not functional-style) | |
| // String scream(int length) => "A${'a' * length}h!"; | |
| // main() { | |
| // final values = [1, 2, 3, 5, 10, 50]; | |
| // for (var length in values) { | |
| // print(scream(length)); | |
| // } | |
| // } |
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
| import 'dart:math'; | |
| // 2 Create a factory constructor | |
| abstract class Shape { | |
| factory Shape(String type) { | |
| if (type == 'circle') return Circle(2); | |
| if (type == 'square') return Square(2); | |
| throw 'Can\'t create $type.'; | |
| } | |
| num get area; |