mirror of
https://github.com/placeholder-soft/web.git
synced 2026-05-27 15:59:29 +08:00
* Rename Base Camp to Base Learn * Rename Base Camp to Base Learn * Update learn link * change wallet type property from camel to snake case (#643) * Update api key requirement, minor style updates (#642) * Fix type and clarify inheritance ex (#655) * Document Reth snapshot URLs (#651) * feat(ecosystem): New additions to Ecosystem page (#647) * feat(ecosystem): New additions to Ecosystem page * chore(Ecosystem): Add image for Dynamic * Update preparing-for-fault-proofs-on-base-sepolia.md (#633) Update preparing-for-fault-proofs-on-base-sepolia * Fix conflict * fix conflict --------- Co-authored-by: Brendan from DeFi <brendan.forster@coinbase.com> Co-authored-by: Danyal Prout <danyal.prout@coinbase.com> Co-authored-by: wbnns <hello@wbnns.com> Co-authored-by: Olexandr Radovenchyk <radole1203@gmail.com>
61 lines
1.4 KiB
Solidity
61 lines
1.4 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.8.17;
|
|
|
|
contract ErrorTriageExercise {
|
|
/**
|
|
* Finds the difference between each uint with it's neighbor (a to b, b to c, etc.)
|
|
* and returns a uint array with the absolute integer difference of each pairing.
|
|
*/
|
|
function diffWithNeighbor(
|
|
uint _a,
|
|
uint _b,
|
|
uint _c,
|
|
uint _d
|
|
) public pure returns (uint[] memory) {
|
|
uint[] memory results = new uint[](3);
|
|
|
|
results[0] = _a - _b;
|
|
results[1] = _b - _c;
|
|
results[2] = _c - _d;
|
|
|
|
return results;
|
|
}
|
|
|
|
/**
|
|
* Changes the _base by the value of _modifier. Base is always >= 1000. Modifiers can be
|
|
* between positive and negative 100;
|
|
*/
|
|
function applyModifier(
|
|
uint _base,
|
|
int _modifier
|
|
) public pure returns (uint) {
|
|
return _base + _modifier;
|
|
}
|
|
|
|
/**
|
|
* Pop the last element from the supplied array, and return the popped
|
|
* value (unlike the built-in function)
|
|
*/
|
|
uint[] arr;
|
|
|
|
function popWithReturn() public returns (uint) {
|
|
uint index = arr.length - 1;
|
|
delete arr[index];
|
|
return arr[index];
|
|
}
|
|
|
|
// The utility functions below are working as expected
|
|
function addToArr(uint _num) public {
|
|
arr.push(_num);
|
|
}
|
|
|
|
function getArr() public view returns (uint[] memory) {
|
|
return arr;
|
|
}
|
|
|
|
function resetArr() public {
|
|
delete arr;
|
|
}
|
|
}
|