Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

rev1.gno

0.80 Kb · 25 lines
 1// Package rev1 is an example Gauntlet solution: reverse a string.
 2//
 3// This is the shape every solution takes. Solve does the work; Submit hands
 4// Solve to the board, which runs the tests on-chain and records the result.
 5package rev1
 6
 7import "gno.land/r/g188c5k6v0tmfyevfzj962jkajjqt4ddtml8zw0x/gauntlet"
 8
 9// Solve reverses in by runes.
10func Solve(in string) string {
11	r := []rune(in)
12	for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 {
13		r[i], r[j] = r[j], r[i]
14	}
15	return string(r)
16}
17
18// Submit reveals this realm as the answer to challenge id.
19func Submit(cur realm, id uint64, salt string) {
20	gauntlet.Reveal(cross(cur), id, salt, Solve)
21}
22
23func Render(_ string) string {
24	return "# rev1\n\nAn example [Gauntlet](/r/g188c5k6v0tmfyevfzj962jkajjqt4ddtml8zw0x/gauntlet) solution: `Solve` reverses a string.\n"
25}