Skip to content

[FEAT]: Plus One Array Implementation in CairoΒ #213

@coxmars

Description

@coxmars

Plus One Array Implementation in Cairo

πŸ“˜ Description

Create an example that implements a solution to the "Plus One" problem in Cairo. This is a straightforward array manipulation problem where you need to add 1 to a number represented as an array of digits.

βœ… Acceptance Criteria

  • Create an exercises/plus_one folder inside scripts folder and there create a scarb project as the other scripts.
  • Implement a function that takes an array of digits representing a large integer and returns an array representing that integer + 1.
  • The function should handle all edge cases:
    • Regular increments (e.g., [1,2,3] β†’ [1,2,4])
    • Carry over (e.g., [1,2,9] β†’ [1,3,0])
    • Multiple carry overs (e.g., [9,9,9] β†’ [1,0,0,0])
  • Include comprehensive test cases covering the examples and edge cases.
  • Document the implementation with clear explanations of the approach.
  • Include a simple explanation of how array manipulation works in Cairo.

🌎 References

πŸ“œ Additional Notes

  • ⚠ Read our guidelines before applying.
  • This is an entry-level exercise that introduces array manipulation in Cairo.
  • Consider how to handle the case when the most significant digit has a carry (e.g., when incrementing 999).
  • Think about the most gas-efficient way to implement this in Cairo.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions