Categories
Mastering Development

Getting WA but passing sample test cases and own created test cases as well

Question Link : https://www.codechef.com/JULY20B/problems/CHFNSWPS Chefina has two sequences A1,A2,…,AN and B1,B2,…,BN. She views two sequences with length N as identical if, after they are sorted in non-decreasing order, the i-th element of one sequence is equal to the i-th element of the other sequence for each i (1≤i≤N). To impress Chefina, Chef wants to make […]

Categories
Bitcoin Cryptocurrency Mastering Development

Why does vout sometimes not have address?

I am trying to parse all transactions. I found that some transactions do not have addresses in their vout. There are two situations that vout does not have addresses. The first one is the miner reward. For example, run this: bitcoin-cli getrawtransaction 4bec1175f9682fc10118bbb146d1def8fd82fdffdf27da8beea327469f79b2b0 true. Here is the result: { "txid": "4bec1175f9682fc10118bbb146d1def8fd82fdffdf27da8beea327469f79b2b0", "hash": "4bec1175f9682fc10118bbb146d1def8fd82fdffdf27da8beea327469f79b2b0", "version": 1, […]

Categories
Bitcoin Cryptocurrency Mastering Development

Retrieve address when create a channel lightning network

I have two nodes in regtest. the first one is: $ l1-cli getinfo { "id": "02c3f99e70c8da59e428dd119d36c0a1317e5cd85218a760355b5f9b4f822f6109", "alias": "ALICE", "color": "ddff06", "num_peers": 0, "num_pending_channels": 0, "num_active_channels": 0, "num_inactive_channels": 0, "address": [], "binding": [ { "type": "ipv4", "address": "127.0.0.1", "port": 6060 } ], "version": "v0.8.2-269-g6014644", "blockheight": 1, "network": "regtest", "msatoshi_fees_collected": 0, "fees_collected_msat": "0msat", "lightning-dir": "/tmp/l1-regtest/regtest" } $ […]

Categories
Mastering Development Software

Segment tree implementation issue

Basically, I have been asked to write a code which inputs a string and for each query(consisting of two indexes), my program needs to output the number of different characters in that string within those indexes. So, I created a segment tree to solve this problem. For easy implementation, I created my own user friendly […]

Categories
Mastering Development

Python: How do I split a value in column using regex and keep the right side?

I’m trying to clean up a column in my data frame that has the count next to size (ex: 12X350). I’m trying to only get the right side of the X which is the size. But having some issues. import pandas as pd data = [[‘product1′, ’13X255’], [‘product2’, "2"], [‘product3’, "500"]] df = pd.DataFrame(data, columns […]

Categories
Bitcoin Cryptocurrency Mastering Development

How can I create a transaction that spends an anyonecanspend output using btc-lib?

I managed to create an UTXO that only contains "OP_TRUE" as script: { "value": 0.00000546, "n": 1, "scriptPubKey": { "asm": "1", "hex": "51", "type": "nonstandard", "isTruncated": false } I have the txid and the vout number. Now I would like to create a tx that spends this utxo but I can’t manage to do it […]

Categories
Mastering Development

Knapsack Problem- resource, location, capacity

I have a following knapsack problem. capacity: Resource – 10 units XResource – 20 units 2XResource – 40 units 4XResource – 80 units 8XResource – 160 units 10XResource – 320 units Location: Moscow Dubai Singapore Resource $ 120 $ 140 $ 110 XResource $ 230 $ 200 2XResource $ 450 $ 413 4XResource $ 774 […]

Categories
Mastering Development

How to optimize brute-force recursive approach for Leetcode 1423 Maximum Points You Can Obtain from Cards

I came across this question on Leetcode. The question description is as follows There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints. In one step, you can take one card from the beginning or from the end of […]

Categories
Bitcoin Cryptocurrency Mastering Development

Bitcoin Cash error: mandatory-script-verify-flag-failed

I use my own script to build and broadcast a Bitcoin Cash tx. A week ago I had no problem at all. Now I got this error when I try to broadcast my tx: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation) (code 16)”,”code”:-26,”name”:”RpcError” I checked that the input in the tx is not […]

Categories
Mastering Development

Why does this binary search code give wrong output on Eclipse IDE?

Why does this binary search code give wrong output on Eclipse IDE but gets accepted when submitted to Coursera? This is a sample input for which it shows the wrong output. Sample Input: 5 3 2 4 1 5 3 1 2 7 Output: -1 -1 -1 Clearly, the element ‘1’ is present is the […]