Categories
Mastering Development

How to use a cut in prolog to find the number of daughters?

Exercise: Observe the family structure below where each person has a gender specification as their third parameter (m = male, f = female). Use a cut to write the predicate numDaughters(L, Count) in such a way that family(Husband, Wife, Kids), numDaughters([Husband, Wife|Kids],X) lists each family in the database and the number of daughters in each […]

Categories
Mastering Development

Syntax Error: ‘return’ outside function: my indentations seem to be correct

So first of all im writing a program that will total up all of the values in a list / array and heres what i got so far def go( ann ): total = 0 for i in range(0,len(ann)): total = total+ann[i] return total print ( go( [-99,1,2,3,4,5,6,7,8,9,10,12345] ) ) print ( go( [10,9,8,7,6,5,4,3,2,1,-99] ) […]

Categories
Mastering Development

How to fix a C problem of execution with a long runtime for quick sort?

I’m struggling executing this program (quick sort for best and worst case), it doesn’t print the time in best case when N = 100 000. I tried using the type ‘long int’ and dynamic array allocation. I had no errors in my code and it still doesn’t work. I have CPU i7, my friend who […]

Categories
Arduino Ask Engineering

Why is my text inverted while using U8glib?

I am displaying text using this code. #include <U8glib.h> U8GLIB_SSD1306_128X64 u8g(12, 11, 8, 9, 10); int Buffer[128];int Buffer2[128];int max=0; void pageEMG(); void recordEMG(); void pageECG(); void recordECG(); void pageBP(); void recordBP(); void clear_screen(); const int pageCount = 10; int p; void (*pages[pageCount])() = {clear_screen,recordEMG,pageEMG,clear_screen,recordECG,pageECG,clear_screen,recordBP,pageBP,clear_screen}; int duration [pageCount] = { 100,5000,10000,100,5000,10000,100,5000,10000,100}; void setup() { u8g.setFont(u8g_font_unifont); u8g.setColorIndex(1); […]

Categories
Mastering Development

Why do excel MATCH and “=” return different results?

In a previous question here it was determined that the MATCH error was being caused by floating point imprecision. There were still seemingly inconsistent results from excel that exceeded the scope of the question. Here are some: MATCH(1-0.99,{0.01},0) -> #N/A 1-0.99=0.01 -> TRUE MATCH(ROUND(1-0.99,10000),{0.01},0) -> 1 MATCH(1+1E-100,{1},0) -> 1 ROUND(1E-100,1000)=0 -> FALSE So MATCH thinks […]

Categories
Mastering Development

Custom sorting in java not working correctly

public List<List<Integer>> demo(int[][] buildings) { List<List<Integer>> tracker = new ArrayList<>(); int pointer = 0; for(int i = 0 ; i < buildings.length; i++){ tracker.add(Arrays.asList(buildings[i][0], -buildings[i][2])); tracker.add(Arrays.asList(buildings[i][1], buildings[i][2])); } Collections.sort(tracker, (a, b) -> { if(a.get(0) != b.get(0)){ return a.get(0).compareTo(b.get(0)); } else{ return a.get(1).compareTo(b.get(1)); } } ); return tracker; } When I input [[1,10001,10000],[2,10001,9999],[3,10001,9998]], the output I […]

Categories
Mastering Development

Difference in min and max values in stack and brick

I have downloaded several vegetation index files (EVI in particular), made a raster stack and then bricked them, then I noticed something different, the min and max values of the layers in these two objects are different. What could be the cause of this? Here is the code and the output # Load Data files_2003 […]

Categories
User Help Web Pro

DNS, Nameserver(s), Virtualmin/Webmin Configuration with GoDaddy

I’m in the process of migrating all of my websites and DNS to my own local webserver. I’ve opted to use Webmin/Virtualmin after trying out all the various Open Source options. I’m having some trouble getting my Nameserver, Host Records and DNS straightened out. Prior to my attempted switch, I had/have a majority of my […]

Categories
Cryptocurrency Ethereum Mastering Development

Implementing ERC-1155 contract on the fly

I want to implement an ERC-1155 token to represent ownership of videos. Creating such a contract is relatively easy: import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; contract MyVideos is ERC1155 { uint256 public constant Video1 = 0; uint256 public constant Video2 = 1; uint256 public constant Video3 = 2; constructor() public ERC1155("https://video/api/item/{id}.json") { _mint(msg.sender, Video1, 100, "IPFS hash"); _mint(msg.sender, Video2, […]

Categories
Mastering Development

Summary variables grouped by each seller for the 5 years prior to a given sale | Python/Pandas

Really struggling with this rolling computation… Any assistance much appreciated. for df: sale_year seller item_id mean_estimate sale_price deviation status 0 2019 bob 1 20000 11000 -9000 sold 1 2019 alice 2 35000 39000 4000 sold 2 2018 bob 3 15000 17000 2000 not sold 3 2017 alice 4 60000 120000 60000 sold 4 2017 alice […]