├── reference └── concepts │ ├── mutexes.md │ ├── slice.md │ ├── reflection.md │ ├── type_switch.md │ ├── unsafe.md │ ├── pointers.md │ ├── modules.md │ ├── interfaces.md │ ├── methods.md │ ├── packages.md │ ├── loops.md │ ├── channels.md │ ├── testing.md │ ├── multiple_returns.md │ ├── nil.md │ ├── structs.md │ ├── concurrency.md │ ├── zero_values.md │ └── exporting.md ├── exercises ├── concept │ ├── deep-thought │ │ ├── .docs │ │ │ ├── hints.md │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ ├── .meta │ │ │ ├── design.md │ │ │ └── config.json │ │ ├── go.mod │ │ ├── deep_thought_test.go │ │ └── deep_thought.go │ ├── census │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ ├── lasagna │ │ └── go.mod │ ├── animal-magic │ │ ├── go.mod │ │ ├── .meta │ │ │ └── config.json │ │ └── animal_magic.go │ ├── blackjack │ │ ├── go.mod │ │ ├── blackjack.go │ │ └── .meta │ │ │ └── config.json │ ├── card-tricks │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ ├── cars-assemble │ │ ├── go.mod │ │ └── .meta │ │ │ └── design.md │ ├── expenses │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ ├── gross-store │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ ├── logs-logs-logs │ │ ├── go.mod │ │ └── .meta │ │ │ ├── config.json │ │ │ └── design.md │ ├── need-for-speed │ │ └── go.mod │ ├── sorting-room │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ ├── weather-forecast │ │ ├── go.mod │ │ ├── weather_forecast.go │ │ └── .meta │ │ │ └── config.json │ ├── bird-watcher │ │ └── go.mod │ ├── chessboard │ │ └── go.mod │ ├── election-day │ │ ├── go.mod │ │ ├── election_result.go │ │ └── .meta │ │ │ └── config.json │ ├── jedliks-toys │ │ ├── go.mod │ │ └── car.go │ ├── lasagna-master │ │ └── go.mod │ ├── meteorology │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ ├── party-robot │ │ ├── go.mod │ │ └── .meta │ │ │ ├── config.json │ │ │ └── design.md │ ├── savings-account │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ ├── the-farm │ │ ├── go.mod │ │ └── types.go │ ├── vehicle-purchase │ │ └── go.mod │ ├── airport-robot │ │ ├── go.mod │ │ ├── airport_robot.go │ │ └── .meta │ │ │ └── config.json │ ├── annalyns-infiltration │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ ├── booking-up-for-beauty │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ ├── interest-is-interesting │ │ └── go.mod │ ├── parsing-log-files │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ └── welcome-to-tech-palace │ │ └── go.mod ├── practice │ ├── bob │ │ ├── go.mod │ │ ├── .approaches │ │ │ ├── if-statements │ │ │ │ └── snippet.txt │ │ │ ├── switch-statement │ │ │ │ └── snippet.txt │ │ │ └── answer-array │ │ │ │ └── snippet.txt │ │ ├── .articles │ │ │ ├── config.json │ │ │ └── performance │ │ │ │ └── snippet.md │ │ ├── .docs │ │ │ └── introduction.md │ │ └── bob_test.go │ ├── etl │ │ ├── go.mod │ │ ├── etl.go │ │ └── .meta │ │ │ └── example.go │ ├── grep │ │ ├── go.mod │ │ ├── grep.go │ │ └── .docs │ │ │ └── instructions.append.md │ ├── leap │ │ ├── go.mod │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .meta │ │ │ └── example.go │ │ ├── .approaches │ │ │ ├── max-two-checks │ │ │ │ └── snippet.txt │ │ │ ├── time-yearday │ │ │ │ └── snippet.txt │ │ │ ├── time-addition │ │ │ │ └── snippet.txt │ │ │ └── boolean-chain │ │ │ │ └── snippet.txt │ │ └── .articles │ │ │ ├── config.json │ │ │ └── performance │ │ │ └── snippet.md │ ├── luhn │ │ ├── go.mod │ │ ├── luhn.go │ │ ├── .approaches │ │ │ ├── validate-as-you-go │ │ │ │ └── snippet.txt │ │ │ └── scrub-and-validate-first │ │ │ │ └── snippet.txt │ │ └── .articles │ │ │ ├── performance │ │ │ └── snippet.md │ │ │ └── config.json │ ├── pov │ │ └── go.mod │ ├── say │ │ ├── go.mod │ │ ├── say.go │ │ └── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ ├── beer-song │ │ ├── go.mod │ │ └── beer_song.go │ ├── binary │ │ ├── go.mod │ │ └── binary.go │ ├── change │ │ ├── go.mod │ │ ├── change.go │ │ └── .docs │ │ │ └── instructions.md │ ├── clock │ │ ├── go.mod │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── .approaches │ │ │ ├── clock-as-int │ │ │ │ └── snippet.txt │ │ │ └── clock-as-struct │ │ │ │ └── snippet.txt │ │ ├── .articles │ │ │ └── config.json │ │ ├── clock.go │ │ └── .meta │ │ │ └── example.go │ ├── darts │ │ ├── go.mod │ │ ├── darts.go │ │ ├── .meta │ │ │ └── example.go │ │ └── .docs │ │ │ └── instructions.append.md │ ├── forth │ │ ├── go.mod │ │ └── forth.go │ ├── grains │ │ ├── go.mod │ │ ├── .approaches │ │ │ ├── bit-shifting │ │ │ │ └── snippet.txt │ │ │ └── math-pow-big-exponentiation │ │ │ │ └── snippet.txt │ │ ├── grains.go │ │ ├── .articles │ │ │ ├── config.json │ │ │ └── performance │ │ │ │ └── snippet.md │ │ └── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.md │ ├── house │ │ ├── go.mod │ │ └── house.go │ ├── ledger │ │ └── go.mod │ ├── matrix │ │ ├── go.mod │ │ ├── .docs │ │ │ └── instructions.append.md │ │ └── matrix.go │ ├── meetup │ │ ├── go.mod │ │ ├── meetup.go │ │ └── .meta │ │ │ └── example.go │ ├── octal │ │ ├── go.mod │ │ ├── octal.go │ │ └── .meta │ │ │ └── example.go │ ├── paasio │ │ ├── go.mod │ │ └── .docs │ │ │ └── instructions.md │ ├── poker │ │ ├── go.mod │ │ ├── poker.go │ │ └── .docs │ │ │ ├── instructions.md │ │ │ └── instructions.append.md │ ├── react │ │ └── go.mod │ ├── series │ │ ├── go.mod │ │ ├── .meta │ │ │ ├── first_example.go │ │ │ └── example.go │ │ └── series.go │ ├── sieve │ │ ├── go.mod │ │ ├── sieve.go │ │ ├── .approaches │ │ │ ├── slice-of-bools │ │ │ │ └── snippet.txt │ │ │ └── config.json │ │ ├── .meta │ │ │ └── example.go │ │ └── .docs │ │ │ └── introduction.md │ ├── strain │ │ ├── go.mod │ │ ├── .approaches │ │ │ ├── using-generics │ │ │ │ └── snippet.txt │ │ │ └── config.json │ │ ├── strain.go │ │ └── .meta │ │ │ └── example.go │ ├── two-fer │ │ ├── go.mod │ │ ├── .meta │ │ │ ├── example.go │ │ │ └── tests.toml │ │ └── .docs │ │ │ └── introduction.md │ ├── wordy │ │ ├── go.mod │ │ └── wordy.go │ ├── yacht │ │ ├── go.mod │ │ ├── yacht.go │ │ └── .docs │ │ │ └── introduction.md │ ├── acronym │ │ ├── go.mod │ │ └── .meta │ │ │ └── example.go │ ├── allergies │ │ ├── go.mod │ │ └── allergies.go │ ├── anagram │ │ ├── go.mod │ │ ├── anagram.go │ │ ├── .approaches │ │ │ ├── case-insensitive-sorting │ │ │ │ └── snippet.txt │ │ │ └── frequency-counter │ │ │ │ └── snippet.txt │ │ └── .docs │ │ │ └── instructions.append.md │ ├── bowling │ │ ├── go.mod │ │ └── bowling.go │ ├── connect │ │ ├── go.mod │ │ └── connect.go │ ├── counter │ │ ├── go.mod │ │ ├── counter.go │ │ ├── counter_test.go │ │ ├── .meta │ │ │ └── .skip_tests │ │ ├── interface.go │ │ └── impl1.go │ ├── diamond │ │ ├── go.mod │ │ └── diamond.go │ ├── dominoes │ │ ├── go.mod │ │ └── dominoes.go │ ├── grade-school │ │ ├── go.mod │ │ └── grade_school.go │ ├── hamming │ │ ├── go.mod │ │ ├── hamming.go │ │ ├── .approaches │ │ │ ├── iterate-runes │ │ │ │ └── snippet.txt │ │ │ └── iterate-bytes │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ ├── .articles │ │ │ ├── performance │ │ │ │ └── snippet.md │ │ │ └── config.json │ │ └── .meta │ │ │ └── example.go │ ├── isbn-verifier │ │ ├── go.mod │ │ ├── isbn_verifier.go │ │ ├── .approaches │ │ │ ├── iterate-bytes │ │ │ │ └── snippet.txt │ │ │ └── iterate-runes │ │ │ │ └── snippet.txt │ │ └── .articles │ │ │ ├── performance │ │ │ └── snippet.md │ │ │ └── config.json │ ├── isogram │ │ ├── go.mod │ │ ├── isogram.go │ │ ├── .approaches │ │ │ ├── map │ │ │ │ └── snippet.txt │ │ │ ├── strings-count │ │ │ │ └── snippet.txt │ │ │ └── bitfield │ │ │ │ └── snippet.txt │ │ ├── .meta │ │ │ └── example.go │ │ ├── .articles │ │ │ ├── config.json │ │ │ └── performance │ │ │ │ └── snippet.md │ │ └── .docs │ │ │ └── instructions.md │ ├── knapsack │ │ ├── go.mod │ │ ├── knapsack.go │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── config.json │ ├── list-ops │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ ├── markdown │ │ └── go.mod │ ├── nth-prime │ │ ├── go.mod │ │ ├── nth_prime.go │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ └── .meta │ │ │ └── example.go │ ├── ocr-numbers │ │ ├── go.mod │ │ └── ocr_numbers.go │ ├── pangram │ │ ├── go.mod │ │ ├── pangram.go │ │ ├── .approaches │ │ │ ├── strings-containsrune │ │ │ │ └── snippet.txt │ │ │ └── bitfield │ │ │ │ └── snippet.txt │ │ ├── .articles │ │ │ ├── performance │ │ │ │ └── snippet.md │ │ │ └── config.json │ │ ├── .docs │ │ │ └── instructions.md │ │ └── .meta │ │ │ └── example.go │ ├── pig-latin │ │ ├── go.mod │ │ ├── pig_latin.go │ │ ├── .articles │ │ │ ├── performance │ │ │ │ └── snippet.md │ │ │ └── config.json │ │ ├── .approaches │ │ │ ├── map-lookups │ │ │ │ └── snippet.txt │ │ │ └── map-lookups-with-generics │ │ │ │ └── snippet.txt │ │ └── .docs │ │ │ └── introduction.md │ ├── prime-factors │ │ ├── go.mod │ │ ├── prime_factors.go │ │ └── .meta │ │ │ └── example.go │ ├── proverb │ │ ├── go.mod │ │ └── .meta │ │ │ └── example.go │ ├── raindrops │ │ ├── go.mod │ │ ├── raindrops.go │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── example.go │ ├── space-age │ │ ├── go.mod │ │ └── space_age.go │ ├── sublist │ │ ├── go.mod │ │ ├── sublist.go │ │ └── relations.go │ ├── transpose │ │ ├── go.mod │ │ ├── transpose.go │ │ └── .meta │ │ │ └── example.go │ ├── tree-building │ │ ├── go.mod │ │ └── tree_building.go │ ├── triangle │ │ ├── go.mod │ │ └── .docs │ │ │ └── instructions.append.md │ ├── trinary │ │ ├── go.mod │ │ └── trinary.go │ ├── twelve-days │ │ ├── go.mod │ │ └── twelve_days.go │ ├── zebra-puzzle │ │ ├── go.mod │ │ ├── zebra_puzzle.go │ │ ├── .meta │ │ │ └── tests.toml │ │ └── zebra_puzzle_test.go │ ├── accumulate │ │ ├── go.mod │ │ ├── accumulate.go │ │ └── .meta │ │ │ └── example.go │ ├── alphametics │ │ ├── go.mod │ │ └── alphametics.go │ ├── atbash-cipher │ │ ├── go.mod │ │ └── atbash_cipher.go │ ├── bank-account │ │ ├── go.mod │ │ └── bank_account.go │ ├── book-store │ │ ├── go.mod │ │ ├── book_store.go │ │ └── .docs │ │ │ └── instructions.append.md │ ├── bottle-song │ │ ├── go.mod │ │ ├── bottle_song.go │ │ └── .meta │ │ │ └── config.json │ ├── circular-buffer │ │ └── go.mod │ ├── complex-numbers │ │ ├── go.mod │ │ └── .meta │ │ │ └── config.json │ ├── custom-set │ │ ├── go.mod │ │ └── .docs │ │ │ └── instructions.md │ ├── error-handling │ │ ├── go.mod │ │ ├── error_handling.go │ │ └── .docs │ │ │ └── instructions.append.md │ ├── flatten-array │ │ ├── go.mod │ │ ├── flatten_array.go │ │ └── .docs │ │ │ └── introduction.md │ ├── food-chain │ │ ├── go.mod │ │ └── food_chain.go │ ├── gigasecond │ │ ├── go.mod │ │ ├── .meta │ │ │ └── example.go │ │ └── .docs │ │ │ └── instructions.md │ ├── hello-world │ │ ├── go.mod │ │ ├── hello_world.go │ │ └── .meta │ │ │ ├── example.go │ │ │ └── tests.toml │ ├── hexadecimal │ │ ├── go.mod │ │ ├── hexadecimal.go │ │ └── .docs │ │ │ └── instructions.md │ ├── linked-list │ │ ├── go.mod │ │ └── .docs │ │ │ └── introduction.md │ ├── minesweeper │ │ ├── go.mod │ │ ├── minesweeper.go │ │ └── .docs │ │ │ └── introduction.md │ ├── nucleotide-count │ │ ├── go.mod │ │ ├── .approaches │ │ │ ├── switch-statement │ │ │ │ └── snippet.txt │ │ │ └── if-with-short-statement │ │ │ │ └── snippet.txt │ │ └── .articles │ │ │ ├── performance │ │ │ └── snippet.md │ │ │ └── config.json │ ├── pascals-triangle │ │ ├── go.mod │ │ ├── pascals_triangle.go │ │ └── .meta │ │ │ └── example.go │ ├── perfect-numbers │ │ ├── go.mod │ │ └── perfect_numbers.go │ ├── phone-number │ │ ├── go.mod │ │ ├── .docs │ │ │ └── instructions.append.md │ │ └── phone_number.go │ ├── queen-attack │ │ ├── go.mod │ │ └── queen_attack.go │ ├── rectangles │ │ ├── go.mod │ │ └── rectangles.go │ ├── reverse-string │ │ ├── go.mod │ │ ├── reverse_string.go │ │ ├── .docs │ │ │ ├── instructions.md │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── example.go │ ├── rna-transcription │ │ ├── go.mod │ │ ├── rna_transcription.go │ │ ├── .approaches │ │ │ ├── map-function │ │ │ │ └── snippet.txt │ │ │ ├── map-object │ │ │ │ └── snippet.txt │ │ │ └── switch │ │ │ │ └── snippet.txt │ │ ├── .meta │ │ │ └── example.go │ │ └── .articles │ │ │ ├── config.json │ │ │ └── performance │ │ │ └── snippet.md │ ├── robot-name │ │ ├── go.mod │ │ ├── robot_name.go │ │ └── .approaches │ │ │ ├── shuffle │ │ │ └── snippet.txt │ │ │ └── config.json │ ├── robot-simulator │ │ └── go.mod │ ├── saddle-points │ │ ├── go.mod │ │ └── saddle_points.go │ ├── scale-generator │ │ ├── go.mod │ │ └── scale_generator.go │ ├── scrabble-score │ │ ├── go.mod │ │ ├── scrabble_score.go │ │ ├── .approaches │ │ │ ├── map │ │ │ │ └── snippet.txt │ │ │ ├── switch-on-runes │ │ │ │ └── snippet.txt │ │ │ └── switch-on-strings │ │ │ │ └── snippet.txt │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .articles │ │ │ ├── config.json │ │ │ └── performance │ │ │ └── snippet.md │ ├── secret-handshake │ │ ├── go.mod │ │ ├── secret_handshake.go │ │ ├── .approaches │ │ │ ├── slice-indexes │ │ │ │ └── snippet.txt │ │ │ └── config.json │ │ └── .docs │ │ │ └── introduction.md │ ├── simple-cipher │ │ ├── go.mod │ │ └── cipher.go │ ├── tournament │ │ ├── go.mod │ │ └── tournament.go │ ├── two-bucket │ │ ├── go.mod │ │ └── two_bucket.go │ ├── word-count │ │ ├── go.mod │ │ ├── word_count.go │ │ └── .docs │ │ │ └── introduction.md │ ├── word-search │ │ ├── go.mod │ │ └── word_search.go │ ├── all-your-base │ │ ├── go.mod │ │ ├── all_your_base.go │ │ └── .docs │ │ │ ├── introduction.md │ │ │ └── instructions.append.md │ ├── armstrong-numbers │ │ ├── go.mod │ │ ├── armstrong_numbers.go │ │ └── .meta │ │ │ └── example.go │ ├── binary-search │ │ ├── go.mod │ │ ├── binary_search.go │ │ ├── .approaches │ │ │ ├── loop-with-switch │ │ │ │ └── snippet.txt │ │ │ └── config.json │ │ └── .meta │ │ │ └── example.go │ ├── crypto-square │ │ ├── go.mod │ │ └── crypto_square.go │ ├── diffie-hellman │ │ └── go.mod │ ├── dnd-character │ │ └── go.mod │ ├── matching-brackets │ │ ├── go.mod │ │ ├── matching_brackets.go │ │ └── .docs │ │ │ └── instructions.md │ ├── protein-translation │ │ ├── go.mod │ │ ├── .approaches │ │ │ ├── map │ │ │ │ └── snippet.txt │ │ │ └── switch │ │ │ │ └── snippet.txt │ │ ├── .articles │ │ │ ├── performance │ │ │ │ └── snippet.md │ │ │ └── config.json │ │ └── protein_translation.go │ ├── rail-fence-cipher │ │ ├── go.mod │ │ └── rail_fence_cipher.go │ ├── resistor-color │ │ ├── go.mod │ │ └── resistor_color.go │ ├── roman-numerals │ │ ├── go.mod │ │ └── roman_numerals.go │ ├── run-length-encoding │ │ ├── go.mod │ │ └── run_length_encoding.go │ ├── simple-linked-list │ │ ├── go.mod │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .approaches │ │ │ ├── keep-track-of-size │ │ │ └── snippet.txt │ │ │ └── config.json │ ├── spiral-matrix │ │ ├── go.mod │ │ ├── spiral_matrix.go │ │ └── .docs │ │ │ └── instructions.md │ ├── sum-of-multiples │ │ ├── go.mod │ │ ├── sum_of_multiples.go │ │ ├── .docs │ │ │ └── introduction.md │ │ └── .meta │ │ │ └── example.go │ ├── difference-of-squares │ │ ├── go.mod │ │ ├── difference_of_squares.go │ │ └── .meta │ │ │ └── example.go │ ├── kindergarten-garden │ │ ├── go.mod │ │ └── .docs │ │ │ └── introduction.md │ ├── largest-series-product │ │ ├── go.mod │ │ ├── largest_series_product.go │ │ └── .docs │ │ │ └── introduction.md │ ├── palindrome-products │ │ ├── go.mod │ │ └── palindrome_products.go │ ├── parallel-letter-frequency │ │ ├── go.mod │ │ └── .docs │ │ │ └── instructions.md │ ├── pythagorean-triplet │ │ ├── go.mod │ │ ├── .docs │ │ │ ├── instructions.append.md │ │ │ └── instructions.md │ │ └── pythagorean_triplet.go │ ├── rotational-cipher │ │ ├── go.mod │ │ ├── rotational_cipher.go │ │ └── .meta │ │ │ └── example.go │ ├── binary-search-tree │ │ └── go.mod │ ├── collatz-conjecture │ │ ├── go.mod │ │ ├── .docs │ │ │ └── instructions.md │ │ ├── collatz_conjecture.go │ │ └── .meta │ │ │ └── example.go │ ├── resistor-color-duo │ │ ├── go.mod │ │ ├── resistor_color_duo.go │ │ └── .meta │ │ │ └── example.go │ ├── resistor-color-trio │ │ ├── go.mod │ │ └── resistor_color_trio.go │ ├── state-of-tic-tac-toe │ │ ├── go.mod │ │ └── state_of_tic_tac_toe.go │ └── variable-length-quantity │ │ ├── go.mod │ │ └── variable_length_quantity.go └── shared │ └── .docs │ ├── help.md │ ├── tests.md │ └── debug.md ├── img ├── mars1.png ├── mars2.png └── mars3.png ├── gomod-sync ├── testdata │ ├── exercise01 │ │ └── go.mod │ ├── exercise02 │ │ └── go.mod │ ├── version_config_no_exceptions.json │ ├── version_config_one_exception.json │ └── version_config_two_exceptions.json ├── config.json ├── main.go ├── go.mod └── cmd │ └── config │ └── load.go ├── docs ├── SNIPPET.txt ├── INSTALLATION.md └── RESOURCES.md ├── concepts ├── variables │ └── .meta │ │ └── config.json ├── packages │ └── .meta │ │ └── config.json ├── time │ └── .meta │ │ └── config.json ├── type-definitions │ └── .meta │ │ └── config.json ├── pointers │ ├── .meta │ │ └── config.json │ └── links.json ├── runes │ └── .meta │ │ └── config.json ├── slices │ └── .meta │ │ └── config.json ├── maps │ └── .meta │ │ └── config.json ├── multiple-return-values │ ├── .meta │ │ └── config.json │ └── links.json ├── randomness │ └── .meta │ │ └── config.json ├── type-conversion │ ├── .meta │ │ └── config.json │ └── links.json ├── arithmetic-operators │ ├── .meta │ │ └── config.json │ └── links.json ├── floating-point-numbers │ ├── .meta │ │ └── config.json │ └── links.json ├── type-assertion │ ├── .meta │ │ └── config.json │ └── links.json ├── comparison │ ├── .meta │ │ └── config.json │ └── links.json ├── first-class-functions │ ├── .meta │ │ └── config.json │ └── links.json ├── for-loops │ ├── .meta │ │ └── config.json │ └── links.json ├── regular-expressions │ └── .meta │ │ └── config.json ├── conditionals-if │ ├── .meta │ │ └── config.json │ └── links.json ├── constants │ ├── .meta │ │ └── config.json │ └── links.json ├── booleans │ ├── .meta │ │ └── config.json │ └── links.json ├── functions │ ├── .meta │ │ └── config.json │ └── links.json ├── interfaces │ ├── .meta │ │ └── config.json │ └── links.json ├── variadic-functions │ ├── .meta │ │ └── config.json │ └── links.json ├── comments │ ├── .meta │ │ └── config.json │ └── introduction.md ├── strings-package │ ├── .meta │ │ └── config.json │ ├── introduction.md │ └── links.json ├── range-iteration │ ├── .meta │ │ └── config.json │ └── links.json ├── stringers │ ├── .meta │ │ └── config.json │ └── links.json ├── structs │ ├── .meta │ │ └── config.json │ └── links.json ├── basics │ └── .meta │ │ └── config.json ├── string-formatting │ ├── .meta │ │ └── config.json │ └── links.json ├── strings │ ├── .meta │ │ └── config.json │ └── links.json ├── zero-values │ ├── .meta │ │ └── config.json │ └── links.json ├── conditionals-switch │ ├── .meta │ │ └── config.json │ └── links.json ├── numbers │ ├── .meta │ │ └── config.json │ └── links.json ├── methods │ ├── .meta │ │ └── config.json │ └── links.json ├── error-wrapping │ ├── .meta │ │ └── config.json │ └── links.json └── errors │ ├── .meta │ └── config.json │ └── links.json ├── .github ├── CODEOWNERS ├── dependabot.yml └── workflows │ ├── configlet.yml │ ├── sync-labels.yml │ └── ping-cross-track-maintainers-team.yml └── .gitignore /reference/concepts/mutexes.md: -------------------------------------------------------------------------------- 1 | # Mutexes 2 | -------------------------------------------------------------------------------- /reference/concepts/slice.md: -------------------------------------------------------------------------------- 1 | # Slice 2 | -------------------------------------------------------------------------------- /reference/concepts/reflection.md: -------------------------------------------------------------------------------- 1 | # Reflection 2 | -------------------------------------------------------------------------------- /reference/concepts/type_switch.md: -------------------------------------------------------------------------------- 1 | # Type Switch 2 | -------------------------------------------------------------------------------- /reference/concepts/unsafe.md: -------------------------------------------------------------------------------- 1 | # `Unsafe` Package 2 | -------------------------------------------------------------------------------- /exercises/concept/deep-thought/.docs/hints.md: -------------------------------------------------------------------------------- 1 | # Hints 2 | -------------------------------------------------------------------------------- /exercises/concept/deep-thought/.meta/design.md: -------------------------------------------------------------------------------- 1 | # Design 2 | -------------------------------------------------------------------------------- /exercises/practice/bob/go.mod: -------------------------------------------------------------------------------- 1 | module bob 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/etl/go.mod: -------------------------------------------------------------------------------- 1 | module etl 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/grep/go.mod: -------------------------------------------------------------------------------- 1 | module grep 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/leap/go.mod: -------------------------------------------------------------------------------- 1 | module leap 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/luhn/go.mod: -------------------------------------------------------------------------------- 1 | module luhn 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/pov/go.mod: -------------------------------------------------------------------------------- 1 | module pov 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/say/go.mod: -------------------------------------------------------------------------------- 1 | module say 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/census/go.mod: -------------------------------------------------------------------------------- 1 | module census 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/lasagna/go.mod: -------------------------------------------------------------------------------- 1 | module lasagna 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/beer-song/go.mod: -------------------------------------------------------------------------------- 1 | module beer 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/binary/go.mod: -------------------------------------------------------------------------------- 1 | module binary 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/change/go.mod: -------------------------------------------------------------------------------- 1 | module change 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/clock/go.mod: -------------------------------------------------------------------------------- 1 | module clock 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/darts/go.mod: -------------------------------------------------------------------------------- 1 | module darts 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/forth/go.mod: -------------------------------------------------------------------------------- 1 | module forth 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/grains/go.mod: -------------------------------------------------------------------------------- 1 | module grains 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/house/go.mod: -------------------------------------------------------------------------------- 1 | module house 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/ledger/go.mod: -------------------------------------------------------------------------------- 1 | module ledger 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/matrix/go.mod: -------------------------------------------------------------------------------- 1 | module matrix 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/meetup/go.mod: -------------------------------------------------------------------------------- 1 | module meetup 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/octal/go.mod: -------------------------------------------------------------------------------- 1 | module octal 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/paasio/go.mod: -------------------------------------------------------------------------------- 1 | module paasio 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/poker/go.mod: -------------------------------------------------------------------------------- 1 | module poker 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/react/go.mod: -------------------------------------------------------------------------------- 1 | module react 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/series/go.mod: -------------------------------------------------------------------------------- 1 | module series 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/sieve/go.mod: -------------------------------------------------------------------------------- 1 | module sieve 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/strain/go.mod: -------------------------------------------------------------------------------- 1 | module strain 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/go.mod: -------------------------------------------------------------------------------- 1 | module twofer 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/wordy/go.mod: -------------------------------------------------------------------------------- 1 | module wordy 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/yacht/go.mod: -------------------------------------------------------------------------------- 1 | module yacht 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/animal-magic/go.mod: -------------------------------------------------------------------------------- 1 | module chance 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/blackjack/go.mod: -------------------------------------------------------------------------------- 1 | module blackjack 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/card-tricks/go.mod: -------------------------------------------------------------------------------- 1 | module cards 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/cars-assemble/go.mod: -------------------------------------------------------------------------------- 1 | module cars 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/deep-thought/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | -------------------------------------------------------------------------------- /exercises/concept/deep-thought/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | -------------------------------------------------------------------------------- /exercises/concept/expenses/go.mod: -------------------------------------------------------------------------------- 1 | module expenses 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/gross-store/go.mod: -------------------------------------------------------------------------------- 1 | module gross 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/logs-logs-logs/go.mod: -------------------------------------------------------------------------------- 1 | module logs 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/need-for-speed/go.mod: -------------------------------------------------------------------------------- 1 | module speed 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/sorting-room/go.mod: -------------------------------------------------------------------------------- 1 | module sorting 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/weather-forecast/go.mod: -------------------------------------------------------------------------------- 1 | module weather 2 | 3 | go 1.23 -------------------------------------------------------------------------------- /exercises/practice/acronym/go.mod: -------------------------------------------------------------------------------- 1 | module acronym 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/allergies/go.mod: -------------------------------------------------------------------------------- 1 | module allergies 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/anagram/go.mod: -------------------------------------------------------------------------------- 1 | module anagram 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/bowling/go.mod: -------------------------------------------------------------------------------- 1 | module bowling 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/connect/go.mod: -------------------------------------------------------------------------------- 1 | module connect 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/counter/go.mod: -------------------------------------------------------------------------------- 1 | module counter 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/diamond/go.mod: -------------------------------------------------------------------------------- 1 | module diamond 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/go.mod: -------------------------------------------------------------------------------- 1 | module dominoes 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/go.mod: -------------------------------------------------------------------------------- 1 | module school 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/hamming/go.mod: -------------------------------------------------------------------------------- 1 | module hamming 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/go.mod: -------------------------------------------------------------------------------- 1 | module isbn 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/isogram/go.mod: -------------------------------------------------------------------------------- 1 | module isogram 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/go.mod: -------------------------------------------------------------------------------- 1 | module knapsack 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/list-ops/go.mod: -------------------------------------------------------------------------------- 1 | module listops 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/markdown/go.mod: -------------------------------------------------------------------------------- 1 | module markdown 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/go.mod: -------------------------------------------------------------------------------- 1 | module prime 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/ocr-numbers/go.mod: -------------------------------------------------------------------------------- 1 | module ocr 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/pangram/go.mod: -------------------------------------------------------------------------------- 1 | module pangram 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/go.mod: -------------------------------------------------------------------------------- 1 | module piglatin 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/go.mod: -------------------------------------------------------------------------------- 1 | module prime 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/proverb/go.mod: -------------------------------------------------------------------------------- 1 | module proverb 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/go.mod: -------------------------------------------------------------------------------- 1 | module raindrops 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/space-age/go.mod: -------------------------------------------------------------------------------- 1 | module space 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/sublist/go.mod: -------------------------------------------------------------------------------- 1 | module sublist 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/transpose/go.mod: -------------------------------------------------------------------------------- 1 | module transpose 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/tree-building/go.mod: -------------------------------------------------------------------------------- 1 | module tree 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/triangle/go.mod: -------------------------------------------------------------------------------- 1 | module triangle 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/trinary/go.mod: -------------------------------------------------------------------------------- 1 | module trinary 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/twelve-days/go.mod: -------------------------------------------------------------------------------- 1 | module twelve 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/go.mod: -------------------------------------------------------------------------------- 1 | module zebra 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /img/mars1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/go/HEAD/img/mars1.png -------------------------------------------------------------------------------- /img/mars2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/go/HEAD/img/mars2.png -------------------------------------------------------------------------------- /img/mars3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exercism/go/HEAD/img/mars3.png -------------------------------------------------------------------------------- /exercises/concept/bird-watcher/go.mod: -------------------------------------------------------------------------------- 1 | module birdwatcher 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/chessboard/go.mod: -------------------------------------------------------------------------------- 1 | module chessboard 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/deep-thought/go.mod: -------------------------------------------------------------------------------- 1 | module deepthought 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/election-day/go.mod: -------------------------------------------------------------------------------- 1 | module electionday 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/jedliks-toys/go.mod: -------------------------------------------------------------------------------- 1 | module jedlik 2 | 3 | go 1.23 4 | 5 | -------------------------------------------------------------------------------- /exercises/concept/lasagna-master/go.mod: -------------------------------------------------------------------------------- 1 | module lasagna 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/meteorology/go.mod: -------------------------------------------------------------------------------- 1 | module meteorology 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/party-robot/go.mod: -------------------------------------------------------------------------------- 1 | module partyrobot 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/savings-account/go.mod: -------------------------------------------------------------------------------- 1 | module savings 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/the-farm/go.mod: -------------------------------------------------------------------------------- 1 | module thefarm 2 | 3 | go 1.23 4 | 5 | -------------------------------------------------------------------------------- /exercises/concept/vehicle-purchase/go.mod: -------------------------------------------------------------------------------- 1 | module purchase 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/go.mod: -------------------------------------------------------------------------------- 1 | module accumulate 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/go.mod: -------------------------------------------------------------------------------- 1 | module alphametics 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/go.mod: -------------------------------------------------------------------------------- 1 | module atbash 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/go.mod: -------------------------------------------------------------------------------- 1 | module account 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/book-store/go.mod: -------------------------------------------------------------------------------- 1 | module bookstore 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/bottle-song/go.mod: -------------------------------------------------------------------------------- 1 | module bottlesong 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/circular-buffer/go.mod: -------------------------------------------------------------------------------- 1 | module standard 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/go.mod: -------------------------------------------------------------------------------- 1 | module complex 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/go.mod: -------------------------------------------------------------------------------- 1 | module stringset 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/error-handling/go.mod: -------------------------------------------------------------------------------- 1 | module erratum 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/go.mod: -------------------------------------------------------------------------------- 1 | module flatten 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/go.mod: -------------------------------------------------------------------------------- 1 | module foodchain 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/go.mod: -------------------------------------------------------------------------------- 1 | module gigasecond 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/go.mod: -------------------------------------------------------------------------------- 1 | module greeting 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/hexadecimal/go.mod: -------------------------------------------------------------------------------- 1 | module hexadecimal 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/go.mod: -------------------------------------------------------------------------------- 1 | module linkedlist 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/go.mod: -------------------------------------------------------------------------------- 1 | module minesweeper 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/go.mod: -------------------------------------------------------------------------------- 1 | module dna 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/go.mod: -------------------------------------------------------------------------------- 1 | module pascal 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/go.mod: -------------------------------------------------------------------------------- 1 | module perfect 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/go.mod: -------------------------------------------------------------------------------- 1 | module phonenumber 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/go.mod: -------------------------------------------------------------------------------- 1 | module queenattack 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/rectangles/go.mod: -------------------------------------------------------------------------------- 1 | module rectangles 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/go.mod: -------------------------------------------------------------------------------- 1 | module reverse 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/go.mod: -------------------------------------------------------------------------------- 1 | module strand 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/go.mod: -------------------------------------------------------------------------------- 1 | module robotname 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/robot-simulator/go.mod: -------------------------------------------------------------------------------- 1 | module robot 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/go.mod: -------------------------------------------------------------------------------- 1 | module matrix 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/scale-generator/go.mod: -------------------------------------------------------------------------------- 1 | module scale 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/go.mod: -------------------------------------------------------------------------------- 1 | module scrabble 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/go.mod: -------------------------------------------------------------------------------- 1 | module secret 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/go.mod: -------------------------------------------------------------------------------- 1 | module cipher 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/tournament/go.mod: -------------------------------------------------------------------------------- 1 | module tournament 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/go.mod: -------------------------------------------------------------------------------- 1 | module twobucket 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/word-count/go.mod: -------------------------------------------------------------------------------- 1 | module wordcount 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/word-search/go.mod: -------------------------------------------------------------------------------- 1 | module wordsearch 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /gomod-sync/testdata/exercise01/go.mod: -------------------------------------------------------------------------------- 1 | module testmodule 2 | 3 | go 1.17 4 | -------------------------------------------------------------------------------- /gomod-sync/testdata/exercise02/go.mod: -------------------------------------------------------------------------------- 1 | module testmodule 2 | 3 | go 1.17 4 | -------------------------------------------------------------------------------- /exercises/concept/airport-robot/go.mod: -------------------------------------------------------------------------------- 1 | module airportrobot 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/annalyns-infiltration/go.mod: -------------------------------------------------------------------------------- 1 | module annalyn 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/booking-up-for-beauty/go.mod: -------------------------------------------------------------------------------- 1 | module booking 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/go.mod: -------------------------------------------------------------------------------- 1 | module allyourbase 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/go.mod: -------------------------------------------------------------------------------- 1 | module armstrong 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/go.mod: -------------------------------------------------------------------------------- 1 | module binarysearch 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/go.mod: -------------------------------------------------------------------------------- 1 | module cryptosquare 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/diffie-hellman/go.mod: -------------------------------------------------------------------------------- 1 | module diffiehellman 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/dnd-character/go.mod: -------------------------------------------------------------------------------- 1 | module dnd-character 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/go.mod: -------------------------------------------------------------------------------- 1 | module brackets 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/go.mod: -------------------------------------------------------------------------------- 1 | module protein 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/go.mod: -------------------------------------------------------------------------------- 1 | module railfence 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/go.mod: -------------------------------------------------------------------------------- 1 | module resistorcolor 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/go.mod: -------------------------------------------------------------------------------- 1 | module romannumerals 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/go.mod: -------------------------------------------------------------------------------- 1 | module encode 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/simple-linked-list/go.mod: -------------------------------------------------------------------------------- 1 | module linkedlist 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/go.mod: -------------------------------------------------------------------------------- 1 | module spiralmatrix 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/go.mod: -------------------------------------------------------------------------------- 1 | module summultiples 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /gomod-sync/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": "1.23", 3 | "exceptions": [] 4 | } 5 | -------------------------------------------------------------------------------- /exercises/concept/interest-is-interesting/go.mod: -------------------------------------------------------------------------------- 1 | module interest 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/parsing-log-files/go.mod: -------------------------------------------------------------------------------- 1 | module parsinglogfiles 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/welcome-to-tech-palace/go.mod: -------------------------------------------------------------------------------- 1 | module techpalace 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/go.mod: -------------------------------------------------------------------------------- 1 | module diffsquares 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/go.mod: -------------------------------------------------------------------------------- 1 | module kindergarten 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/go.mod: -------------------------------------------------------------------------------- 1 | module lsproduct 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/go.mod: -------------------------------------------------------------------------------- 1 | module palindrome 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/go.mod: -------------------------------------------------------------------------------- 1 | module letter 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/go.mod: -------------------------------------------------------------------------------- 1 | module pythagorean 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/go.mod: -------------------------------------------------------------------------------- 1 | module rotationalcipher 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/binary-search-tree/go.mod: -------------------------------------------------------------------------------- 1 | module binarysearchtree 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/go.mod: -------------------------------------------------------------------------------- 1 | module collatzconjecture 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/counter/counter.go: -------------------------------------------------------------------------------- 1 | package counter 2 | 3 | // TODO: add solution stub 4 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/go.mod: -------------------------------------------------------------------------------- 1 | module resistorcolorduo 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/go.mod: -------------------------------------------------------------------------------- 1 | module resistorcolortrio 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/state-of-tic-tac-toe/go.mod: -------------------------------------------------------------------------------- 1 | module stateoftictactoe 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/practice/counter/counter_test.go: -------------------------------------------------------------------------------- 1 | package counter 2 | 3 | // Define your tests here 4 | -------------------------------------------------------------------------------- /exercises/concept/deep-thought/deep_thought_test.go: -------------------------------------------------------------------------------- 1 | package deepthought 2 | 3 | // TODO: add tests 4 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/go.mod: -------------------------------------------------------------------------------- 1 | module variablelengthquantity 2 | 3 | go 1.23 4 | -------------------------------------------------------------------------------- /exercises/concept/deep-thought/deep_thought.go: -------------------------------------------------------------------------------- 1 | package deepthought 2 | 3 | // TODO: add solution stub 4 | -------------------------------------------------------------------------------- /reference/concepts/pointers.md: -------------------------------------------------------------------------------- 1 | # Pointers 2 | 3 | There are some specialties about pointers in Go... 4 | -------------------------------------------------------------------------------- /gomod-sync/testdata/version_config_no_exceptions.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": "1.16", 3 | "exceptions": [] 4 | } 5 | -------------------------------------------------------------------------------- /exercises/practice/counter/.meta/.skip_tests: -------------------------------------------------------------------------------- 1 | Do not remove this file. It indicates that testing should be skipped. 2 | -------------------------------------------------------------------------------- /exercises/practice/leap/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine whether a given year is a leap year. 4 | -------------------------------------------------------------------------------- /reference/concepts/modules.md: -------------------------------------------------------------------------------- 1 | # Modules 2 | 3 | Modules, mostly referred to as `Go modules` are Go's answer to dependency management. 4 | -------------------------------------------------------------------------------- /docs/SNIPPET.txt: -------------------------------------------------------------------------------- 1 | package greeting 2 | 3 | // HelloWorld greets the world. 4 | func HelloWorld() string { 5 | return "Hello, World!" 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/luhn/luhn.go: -------------------------------------------------------------------------------- 1 | package luhn 2 | 3 | func Valid(id string) bool { 4 | panic("Please implement the Valid function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/say/say.go: -------------------------------------------------------------------------------- 1 | package say 2 | 3 | func Say(n int64) (string, bool) { 4 | panic("Please implement the Say function") 5 | } 6 | -------------------------------------------------------------------------------- /gomod-sync/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/exercism/go/gomod-sync/cmd" 4 | 5 | func main() { 6 | cmd.Execute() 7 | } 8 | -------------------------------------------------------------------------------- /concepts/variables/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "TODO: add blurb", 3 | "authors": ["ErikSchierboom"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/darts/darts.go: -------------------------------------------------------------------------------- 1 | package darts 2 | 3 | func Score(x, y float64) int { 4 | panic("Please implement the Score function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/sieve/sieve.go: -------------------------------------------------------------------------------- 1 | package sieve 2 | 3 | func Sieve(limit int) []int { 4 | panic("Please implement the Sieve function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/leap/.meta/example.go: -------------------------------------------------------------------------------- 1 | package leap 2 | 3 | func IsLeapYear(i int) bool { 4 | return i%4 == 0 && i%100 != 0 || i%400 == 0 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/book-store/book_store.go: -------------------------------------------------------------------------------- 1 | package bookstore 2 | 3 | func Cost(books []int) int { 4 | panic("Please implement the Cost function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/diamond/diamond.go: -------------------------------------------------------------------------------- 1 | package diamond 2 | 3 | func Gen(char byte) (string, error) { 4 | panic("Please implement the Gen function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/simple-cipher/cipher.go: -------------------------------------------------------------------------------- 1 | package cipher 2 | 3 | type Cipher interface { 4 | Encode(string) string 5 | Decode(string) string 6 | } 7 | -------------------------------------------------------------------------------- /reference/concepts/interfaces.md: -------------------------------------------------------------------------------- 1 | # Interfaces 2 | 3 | The main difference to many other languages is that Go's interfaces are _implicitly_ implemented... 4 | -------------------------------------------------------------------------------- /exercises/practice/forth/forth.go: -------------------------------------------------------------------------------- 1 | package forth 2 | 3 | func Forth(input []string) ([]int, error) { 4 | panic("Please implement the Forth function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/hamming/hamming.go: -------------------------------------------------------------------------------- 1 | package hamming 2 | 3 | func Distance(a, b string) (int, error) { 4 | panic("Implement the Distance function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/isogram/isogram.go: -------------------------------------------------------------------------------- 1 | package isogram 2 | 3 | func IsIsogram(word string) bool { 4 | panic("Please implement the IsIsogram function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/pangram/pangram.go: -------------------------------------------------------------------------------- 1 | package pangram 2 | 3 | func IsPangram(input string) bool { 4 | panic("Please implement the IsPangram function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/wordy/wordy.go: -------------------------------------------------------------------------------- 1 | package wordy 2 | 3 | func Answer(question string) (int, bool) { 4 | panic("Please implement the Answer function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/yacht/yacht.go: -------------------------------------------------------------------------------- 1 | package yacht 2 | 3 | func Score(dice []int, category string) int { 4 | panic("Please implement the Score function") 5 | } 6 | -------------------------------------------------------------------------------- /concepts/packages/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Packages are the unit of code reuse in Go.", 3 | "authors": ["bobtfish"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/time/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Learn how to work with times and dates in Go.", 3 | "authors": ["jamessouth"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/type-definitions/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Go allows you to define custom types.", 3 | "authors": ["bobtfish"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/atbash-cipher/atbash_cipher.go: -------------------------------------------------------------------------------- 1 | package atbash 2 | 3 | func Atbash(s string) string { 4 | panic("Please implement the Atbash function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/etl/etl.go: -------------------------------------------------------------------------------- 1 | package etl 2 | 3 | func Transform(in map[int][]string) map[string]int { 4 | panic("Please implement the Transform function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/ocr-numbers/ocr_numbers.go: -------------------------------------------------------------------------------- 1 | package ocr 2 | 3 | func Recognize(string) []string { 4 | panic("Please implement the Recognize function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/prime_factors.go: -------------------------------------------------------------------------------- 1 | package prime 2 | 3 | func Factors(n int64) []int64 { 4 | panic("Please implement the Factors function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/raindrops.go: -------------------------------------------------------------------------------- 1 | package raindrops 2 | 3 | func Convert(number int) string { 4 | panic("Please implement the Convert function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/rectangles/rectangles.go: -------------------------------------------------------------------------------- 1 | package rectangles 2 | 3 | func Count(diagram []string) int { 4 | panic("Please implement the Count function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/scrabble_score.go: -------------------------------------------------------------------------------- 1 | package scrabble 2 | 3 | func Score(word string) int { 4 | panic("Please implement the Score function") 5 | } 6 | -------------------------------------------------------------------------------- /concepts/pointers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Pointers hold the memory address of a value.", 3 | "authors": ["andrerfcsantos"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/runes/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Runes represent the Unicode characters in Go strings.", 3 | "authors": ["sudomateo"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/slices/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Slices are lists of items of the same type.", 3 | "authors": ["ErikSchierboom"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/connect/connect.go: -------------------------------------------------------------------------------- 1 | package connect 2 | 3 | func ResultOf(lines []string) (string, error) { 4 | panic("Please implement the ResultOf function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/crypto-square/crypto_square.go: -------------------------------------------------------------------------------- 1 | package cryptosquare 2 | 3 | func Encode(pt string) string { 4 | panic("Please implement the Encode function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/flatten_array.go: -------------------------------------------------------------------------------- 1 | package flatten 2 | 3 | func Flatten(nested any) []any { 4 | panic("Please implement the Flatten function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/hello_world.go: -------------------------------------------------------------------------------- 1 | package greeting 2 | 3 | // HelloWorld greets the world. 4 | func HelloWorld() string { 5 | return "Goodbye, Mars!" 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/pascals_triangle.go: -------------------------------------------------------------------------------- 1 | package pascal 2 | 3 | func Triangle(n int) [][]int { 4 | panic("Please implement the Triangle function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/pig_latin.go: -------------------------------------------------------------------------------- 1 | package piglatin 2 | 3 | func Sentence(sentence string) string { 4 | panic("Please implement the Sentence function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/poker/poker.go: -------------------------------------------------------------------------------- 1 | package poker 2 | 3 | func BestHand(hands []string) ([]string, error) { 4 | panic("Please implement the BestHand function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/rna_transcription.go: -------------------------------------------------------------------------------- 1 | package strand 2 | 3 | func ToRNA(dna string) string { 4 | panic("Please implement the ToRNA function") 5 | } 6 | -------------------------------------------------------------------------------- /reference/concepts/methods.md: -------------------------------------------------------------------------------- 1 | # Methods 2 | 3 | Unlike many other programming languages that use classes to hold methods, in Go methods can be attached to any type... 4 | -------------------------------------------------------------------------------- /reference/concepts/packages.md: -------------------------------------------------------------------------------- 1 | # Packages 2 | 3 | Packages are used to structure Go code. From outside a package only public (capitalized) identifiers are accessible. 4 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/armstrong_numbers.go: -------------------------------------------------------------------------------- 1 | package armstrong 2 | 3 | func IsNumber(n int) bool { 4 | panic("Please implement the IsNumber function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/change/change.go: -------------------------------------------------------------------------------- 1 | package change 2 | 3 | func Change(coins []int, target int) ([]int, error) { 4 | panic("Please implement the Change function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/grep/grep.go: -------------------------------------------------------------------------------- 1 | package grep 2 | 3 | func Search(pattern string, flags, files []string) []string { 4 | panic("Please implement the Search function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/example.go: -------------------------------------------------------------------------------- 1 | package greeting 2 | 3 | // HelloWorld greets the world. 4 | func HelloWorld() string { 5 | return "Hello, World!" 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/isbn_verifier.go: -------------------------------------------------------------------------------- 1 | package isbn 2 | 3 | func IsValidISBN(isbn string) bool { 4 | panic("Please implement the IsValidISBN function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/reverse_string.go: -------------------------------------------------------------------------------- 1 | package reverse 2 | 3 | func Reverse(input string) string { 4 | panic("Please implement the Reverse function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/transpose/transpose.go: -------------------------------------------------------------------------------- 1 | package transpose 2 | 3 | func Transpose(input []string) []string { 4 | panic("Please implement the Transpose function") 5 | } 6 | -------------------------------------------------------------------------------- /concepts/maps/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Maps are a bultin type in Go that associates values with keys.", 3 | "authors": ["chocopowwwa"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/multiple-return-values/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Functions can return multiple return values.", 3 | "authors": ["jmrunkle"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/randomness/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Generate pseudo-random integer and floating-point numbers.", 3 | "authors": ["norbs57"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/anagram/anagram.go: -------------------------------------------------------------------------------- 1 | package anagram 2 | 3 | func Detect(subject string, candidates []string) []string { 4 | panic("Please implement the Detect function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/matching_brackets.go: -------------------------------------------------------------------------------- 1 | package brackets 2 | 3 | func Bracket(input string) bool { 4 | panic("Please implement the Bracket function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Raindrops is a slightly more complex version of the FizzBuzz challenge, a classic interview question. 4 | -------------------------------------------------------------------------------- /exercises/practice/scale-generator/scale_generator.go: -------------------------------------------------------------------------------- 1 | package scale 2 | 3 | func Scale(tonic, interval string) []string { 4 | panic("Please implement the Scale function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/secret_handshake.go: -------------------------------------------------------------------------------- 1 | package secret 2 | 3 | func Handshake(code uint) []string { 4 | panic("Please implement the Handshake function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/trinary/trinary.go: -------------------------------------------------------------------------------- 1 | package trinary 2 | 3 | func ParseTrinary(arg string, want int64, ok bool) { 4 | panic("Please implement the ParseTrinary function") 5 | } 6 | -------------------------------------------------------------------------------- /reference/concepts/loops.md: -------------------------------------------------------------------------------- 1 | # Loops 2 | 3 | Cases in Go 4 | 5 | - for loop 6 | - range loop 7 | - iterating a bool 8 | - iterating a channel 9 | - iterating a string 10 | -------------------------------------------------------------------------------- /concepts/type-conversion/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Go requires explicit conversion between different types.", 3 | "authors": ["jmrunkle"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/alphametics/alphametics.go: -------------------------------------------------------------------------------- 1 | package alphametics 2 | 3 | func Solve(puzzle string) (map[string]int, error) { 4 | panic("Please implement the Solve function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/binary_search.go: -------------------------------------------------------------------------------- 1 | package binarysearch 2 | 3 | func SearchInts(list []int, key int) int { 4 | panic("Please implement the SearchInts function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/bottle-song/bottle_song.go: -------------------------------------------------------------------------------- 1 | package bottlesong 2 | 3 | func Recite(startBottles, takeDown int) []string { 4 | panic("Please implement the Recite function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/error-handling/error_handling.go: -------------------------------------------------------------------------------- 1 | package erratum 2 | 3 | func Use(opener ResourceOpener, input string) error { 4 | panic("Please implement the Use function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/octal/octal.go: -------------------------------------------------------------------------------- 1 | package octal 2 | 3 | func ParseOctal(input string, expectedNum int64, expectErr bool) { 4 | panic("Please implement the ParseOctal function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/spiral_matrix.go: -------------------------------------------------------------------------------- 1 | package spiralmatrix 2 | 3 | func SpiralMatrix(size int) [][]int { 4 | panic("Please implement the SpiralMatrix function") 5 | } 6 | -------------------------------------------------------------------------------- /concepts/arithmetic-operators/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Go has standard arithmetic operators for numeric types.", 3 | "authors": ["jmrunkle"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/hexadecimal/hexadecimal.go: -------------------------------------------------------------------------------- 1 | package hexadecimal 2 | 3 | func ParseHex(in string, out int64, errCase string) { 4 | panic("Please implement the ParseHex function") 5 | } 6 | -------------------------------------------------------------------------------- /concepts/floating-point-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Go has two floating-point types: float32 and float64.", 3 | "authors": ["ErikSchierboom"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/counter/interface.go: -------------------------------------------------------------------------------- 1 | package counter 2 | 3 | type Counter interface { 4 | AddString(string) 5 | 6 | Lines() int 7 | Letters() int 8 | Characters() int 9 | } 10 | -------------------------------------------------------------------------------- /reference/concepts/channels.md: -------------------------------------------------------------------------------- 1 | # Channels 2 | 3 | Channels are a kind of pipeline that can be used to safely communicate between different goroutines (and sometimes within a single goroutine). 4 | -------------------------------------------------------------------------------- /exercises/practice/bob/.approaches/if-statements/snippet.txt: -------------------------------------------------------------------------------- 1 | if shout { 2 | if question { 3 | return "Calm down, I know what I'm doing!" 4 | } 5 | return "Whoa, chill out!" 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/max-two-checks/snippet.txt: -------------------------------------------------------------------------------- 1 | func IsLeapYear(year int) bool { 2 | if year%100 == 0 { 3 | return year%400 == 0 4 | } else { 5 | return year%4 == 0 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/roman-numerals/roman_numerals.go: -------------------------------------------------------------------------------- 1 | package romannumerals 2 | 3 | func ToRomanNumeral(input int) (string, error) { 4 | panic("Please implement the ToRomanNumeral function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/series/.meta/first_example.go: -------------------------------------------------------------------------------- 1 | package series 2 | 3 | func First(n int, s string) (string, bool) { 4 | if n > len(s) { 5 | return "", false 6 | } 7 | return s[:n], true 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/space-age/space_age.go: -------------------------------------------------------------------------------- 1 | package space 2 | 3 | type Planet string 4 | 5 | func Age(seconds float64, planet Planet) float64 { 6 | panic("Please implement the Age function") 7 | } 8 | -------------------------------------------------------------------------------- /concepts/type-assertion/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Use type assertions to access an interface value's underlying concrete value.", 3 | "authors": ["jmrunkle"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /docs/INSTALLATION.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | Follow the instructions for your system on the installation page at [golang.org](http://golang.org/doc/install). 4 | 5 | Exercism supports Go 1.2 and higher. 6 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.approaches/map/snippet.txt: -------------------------------------------------------------------------------- 1 | func Score(word string) score int { 2 | for _, ltr := range word { 3 | score += lookup[unicode.ToLower(ltr)] 4 | } 5 | return score 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/sum_of_multiples.go: -------------------------------------------------------------------------------- 1 | package summultiples 2 | 3 | func SumMultiples(limit int, divisors ...int) int { 4 | panic("Please implement the SumMultiples function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/tournament/tournament.go: -------------------------------------------------------------------------------- 1 | package tournament 2 | 3 | import "io" 4 | 5 | func Tally(reader io.Reader, writer io.Writer) error { 6 | panic("Please implement the Tally function") 7 | } 8 | -------------------------------------------------------------------------------- /concepts/comparison/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Compare values using the equality and ordering operators of Go.", 3 | "authors": [ 4 | "andrerfcsantos" 5 | ], 6 | "contributors": [] 7 | } 8 | -------------------------------------------------------------------------------- /concepts/first-class-functions/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": ["antklim"], 3 | "contributors": ["andrerfcsantos"], 4 | "blurb": "Functions in Go can be used as regular values of the language." 5 | } 6 | -------------------------------------------------------------------------------- /concepts/for-loops/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Execute the same piece of code several times", 3 | "authors": [ 4 | "sachinmk27", 5 | "andrerfcsantos" 6 | ], 7 | "contributors": [] 8 | } 9 | -------------------------------------------------------------------------------- /concepts/regular-expressions/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "A regular expression is a sequence of characters that specify a search pattern.", 3 | "authors": ["norbs57"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/accumulate.go: -------------------------------------------------------------------------------- 1 | package accumulate 2 | 3 | func Accumulate(list []string, transform func(string) string) []string { 4 | panic("Please implement the Accumulate function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/binary/binary.go: -------------------------------------------------------------------------------- 1 | package binary 2 | 3 | // TODO: add solution stub 4 | func ParseBinary(binary string, expected int, ok bool) { 5 | panic("Please implement the ParseBinary function") 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a positive integer, return the number of steps it takes to reach 1 according to the rules of the Collatz Conjecture. 4 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/collatz_conjecture.go: -------------------------------------------------------------------------------- 1 | package collatzconjecture 2 | 3 | func CollatzConjecture(n int) (int, error) { 4 | panic("Please implement the CollatzConjecture function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/word-search/word_search.go: -------------------------------------------------------------------------------- 1 | package wordsearch 2 | 3 | func Solve(words []string, puzzle []string) (map[string][2][2]int, error) { 4 | panic("Please implement the Solve function") 5 | } 6 | -------------------------------------------------------------------------------- /concepts/conditionals-if/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "If statements control the flow of execution of a program based on a boolean condition.", 3 | "authors": ["tehsphinx"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/queen-attack/queen_attack.go: -------------------------------------------------------------------------------- 1 | package queenattack 2 | 3 | func CanQueenAttack(whitePosition, blackPosition string) (bool, error) { 4 | panic("Please implement the CanQueenAttack function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/word-count/word_count.go: -------------------------------------------------------------------------------- 1 | package wordcount 2 | 3 | type Frequency map[string]int 4 | 5 | func WordCount(phrase string) Frequency { 6 | panic("Please implement the WordCount function") 7 | } 8 | -------------------------------------------------------------------------------- /gomod-sync/testdata/version_config_one_exception.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": "1.16", 3 | "exceptions": [ 4 | { 5 | "exercise": "exercise01", 6 | "version": "1.17" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /concepts/constants/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Constants are pieces of data similar to variables, but whose value cannot change during execution.", 3 | "authors": ["jamessouth"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/dominoes/dominoes.go: -------------------------------------------------------------------------------- 1 | package dominoes 2 | 3 | // Define the Domino type here. 4 | 5 | func MakeChain(input []Domino) ([]Domino, bool) { 6 | panic("Please implement the MakeChain function") 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/minesweeper.go: -------------------------------------------------------------------------------- 1 | package minesweeper 2 | 3 | // Annotate returns an annotated board 4 | func Annotate(board []string) []string { 5 | panic("Please implement the Annotate function") 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/rotational_cipher.go: -------------------------------------------------------------------------------- 1 | package rotationalcipher 2 | 3 | func RotationalCipher(plain string, shiftKey int) string { 4 | panic("Please implement the RotationalCipher function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/simple-linked-list/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a music streaming company. 4 | 5 | You've been tasked with creating a playlist feature for your music player application. 6 | -------------------------------------------------------------------------------- /exercises/practice/sublist/sublist.go: -------------------------------------------------------------------------------- 1 | package sublist 2 | 3 | // Relation type is defined in relations.go file. 4 | 5 | func Sublist(l1, l2 []int) Relation { 6 | panic("Please implement the Sublist function") 7 | } 8 | -------------------------------------------------------------------------------- /concepts/booleans/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Representation of true and false. Booleans can be combined into expressions using operators AND, OR and NOT.", 3 | "authors": ["oanaOM"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.approaches/loop-with-switch/snippet.txt: -------------------------------------------------------------------------------- 1 | switch { 2 | case list[mid] == key: 3 | return mid 4 | case key < list[mid]: 5 | right = mid 6 | case key > list[mid]: 7 | left = mid + 1 8 | } 9 | -------------------------------------------------------------------------------- /reference/concepts/testing.md: -------------------------------------------------------------------------------- 1 | # Testing in Go 2 | 3 | TODO: proper intro to testing. 4 | 5 | Possible reference to use: [https://ieftimov.com/post/testing-in-go-go-test/](https://ieftimov.com/post/testing-in-go-go-test/) 6 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/all_your_base.go: -------------------------------------------------------------------------------- 1 | package allyourbase 2 | 3 | func ConvertToBase(inputBase int, inputDigits []int, outputBase int) ([]int, error) { 4 | panic("Please implement the ConvertToBase function") 5 | } 6 | -------------------------------------------------------------------------------- /concepts/functions/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Functions split a program up into logical units of computation. They optionally take arguments and return values.", 3 | "authors": ["bobtfish"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/interfaces/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Interfaces define method sets and are implemented implicitily by all types that have those methods.", 3 | "authors": ["jmrunkle", "junedev"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/variadic-functions/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Variadic functions allow for an arbitrary number of arguments to be passed to a function.", 3 | "authors": ["myworkcircle"], 4 | "contributors": ["junedev"] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/house/house.go: -------------------------------------------------------------------------------- 1 | package house 2 | 3 | func Verse(v int) string { 4 | panic("Please implement the Verse function") 5 | } 6 | 7 | func Song() string { 8 | panic("Please implement the Song function") 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/largest_series_product.go: -------------------------------------------------------------------------------- 1 | package lsproduct 2 | 3 | func LargestSeriesProduct(digits string, span int) (int64, error) { 4 | panic("Please implement the LargestSeriesProduct function") 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.approaches/map-function/snippet.txt: -------------------------------------------------------------------------------- 1 | func ToRNA(dna string) string { 2 | return strings.Map(func(r rune) rune { 3 | switch r { 4 | case 'G': 5 | return 'C' 6 | case 'C': 7 | return 'G' 8 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.approaches/map-object/snippet.txt: -------------------------------------------------------------------------------- 1 | func ToRNA(dna string) string { 2 | rna := make([]byte, len(dna)) 3 | for i, c := range dna { 4 | rna[i] = translate[c] 5 | } 6 | return string(rna) 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/two-bucket/two_bucket.go: -------------------------------------------------------------------------------- 1 | package twobucket 2 | 3 | func Solve(sizeBucketOne, sizeBucketTwo, goalAmount int, startBucket string) (string, int, int, error) { 4 | panic("Please implement the Solve function") 5 | } 6 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners 2 | .github/CODEOWNERS @exercism/maintainers-admin 3 | 4 | # Changes to `fetch-configlet` should be made in the `exercism/configlet` repo 5 | bin/fetch-configlet @exercism/maintainers-admin 6 | 7 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | 5 | # Keep dependencies for GitHub Actions up-to-date 6 | - package-ecosystem: 'github-actions' 7 | directory: '/' 8 | schedule: 9 | interval: 'monthly' 10 | -------------------------------------------------------------------------------- /concepts/comments/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Comments are human-readable annotations on the code that make programs easier to understand by other programmers.", 3 | "authors": ["nikimanoledaki"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/strings-package/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "The standard library strings package includes great utility functions to work with strings.", 3 | "authors": ["tehsphinx", "erikschierboom"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/strings-package/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The `strings` package contains many useful functions to work on strings. 4 | 5 | ```go 6 | import "strings" 7 | 8 | strings.ToUpper("test") // => "TEST" 9 | ``` 10 | -------------------------------------------------------------------------------- /exercises/concept/airport-robot/airport_robot.go: -------------------------------------------------------------------------------- 1 | package airportrobot 2 | 3 | // Write your code here. 4 | // This exercise does not have tests for each individual task. 5 | // Try to solve all the tasks first before running the tests. 6 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.approaches/validate-as-you-go/snippet.txt: -------------------------------------------------------------------------------- 1 | func Valid(num string) bool { 2 | total := 0 3 | pos := 0 4 | for i := len(num) - 1; i > -1; i-- { 5 | char := num[i] 6 | if char == ' ' { 7 | continue 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/perfect-numbers/perfect_numbers.go: -------------------------------------------------------------------------------- 1 | package perfect 2 | 3 | // Define the Classification type here. 4 | 5 | func Classify(n int64) (Classification, error) { 6 | panic("Please implement the Classify function") 7 | } 8 | -------------------------------------------------------------------------------- /concepts/range-iteration/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Go has a special \"for range\" loop to easily iterate over collections of data.", 3 | "authors": [ 4 | "brugnara", 5 | "tehsphinx" 6 | ], 7 | "contributors": [] 8 | } 9 | -------------------------------------------------------------------------------- /concepts/stringers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Stringer is an interface for defining the string format of values.", 3 | "authors": [ 4 | "norbs57" 5 | ], 6 | "contributors": [ 7 | "andrerfcsantos" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /concepts/structs/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Structs group pieces of related data together.", 3 | "authors": [ 4 | "tehsphinx" 5 | ], 6 | "contributors": [ 7 | "eklatzer", 8 | "andrerfcsantos" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.meta/example.go: -------------------------------------------------------------------------------- 1 | package gigasecond 2 | 3 | import "time" 4 | 5 | // AddGigasecond returns time t plus one gigasecond. 6 | func AddGigasecond(t time.Time) time.Time { 7 | return t.Add(1e9 * time.Second) 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/palindrome-products/palindrome_products.go: -------------------------------------------------------------------------------- 1 | package palindrome 2 | 3 | // Define Product type here. 4 | 5 | func Products(fmin, fmax int) (Product, Product, error) { 6 | panic("Please implement the Products function") 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.approaches/map/snippet.txt: -------------------------------------------------------------------------------- 1 | protein = lookup[codon] 2 | if protein == "" { 3 | err = ErrInvalidBase 4 | } else if protein == "STOP" { 5 | protein = "" 6 | err = ErrStop 7 | } 8 | return protein, err 9 | -------------------------------------------------------------------------------- /concepts/basics/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Introduction to Packages, Functions, and Variables", 3 | "authors": [ 4 | "tehsphinx" 5 | ], 6 | "contributors": [ 7 | "ekingery", 8 | "andrerfcsantos" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/grains/.approaches/bit-shifting/snippet.txt: -------------------------------------------------------------------------------- 1 | func Square(num int) (uint64, error) { 2 | if num < 1 || num > 64 { 3 | return 0, errors.New("square number must be 1 through 64") 4 | } 5 | 6 | return 1 << (num - 1), nil 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.approaches/iterate-runes/snippet.txt: -------------------------------------------------------------------------------- 1 | strand1Runes := []rune(strand1) 2 | strand2Runes := []rune(strand2) 3 | for idx, rooney := range strand1Runes { 4 | if rooney != strand2Runes[idx] { 5 | distance++ 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.approaches/map/snippet.txt: -------------------------------------------------------------------------------- 1 | for _, chr := range phrase { 2 | if !unicode.IsLetter(chr) { 3 | continue 4 | } 5 | ltr := unicode.ToLower(chr) 6 | if _, exists := lookup[ltr]; exists { 7 | return false 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/twelve-days/twelve_days.go: -------------------------------------------------------------------------------- 1 | package twelve 2 | 3 | func Verse(i int) string { 4 | panic("Please implement the Verse function") 5 | } 6 | 7 | func Song() string { 8 | panic("Please implement the Song function") 9 | } 10 | -------------------------------------------------------------------------------- /concepts/comments/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | In the previous concept, we saw that there are two ways to write comments in Go: single-line comments that are preceded by `//`, and multiline comment blocks that are wrapped with `/*` and `*/`. 4 | -------------------------------------------------------------------------------- /concepts/string-formatting/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "You can use the built-in formatting package \"fmt\" to create strings that embed values or variables with special formatting.", 3 | "authors": ["tehsphinx"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/strings/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "A string in Go is an immutable sequence of bytes, which don't necessarily have to represent characters.", 3 | "authors": ["tehsphinx", "erikschierboom"], 4 | "contributors": ["kekimaker"] 5 | } 6 | -------------------------------------------------------------------------------- /concepts/zero-values/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "When a variable is created without a value, it gets assigned the zero value of its type.", 3 | "authors": [ 4 | "ErikSchierboom", 5 | "sudomateo" 6 | ], 7 | "contributors": [] 8 | } 9 | -------------------------------------------------------------------------------- /concepts/conditionals-switch/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Switches control the flow of a program based on the value of a variable or expression.", 3 | "authors": [ 4 | "tehsphinx", 5 | "andrerfcsantos" 6 | ], 7 | "contributors": [] 8 | } 9 | -------------------------------------------------------------------------------- /concepts/numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Go has several types to represent integers, floating point and even complex numbers!", 3 | "authors": [ 4 | "DavyJ0nes" 5 | ], 6 | "contributors": [ 7 | "tehsphinx" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/grains/grains.go: -------------------------------------------------------------------------------- 1 | package grains 2 | 3 | func Square(number int) (uint64, error) { 4 | panic("Please implement the Square function") 5 | } 6 | 7 | func Total() uint64 { 8 | panic("Please implement the Total function") 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/resistor_color_duo.go: -------------------------------------------------------------------------------- 1 | package resistorcolorduo 2 | 3 | // Value should return the resistance value of a resistor with a given colors. 4 | func Value(colors []string) int { 5 | panic("Implement the Value function") 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/zebra_puzzle.go: -------------------------------------------------------------------------------- 1 | package zebra 2 | 3 | type Solution struct { 4 | DrinksWater string 5 | OwnsZebra string 6 | } 7 | 8 | func SolvePuzzle() Solution { 9 | panic("Please implement the SolvePuzzle function") 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | .DS_Store 3 | .editorconfig 4 | tmp 5 | bin/configlet 6 | bin/configlet.exe 7 | bin/golangci-lint 8 | bin/golangci-lint.exe 9 | 10 | # gomod-sync 11 | 12 | gomod-sync/gomod-sync 13 | gomod-sync/gomod-sync.exe 14 | gomod-sync/vendor 15 | -------------------------------------------------------------------------------- /exercises/practice/bob/.approaches/switch-statement/snippet.txt: -------------------------------------------------------------------------------- 1 | switch true { 2 | case question && shout: 3 | return "Calm down, I know what I'm doing!" 4 | case shout: 5 | return "Whoa, chill out!" 6 | case question: 7 | return "Sure." 8 | default: 9 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | Additionally, a `Format()` function should produce the output 4 | 5 | `(613) 995-0253` 6 | 7 | and an `AreaCode()` function should output 8 | 9 | `613` 10 | 11 | -------------------------------------------------------------------------------- /exercises/practice/poker/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Pick the best hand(s) from a list of poker hands. 4 | 5 | See [Wikipedia][poker-hands] for an overview of poker hands. 6 | 7 | [poker-hands]: https://en.wikipedia.org/wiki/List_of_poker_hands 8 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.approaches/slice-indexes/snippet.txt: -------------------------------------------------------------------------------- 1 | output := []string{} 2 | for ; action != end; action += actionIncr { 3 | if (code & (1 << action)) != 0 { 4 | output = append(output, signs[action]) 5 | } 6 | } 7 | return output 8 | -------------------------------------------------------------------------------- /exercises/practice/simple-linked-list/.approaches/keep-track-of-size/snippet.txt: -------------------------------------------------------------------------------- 1 | if l.size < 1 { 2 | return 0, errors.New("no elements") 3 | } 4 | deadHead := l.head 5 | l.head = deadHead.next 6 | deadHead.next = nil 7 | l.size-- 8 | return deadHead.data, nil 9 | -------------------------------------------------------------------------------- /exercises/practice/clock/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Implement a clock that handles times without dates. 4 | 5 | You should be able to add and subtract minutes to it. 6 | 7 | Two clocks that represent the same time should be equal to each other. 8 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.approaches/strings-count/snippet.txt: -------------------------------------------------------------------------------- 1 | phrase = strings.ToLower(phrase) 2 | for _, chr := range phrase { 3 | if !unicode.IsLetter(chr) { 4 | continue 5 | } 6 | if strings.Count(phrase, string(chr)) > 1 { 7 | return false 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.approaches/switch-statement/snippet.txt: -------------------------------------------------------------------------------- 1 | for _, nuc := range dna { 2 | switch nuc { 3 | case 'A', 'C', 'G', 'T': 4 | results[nuc]++ 5 | default: 6 | return nil, fmt.Errorf("invalid nucleotide '%c'", nuc) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.approaches/switch-on-runes/snippet.txt: -------------------------------------------------------------------------------- 1 | for _, letter := range word { 2 | 3 | switch unicode.ToLower(letter) { 4 | case 'a', 'e', 'i', 'o', 'u', 'l', 'n', 'r', 's', 't': 5 | score += 1 6 | case 'd', 'g': 7 | score += 2 8 | -------------------------------------------------------------------------------- /reference/concepts/multiple_returns.md: -------------------------------------------------------------------------------- 1 | # Multiple Return Values 2 | 3 | Go allows any function or method to return multiple values. 4 | 5 | This is a prerequisite for how Go handles errors. If a function returns an error, it should always be the last return value. 6 | -------------------------------------------------------------------------------- /reference/concepts/nil.md: -------------------------------------------------------------------------------- 1 | # Nil 2 | 3 | The empty value for pointers and pointer-based types in Go is `nil`. The builtin pointer based types are (incl. pointer): 4 | 5 | - channels 6 | - functions 7 | - interfaces 8 | - maps 9 | - pointers 10 | - slices 11 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.approaches/switch/snippet.txt: -------------------------------------------------------------------------------- 1 | func ToRNA(dna string) string { 2 | length := len(dna) 3 | var output = make([]byte, length) 4 | for i := 0; i < length; i++ { 5 | output[i] = (nucComp(dna[i])) 6 | } 7 | return string(output) 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/series/series.go: -------------------------------------------------------------------------------- 1 | package series 2 | 3 | func All(n int, s string) []string { 4 | panic("Please implement the All function") 5 | } 6 | 7 | func UnsafeFirst(n int, s string) string { 8 | panic("Please implement the UnsafeFirst function") 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/example.go: -------------------------------------------------------------------------------- 1 | package twofer 2 | 3 | // ShareWith apportions the goods between two people. 4 | func ShareWith(name string) string { 5 | if name == "" { 6 | name = "you" 7 | } 8 | return "One for " + name + ", one for me." 9 | } 10 | -------------------------------------------------------------------------------- /concepts/methods/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Methods are functions with a special receiver argument that can be called on an instance of the receiver type.", 3 | "authors": [ 4 | "tehsphinx" 5 | ], 6 | "contributors": [ 7 | "oanaOM" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/bob/.approaches/answer-array/snippet.txt: -------------------------------------------------------------------------------- 1 | func Hey(remark string) string { 2 | remark = strings.TrimSpace(remark) 3 | if isEmpty(remark) { 4 | return "Fine. Be that way!" 5 | } 6 | return answers[isQuestion(remark)+isShout(remark)] 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | You may be wondering about the `cases_test.go` file. We explain it in the 4 | [leap exercise][leap-exercise-link]. 5 | 6 | [leap-exercise-link]: https://exercism.org/tracks/go/exercises/leap 7 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/.approaches/iterate-bytes/snippet.txt: -------------------------------------------------------------------------------- 1 | for i := 0; i < length; i++ { 2 | chr := input[i] 3 | if digit, ok := getDigit(chr); ok { 4 | sum += (digit * pos) 5 | pos-- 6 | } else if pos == 1 && chr == 'X' { 7 | sum += 10 8 | pos-- 9 | -------------------------------------------------------------------------------- /exercises/practice/meetup/meetup.go: -------------------------------------------------------------------------------- 1 | package meetup 2 | 3 | import "time" 4 | 5 | // Define the WeekSchedule type here. 6 | 7 | func Day(wSched WeekSchedule, wDay time.Weekday, month time.Month, year int) int { 8 | panic("Please implement the Day function") 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.approaches/strings-containsrune/snippet.txt: -------------------------------------------------------------------------------- 1 | func IsPangram(s string) bool { 2 | lookup := strings.ToLower(s) 3 | for chr := 'a'; chr <= 'z'; chr++ { 4 | if !strings.ContainsRune(lookup, chr) { 5 | return false 6 | } 7 | } 8 | return true 9 | -------------------------------------------------------------------------------- /concepts/error-wrapping/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Go allows to add context to errors and provides functions to check for or retrieve the original error later on. This is called error wrapping (and unwrapping).", 3 | "authors": ["junedev"], 4 | "contributors": [] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/grains/.approaches/math-pow-big-exponentiation/snippet.txt: -------------------------------------------------------------------------------- 1 | func Square(num int) (uint64, error) { 2 | if num < 1 || num > 64 { 3 | return 0, errors.New("square number must be 1 through 64") 4 | } 5 | 6 | return uint64(math.Pow(2, float64(num-1))), nil 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.approaches/iterate-bytes/snippet.txt: -------------------------------------------------------------------------------- 1 | if len(strand1) != len(strand2) { 2 | return distance, errors.New("strands must be of equal length") 3 | } 4 | for i := 0; i < len(strand1); i++ { 5 | if strand1[i] != strand2[i] { 6 | distance++ 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/.approaches/iterate-runes/snippet.txt: -------------------------------------------------------------------------------- 1 | for _, chr := range input { 2 | if digit, ok := getDigit(chr); ok { 3 | sum += (digit * pos) 4 | pos-- 5 | } else if pos == 1 && chr == 'X' { 6 | sum += 10 7 | pos-- 8 | } else if chr != '-' { 9 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to reverse a given string. 4 | 5 | Some examples: 6 | 7 | - Turn `"stressed"` into `"desserts"`. 8 | - Turn `"strops"` into `"sports"`. 9 | - Turn `"racecar"` into `"racecar"`. 10 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | bytes 3 | BenchmarkIsValidISBN-12 4561827 253.0 ns/op 0 B/op 0 allocs/op 4 | 5 | runes 6 | BenchmarkIsValidISBN-12 3094387 354.9 ns/op 0 B/op 0 allocs/op 7 | ``` 8 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.approaches/switch-on-strings/snippet.txt: -------------------------------------------------------------------------------- 1 | for _, letter := range strings.Split(strings.ToLower(word), "") { 2 | 3 | switch letter { 4 | case "a", "e", "i", "o", "u", "l", "n", "r", "s", "t": 5 | score += 1 6 | case "d", "g": 7 | score += 2 8 | -------------------------------------------------------------------------------- /concepts/errors/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "blurb": "Error handling is NOT done via exceptions in Go. Instead, errors are normal values that are returned as the last return value of a function.", 3 | "authors": ["micuffaro", "brugnara", "junedev"], 4 | "contributors": ["jmrunkle"] 5 | } 6 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.approaches/bitfield/snippet.txt: -------------------------------------------------------------------------------- 1 | for i := 0; i < theEnd; i++ { 2 | letter := phrase[i] 3 | if letter > 96 && letter < 123 { 4 | if (letterFlags & (1 << (letter - 'a'))) != 0 { 5 | return false 6 | } else { 7 | letterFlags |= (1 << (letter - 'a')) 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/time-yearday/snippet.txt: -------------------------------------------------------------------------------- 1 | package leap 2 | 3 | import "time" 4 | 5 | // IsLeapYear returns if the passed in year is a leap year. 6 | func IsLeapYear(year int) bool { 7 | return time.Date(year, time.December, 31, 0, 0, 0, 0, time.UTC).YearDay() == 366 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.approaches/scrub-and-validate-first/snippet.txt: -------------------------------------------------------------------------------- 1 | func Valid(num string) bool { 2 | num = strings.ReplaceAll(num, " ", "") 3 | if _, err := strconv.Atoi(num); err != nil { 4 | return false 5 | } 6 | total := 0 7 | pos := 0 8 | for i := len(num) - 1; i > -1; i-- { 9 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/nth_prime.go: -------------------------------------------------------------------------------- 1 | package prime 2 | 3 | // Nth returns the nth prime number. An error must be returned if the nth prime number can't be calculated ('n' is equal or less than zero) 4 | func Nth(n int) (int, error) { 5 | panic("Please implement the Nth function") 6 | } 7 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.approaches/bitfield/snippet.txt: -------------------------------------------------------------------------------- 1 | for i := 0; i < length; i++ { 2 | letter := phrase[i] 3 | if letter > 96 && letter < 123 { 4 | phrasemask |= 1 << (letter - 97) 5 | } else if letter > 64 && letter < 91 { 6 | phrasemask |= 1 << (letter - 65) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | bit field 3 | BenchmarkPangram-12 6435968 164.8 ns/op 0 B/op 0 allocs/op 4 | 5 | strings.ContainsRune() 6 | BenchmarkPangram-12 707517 1723 ns/op 96 B/op 2 allocs/op 7 | ``` 8 | -------------------------------------------------------------------------------- /concepts/string-formatting/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://gobyexample.com/string-formatting", 4 | "description": "Go by Example: String formatting" 5 | }, 6 | { 7 | "url": "https://pkg.go.dev/fmt", 8 | "description": "Go Packages: fmt package" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /exercises/practice/clock/.approaches/clock-as-int/snippet.txt: -------------------------------------------------------------------------------- 1 | func normalize(minutes int) Clock { 2 | if minutes < 0 { 3 | return Clock(dayMinutes + (minutes % dayMinutes)) 4 | } else if minutes >= dayMinutes { 5 | return Clock(minutes % dayMinutes) 6 | } 7 | return Clock(minutes) 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/clock/.approaches/clock-as-struct/snippet.txt: -------------------------------------------------------------------------------- 1 | func normalize(minutes int) Clock { 2 | if minutes < 0 { 3 | return Clock{dayMinutes + (minutes % dayMinutes)} 4 | } else if minutes >= dayMinutes { 5 | return Clock{minutes % dayMinutes} 6 | } 7 | return Clock{minutes} 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | iterate as bytes 3 | BenchmarkHamming-12 43623610 26.92 ns/op 0 B/op 0 allocs/o 4 | 5 | iterate as runes 6 | BenchmarkHamming-12 3330171 361.5 ns/op 64 B/op 4 allocs/op 7 | ``` 8 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | validate as you go 3 | BenchmarkValid-12 4668248 248.4 ns/op 0 B/op 0 allocs/op 4 | 5 | scrub and validate first 6 | BenchmarkValid-12 969022 1121 ns/op 352 B/op 14 allocs/op 7 | ``` 8 | -------------------------------------------------------------------------------- /exercises/practice/series/.meta/example.go: -------------------------------------------------------------------------------- 1 | package series 2 | 3 | func All(n int, s string) (r []string) { 4 | for i := 0; n <= len(s); i++ { 5 | r = append(r, s[i:n]) 6 | n++ 7 | } 8 | return r 9 | } 10 | 11 | func UnsafeFirst(n int, s string) string { 12 | return s[:n] 13 | } 14 | -------------------------------------------------------------------------------- /concepts/strings-package/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://pkg.go.dev/strings", 4 | "description": "Go Packages: strings package" 5 | }, 6 | { 7 | "url": "https://gobyexample.com/string-functions", 8 | "description": "Go by Example: String Functions" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.approaches/switch/snippet.txt: -------------------------------------------------------------------------------- 1 | func FromCodon(codon string) (protein string, err error) { 2 | switch codon { 3 | case "AUG": 4 | protein = "Methionine" 5 | case "UUU", "UUC": 6 | protein = "Phenylalanine" 7 | case "UUA", "UUG": 8 | protein = "Leucine" 9 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | switch statement 3 | BenchmarkProtein-12 1207272 952.3 ns/op 400 B/op 12 allocs/op 4 | 5 | map object 6 | BenchmarkProtein-12 1254066 953.3 ns/op 400 B/op 12 allocs/op 7 | ``` 8 | -------------------------------------------------------------------------------- /gomod-sync/testdata/version_config_two_exceptions.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": "1.16", 3 | "exceptions": [ 4 | { 5 | "exercise": "exercise01", 6 | "version": "1.17" 7 | }, 8 | { 9 | "exercise": "exercise02", 10 | "version": "1.17" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/allergies/allergies.go: -------------------------------------------------------------------------------- 1 | package allergies 2 | 3 | func Allergies(allergies uint) []string { 4 | panic("Please implement the Allergies function") 5 | } 6 | 7 | func AllergicTo(allergies uint, allergen string) bool { 8 | panic("Please implement the AllergicTo function") 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.approaches/case-insensitive-sorting/snippet.txt: -------------------------------------------------------------------------------- 1 | func isAnagram(a, b string) bool { return a != b && sortString(a) == sortString(b) } 2 | 3 | func sortString(s string) string { 4 | chars := strings.Split(s, "") 5 | sort.Strings(chars) 6 | return strings.Join(chars, "") 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | switch statement 3 | BenchmarkCounts-12 593500 1942 ns/op 840 B/op 12 allocs/op 4 | 5 | if with short statement 6 | BenchmarkCounts-12 527168 2208 ns/op 840 B/op 12 allocs/op 7 | ``` 8 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | // map lookups 3 | BenchmarkSentence-12 310228 3845 ns/op 616 B/op 46 allocs/op 4 | 5 | // map lookups with generics 6 | BenchmarkSentence-12 306960 3809 ns/op 616 B/op 46 allocs/op 7 | ``` 8 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/robot_name.go: -------------------------------------------------------------------------------- 1 | package robotname 2 | 3 | // Define the Robot type here. 4 | 5 | func (r *Robot) Name() (string, error) { 6 | panic("Please implement the Name function") 7 | } 8 | 9 | func (r *Robot) Reset() { 10 | panic("Please implement the Reset function") 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.approaches/slice-of-bools/snippet.txt: -------------------------------------------------------------------------------- 1 | for number := 2; number <= limit; number++ { 2 | if !composite[number] { 3 | primes[primeIndex] = number 4 | primeIndex++ 5 | for idx := number + number; idx <= limit; idx += number { 6 | composite[idx] = true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/strain/.approaches/using-generics/snippet.txt: -------------------------------------------------------------------------------- 1 | func Keep[T Slicer](input []T, filter func(T) bool) []T { 2 | if input == nil { 3 | return input 4 | } 5 | output := make([]T, 0, len(input)) 6 | for _, value := range input { 7 | if filter(value) { 8 | output = append(output, value) 9 | -------------------------------------------------------------------------------- /exercises/concept/election-day/election_result.go: -------------------------------------------------------------------------------- 1 | package electionday 2 | 3 | // ElectionResult represents an election result. 4 | type ElectionResult struct { 5 | // Name is the name of the candidate. 6 | Name string 7 | // Votes is the total number of votes the candidate had. 8 | Votes int 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.approaches/map-lookups/snippet.txt: -------------------------------------------------------------------------------- 1 | if vowels[word[0]] || specials[word[:2]] { 2 | piggyfied.WriteString(word + "ay") 3 | continue 4 | } 5 | for pos := 1; pos < len(word); pos++ { 6 | letter := word[pos] 7 | if vowels_y[letter] { 8 | if letter == 'u' && word[pos-1] == 'q' { 9 | -------------------------------------------------------------------------------- /exercises/practice/rail-fence-cipher/rail_fence_cipher.go: -------------------------------------------------------------------------------- 1 | package railfence 2 | 3 | func Encode(message string, rails int) string { 4 | panic("Please implement the Encode function") 5 | } 6 | 7 | func Decode(message string, rails int) string { 8 | panic("Please implement the Decode function") 9 | } 10 | -------------------------------------------------------------------------------- /.github/workflows/configlet.yml: -------------------------------------------------------------------------------- 1 | name: Configlet 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | workflow_dispatch: 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | configlet: 15 | uses: exercism/github-actions/.github/workflows/configlet.yml@main 16 | -------------------------------------------------------------------------------- /exercises/practice/accumulate/.meta/example.go: -------------------------------------------------------------------------------- 1 | package accumulate 2 | 3 | // Accumulate transform given strings by using given function 4 | func Accumulate(s []string, f func(st string) string) (result []string) { 5 | for _, v := range s { 6 | result = append(result, f(v)) 7 | } 8 | return result 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.approaches/if-with-short-statement/snippet.txt: -------------------------------------------------------------------------------- 1 | results := Histogram{'A': 0, 'C': 0, 'G': 0, 'T': 0} 2 | for _, nuc := range dna { 3 | if _, ok := results[nuc]; ok { 4 | results[nuc]++ 5 | } else { 6 | return nil, fmt.Errorf("invalid nucleotide '%c'", nuc) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/protein_translation.go: -------------------------------------------------------------------------------- 1 | package protein 2 | 3 | func FromRNA(rna string) ([]string, error) { 4 | panic("Please implement the FromRNA function") 5 | } 6 | 7 | func FromCodon(codon string) (string, error) { 8 | panic("Please implement the FromCodon function") 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | [Scrabble][wikipedia] is a word game where players place letter tiles on a board to form words. 4 | Each letter has a value. 5 | A word's score is the sum of its letters' values. 6 | 7 | [wikipedia]: https://en.wikipedia.org/wiki/Scrabble 8 | -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/time-addition/snippet.txt: -------------------------------------------------------------------------------- 1 | package leap 2 | 3 | import "time" 4 | 5 | // IsLeapYear returns if the passed in year is a leap year. 6 | func IsLeapYear(year int) bool { 7 | return time.Date(year, time.February, 28, 0, 0, 0, 0, time.UTC).Add(time.Duration(time.Hour*24)).Day() == 29 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.meta/example.go: -------------------------------------------------------------------------------- 1 | package reverse 2 | 3 | // Reverse reverses given string 4 | func Reverse(s string) string { 5 | runes := []rune(s) 6 | for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 { 7 | runes[i], runes[j] = runes[j], runes[i] 8 | } 9 | return string(runes) 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/run-length-encoding/run_length_encoding.go: -------------------------------------------------------------------------------- 1 | package encode 2 | 3 | func RunLengthEncode(input string) string { 4 | panic("Please implement the RunLengthEncode function") 5 | } 6 | 7 | func RunLengthDecode(input string) string { 8 | panic("Please implement the RunLengthDecode function") 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/saddle-points/saddle_points.go: -------------------------------------------------------------------------------- 1 | package matrix 2 | 3 | // Define the Matrix and Pair types here. 4 | 5 | func New(s string) (*Matrix, error) { 6 | panic("Please implement the New function") 7 | } 8 | 9 | func (m *Matrix) Saddle() []Pair { 10 | panic("Please implement the Saddle function") 11 | } 12 | -------------------------------------------------------------------------------- /gomod-sync/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/exercism/go/gomod-sync 2 | 3 | go 1.25 4 | 5 | require ( 6 | github.com/logrusorgru/aurora/v3 v3.0.0 7 | github.com/spf13/cobra v1.10.1 8 | ) 9 | 10 | require ( 11 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 12 | github.com/spf13/pflag v1.0.10 // indirect 13 | ) 14 | -------------------------------------------------------------------------------- /exercises/practice/hello-world/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [af9ffe10-dc13-42d8-a742-e7bdafac449d] 6 | description = "Say Hi!" 7 | -------------------------------------------------------------------------------- /exercises/practice/strain/strain.go: -------------------------------------------------------------------------------- 1 | package strain 2 | 3 | // Implement the "Keep" and "Discard" function in this file. 4 | 5 | // You will need typed parameters (aka "Generics") to solve this exercise. 6 | // They are not part of the Exercism syllabus yet but you can learn about 7 | // them here: https://go.dev/tour/generics/1 8 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a company that makes an online, fantasy-survival game. 4 | 5 | When a player finishes a level, they are awarded energy points. 6 | The amount of energy awarded depends on which magical items the player found while exploring that level. 7 | -------------------------------------------------------------------------------- /concepts/type-conversion/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/basics/13", 4 | "description": "A Tour of Go: Type Conversions" 5 | }, 6 | { 7 | "url": "https://golangdocs.com/type-casting-in-golang", 8 | "description": "GoDocs: Type-casting in GoLang" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /exercises/practice/leap/.approaches/boolean-chain/snippet.txt: -------------------------------------------------------------------------------- 1 | // Package leap is a small library for determing if the passed in year is a leap year. 2 | package leap 3 | 4 | // IsLeapYear returns if the passed in year is a leap year. 5 | func IsLeapYear(year int) bool { 6 | return year%4 == 0 && (year%100 != 0 || year%400 == 0) 7 | } 8 | -------------------------------------------------------------------------------- /exercises/practice/custom-set/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Create a custom set type. 4 | 5 | Sometimes it is necessary to define a custom data structure of some type, like a set. 6 | In this exercise you will define your own set. 7 | How it works internally doesn't matter, as long as it behaves like a set of unique elements. 8 | -------------------------------------------------------------------------------- /exercises/practice/linked-list/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You are working on a project to develop a train scheduling system for a busy railway network. 4 | 5 | You've been asked to develop a prototype for the train routes in the scheduling system. 6 | Each route consists of a sequence of train stations that a given train stops at. 7 | -------------------------------------------------------------------------------- /exercises/practice/variable-length-quantity/variable_length_quantity.go: -------------------------------------------------------------------------------- 1 | package variablelengthquantity 2 | 3 | func EncodeVarint(input []uint32) []byte { 4 | panic("Please implement the EncodeVarint function") 5 | } 6 | 7 | func DecodeVarint(input []byte) ([]uint32, error) { 8 | panic("Please implement the DecodeVarint function") 9 | } 10 | -------------------------------------------------------------------------------- /exercises/practice/food-chain/food_chain.go: -------------------------------------------------------------------------------- 1 | package foodchain 2 | 3 | func Verse(v int) string { 4 | panic("Please implement the Verse function") 5 | } 6 | 7 | func Verses(start, end int) string { 8 | panic("Please implement the Verses function") 9 | } 10 | 11 | func Song() string { 12 | panic("Please implement the Song function") 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.meta/example.go: -------------------------------------------------------------------------------- 1 | package hamming 2 | 3 | import "errors" 4 | 5 | func Distance(a, b string) (d int, err error) { 6 | if len(b) != len(a) { 7 | return 0, errors.New("strings of unequal length") 8 | } 9 | for i := 0; i < len(a); i++ { 10 | if a[i] != b[i] { 11 | d++ 12 | } 13 | } 14 | return d, err 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.meta/example.go: -------------------------------------------------------------------------------- 1 | package isogram 2 | 3 | import "strings" 4 | 5 | func IsIsogram(word string) bool { 6 | lowerWord := strings.ToLower(word) 7 | for i, r := range lowerWord { 8 | if r != ' ' && r != '-' && i < strings.LastIndex(lowerWord, string(r)) { 9 | return false 10 | } 11 | } 12 | return true 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/minesweeper/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | [Minesweeper][wikipedia] is a popular game where the user has to find the mines using numeric hints that indicate how many mines are directly adjacent (horizontally, vertically, diagonally) to a square. 4 | 5 | [wikipedia]: https://en.wikipedia.org/wiki/Minesweeper_(video_game) 6 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.approaches/map-lookups-with-generics/snippet.txt: -------------------------------------------------------------------------------- 1 | if contains(vowels, word[0]) || contains(specials, word[:2]) { 2 | piggyfied.WriteString(word + "ay") 3 | continue 4 | } 5 | for pos := 1; pos < len(word); pos++ { 6 | letter := word[pos] 7 | if contains(vowels_y, letter) { 8 | if letter == 'u' && word[pos-1] == 'q' { 9 | -------------------------------------------------------------------------------- /concepts/comparison/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://golang.org/ref/spec#Comparison_operators", 4 | "description": "Go Language Spec: Comparison Operators" 5 | }, 6 | { 7 | "url": "https://medium.com/golangspec/comparison-operators-in-go-910d9d788ec0", 8 | "description": "Article: Comparison Operators in Go" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /exercises/concept/weather-forecast/weather_forecast.go: -------------------------------------------------------------------------------- 1 | package weather 2 | 3 | var ( 4 | CurrentCondition string 5 | CurrentLocation string 6 | ) 7 | 8 | func Forecast(city, condition string) string { 9 | CurrentLocation, CurrentCondition = city, condition 10 | return CurrentLocation + " - current weather condition: " + CurrentCondition 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/matching-brackets/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a string containing brackets `[]`, braces `{}`, parentheses `()`, or any combination thereof, verify that any and all pairs are matched and nested correctly. 4 | Any other characters should be ignored. 5 | For example, `"{what is (42)}?"` is balanced and `"[text}"` is not. 6 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | For inputs lesser than `1`, the nth prime number can't be computed. In that case, your function must return an error. The error message should be descriptive of the error. In case the input is inside a valid range, the function must return the actual prime number and no error. -------------------------------------------------------------------------------- /exercises/practice/beer-song/beer_song.go: -------------------------------------------------------------------------------- 1 | package beer 2 | 3 | func Song() string { 4 | panic("Please implement the Song function") 5 | } 6 | 7 | func Verses(start, stop int) (string, error) { 8 | panic("Please implement the Verses function") 9 | } 10 | 11 | func Verse(n int) (string, error) { 12 | panic("Please implement the Verse function") 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/etl/.meta/example.go: -------------------------------------------------------------------------------- 1 | package etl 2 | 3 | import "strings" 4 | 5 | type legacy map[int][]string 6 | 7 | func Transform(in legacy) (out map[string]int) { 8 | out = make(map[string]int) 9 | for key, values := range in { 10 | for _, val := range values { 11 | out[strings.ToLower(val)] = key 12 | } 13 | } 14 | return out 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.meta/example.go: -------------------------------------------------------------------------------- 1 | package strand 2 | 3 | import "strings" 4 | 5 | func ToRNA(dna string) string { 6 | dna = strings.ReplaceAll(dna, "A", "u") 7 | dna = strings.ReplaceAll(dna, "T", "a") 8 | dna = strings.ReplaceAll(dna, "C", "g") 9 | dna = strings.ReplaceAll(dna, "G", "c") 10 | return strings.ToUpper(dna) 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/state-of-tic-tac-toe/state_of_tic_tac_toe.go: -------------------------------------------------------------------------------- 1 | package stateoftictactoe 2 | 3 | type State string 4 | 5 | const ( 6 | Win State = "win" 7 | Ongoing State = "ongoing" 8 | Draw State = "draw" 9 | ) 10 | 11 | func StateOfTicTacToe(board []string) (State, error) { 12 | panic("Please implement the StateOfTicTacToe function") 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/bob/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "5640fa40-6c9c-45e2-bf3e-8e73d2a83bb8", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach for Bob's response.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/bob/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | if statements 3 | BenchmarkHey-12 624798 1746 ns/op 432 B/op 12 allocs/op 4 | switch statement 5 | BenchmarkHey-12 617388 1791 ns/op 432 B/op 12 allocs/op 6 | answer array 7 | BenchmarkHey-12 632600 1819 ns/op 432 B/op 12 allocs/op 8 | ``` 9 | -------------------------------------------------------------------------------- /exercises/practice/clock/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "f69f7d90-2ec6-435b-b324-6f8bca9499c6", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach to solving Clock.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/luhn/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "99421490-eeb4-4bca-bfba-00e44187df02", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach to validating Luhn.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-trio/resistor_color_trio.go: -------------------------------------------------------------------------------- 1 | package resistorcolortrio 2 | 3 | // Label describes the resistance value given the colors of a resistor. 4 | // The label is a string with a resistance value with an unit appended 5 | // (e.g. "33 ohms", "470 kiloohms"). 6 | func Label(colors []string) string { 7 | panic("Implement the Label function") 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/sublist/relations.go: -------------------------------------------------------------------------------- 1 | package sublist 2 | 3 | // Relation is the comparison between lists 4 | type Relation string 5 | 6 | // Possible relations 7 | const ( 8 | RelationEqual Relation = "equal" 9 | RelationSublist Relation = "sublist" 10 | RelationSuperlist Relation = "superlist" 11 | RelationUnequal Relation = "unequal" 12 | ) 13 | -------------------------------------------------------------------------------- /exercises/shared/.docs/help.md: -------------------------------------------------------------------------------- 1 | # Help 2 | 3 | To get help if you're having trouble, you can use one of the following resources: 4 | 5 | - [How to Write Go Code](https://golang.org/doc/code.html) 6 | - [Effective Go](https://golang.org/doc/effective_go.html) 7 | - [Go Resources](http://golang.org/help) 8 | - [StackOverflow](http://stackoverflow.com/questions/tagged/go) 9 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.approaches/frequency-counter/snippet.txt: -------------------------------------------------------------------------------- 1 | func isAnagram(a, b string) bool { 2 | for _, r := range b { 3 | if _, ok := freqCounter[unicode.ToLower(r)]; !ok { return false } 4 | freqCounter[unicode.ToLower(r)]-- 5 | if freqCounter[unicode.ToLower(r)] == 0 { delete(freqCounter, unicode.ToLower(r)) } 6 | } 7 | return len(freqCounter) == 0 8 | } 9 | -------------------------------------------------------------------------------- /exercises/practice/grains/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "03f25b6b-2147-4550-a444-8f6d9fb2a1da", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach to calculating Grains.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "39d040a8-4b08-4135-9fcc-aa8bda94f9f5", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach to solving Hamming.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/darts/.meta/example.go: -------------------------------------------------------------------------------- 1 | package darts 2 | 3 | import "math" 4 | 5 | func Score(x, y float64) int { 6 | dart_location := math.Sqrt(x*x + y*y) 7 | 8 | switch { 9 | case dart_location <= 1.0: 10 | return 10 11 | case dart_location <= 5.0: 12 | return 5 13 | case dart_location <= 10.0: 14 | return 1 15 | default: 16 | return 0 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "9f0bd10f-2f90-40fc-be65-d9b72e5830aa", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach to determining an isogram.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | map 3 | BenchmarkIsIsogram-12 237565 4960 ns/op 1201 B/op 13 allocs/op 4 | strings.Count() 5 | BenchmarkIsIsogram-12 896049 1409 ns/op 40 B/op 3 allocs/op 6 | bit field 7 | BenchmarkIsIsogram-12 6214525 185.2 ns/op 0 B/op 0 allocs/op 8 | ``` 9 | -------------------------------------------------------------------------------- /exercises/practice/leap/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "8f0c6960-30fe-4c17-9b4b-193fef9e5d94", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach for determining a leap year.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a number n, determine what the nth prime is. 4 | 5 | By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. 6 | 7 | If your language provides methods in the standard library to deal with prime numbers, pretend they don't exist and implement them yourself. 8 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "1b6499d8-c14c-441e-9572-c9bf5e5a42b9", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach to determining a pangram.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "f39f680a-71c0-4a3d-b568-9d49d7564d73", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach to solving Pig Latin.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "f14e3344-2fb2-4aa9-b8f7-d46c87bc15cd", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach for Scrabble Score.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/darts/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | 2 | ## Scoring Note 3 | 4 | In scoring, consider a dart landing on the border of a circle to be "in the circle" 5 | and receive the higher score, like "inward scoring" for a shooting contest. 6 | A real dartboard avoids this issue by using lines made of wire; the dart cannot 7 | land on a wire, but goes to one side or the other. 8 | -------------------------------------------------------------------------------- /exercises/practice/isbn-verifier/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "80e6b454-9ec3-489b-90a8-10f300ee19b9", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach to solving ISBN Verifier.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/nucleotide-count/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "5b8711ce-2725-4561-85ea-d419bda7937d", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach for Nucleotide Count.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/error-handling/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | Testing for specific error types may be performed by 4 | [type assertions](https://golang.org/ref/spec#Type_assertions). You may also 5 | need to look at 6 | [named return values](https://blog.golang.org/defer-panic-and-recover) as a 7 | helpful way to return error information from panic recovery. 8 | -------------------------------------------------------------------------------- /exercises/practice/protein-translation/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "52d5b81c-09c2-49f1-a162-1f94eda387ef", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach for Protein Translation.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/raindrops/.meta/example.go: -------------------------------------------------------------------------------- 1 | package raindrops 2 | 3 | import "strconv" 4 | 5 | func Convert(number int) string { 6 | s := "" 7 | if number%3 == 0 { 8 | s += "Pling" 9 | } 10 | if number%5 == 0 { 11 | s += "Plang" 12 | } 13 | if number%7 == 0 { 14 | s += "Plong" 15 | } 16 | if s == "" { 17 | s = strconv.Itoa(number) 18 | } 19 | return s 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color/resistor_color.go: -------------------------------------------------------------------------------- 1 | package resistorcolor 2 | 3 | // Colors returns the list of all colors. 4 | func Colors() []string { 5 | panic("Please implement the Colors function") 6 | } 7 | 8 | // ColorCode returns the resistance value of the given color. 9 | func ColorCode(color string) int { 10 | panic("Please implement the ColorCode function") 11 | } 12 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.articles/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "articles": [ 3 | { 4 | "uuid": "f498ca96-7d55-477b-9892-a92125c51564", 5 | "slug": "performance", 6 | "title": "Performance deep dive", 7 | "blurb": "Deep dive to find out the most performant approach to translating DNA to RNA.", 8 | "authors": ["bobahop"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /exercises/concept/the-farm/types.go: -------------------------------------------------------------------------------- 1 | package thefarm 2 | 3 | // This file contains types used in the exercise and tests and should not be modified. 4 | 5 | // FodderCalculator provides helper methods to determine the optimal 6 | // amount of fodder to feed cows. 7 | type FodderCalculator interface { 8 | FodderAmount(int) (float64, error) 9 | FatteningFactor() (float64, error) 10 | } 11 | -------------------------------------------------------------------------------- /exercises/practice/parallel-letter-frequency/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Count the frequency of letters in texts using parallel computation. 4 | 5 | Parallelism is about doing things in parallel that can also be done sequentially. 6 | A common example is counting the frequency of letters. 7 | Employ parallelism to calculate the total frequency of each letter in a list of texts. 8 | -------------------------------------------------------------------------------- /concepts/error-wrapping/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://go.dev/blog/go1.13-errors", 4 | "description": "Go Blog: Working with Errors in Go 1.13" 5 | }, 6 | { 7 | "url": "https://www.digitalocean.com/community/tutorials/how-to-add-extra-information-to-errors-in-go", 8 | "description": "Digital Ocean: How to Add Extra Information to Errors in Go" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /exercises/practice/bob/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Bob is a [lackadaisical][] teenager. 4 | He likes to think that he's very cool. 5 | And he definitely doesn't get excited about things. 6 | That wouldn't be cool. 7 | 8 | When people talk to him, his responses are pretty limited. 9 | 10 | [lackadaisical]: https://www.collinsdictionary.com/dictionary/english/lackadaisical 11 | -------------------------------------------------------------------------------- /exercises/practice/bowling/bowling.go: -------------------------------------------------------------------------------- 1 | package bowling 2 | 3 | // Define the Game type here. 4 | 5 | func NewGame() *Game { 6 | panic("Please implement the NewGame function") 7 | } 8 | 9 | func (g *Game) Roll(pins int) error { 10 | panic("Please implement the Roll function") 11 | } 12 | 13 | func (g *Game) Score() (int, error) { 14 | panic("Please implement the Score function") 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/difference_of_squares.go: -------------------------------------------------------------------------------- 1 | package diffsquares 2 | 3 | func SquareOfSum(n int) int { 4 | panic("Please implement the SquareOfSum function") 5 | } 6 | 7 | func SumOfSquares(n int) int { 8 | panic("Please implement the SumOfSquares function") 9 | } 10 | 11 | func Difference(n int) int { 12 | panic("Please implement the Difference function") 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/.approaches/shuffle/snippet.txt: -------------------------------------------------------------------------------- 1 | for i := 'A'; i <= 'Z'; i++ { 2 | for j := 'A'; j <= 'Z'; j++ { 3 | for k := 0; k < 1000; k++ { 4 | names[pos] = fmt.Sprintf("%s%s%03d", string(i), string(j), k) 5 | pos++ 6 | // closing braces snipped 7 | rand.Seed(time.Now().UnixNano()) 8 | rand.Shuffle(len(names), func(i, j int) { names[i], names[j] = names[j], names[i] }) 9 | -------------------------------------------------------------------------------- /exercises/practice/scrabble-score/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | map 3 | BenchmarkScore-12 1544814 711.7 ns/op 0 B/op 0 allocs/op 4 | 5 | switch on runes 6 | BenchmarkScore-12 4171696 242.1 ns/op 0 B/op 0 allocs/op 7 | 8 | switch on strings 9 | BenchmarkScore-12 413484 2527 ns/op 1088 B/op 12 allocs/op 10 | ``` 11 | -------------------------------------------------------------------------------- /concepts/stringers/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://pkg.go.dev/fmt", 4 | "description": "Go standard library: package fmt" 5 | }, 6 | { 7 | "url": "https://pkg.go.dev/fmt#Stringer", 8 | "description": "Go standard library: interface Stringer" 9 | }, 10 | { 11 | "url": "https://go.dev/tour/methods/17", 12 | "description": "A Tour of Go: Stringers" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/practice/gigasecond/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to determine the date and time one gigasecond after a certain date. 4 | 5 | A gigasecond is one thousand million seconds. 6 | That is a one with nine zeros after it. 7 | 8 | If you were born on _January 24th, 2015 at 22:00 (10:00:00pm)_, then you would be a gigasecond old on _October 2nd, 2046 at 23:46:40 (11:46:40pm)_. 9 | -------------------------------------------------------------------------------- /exercises/practice/say/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Given a number, your task is to express it in English words exactly as your friend should say it out loud. 4 | Yaʻqūb expects to use numbers from 0 up to 999,999,999,999. 5 | 6 | Examples: 7 | 8 | - 0 → zero 9 | - 1 → one 10 | - 12 → twelve 11 | - 123 → one hundred twenty-three 12 | - 1,234 → one thousand two hundred thirty-four 13 | -------------------------------------------------------------------------------- /exercises/practice/word-count/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You teach English as a foreign language to high school students. 4 | 5 | You've decided to base your entire curriculum on TV shows. 6 | You need to analyze which words are used, and how often they're repeated. 7 | 8 | This will let you choose the simplest shows to start with, and to gradually increase the difficulty as time passes. 9 | -------------------------------------------------------------------------------- /exercises/practice/anagram/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Implementation 2 | 3 | You must return the anagrams in the same order as they are listed in the candidate words. 4 | 5 | Unlike other tracks, the Go version of the exercise includes test cases that use UTF-8 (non-ASCII) characters in the strings. 6 | However, with Go's first-class support for UTF-8 given by the `rune` type, that should not bother you too much. -------------------------------------------------------------------------------- /exercises/practice/grains/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | There once was a wise servant who saved the life of a prince. 4 | The king promised to pay whatever the servant could dream up. 5 | Knowing that the king loved chess, the servant told the king he would like to have grains of wheat. 6 | One grain on the first square of a chessboard, with the number of grains doubling on each successive square. 7 | -------------------------------------------------------------------------------- /concepts/functions/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/basics/4", 4 | "description": "A Tour of Go: Functions" 5 | }, 6 | { 7 | "url": "https://gobyexample.com/functions", 8 | "description": "Go by Example: Functions" 9 | }, 10 | { 11 | "url": "https://golang.org/ref/spec#Return_statements", 12 | "description": "Go Language Spec: Return Statements" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /concepts/numbers/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/basics/11", 4 | "description": "A Tour of Go: Basic Types" 5 | }, 6 | { 7 | "url": "https://tour.golang.org/basics/13", 8 | "description": "A Tour of Go: Type Conversion" 9 | }, 10 | { 11 | "url": "https://golang.org/ref/spec#Numeric_types", 12 | "description": "Go Language Spec: Numeric types" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/practice/grains/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Calculate the number of grains of wheat on a chessboard. 4 | 5 | A chessboard has 64 squares. 6 | Square 1 has one grain, square 2 has two grains, square 3 has four grains, and so on, doubling each time. 7 | 8 | Write code that calculates: 9 | 10 | - the number of grains on a given square 11 | - the total number of grains on the chessboard 12 | -------------------------------------------------------------------------------- /exercises/practice/tree-building/tree_building.go: -------------------------------------------------------------------------------- 1 | package tree 2 | 3 | type Record struct { 4 | ID int 5 | Parent int 6 | // feel free to add fields as you see fit 7 | } 8 | 9 | type Node struct { 10 | ID int 11 | Children []*Node 12 | // feel free to add fields as you see fit 13 | } 14 | 15 | func Build(records []Record) (*Node, error) { 16 | panic("Please implement the Build function") 17 | } 18 | -------------------------------------------------------------------------------- /reference/concepts/structs.md: -------------------------------------------------------------------------------- 1 | # Structs 2 | 3 | See also [records](https://github.com/exercism/v3/blob/main/reference/types/record.md) 4 | 5 | # Classes 6 | 7 | When talking about classes in Go, many refer to `structs`. They are often called Go's classes. 8 | In fact, Go does not need classes or a replacement for them. Any type in Go can be used like a class. 9 | For more information see [methods](methods.md). 10 | -------------------------------------------------------------------------------- /concepts/range-iteration/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/moretypes/16", 4 | "description": "A Tour of Go: Range" 5 | }, 6 | { 7 | "url": "https://gobyexample.com/range", 8 | "description": "Go by Example: Range" 9 | }, 10 | { 11 | "url": "https://golang.org/ref/spec#For_range", 12 | "description": "Go Language Spec: For statements with range clause" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /concepts/structs/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://gobyexample.com/structs", 4 | "description": "Go by Example: Structs" 5 | }, 6 | { 7 | "url": "https://tour.golang.org/moretypes/2", 8 | "description": "A Tour of Go: Structs" 9 | }, 10 | { 11 | "url": "https://medium.com/rungo/structures-in-go-76377cc106a2", 12 | "description": "Article: Structures in Go (structs)" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/practice/difference-of-squares/.meta/example.go: -------------------------------------------------------------------------------- 1 | package diffsquares 2 | 3 | func SquareOfSum(n int) int { 4 | s := 0 5 | for i := 1; i <= n; i++ { 6 | s += i 7 | } 8 | return s * s 9 | } 10 | 11 | func SumOfSquares(n int) (s int) { 12 | for i := 1; i <= n; i++ { 13 | s += i * i 14 | } 15 | return s 16 | } 17 | 18 | func Difference(n int) int { 19 | return SquareOfSum(n) - SumOfSquares(n) 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/largest-series-product/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You work for a government agency that has intercepted a series of encrypted communication signals from a group of bank robbers. 4 | The signals contain a long sequence of digits. 5 | Your team needs to use various digital signal processing techniques to analyze the signals and identify any patterns that may indicate the planning of a heist. 6 | -------------------------------------------------------------------------------- /exercises/practice/phone-number/phone_number.go: -------------------------------------------------------------------------------- 1 | package phonenumber 2 | 3 | func Number(phoneNumber string) (string, error) { 4 | panic("Please implement the Number function") 5 | } 6 | 7 | func AreaCode(phoneNumber string) (string, error) { 8 | panic("Please implement the AreaCode function") 9 | } 10 | 11 | func Format(phoneNumber string) (string, error) { 12 | panic("Please implement the Format function") 13 | } 14 | -------------------------------------------------------------------------------- /exercises/practice/robot-name/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "4984e274-a7fa-40de-beb6-6e4c0103ae15", 9 | "slug": "shuffle", 10 | "title": "Shuffle", 11 | "blurb": "Generate in sequence and then shuffle.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to figure out if a sentence is a pangram. 4 | 5 | A pangram is a sentence using every letter of the alphabet at least once. 6 | It is case insensitive, so it doesn't matter if a letter is lower-case (e.g. `k`) or upper-case (e.g. `K`). 7 | 8 | For this exercise, a sentence is a pangram if it contains each of the 26 letters in the English alphabet. 9 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.meta/example.go: -------------------------------------------------------------------------------- 1 | package sieve 2 | 3 | func Sieve(limit int) (primes []int) { 4 | c := make([]bool, limit+1) 5 | for p := 2; p <= limit; { 6 | for i := p + p; i <= limit; i += p { 7 | c[i] = true 8 | } 9 | for p++; p <= limit && c[p]; p++ { 10 | } 11 | } 12 | for i := 2; i <= limit; i++ { 13 | if !c[i] { 14 | primes = append(primes, i) 15 | } 16 | } 17 | return primes 18 | } 19 | -------------------------------------------------------------------------------- /concepts/for-loops/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/flowcontrol/1", 4 | "description": "Tour of Go: For" 5 | }, 6 | { 7 | "url": "https://gobyexample.com/for", 8 | "description": "Go by Example: For" 9 | }, 10 | { 11 | "url": "https://yourbasic.org/golang/for-loop/", 12 | "description": "Article: 5 basic for loop patterns" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/practice/matrix/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | In addition to being able to get a list of rows and columns, 4 | your code should also: 5 | 6 | - Set the value of an element in the matrix given its row and column number. 7 | 8 | For all operations on the matrix, assume that rows and columns are zero-based. 9 | This means that first row will be row 0, the second row will be row 1, and so on. 10 | -------------------------------------------------------------------------------- /exercises/practice/rna-transcription/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | map function 3 | BenchmarkRNATranscription-12 5396551 217.5 ns/op 37 B/op 5 allocs/op 4 | 5 | map object 6 | BenchmarkRNATranscription-12 8124092 154.8 ns/op 16 B/op 5 allocs/op 7 | 8 | switch 9 | BenchmarkRNATranscription-12 11808524 97.69 ns/op 16 B/op 5 allocs/op 10 | ``` 11 | -------------------------------------------------------------------------------- /exercises/practice/strain/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "9642077f-c65d-407a-b9f7-272eaca64a1c", 9 | "slug": "using-generics", 10 | "title": "Using generics", 11 | "blurb": "Use generics to slice different types.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /concepts/booleans/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://golangdocs.com/booleans-in-golang", 4 | "description": "Article: Booleans in Golang" 5 | }, 6 | { 7 | "url": "https://golang.org/ref/spec#Logical_operators", 8 | "description": "Go Language Spec: Logical Operators" 9 | }, 10 | { 11 | "url": "https://golang.org/ref/spec#Operators", 12 | "description": "Go Language Spec: Operators" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/practice/acronym/.meta/example.go: -------------------------------------------------------------------------------- 1 | package acronym 2 | 3 | import ( 4 | "regexp" 5 | "strings" 6 | ) 7 | 8 | func Abbreviate(s string) string { 9 | regex := regexp.MustCompile("[A-Z]+[a-z']*|[a-z]+") 10 | words := regex.FindAllString(s, -1) 11 | 12 | var abbr []string 13 | for _, word := range words { 14 | abbr = append(abbr, string(word[0])) 15 | } 16 | 17 | return strings.ToUpper(strings.Join(abbr, "")) 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/pascals-triangle/.meta/example.go: -------------------------------------------------------------------------------- 1 | package pascal 2 | 3 | func Triangle(n int) (t [][]int) { 4 | if n < 1 { 5 | return t 6 | } 7 | t = make([][]int, n) 8 | r := []int{1} 9 | t[0] = r 10 | for i := 1; i < n; i++ { 11 | last := r 12 | r = make([]int, i+1) 13 | r[0] = 1 14 | r[i] = 1 15 | for j := 1; j < i; j++ { 16 | r[j] = last[j-1] + last[j] 17 | } 18 | t[i] = r 19 | } 20 | return t 21 | } 22 | -------------------------------------------------------------------------------- /exercises/practice/reverse-string/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Reversing strings (reading them from right to left, rather than from left to right) is a surprisingly common task in programming. 4 | 5 | For example, in bioinformatics, reversing the sequence of DNA or RNA strings is often important for various analyses, such as finding complementary strands or identifying palindromic sequences that have biological significance. 6 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "c2f21e5f-da35-488c-8b73-62b936bc2216", 9 | "slug": "loop-with-switch", 10 | "title": "Loop with switch", 11 | "blurb": "Loop and use switch to return the answer.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "59d34e3b-b310-4686-bf79-53d3eae1cdf3", 9 | "slug": "slice-indexes", 10 | "title": "Slice indexes", 11 | "blurb": "Use slice indexes to compare bitwise values.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [16efb4e4-8ad7-4d5e-ba96-e5537b66fd42] 6 | description = "resident who drinks water" 7 | 8 | [084d5b8b-24e2-40e6-b008-c800da8cd257] 9 | description = "resident who owns zebra" 10 | -------------------------------------------------------------------------------- /reference/concepts/concurrency.md: -------------------------------------------------------------------------------- 1 | # Concurrency 2 | 3 | > When people hear the word _concurrency_ they often think of _parallelism_, a related but quite distinct concept. 4 | > In programming, concurrency is the _composition_ of independently executing processes, while parallelism is the 5 | > _simultaneous execution_ of (possibly related) computations. 6 | > [Concurrency is not parallelism](https://blog.golang.org/concurrency-is-not-parallelism) 7 | -------------------------------------------------------------------------------- /.github/workflows/sync-labels.yml: -------------------------------------------------------------------------------- 1 | name: Tools 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - .github/labels.yml 9 | - .github/workflows/sync-labels.yml 10 | workflow_dispatch: 11 | schedule: 12 | - cron: 0 0 1 * * # First day of each month 13 | 14 | permissions: 15 | issues: write 16 | 17 | jobs: 18 | sync-labels: 19 | uses: exercism/github-actions/.github/workflows/labels.yml@main 20 | -------------------------------------------------------------------------------- /exercises/practice/say/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your friend Yaʻqūb works the counter at the busiest deli in town, slicing, weighing, and wrapping orders for a never-ending line of hungry customers. 4 | To keep things moving, each customer takes a numbered ticket when they arrive. 5 | 6 | When it’s time to call the next person, Yaʻqūb reads their number out loud, always in full English words to make sure everyone hears it clearly. 7 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "da0b7fca-2422-453f-8e3a-48ac1bc23eae", 9 | "slug": "slice-of-bools", 10 | "title": "Slice of bools", 11 | "blurb": "Use a slice of bools to keep track of composite numbers.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/simple-linked-list/.approaches/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "authors": ["bobahop"], 4 | "contributors": [] 5 | }, 6 | "approaches": [ 7 | { 8 | "uuid": "ba6d7fa1-d891-4bb8-89b4-80a31b0b0fc5", 9 | "slug": "keep-track-of-size", 10 | "title": "Keep track of the size", 11 | "blurb": "Keep track of the size as you go.", 12 | "authors": ["bobahop"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /exercises/practice/sum-of-multiples/.meta/example.go: -------------------------------------------------------------------------------- 1 | package summultiples 2 | 3 | // SumMultiples returns the sum of the multiples of the given divisors 4 | // up to, but not including, the given limit. 5 | func SumMultiples(limit int, divisors ...int) (sum int) { 6 | for i := 1; i < limit; i++ { 7 | for _, d := range divisors { 8 | if d != 0 && i%d == 0 { 9 | sum += i 10 | break 11 | } 12 | } 13 | } 14 | return sum 15 | } 16 | -------------------------------------------------------------------------------- /concepts/first-class-functions/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://go.dev/ref/spec#Function_types", 4 | "description": "Go Language Spec: Function types" 5 | }, 6 | { 7 | "url": "https://go.dev/tour/moretypes/24", 8 | "description": "Tour of Go: Function values" 9 | }, 10 | { 11 | "url": "https://golangbot.com/first-class-functions/", 12 | "description": "Golang tutorial: First Class Functions" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/practice/binary-search/.meta/example.go: -------------------------------------------------------------------------------- 1 | package binarysearch 2 | 3 | // SearchInts search given key in the given slice 4 | // upon finding returns its index, otherwise -1 5 | func SearchInts(s []int, k int) int { 6 | for i, j := 0, len(s)-1; i <= j; { 7 | h := (i + j) / 2 8 | switch { 9 | case s[h] < k: 10 | i = h + 1 11 | case s[h] > k: 12 | j = h - 1 13 | default: 14 | return h 15 | } 16 | } 17 | return -1 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/hexadecimal/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Convert a hexadecimal number, represented as a string (e.g. "10af8c"), to its decimal equivalent using first principles (i.e. no, you may not use built-in or external libraries to accomplish the conversion). 4 | 5 | On the web we use hexadecimal to represent colors, e.g. green: 008000, 6 | teal: 008080, navy: 000080). 7 | 8 | The program should handle invalid hexadecimal strings. 9 | -------------------------------------------------------------------------------- /exercises/shared/.docs/tests.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | To run the tests run the command `go test` from within the exercise directory. 4 | 5 | If the test suite contains benchmarks, you can run these with the `--bench` and `--benchmem` 6 | flags: 7 | 8 | go test -v --bench . --benchmem 9 | 10 | Keep in mind that each reviewer will run benchmarks on a different machine, with 11 | different specs, so the results from these benchmark tests may vary. 12 | -------------------------------------------------------------------------------- /concepts/errors/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://go.dev/blog/error-handling-and-go", 4 | "description": "Go Blog: Error Handling and Go" 5 | }, 6 | { 7 | "url": "https://github.com/golang/go/wiki/Errors", 8 | "description": "Go Wiki: Errors" 9 | }, 10 | { 11 | "url": "https://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully", 12 | "description": "Dave Cheney on error handling" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/concept/jedliks-toys/car.go: -------------------------------------------------------------------------------- 1 | package jedlik 2 | 3 | // Car implements a remote controlled car. 4 | type Car struct { 5 | speed int 6 | batteryDrain int 7 | 8 | battery int 9 | distance int 10 | } 11 | 12 | // NewCar creates a new car with given specifications. 13 | func NewCar(speed, batteryDrain int) *Car { 14 | return &Car{ 15 | speed: speed, 16 | batteryDrain: batteryDrain, 17 | battery: 100, 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/poker/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | Your function will receive an array of strings. Each string represents 4 | a hand composed of 5 cards separated by spaces. A card is represented 5 | by a number and its suit. 6 | 7 | You are to return an array containing either the best hand or, in case 8 | of a tie, the best hands. Each hand should be a string in the same 9 | format as given to you initially as input. 10 | -------------------------------------------------------------------------------- /concepts/multiple-return-values/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/basics/6", 4 | "description": "A Tour of Go: Multiple Results" 5 | }, 6 | { 7 | "url": "https://gobyexample.com/multiple-return-values", 8 | "description": "Go By Example: Multiple Return Values" 9 | }, 10 | { 11 | "url": "https://golang.org/doc/effective_go#multiple-returns", 12 | "description": "Effective Go: Multiple Returns" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /concepts/variadic-functions/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://go.dev/ref/spec#Function_types", 4 | "description": "Go Dev: Variadic Functions" 5 | }, 6 | { 7 | "url": "https://gobyexample.com/variadic-functions", 8 | "description": "Go by Example: Variadic Functions" 9 | }, 10 | { 11 | "url": "https://medium.com/rungo/variadic-function-in-go-5d9b23f4c01a", 12 | "description": "Article: Variadic functions in Go" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/practice/prime-factors/.meta/example.go: -------------------------------------------------------------------------------- 1 | package prime 2 | 3 | func Factors(n int64) []int64 { 4 | factors := []int64{} 5 | possibleFactor := int64(2) 6 | 7 | for possibleFactor*possibleFactor <= n { 8 | for n%possibleFactor == 0 { 9 | factors = append(factors, possibleFactor) 10 | n /= possibleFactor 11 | } 12 | possibleFactor++ 13 | } 14 | 15 | if n > 1 { 16 | factors = append(factors, n) 17 | } 18 | 19 | return factors 20 | } 21 | -------------------------------------------------------------------------------- /concepts/type-assertion/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/methods/15", 4 | "description": "A Tour of Go: Type Assertions" 5 | }, 6 | { 7 | "url": "https://tour.golang.org/methods/16", 8 | "description": "A Tour of Go: Type Switches" 9 | }, 10 | { 11 | "url": "https://golangdocs.com/type-assertions-in-golang", 12 | "description": "GoDocs: Type Assertions in GoLang" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/practice/kindergarten-garden/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The kindergarten class is learning about growing plants. 4 | The teacher thought it would be a good idea to give the class seeds to plant and grow in the dirt. 5 | To this end, the children have put little cups along the window sills and planted one type of plant in each cup. 6 | The children got to pick their favorites from four available types of seeds: grass, clover, radishes, and violets. 7 | -------------------------------------------------------------------------------- /exercises/practice/leap/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | boolean chain 3 | Benchmark400-12 4936674 219.4 ns/op 0 B/op 0 allocs/op 4 | max two checks 5 | Benchmark400-12 10733403 110.8 ns/op 0 B/op 0 allocs/op 6 | time add 7 | Benchmark400-12 89797 12741 ns/op 0 B/op 0 allocs/op 8 | time yearday 9 | Benchmark400-12 118605 9700 ns/op 0 B/op 0 allocs/op 10 | ``` 11 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/knapsack.go: -------------------------------------------------------------------------------- 1 | package knapsack 2 | 3 | type Item struct { 4 | Weight, Value int 5 | } 6 | 7 | // Knapsack takes in a maximum carrying capacity and a collection of items 8 | // and returns the maximum value that can be carried by the knapsack 9 | // given that the knapsack can only carry a maximum weight given by maximumWeight 10 | func Knapsack(maximumWeight int, items []Item) int { 11 | panic("Please implement the Knapsack() function") 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/grep/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Implementation 2 | 3 | In package grep, Define a single Go func, Search, which accepts a pattern string, 4 | a slice of flags which are strings, and a slice of filename strings. 5 | Search should return a slice of strings of the output for 6 | the given flags and filenames. 7 | 8 | Use the following signature for func Search: 9 | 10 | ``` 11 | func Search(pattern string, flags, files []string) []string { 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /exercises/practice/isogram/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Determine if a word or phrase is an isogram. 4 | 5 | An isogram (also known as a "non-pattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. 6 | 7 | Examples of isograms: 8 | 9 | - lumberjacks 10 | - background 11 | - downstream 12 | - six-year-old 13 | 14 | The word _isograms_, however, is not an isogram, because the s repeats. 15 | -------------------------------------------------------------------------------- /exercises/concept/deep-thought/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "micuffaro" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "deep_thought.go" 8 | ], 9 | "test": [ 10 | "deep_thought_test.go" 11 | ], 12 | "exemplar": [ 13 | ".meta/exemplar.go" 14 | ], 15 | "invalidator": [ 16 | "go.mod" 17 | ] 18 | }, 19 | "blurb": "Learn about errors by finding the absolute answer to life, the universe, and everything." 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/clock/clock.go: -------------------------------------------------------------------------------- 1 | package clock 2 | 3 | // Define the Clock type here. 4 | 5 | func New(h, m int) Clock { 6 | panic("Please implement the New function") 7 | } 8 | 9 | func (c Clock) Add(m int) Clock { 10 | panic("Please implement the Add function") 11 | } 12 | 13 | func (c Clock) Subtract(m int) Clock { 14 | panic("Please implement the Subtract function") 15 | } 16 | 17 | func (c Clock) String() string { 18 | panic("Please implement the String function") 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Instructions append 2 | 3 | ## Implementation Notes 4 | 5 | `Range` should return a list of all Pythagorean triplets with sides in the range `min` to `max` inclusive. 6 | 7 | `Sum` should return a list of all Pythagorean triplets where the sum `a+b+c` (the perimeter) is equal to `p`. 8 | The three elements of each returned triplet must be in order, `t[0] <= t[1] <= t[2]`, and the list of triplets must be in lexicographic order. 9 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/pythagorean_triplet.go: -------------------------------------------------------------------------------- 1 | package pythagorean 2 | 3 | type Triplet [3]int 4 | 5 | // Range generates list of all Pythagorean triplets with side lengths 6 | // in the provided range. 7 | func Range(min, max int) []Triplet { 8 | panic("Please implement the Range function") 9 | } 10 | 11 | // Sum returns a list of all Pythagorean triplets with a certain perimeter. 12 | func Sum(p int) []Triplet { 13 | panic("Please implement the Sum function") 14 | } 15 | -------------------------------------------------------------------------------- /concepts/pointers/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/moretypes/1", 4 | "description": "A Tour of Go: Pointers" 5 | }, 6 | { 7 | "url": "https://gobyexample.com/pointers", 8 | "description": "Go by Example: Pointers" 9 | }, 10 | { 11 | "url": "https://www.digitalocean.com/community/conceptual_articles/understanding-pointers-in-go", 12 | "description": "Article: Understanding Pointers in Go" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /concepts/zero-values/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/basics/12", 4 | "description": "A Tour of Go: Zero values" 5 | }, 6 | { 7 | "url": "https://golang.org/ref/spec#The_zero_value", 8 | "description": "Go Language Spec: The zero value" 9 | }, 10 | { 11 | "url": "https://dave.cheney.net/2013/01/19/what-is-the-zero-value-and-why-is-it-useful", 12 | "description": "Blog Post: What is the zero value, and what is it useful?" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/concept/blackjack/blackjack.go: -------------------------------------------------------------------------------- 1 | package blackjack 2 | 3 | // ParseCard returns the integer value of a card following blackjack ruleset. 4 | func ParseCard(card string) int { 5 | panic("Please implement the ParseCard function") 6 | } 7 | 8 | // FirstTurn returns the decision for the first turn, given two cards of the 9 | // player and one card of the dealer. 10 | func FirstTurn(card1, card2, dealerCard string) string { 11 | panic("Please implement the FirstTurn function") 12 | } 13 | -------------------------------------------------------------------------------- /exercises/practice/sieve/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You bought a big box of random computer parts at a garage sale. 4 | You've started putting the parts together to build custom computers. 5 | 6 | You want to test the performance of different combinations of parts, and decide to create your own benchmarking program to see how your computers compare. 7 | You choose the famous "Sieve of Eratosthenes" algorithm, an ancient algorithm, but one that should push your computers to the limits. 8 | -------------------------------------------------------------------------------- /concepts/floating-point-numbers/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://golangdocs.com/floating-point-numbers-in-golang", 4 | "description": "Article: Floating-Point Numbers in GoLang" 5 | }, 6 | { 7 | "url": "https://golang.org/ref/spec#Floating-point_literals", 8 | "description": "Go Language Spec: Floating-point literals" 9 | }, 10 | { 11 | "url": "https://golang.org/ref/spec#Numeric_types", 12 | "description": "Go Language Spec: Numeric Types" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/practice/resistor-color-duo/.meta/example.go: -------------------------------------------------------------------------------- 1 | package resistorcolorduo 2 | 3 | var colorMap = map[string]int{ 4 | "black": 0, 5 | "brown": 1, 6 | "red": 2, 7 | "orange": 3, 8 | "yellow": 4, 9 | "green": 5, 10 | "blue": 6, 11 | "violet": 7, 12 | "grey": 8, 13 | "white": 9, 14 | } 15 | 16 | // Value should return the resistance value of a resistor with a given colors. 17 | func Value(colors []string) int { 18 | return 10*colorMap[colors[0]] + colorMap[colors[1]] 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.meta/tests.toml: -------------------------------------------------------------------------------- 1 | # This is an auto-generated file. Regular comments will be removed when this 2 | # file is regenerated. Regenerating will not touch any manually added keys, 3 | # so comments can be added in a "comment" key. 4 | 5 | [1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce] 6 | description = "no name given" 7 | 8 | [b4c6dbb8-b4fb-42c2-bafd-10785abe7709] 9 | description = "a name given" 10 | 11 | [3549048d-1a6e-4653-9a79-b0bda163e8d5] 12 | description = "another name given" 13 | -------------------------------------------------------------------------------- /exercises/practice/clock/.meta/example.go: -------------------------------------------------------------------------------- 1 | package clock 2 | 3 | import "fmt" 4 | 5 | type Clock int 6 | 7 | func New(h, m int) Clock { 8 | c := Clock((h*60 + m) % 1440) 9 | if c < 0 { 10 | c += 1440 11 | } 12 | return c 13 | } 14 | 15 | func (c Clock) Add(m int) Clock { 16 | return New(0, int(c)+m) 17 | } 18 | 19 | func (c Clock) Subtract(m int) Clock { 20 | return New(0, int(c)-m) 21 | } 22 | 23 | func (c Clock) String() string { 24 | return fmt.Sprintf("%02d:%02d", c/60, c%60) 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/nth-prime/.meta/example.go: -------------------------------------------------------------------------------- 1 | package prime 2 | 3 | import "errors" 4 | 5 | var primes []int = []int{2} 6 | 7 | func Nth(n int) (int, error) { 8 | if n <= 0 { 9 | return 0, errors.New("input must be greater than 1") 10 | } 11 | for i := 3; len(primes) < n; i++ { 12 | isPrime(i) 13 | } 14 | return primes[n-1], nil 15 | } 16 | 17 | func isPrime(n int) { 18 | for _, v := range primes { 19 | if n%v == 0 { 20 | return 21 | } 22 | } 23 | primes = append(primes, n) 24 | } 25 | -------------------------------------------------------------------------------- /concepts/arithmetic-operators/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://www.tutorialspoint.com/go/go_arithmetic_operators.htm", 4 | "description": "Go - Arithmetic Operators" 5 | }, 6 | { 7 | "url": "https://golang.org/ref/spec#Arithmetic_operators", 8 | "description": "Go Language Spec: Arithmetic operators" 9 | }, 10 | { 11 | "url": "https://golang.org/ref/spec#IncDec_statements", 12 | "description": "Go Language Spec: IncDec statements" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /exercises/practice/flatten-array/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | A shipment of emergency supplies has arrived, but there's a problem. 4 | To protect from damage, the items — flashlights, first-aid kits, blankets — are packed inside boxes, and some of those boxes are nested several layers deep inside other boxes! 5 | 6 | To be prepared for an emergency, everything must be easily accessible in one box. 7 | Can you unpack all the supplies and place them into a single box, so they're ready when needed most? 8 | -------------------------------------------------------------------------------- /exercises/practice/paasio/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Report network IO statistics. 4 | 5 | You are writing a [PaaS][paas], and you need a way to bill customers based on network and filesystem usage. 6 | 7 | Create a wrapper for network connections and files that can report IO statistics. 8 | The wrapper must report: 9 | 10 | - The total number of bytes read/written. 11 | - The total number of read/write operations. 12 | 13 | [paas]: https://en.wikipedia.org/wiki/Platform_as_a_service 14 | -------------------------------------------------------------------------------- /exercises/practice/grains/.articles/performance/snippet.md: -------------------------------------------------------------------------------- 1 | ``` 2 | math.Pow square 3 | BenchmarkSquare-12 4761478 241.9 ns/op 48 B/op 3 allocs/op 4 | big exponentiation total 5 | BenchmarkTotal-12 5606967 238.7 ns/op 128 B/op 6 allocs/op 6 | bit shift square 7 | BenchmarkSquare-12 98908706 11.21 ns/op 0 B/op 0 allocs/op 8 | bit shift total 9 | BenchmarkTotal-12 1000000000 0.2689 ns/op 0 B/op 0 allocs/op 10 | ``` 11 | -------------------------------------------------------------------------------- /exercises/practice/two-fer/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | In some English accents, when you say "two for" quickly, it sounds like "two fer". 4 | Two-for-one is a way of saying that if you buy one, you also get one for free. 5 | So the phrase "two-fer" often implies a two-for-one offer. 6 | 7 | Imagine a bakery that has a holiday offer where you can buy two cookies for the price of one ("two-fer one!"). 8 | You take the offer and (very generously) decide to give the extra cookie to someone else in the queue. 9 | -------------------------------------------------------------------------------- /exercises/concept/savings-account/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "jamessouth" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "savings_account.go" 8 | ], 9 | "test": [ 10 | "savings_account_test.go" 11 | ], 12 | "exemplar": [ 13 | ".meta/exemplar.go" 14 | ], 15 | "invalidator": [ 16 | "go.mod" 17 | ] 18 | }, 19 | "blurb": "Learn about constants by managing a savings account.", 20 | "custom": { 21 | "taskIdsEnabled": true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /exercises/practice/book-store/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Implementation 2 | 3 | Define a single Go func, Cost, which calculates the cost 4 | for a given list of books based on the defined discounts. 5 | 6 | Use the following signature for func Cost: 7 | 8 | ``` 9 | func Cost(books []int) int 10 | ``` 11 | Cost will return the total cost (after discounts) in cents. 12 | For example, for a single book, the cost is 800 cents, which equals $8.00. 13 | Only integer calculations are necessary for this exercise. 14 | 15 | -------------------------------------------------------------------------------- /exercises/practice/change/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Determine the fewest number of coins to give a customer so that the sum of their values equals the correct amount of change. 4 | 5 | ## Examples 6 | 7 | - An amount of 15 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5 and one coin of value 10, or [5, 10]. 8 | - An amount of 40 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5, one coin of value 10, and one coin of value 25, or [5, 10, 25]. 9 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Lhakpa is a [Sherpa][sherpa] mountain guide and porter. 4 | After months of careful planning, the expedition Lhakpa works for is about to leave. 5 | She will be paid the value she carried to the base camp. 6 | 7 | In front of her are many items, each with a value and weight. 8 | Lhakpa would gladly take all of the items, but her knapsack can only hold so much weight. 9 | 10 | [sherpa]: https://en.wikipedia.org/wiki/Sherpa_people#Mountaineering 11 | -------------------------------------------------------------------------------- /exercises/practice/octal/.meta/example.go: -------------------------------------------------------------------------------- 1 | package octal 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func ParseOctal(octal string) (int64, error) { 8 | num := int64(0) 9 | for _, digit := range octal { 10 | // if any digits aren't octal digits (0-7), return 0 11 | if digit < '0' || digit > '7' { 12 | return 0, fmt.Errorf("unexpected rune '%c'", digit) 13 | } 14 | // multiply the current number by 8 (left shift) and add the digit 15 | num = num<<3 + int64(digit-'0') 16 | } 17 | return num, nil 18 | } 19 | -------------------------------------------------------------------------------- /exercises/practice/strain/.meta/example.go: -------------------------------------------------------------------------------- 1 | package strain 2 | 3 | func Keep[T any](list []T, fn func(T) bool) []T { 4 | result := []T{} 5 | 6 | for _, entry := range list { 7 | if fn(entry) { 8 | result = append(result, entry) 9 | } 10 | } 11 | 12 | return result 13 | } 14 | 15 | func Discard[T any](list []T, fn func(T) bool) []T { 16 | result := []T{} 17 | 18 | for _, entry := range list { 19 | if !fn(entry) { 20 | result = append(result, entry) 21 | } 22 | } 23 | 24 | return result 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/triangle/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Constant Declarations 2 | 3 | In this exercise you are asked to declare a series of constants used to identify 4 | different types of triangles. Pick the data type you think works best for this 5 | and get the tests passing. 6 | 7 | Afterwards, it may be worth reading about Go's 8 | predeclared identifier [iota](https://golang.org/ref/spec#Iota). There's an 9 | excellent write up about it 10 | [here](https://splice.com/blog/iota-elegant-constants-golang/). 11 | -------------------------------------------------------------------------------- /exercises/practice/secret-handshake/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You are starting a secret coding club with some friends and friends-of-friends. 4 | Not everyone knows each other, so you and your friends have decided to create a secret handshake that you can use to recognize that someone is a member. 5 | You don't want anyone who isn't in the know to be able to crack the code. 6 | 7 | You've designed the code so that one person says a number between 1 and 31, and the other person turns it into a series of actions. 8 | -------------------------------------------------------------------------------- /exercises/practice/complex-numbers/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "eklatzer" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "complex_numbers.go" 8 | ], 9 | "test": [ 10 | "complex_numbers_test.go" 11 | ], 12 | "example": [ 13 | ".meta/example.go" 14 | ], 15 | "invalidator": [ 16 | "go.mod" 17 | ] 18 | }, 19 | "blurb": "Implement complex numbers.", 20 | "source": "Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Complex_number" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/concept/logs-logs-logs/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "sudomateo", 4 | "tehsphinx" 5 | ], 6 | "files": { 7 | "solution": [ 8 | "logs_logs_logs.go" 9 | ], 10 | "test": [ 11 | "logs_logs_logs_test.go" 12 | ], 13 | "exemplar": [ 14 | ".meta/exemplar.go" 15 | ], 16 | "invalidator": [ 17 | "go.mod" 18 | ] 19 | }, 20 | "blurb": "Learn about the strings package by parsing logs.", 21 | "custom": { 22 | "taskIdsEnabled": true 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/collatz-conjecture/.meta/example.go: -------------------------------------------------------------------------------- 1 | package collatzconjecture 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // CollatzConjecture is an example implementation of the collatz conjecture exercise. 8 | func CollatzConjecture(n int) (int, error) { 9 | if n <= 0 { 10 | return -1, errors.New("only positive integers are allowed") 11 | } 12 | 13 | steps := 0 14 | for n != 1 { 15 | if n%2 == 0 { 16 | n /= 2 17 | } else { 18 | n = 3*n + 1 19 | } 20 | steps++ 21 | } 22 | 23 | return steps, nil 24 | } 25 | -------------------------------------------------------------------------------- /concepts/conditionals-if/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://gobyexample.com/if-else", 4 | "description": "Go by Example: If/Else" 5 | }, 6 | { 7 | "url": "https://tour.golang.org/flowcontrol/7", 8 | "description": "A Tour of Go: If and else" 9 | }, 10 | { 11 | "url": "https://golang.org/doc/effective_go#if", 12 | "description": "Effective Go: If" 13 | }, 14 | { 15 | "url": "https://golang.org/ref/spec#If_statements", 16 | "description": "Go Language Spec: If Statements" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /concepts/strings/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://golangbot.com/strings/", 4 | "description": "Article: Introduction to Strings in Go" 5 | }, 6 | { 7 | "url": "https://go101.org/article/string.html", 8 | "description": "Article: Strings in Go" 9 | }, 10 | { 11 | "url": "https://pkg.go.dev/strings", 12 | "description": "Go Packages: strings package" 13 | }, 14 | { 15 | "url": "https://gobyexample.com/string-functions", 16 | "description": "Go by Example: String Functions" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /exercises/practice/grade-school/grade_school.go: -------------------------------------------------------------------------------- 1 | package school 2 | 3 | // Define the Grade and School types here. 4 | 5 | func New() *School { 6 | panic("Please implement the New function") 7 | } 8 | 9 | func (s *School) Add(student string, grade int) { 10 | panic("Please implement the Add function") 11 | } 12 | 13 | func (s *School) Grade(level int) []string { 14 | panic("Please implement the Grade function") 15 | } 16 | 17 | func (s *School) Enrollment() []Grade { 18 | panic("Please implement the Enrollment function") 19 | } 20 | -------------------------------------------------------------------------------- /.github/workflows/ping-cross-track-maintainers-team.yml: -------------------------------------------------------------------------------- 1 | name: Ping cross-track maintainers team 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - opened 7 | 8 | permissions: 9 | pull-requests: write 10 | 11 | jobs: 12 | ping: 13 | if: github.repository_owner == 'exercism' # Stops this job from running on forks 14 | uses: exercism/github-actions/.github/workflows/ping-cross-track-maintainers-team.yml@main 15 | secrets: 16 | github_membership_token: ${{ secrets.COMMUNITY_CONTRIBUTIONS_WORKFLOW_TOKEN }} 17 | -------------------------------------------------------------------------------- /exercises/concept/expenses/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "antklim", 4 | "andrerfcsantos" 5 | ], 6 | "files": { 7 | "solution": [ 8 | "expenses.go" 9 | ], 10 | "test": [ 11 | "expenses_test.go" 12 | ], 13 | "exemplar": [ 14 | ".meta/exemplar.go" 15 | ], 16 | "invalidator": [ 17 | "go.mod" 18 | ] 19 | }, 20 | "blurb": "Learn about first-class functions by helping Bob manage expense records.", 21 | "custom": { 22 | "taskIdsEnabled": true 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/armstrong-numbers/.meta/example.go: -------------------------------------------------------------------------------- 1 | package armstrong 2 | 3 | import "math" 4 | 5 | func order(n int) (result int) { 6 | for n != 0 { 7 | result++ 8 | n /= 10 9 | } 10 | return result 11 | } 12 | 13 | // IsNumber returns true for an armstrong number 14 | func IsNumber(n int) bool { 15 | originalNumber := n 16 | pow := order(n) 17 | sum := 0 18 | for n != 0 { 19 | remainder := n % 10 20 | sum += int(math.Pow(float64(remainder), float64(pow))) 21 | n /= 10 22 | } 23 | return originalNumber == sum 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/pig-latin/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Your parents have challenged you and your sibling to a game of two-on-two basketball. 4 | Confident they'll win, they let you score the first couple of points, but then start taking over the game. 5 | Needing a little boost, you start speaking in [Pig Latin][pig-latin], which is a made-up children's language that's difficult for non-children to understand. 6 | This will give you the edge to prevail over your parents! 7 | 8 | [pig-latin]: https://en.wikipedia.org/wiki/Pig_latin 9 | -------------------------------------------------------------------------------- /concepts/conditionals-switch/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/flowcontrol/9", 4 | "description": "A Tour of Go: Switch" 5 | }, 6 | { 7 | "url": "https://gobyexample.com/switch", 8 | "description": "Go by Example: Switch" 9 | }, 10 | { 11 | "url": "https://golang.org/doc/effective_go#switch", 12 | "description": "Effective Go: Switch" 13 | }, 14 | { 15 | "url": "https://golang.org/ref/spec#Switch_statements", 16 | "description": "Language Spec: Switch Statements" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /exercises/concept/card-tricks/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "tehsphinx" 4 | ], 5 | "contributors": [ 6 | "norbs57" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "card_tricks.go" 11 | ], 12 | "test": [ 13 | "card_tricks_test.go" 14 | ], 15 | "exemplar": [ 16 | ".meta/exemplar.go" 17 | ], 18 | "invalidator": [ 19 | "go.mod" 20 | ] 21 | }, 22 | "blurb": "Learn about slices by doing card tricks.", 23 | "custom": { 24 | "taskIdsEnabled": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/spiral-matrix/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Your task is to return a square matrix of a given size. 4 | 5 | The matrix should be filled with natural numbers, starting from 1 in the top-left corner, increasing in an inward, clockwise spiral order, like these examples: 6 | 7 | ## Examples 8 | 9 | ### Spiral matrix of size 3 10 | 11 | ```text 12 | 1 2 3 13 | 8 9 4 14 | 7 6 5 15 | ``` 16 | 17 | ### Spiral matrix of size 4 18 | 19 | ```text 20 | 1 2 3 4 21 | 12 13 14 5 22 | 11 16 15 6 23 | 10 9 8 7 24 | ``` 25 | -------------------------------------------------------------------------------- /concepts/methods/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/methods/1", 4 | "description": "A Tour of Go: Methods" 5 | }, 6 | { 7 | "url": "https://tour.golang.org/methods/4", 8 | "description": "A Tour of Go: Pointer receivers" 9 | }, 10 | { 11 | "url": "https://gobyexample.com/methods", 12 | "description": "Go By Example: Methods" 13 | }, 14 | { 15 | "url": "https://www.callicoder.com/golang-methods-tutorial/", 16 | "description": "Article: Golang Methods Tutorial with Examples" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /exercises/practice/bank-account/bank_account.go: -------------------------------------------------------------------------------- 1 | package account 2 | 3 | // Define the Account type here. 4 | 5 | func Open(amount int64) *Account { 6 | panic("Please implement the Open function") 7 | } 8 | 9 | func (a *Account) Balance() (int64, bool) { 10 | panic("Please implement the Balance function") 11 | } 12 | 13 | func (a *Account) Deposit(amount int64) (int64, bool) { 14 | panic("Please implement the Deposit function") 15 | } 16 | 17 | func (a *Account) Close() (int64, bool) { 18 | panic("Please implement the Close function") 19 | } 20 | -------------------------------------------------------------------------------- /reference/concepts/zero_values.md: -------------------------------------------------------------------------------- 1 | # Zero Values 2 | 3 | Every type in Go has a [zero value](https://golang.org/ref/spec#The_zero_value). 4 | If a variable is declared and no value assigned, its zero value is automatically assigned to it. 5 | A variable in Go therefore can never be empty or undefined, etc. 6 | 7 | The zero values are: 8 | 9 | - `false` for booleans 10 | - `""` (empty string) for strings 11 | - `0` for any numerical type (int, in64, float64, uint8, byte, etc.) 12 | - `nil` for pointers, functions, interfaces, slices, channels and maps 13 | -------------------------------------------------------------------------------- /concepts/interfaces/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/methods/9", 4 | "description": "A Tour of Go: Interfaces" 5 | }, 6 | { 7 | "url": "https://golangbot.com/interfaces-part-1", 8 | "description": "Golangbot: A Practical Guide to Interfaces" 9 | }, 10 | { 11 | "url": "https://gobyexample.com/interfaces", 12 | "description": "Go by Example: Interfaces" 13 | }, 14 | { 15 | "url": "https://golang.org/doc/effective_go#interfaces", 16 | "description": "Effective Go: Interfaces" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /docs/RESOURCES.md: -------------------------------------------------------------------------------- 1 | # Resources 2 | 3 | There are many great free online resources to help you get started with Go including: 4 | 5 | * [How to Write Go Code](https://golang.org/doc/code.html) 6 | * [Tour of Go](https://go.dev/tour) 7 | * [Effective Go](https://golang.org/doc/effective_go.html) 8 | 9 | ## Books 10 | * [Go Books](https://github.com/dariubs/GoBooks) 11 | 12 | ## Blogposts 13 | * [Resources for new Go programmers](https://dave.cheney.net/resources-for-new-go-programmers) 14 | 15 | ## Organizations 16 | * [GoBridge](https://gobridge.org/) 17 | -------------------------------------------------------------------------------- /exercises/practice/pangram/.meta/example.go: -------------------------------------------------------------------------------- 1 | package pangram 2 | 3 | import "strings" 4 | 5 | // IsPangram checks if given string is a pangram 6 | func IsPangram(s string) bool { 7 | var check [26]bool 8 | var count int 9 | for _, c := range strings.ToLower(s) { 10 | if c >= 'a' { 11 | if c > 'z' { 12 | continue 13 | } 14 | c -= 97 15 | } else { 16 | continue 17 | } 18 | 19 | if !check[c] { 20 | if count == 25 { 21 | return true 22 | } 23 | check[c] = true 24 | count++ 25 | } 26 | } 27 | return false 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/transpose/.meta/example.go: -------------------------------------------------------------------------------- 1 | package transpose 2 | 3 | func Transpose(m []string) []string { 4 | max := maxLen(m) 5 | t := make([]string, max) 6 | for i, row := range m { 7 | for j, c := range row { 8 | t[j] += string(c) 9 | } 10 | remMax := maxLen(m[i:]) 11 | for j := len(row); j < remMax; j++ { 12 | t[j] += " " 13 | } 14 | } 15 | return t 16 | } 17 | 18 | func maxLen(m []string) (length int) { 19 | for _, l := range m { 20 | if len(l) > length { 21 | length = len(l) 22 | } 23 | } 24 | return length 25 | } 26 | -------------------------------------------------------------------------------- /concepts/constants/links.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "url": "https://tour.golang.org/basics/15", 4 | "description": "A Tour of Go: Constants" 5 | }, 6 | { 7 | "url": "https://gobyexample.com/constants", 8 | "description": "Go by Example: Constants" 9 | }, 10 | { 11 | "url": "https://go.dev/blog/constants", 12 | "description": "Go Dev Blog: Constants" 13 | }, 14 | { 15 | "url": "https://golang.org/ref/spec#Constants", 16 | "description": "Go Language Spec: Constants" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /exercises/concept/census/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "jamessouth", 4 | "sudomateo" 5 | ], 6 | "contributors": [ 7 | "tehsphinx", 8 | "eklatzer" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "census.go" 13 | ], 14 | "test": [ 15 | "census_test.go" 16 | ], 17 | "exemplar": [ 18 | ".meta/exemplar.go" 19 | ], 20 | "invalidator": [ 21 | "go.mod" 22 | ] 23 | }, 24 | "blurb": "Learn about zero values.", 25 | "custom": { 26 | "taskIdsEnabled": true 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/pythagorean-triplet/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | A Pythagorean triplet is a set of three natural numbers, {a, b, c}, for which, 4 | 5 | ```text 6 | a² + b² = c² 7 | ``` 8 | 9 | and such that, 10 | 11 | ```text 12 | a < b < c 13 | ``` 14 | 15 | For example, 16 | 17 | ```text 18 | 3² + 4² = 5². 19 | ``` 20 | 21 | Given an input integer N, find all Pythagorean triplets for which `a + b + c = N`. 22 | 23 | For example, with N = 1000, there is exactly one Pythagorean triplet for which `a + b + c = 1000`: `{200, 375, 425}`. 24 | -------------------------------------------------------------------------------- /exercises/practice/zebra-puzzle/zebra_puzzle_test.go: -------------------------------------------------------------------------------- 1 | package zebra 2 | 3 | import "testing" 4 | 5 | func TestSolvePuzzle(t *testing.T) { 6 | expected := Solution{DrinksWater: "Norwegian", OwnsZebra: "Japanese"} 7 | actual := SolvePuzzle() 8 | if expected != actual { 9 | t.Fatalf("FAILED:\nExpected: %#v\nActual: %#v", 10 | expected, actual) 11 | } 12 | } 13 | 14 | func BenchmarkScore(b *testing.B) { 15 | if testing.Short() { 16 | b.Skip("skipping benchmark in short mode.") 17 | } 18 | for i := 0; i < b.N; i++ { 19 | SolvePuzzle() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /exercises/concept/cars-assemble/.meta/design.md: -------------------------------------------------------------------------------- 1 | # Design 2 | 3 | ## Goal 4 | 5 | The goal of this exercise is to teach the student how to deal with numbers in Go. 6 | 7 | ## Learning objectives 8 | 9 | - This should introduce the `uint`, `int` and `float64` types (the basic number types in Go). 10 | - It should introduce operations with numbers like multiplication, division, etc. 11 | - Introduce basic type conversion between number types 12 | 13 | ## Concepts 14 | 15 | - `numbers` 16 | - `arithmetic-operators` 17 | 18 | ## Prerequisites 19 | 20 | - `basics` 21 | -------------------------------------------------------------------------------- /exercises/practice/yacht/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Each year, something new is "all the rage" in your high school. 4 | This year it is a dice game: [Yacht][yacht]. 5 | 6 | The game of Yacht is from the same family as Poker Dice, Generala and particularly Yahtzee, of which it is a precursor. 7 | The game consists of twelve rounds. 8 | In each, five dice are rolled and the player chooses one of twelve categories. 9 | The chosen category is then used to score the throw of the dice. 10 | 11 | [yacht]: https://en.wikipedia.org/wiki/Yacht_(dice_game) 12 | -------------------------------------------------------------------------------- /exercises/concept/logs-logs-logs/.meta/design.md: -------------------------------------------------------------------------------- 1 | # Design 2 | 3 | ## Goal 4 | 5 | The goal of this exercise is to teach the student about runes. 6 | 7 | ## Learning objectives 8 | 9 | - Understand the `rune` type in Go. 10 | - Understand how runes relate to Unicode and UTF-8. 11 | - Understand that runes can be 1, 2, 3, or 4 bytes. 12 | 13 | ## Out of scope 14 | 15 | ## Concepts 16 | 17 | - `runes` 18 | 19 | ## Prerequisites 20 | 21 | - `strings` 22 | - `conditionals-if` 23 | - `slices` 24 | - `maps` 25 | - `range-iteration` 26 | 27 | ## Analyzer 28 | 29 | N/A 30 | -------------------------------------------------------------------------------- /exercises/concept/parsing-log-files/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "norbs57" 4 | ], 5 | "contributors": [ 6 | "eklatzer" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "parsing_log_files.go" 11 | ], 12 | "test": [ 13 | "parsing_log_files_test.go" 14 | ], 15 | "exemplar": [ 16 | ".meta/exemplar.go" 17 | ], 18 | "invalidator": [ 19 | "go.mod" 20 | ] 21 | }, 22 | "blurb": "Learn about regular expressions by parsing logs.", 23 | "custom": { 24 | "taskIdsEnabled": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /exercises/concept/sorting-room/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "jmrunkle" 4 | ], 5 | "contributors": [ 6 | "junedev" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "sorting_room.go" 11 | ], 12 | "test": [ 13 | "sorting_room_test.go" 14 | ], 15 | "exemplar": [ 16 | ".meta/exemplar.go" 17 | ], 18 | "invalidator": [ 19 | "go.mod" 20 | ] 21 | }, 22 | "blurb": "Learn about type casting and type assertions in the sorting room.", 23 | "custom": { 24 | "taskIdsEnabled": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/bottle-song/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "PakkuDon" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "bottle_song.go" 8 | ], 9 | "test": [ 10 | "bottle_song_test.go" 11 | ], 12 | "example": [ 13 | ".meta/example.go" 14 | ], 15 | "invalidator": [ 16 | "go.mod" 17 | ] 18 | }, 19 | "blurb": "Produce the lyrics to the popular children's repetitive song: Ten Green Bottles.", 20 | "source": "Wikipedia", 21 | "source_url": "https://en.wikipedia.org/wiki/Ten_Green_Bottles" 22 | } 23 | -------------------------------------------------------------------------------- /exercises/concept/airport-robot/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "junedev" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "airport_robot.go" 8 | ], 9 | "test": [ 10 | "airport_robot_test.go" 11 | ], 12 | "exemplar": [ 13 | ".meta/exemplar.go" 14 | ], 15 | "invalidator": [ 16 | "go.mod" 17 | ] 18 | }, 19 | "icon": "squeaky-clean", 20 | "blurb": "Learn about defining and implementing interfaces by programming an airport service robot.", 21 | "custom": { 22 | "taskIdsEnabled": true 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /exercises/concept/party-robot/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "tehsphinx" 4 | ], 5 | "contributors": [ 6 | "oanaOM", 7 | "bobtfish" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "party_robot.go" 12 | ], 13 | "test": [ 14 | "party_robot_test.go" 15 | ], 16 | "exemplar": [ 17 | ".meta/exemplar.go" 18 | ], 19 | "invalidator": [ 20 | "go.mod" 21 | ] 22 | }, 23 | "blurb": "Learn about strings by programming a party robot.", 24 | "custom": { 25 | "taskIdsEnabled": true 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /exercises/practice/hamming/.docs/instructions.md: -------------------------------------------------------------------------------- 1 | # Instructions 2 | 3 | Calculate the Hamming distance between two DNA strands. 4 | 5 | We read DNA using the letters C, A, G and T. 6 | Two strands might look like this: 7 | 8 | GAGCCTACTAACGGGAT 9 | CATCGTAATGACGGCCT 10 | ^ ^ ^ ^ ^ ^^ 11 | 12 | They have 7 differences, and therefore the Hamming distance is 7. 13 | 14 | ## Implementation notes 15 | 16 | The Hamming distance is only defined for sequences of equal length, so an attempt to calculate it between sequences of different lengths should not work. 17 | -------------------------------------------------------------------------------- /exercises/practice/matrix/matrix.go: -------------------------------------------------------------------------------- 1 | package matrix 2 | 3 | // Define the Matrix type here. 4 | 5 | func New(s string) (Matrix, error) { 6 | panic("Please implement the New function") 7 | } 8 | 9 | // Cols and Rows must return the results without affecting the matrix. 10 | func (m Matrix) Cols() [][]int { 11 | panic("Please implement the Cols function") 12 | } 13 | 14 | func (m Matrix) Rows() [][]int { 15 | panic("Please implement the Rows function") 16 | } 17 | 18 | func (m Matrix) Set(row, col, val int) bool { 19 | panic("Please implement the Set function") 20 | } 21 | -------------------------------------------------------------------------------- /exercises/concept/animal-magic/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "norbs57" 4 | ], 5 | "contributors": [ 6 | "junedev" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "animal_magic.go" 11 | ], 12 | "test": [ 13 | "animal_magic_test.go" 14 | ], 15 | "exemplar": [ 16 | ".meta/exemplar.go" 17 | ], 18 | "invalidator": [ 19 | "go.mod" 20 | ] 21 | }, 22 | "icon": "roll-the-die", 23 | "blurb": "Learn how to work with pseudo-random numbers", 24 | "custom": { 25 | "taskIdsEnabled": true 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /exercises/concept/election-day/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "andrerfcsantos" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "election_day.go" 8 | ], 9 | "test": [ 10 | "election_day_test.go" 11 | ], 12 | "exemplar": [ 13 | ".meta/exemplar.go" 14 | ], 15 | "editor": [ 16 | "election_result.go" 17 | ], 18 | "invalidator": [ 19 | "go.mod" 20 | ] 21 | }, 22 | "blurb": "Learn about pointers by creating a simple voting system.", 23 | "custom": { 24 | "taskIdsEnabled": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /exercises/concept/gross-store/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "chocopowwwa" 4 | ], 5 | "contributors": [ 6 | "MiroslavGatsanoga" 7 | ], 8 | "files": { 9 | "solution": [ 10 | "gross_store.go" 11 | ], 12 | "test": [ 13 | "gross_store_test.go" 14 | ], 15 | "exemplar": [ 16 | ".meta/exemplar.go" 17 | ], 18 | "invalidator": [ 19 | "go.mod" 20 | ] 21 | }, 22 | "blurb": "Learn about maps by selling items by the dozen at the Gross Store.", 23 | "custom": { 24 | "taskIdsEnabled": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/meetup/.meta/example.go: -------------------------------------------------------------------------------- 1 | package meetup 2 | 3 | import "time" 4 | 5 | type WeekSchedule int 6 | 7 | const ( 8 | First WeekSchedule = 1 9 | Second WeekSchedule = 8 10 | Third WeekSchedule = 15 11 | Fourth WeekSchedule = 22 12 | Teenth WeekSchedule = 13 13 | Last WeekSchedule = -6 14 | ) 15 | 16 | func Day(wSched WeekSchedule, wDay time.Weekday, month time.Month, year int) int { 17 | if wSched == Last { 18 | month++ 19 | } 20 | t := time.Date(year, month, int(wSched), 12, 0, 0, 0, time.UTC) 21 | return t.Day() + int(wDay-t.Weekday()+7)%7 22 | } 23 | -------------------------------------------------------------------------------- /exercises/practice/rotational-cipher/.meta/example.go: -------------------------------------------------------------------------------- 1 | package rotationalcipher 2 | 3 | import ( 4 | "unicode" 5 | ) 6 | 7 | // RotationalCipher is an implementation for the rotational cipher exercise. 8 | func RotationalCipher(plain string, shiftKey int) string { 9 | var cipher []rune 10 | for _, ru := range plain { 11 | if unicode.IsUpper(ru) { 12 | ru = rune('A' + (int(ru-'A')+shiftKey)%26) 13 | } else if unicode.IsLower(ru) { 14 | ru = rune('a' + (int(ru-'a')+shiftKey)%26) 15 | } 16 | cipher = append(cipher, ru) 17 | } 18 | 19 | return string(cipher) 20 | } 21 | -------------------------------------------------------------------------------- /exercises/shared/.docs/debug.md: -------------------------------------------------------------------------------- 1 | # Debug 2 | 3 | When a test fails, a message is displayed describing what went wrong and for which input. You can also use the fact that [console output][fmt-println] will be shown too. You can write to the console using: 4 | 5 | ```go 6 | import "fmt" 7 | fmt.Println("Debug message") 8 | ``` 9 | 10 | [fmt-println]: https://pkg.go.dev/fmt#Println 11 | 12 | Note: When debugging with the in-browser editor, using e.g. `fmt.Print` will not add a newline after the output which can provoke a bug in `go test --json` and result in messed up test output. 13 | -------------------------------------------------------------------------------- /reference/concepts/exporting.md: -------------------------------------------------------------------------------- 1 | # Exported Identifiers 2 | 3 | Go does not have `public` and `private` keywords. Instead it exports identifiers that start with a capital letter. 4 | 5 | > An identifier is exported if both: 6 | > 7 | > - the first character of the identifier's name is a Unicode upper case letter (Unicode class "Lu"); and 8 | > - the identifier is declared in the package block or it is a field name or method name. 9 | > 10 | > All other identifiers are not exported. 11 | > [The Go Programming Language Specification](https://golang.org/ref/spec#Exported_identifiers) 12 | -------------------------------------------------------------------------------- /exercises/concept/meteorology/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "norbs57" 4 | ], 5 | "contributors": [ 6 | "andrerfcsantos", 7 | "eklatzer" 8 | ], 9 | "files": { 10 | "solution": [ 11 | "meteorology.go" 12 | ], 13 | "test": [ 14 | "meteorology_test.go" 15 | ], 16 | "exemplar": [ 17 | ".meta/exemplar.go" 18 | ], 19 | "invalidator": [ 20 | "go.mod" 21 | ] 22 | }, 23 | "blurb": "Format metereological data of custom types into strings.", 24 | "custom": { 25 | "taskIdsEnabled": true 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /exercises/concept/weather-forecast/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "nikimanoledaki", 4 | "micuffaro" 5 | ], 6 | "files": { 7 | "solution": [ 8 | "weather_forecast.go" 9 | ], 10 | "test": [ 11 | "weather_forecast_test.go" 12 | ], 13 | "exemplar": [ 14 | ".meta/exemplar.go" 15 | ], 16 | "invalidator": [ 17 | "go.mod" 18 | ] 19 | }, 20 | "blurb": "Learn about comments by helping a weather station manage their weather forecasting program.", 21 | "custom": { 22 | "taskIdsEnabled": false 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.docs/introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | You've just been hired as professor of mathematics. 4 | Your first week went well, but something is off in your second week. 5 | The problem is that every answer given by your students is wrong! 6 | Luckily, your math skills have allowed you to identify the problem: the student answers _are_ correct, but they're all in base 2 (binary)! 7 | Amazingly, it turns out that each week, the students use a different base. 8 | To help you quickly verify the student answers, you'll be building a tool to translate between bases. 9 | -------------------------------------------------------------------------------- /exercises/concept/animal-magic/animal_magic.go: -------------------------------------------------------------------------------- 1 | package chance 2 | 3 | // RollADie returns a random int d with 1 <= d <= 20. 4 | func RollADie() int { 5 | panic("Please implement the RollADie function") 6 | } 7 | 8 | // GenerateWandEnergy returns a random float64 f with 0.0 <= f < 12.0. 9 | func GenerateWandEnergy() float64 { 10 | panic("Please implement the GenerateWandEnergy function") 11 | } 12 | 13 | // ShuffleAnimals returns a slice with all eight animal strings in random order. 14 | func ShuffleAnimals() []string { 15 | panic("Please implement the ShuffleAnimals function") 16 | } 17 | -------------------------------------------------------------------------------- /exercises/concept/party-robot/.meta/design.md: -------------------------------------------------------------------------------- 1 | # Design 2 | 3 | ## Goal 4 | 5 | The goal of this exercise is to teach the student the basics on `strings` in Go. Focuses on formatting. 6 | 7 | ## Learning objectives 8 | 9 | - Know of the existence of the `string` type. 10 | - Know how to create a string. 11 | - Know how to do string formatting: `fmt.Sprintf` 12 | 13 | ## Out of scope 14 | 15 | - iteration of strings 16 | - strings package 17 | - immutability of strings 18 | - bytes and runes 19 | 20 | ## Concepts 21 | 22 | - `strings` 23 | 24 | ## Prerequisites 25 | 26 | - `basics` 27 | -------------------------------------------------------------------------------- /exercises/practice/all-your-base/.docs/instructions.append.md: -------------------------------------------------------------------------------- 1 | # Implementation 2 | 3 | Assumptions: 4 | 1. Zero is always represented in outputs as [0] instead of []. 5 | 2. In no other instances are leading zeroes present in any outputs. 6 | 3. Leading zeroes are accepted in inputs. 7 | 4. An empty sequence of input digits is considered zero, rather than an error. 8 | 9 | Handle problem cases by returning an error whose Error() method 10 | returns one of following messages: 11 | * input base must be >= 2 12 | * output base must be >= 2 13 | * all digits must satisfy 0 <= d < input base 14 | -------------------------------------------------------------------------------- /exercises/concept/blackjack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "andres-zartab" 4 | ], 5 | "contributors": [ 6 | "tehsphinx", 7 | "andrerfcsantos", 8 | "norbs57" 9 | ], 10 | "files": { 11 | "solution": [ 12 | "blackjack.go" 13 | ], 14 | "test": [ 15 | "blackjack_test.go" 16 | ], 17 | "exemplar": [ 18 | ".meta/exemplar.go" 19 | ], 20 | "invalidator": [ 21 | "go.mod" 22 | ] 23 | }, 24 | "blurb": "Learn about conditionals by playing Blackjack.", 25 | "custom": { 26 | "taskIdsEnabled": true 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /exercises/practice/proverb/.meta/example.go: -------------------------------------------------------------------------------- 1 | // Package proverb deals with outputting the lines of a rhyme. 2 | package proverb 3 | 4 | import "fmt" 5 | 6 | // Proverb outputs the lines of for want of a nail 7 | func Proverb(rhyme []string) []string { 8 | if len(rhyme) == 0 { 9 | return []string{} 10 | } 11 | var r []string 12 | if len(rhyme) > 1 { 13 | for i := 0; i < len(rhyme)-1; i++ { 14 | r = append(r, fmt.Sprintf("For want of a %s the %s was lost.", rhyme[i], rhyme[i+1])) 15 | } 16 | } 17 | r = append(r, fmt.Sprintf("And all for the want of a %s.", rhyme[0])) 18 | return r 19 | } 20 | -------------------------------------------------------------------------------- /exercises/practice/counter/impl1.go: -------------------------------------------------------------------------------- 1 | package counter 2 | 3 | import "unicode" 4 | 5 | // Incorrect implementation: wrongly counts lines. 6 | type Impl1 struct { 7 | lines, characters, letters int 8 | } 9 | 10 | func (c *Impl1) AddString(s string) { 11 | for _, char := range s { 12 | if char == '\n' { 13 | c.lines++ 14 | } else if unicode.IsLetter(char) { 15 | c.letters++ 16 | } 17 | c.characters++ 18 | } 19 | } 20 | 21 | func (c Impl1) Lines() int { return c.lines } 22 | func (c Impl1) Letters() int { return c.letters } 23 | func (c Impl1) Characters() int { return c.characters } 24 | -------------------------------------------------------------------------------- /exercises/concept/annalyns-infiltration/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "oanaOM" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "annalyns_infiltration.go" 8 | ], 9 | "test": [ 10 | "annalyns_infiltration_test.go" 11 | ], 12 | "exemplar": [ 13 | ".meta/exemplar.go" 14 | ], 15 | "invalidator": [ 16 | "go.mod" 17 | ] 18 | }, 19 | "forked_from": [ 20 | "csharp/annalyns-infiltration" 21 | ], 22 | "blurb": "Learn about booleans by helping Annalyn free her best friend.", 23 | "custom": { 24 | "taskIdsEnabled": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /exercises/practice/bob/bob_test.go: -------------------------------------------------------------------------------- 1 | package bob 2 | 3 | import "testing" 4 | 5 | func TestHey(t *testing.T) { 6 | for _, tc := range testCases { 7 | t.Run(tc.description, func(t *testing.T) { 8 | actual := Hey(tc.input) 9 | if actual != tc.expected { 10 | t.Fatalf("Hey(%q) = %q, want: %q", tc.input, actual, tc.expected) 11 | } 12 | }) 13 | } 14 | } 15 | 16 | func BenchmarkHey(b *testing.B) { 17 | if testing.Short() { 18 | b.Skip("skipping benchmark in short mode.") 19 | } 20 | for i := 0; i < b.N; i++ { 21 | for _, tc := range testCases { 22 | Hey(tc.input) 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /exercises/practice/knapsack/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": ["jesse-kroon"], 3 | "files": { 4 | "solution": [ 5 | "knapsack.go" 6 | ], 7 | "test": [ 8 | "knapsack_test.go" 9 | ], 10 | "editor": [ 11 | "cases_test.go" 12 | ], 13 | "example": [ 14 | ".meta/example.go" 15 | ] 16 | }, 17 | "blurb": "Given a knapsack that can only carry a certain weight, determine which items to put in the knapsack in order to maximize their combined value.", 18 | "source": "Wikipedia", 19 | "source_url": "https://en.wikipedia.org/wiki/Knapsack_problem" 20 | } 21 | -------------------------------------------------------------------------------- /exercises/practice/list-ops/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "ljagged" 4 | ], 5 | "contributors": [ 6 | "bitfield", 7 | "Daveed9", 8 | "ekingery", 9 | "ferhatelmas", 10 | "hilary", 11 | "ivenk", 12 | "leenipper", 13 | "eklatzer" 14 | ], 15 | "files": { 16 | "solution": [ 17 | "list_ops.go" 18 | ], 19 | "test": [ 20 | "list_ops_test.go" 21 | ], 22 | "example": [ 23 | ".meta/example.go" 24 | ], 25 | "invalidator": [ 26 | "go.mod" 27 | ] 28 | }, 29 | "blurb": "Implement basic list operations." 30 | } 31 | -------------------------------------------------------------------------------- /gomod-sync/cmd/config/load.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "os" 7 | ) 8 | 9 | // Load loads a configuration from a path to a JSON file. 10 | func Load(file string) (VersionConfig, error) { 11 | var config VersionConfig 12 | 13 | f, err := os.Open(file) 14 | if err != nil { 15 | return config, fmt.Errorf("failed to open config file: %v", err) 16 | } 17 | defer f.Close() 18 | 19 | err = json.NewDecoder(f).Decode(&config) 20 | if err != nil { 21 | return config, fmt.Errorf("failed to decode config file: %v", err) 22 | } 23 | 24 | return config, nil 25 | } 26 | -------------------------------------------------------------------------------- /exercises/concept/booking-up-for-beauty/.meta/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | "jamessouth" 4 | ], 5 | "files": { 6 | "solution": [ 7 | "booking_up_for_beauty.go" 8 | ], 9 | "test": [ 10 | "booking_up_for_beauty_test.go" 11 | ], 12 | "exemplar": [ 13 | ".meta/exemplar.go" 14 | ], 15 | "invalidator": [ 16 | "go.mod" 17 | ] 18 | }, 19 | "forked_from": [ 20 | "csharp/booking-up-for-beauty" 21 | ], 22 | "blurb": "Learn about time by handling appointments in a beauty salon.", 23 | "custom": { 24 | "taskIdsEnabled": true 25 | } 26 | } 27 | --------------------------------------------------------------------------------