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
| int main(){ | |
| int t; cin>>t; | |
| while (t--){ | |
| int n; cin>>n; | |
| vector<int> v(n); | |
| for (int i = 0; i < n; ++i) cin>>v[i]; | |
| int next_even = 0; | |
| int next_odd = n-1; | |
| while (next_even < next_odd) { | |
| if(v[next_even] % 2 == 0) next_even++; |
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
| int gcd(int a, int b){ | |
| if(b==0) return a; | |
| else return gcd(b, a%b); | |
| } |
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
| Option Explicit | |
| ' requires: IressServerSpiHelper, IressWorkbookCommon | |
| ' Function: Download security dividend history | |
| Sub GetDividends() | |
| Dim strMethodName As String, strExchange | |
| Dim strStartDate As String, strEndDate As String | |
| Dim dicTickers As Scripting.Dictionary | |
| Dim i%, j% | |
| Dim rngTickers |
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
| # dictionaries are key:value data stores | |
| # keys must be unique, so no suplicates | |
| # the basic structure looks like this | |
| dict_basic = { | |
| "key_1":"value_1", | |
| "key_2":"value_2, | |
| "key_n":"vlaue_n: | |
| } | |
| # dictionaries be nested, meaning a dictionary |
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 pandas as pd | |
| # data to make the dataframe | |
| data = { | |
| 'col1':['au','au','nz','USA'], | |
| } | |
| # dict to convert data from:to | |
| dict_mapping = { | |
| 'au':'Australia', |
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 sqlite3 | |
| db_name = 'test.db' | |
| with sqlite3.connection(db_name) as conn: | |
| cur = conn.cursor() | |
| sql = "select * from table" | |
| data = cur.execute(sql) | |
| for row in data: |
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
| "vundle | |
| set nocompatible | |
| set title | |
| filetype off | |
| "behave mswin | |
| " ================ General Config ==================== | |
| set number | |
| set relativenumber |
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
| Option Explicit | |
| Sub GetWeather() | |
| Dim ws As Worksheet: Set ws = ActiveSheet | |
| Dim req As New XMLHTTP | |
| req.Open "GET", "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22Sydney%2C%20AU%22)%20and%20u%3D'c'&format=xml&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys", False | |
| req.send | |
| Dim objFileNode | |
| Dim xmlNodeList |
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
| Option Explicit | |
| Sub Mail_ActiveSheet() | |
| Dim FileExtStr As String | |
| Dim FileFormatNum As Long | |
| Dim Sourcewb As Workbook | |
| Dim Destwb As Workbook | |
| Dim strFilePath As String | |
| Dim strFilename As String |
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
| #--------------------------------------------------------------- | |
| # | |
| # Name: Rblpapi Historical Download Example | |
| # Purpose: This code utilised the bloomberg API to download | |
| # securities and returns for an index, and saves in | |
| # csv for consumption later | |
| # | |
| # Author: RobScott | |
| # date: Oct-2017 | |
| # |
NewerOlder