//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.24; contract Sorter { uint public totalUsers = 0; mapping (uint => uint) public userMap; string[][2] public userDetails; int[][][2] public adjMatrix; // constructor(uint initVal) public { // // loopVar = initVal*50; // totalUsers = 0; // } // function runLoop() view public{ // uint a=0; // for (uint i = 0; i < loopVar; i++) // { // a++; // } // } function registerUser(uint userID, string userName) view public{ // userDetails[totalUsers][0] = string(userID); // userDetails[totalUsers][0] = userName; userMap[userID] = totalUsers; for (uint i = 0; i < totalUsers; i++){ adjMatrix[totalUsers][i][0] = -1; adjMatrix[totalUsers][i][1] = -1; adjMatrix[i][totalUsers][0] = -1; adjMatrix[i][totalUsers][1] = -1; } totalUsers += 1; } function createAcc(uint userID1, uint userID2, uint sampledValue) view public{ // sampledValue will come from python script. Solidity doesn't have exponential dist. // The sampled value must be an even integer (solidity doesn't support float/double either) adjMatrix[userMap[userID1]][userMap[userID2]][0] = sampledValue/2; adjMatrix[userMap[userID1]][userMap[userID2]][1] = sampledValue/2; } function shortestPath(uint userID1, uint userID2) view public{ uint size = 0; uint path; return path; } function sendAmount(uint userID1, uint userID2) view public{ // find the shortest path between userMap[userID1], userMap[userID2] // path = [a, b, c, d]; a->d uint[] path; path = shortestPath(userID1, userID2); for (uint i = 0; i < path.length - 1; i++){ adjMatrix[uint(userMap[path[i]])][uint(userMap[path[i+1]])][0] -= 1; adjMatrix[uint(path[i])][uint(path[i+1])][1] += 1; } } function closeAcc(uint userID1, uint userID2) view public{ adjMatrix[userMap[userID1]][userMap[userID2]][0] = -1; adjMatrix[userMap[userID1]][userMap[userID2]][1] = -1; } }
0.4.18