# exercism **Repository Path**: zoomquiet/exercism ## Basic Information - **Project Name**: exercism - **Description**: play in exercism - **Primary Language**: Elixir - **License**: BSD-2-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-10-23 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # exercism https://exercism.io/ ## 介绍 play in exercism ## 安装 > follow doc. - [installation elixir](https://exercism.io/tracks/elixir/installation) - [Running the Tests](https://exercism.io/tracks/elixir/tests) - [Learning Elixir](https://exercism.io/tracks/elixir/learning) - [Useful Elixir Resources](https://exercism.io/tracks/elixir/resources) - [Remind me how to set up the CLI](https://exercism.io/cli-walkthrough) + 官方提供了专门的答案提交工具 + 反正最后在 Ubuntu 中完成部署, 用 VSCode 远程操作代码来进行... $ exercism -h A command-line interface for the v2 redesign of Exercism. Download exercises and submit your solutions. Usage: [command] Available Commands: configure Configure the command-line client. download Download an exercise. help Help about any command open Open an exercise on the website. prepare Prepare does setup for Exercism and its tracks. submit Submit your solution to an exercise. troubleshoot Troubleshoot does a diagnostic self-check. upgrade Upgrade to the latest version of the CLI. version Version outputs the version of CLI. workspace Print out the path to your Exercism workspace. Flags: -h, --help help for this command --timeout int override the default HTTP timeout (seconds) --unmask-token will unmask the API during a request/response dump -v, --verbose verbose output Use " [command] --help" for more information about a command. zoomq @ i3SPAM in ~/working $ exercism configure -w /home/zoomq/working/exercism You have configured the Exercism command-line client: Config dir: /home/zoomq/snap/exercism/5/.config/exercism Token: (-t, --token) ... Workspace: (-w, --workspace) /home/zoomq/working/exercism API Base URL: (-a, --api) https://api.exercism.io/v1 ------ - [exercism](#exercism) - [介绍](#介绍) - [安装](#安装) - [Exercism Elixir](#exercism-elixir) - ["Easy" difficulty exercises:](#easy-difficulty-exercises) - ["Medium" difficulty exercises:](#medium-difficulty-exercises) - ["Hard" difficulty exercises:](#hard-difficulty-exercises) - [refer.](#refer) - [logging](#logging) # Exercism Elixir Exercism 发布三种级别 Elixir 练习 3 levels of difficulty: 1. Easy - 58 Exercises 2. Medium - 32 Exercises 3. Hard - 4 Exercises ## "Easy" difficulty exercises: 1. Hello World - 嘦对应修改字串即可 2. RNA Transcription - 嘦知道如何遍历 char list 即可 3. Word Count - Creates a map showing the frequency of each word for a given string - Map.update + Enum.reduce 组合的威力... - 这是 Mentor 介入节点, 必须通过点评才能继续 4. Roman Numerals - Converts a positive INT up to 3999 into the right Roman numerals - 模拟人工书写数字过程... 5. Bob - Parses a given string and 'Bob' responds with 1 of 5 stings - cond 顺序很重要... - @eggman 很 mice 提醒俺没将所有 test case 打开, 其实一直仅仅测试了第一个 6. Beer Song - Gives either a single verse or range of lyrics printed out from "99 bottles of beer on the wall..." - Enum.map_join 或是其它现成就好 7. Nucleotide Count - Gives how many times a nucleotide appears in a charlist - 对 Map 的内置函式熟悉即可 - Map.update(c2map, h, 0, &(&1 + 1)) - 匿名函式的形式也得有信心 8. Secret Handshake - 必须猜到只处到32, 而且理解 &&& 计算结果的含义/窗口过滤 - 关键是声明式编程的气质... 9. Rotational Cipher - Apply a Caesar cipher to a given string - 旋转密匙, 最简洁实现形式 - ?A+rem(c - ?A + shift, 26) 就是对 26 求余 10. Strain - Filter results WITHOUT using Enum.filter or Enum.reject - Enum.filter 的人工实现姿势 - cond do 的合理场景 11. Protein Translation - Turn strings of RNA into the right proteins - 太鳮贼了...将复杂逻辑变成线性判定, 所以, 程序猿的思考比语言要重要的多 12. Pig Latin - Converts any string of words to pig latin - 对规则的理解占了 80% 工作量... - 感谢 IO.inspect 可以看到规则叠用过程... 13. Space Age - Calculate how old you are in years according to each planet's orbital cycle - 没什么好说的, 用模式匹配优雅又直观... 14. Twelve Days - Prints a verse or range of verses from the Christmas Carol "Twelve days of Christmas" - Enum 好东西, 不过硬抄词也没什么毛病... 15. Accumulate - Asks you to pretty much reimplement Enum.map - 徒手累积器, 没想到有这么鳮贼的形式... 16. Acronym - Convert a phrase to its acronym - 还是脚本顺序说明自然, 就是不够函式 17. Series - Given a string of digits, output all the contiguous substrings of length `n` in that string in the order that they appear - 如果处理目标序列困难, 那就生成单纯的数字序列, 然后用对应合理内置函式去提取 18. Raindrops - Convert a number to a string, the contents of which depend on the number's factors. - 质数分解是有次序的, 所以, 最终词组也是有顺序的, 那就可以进行直接构造了 19. Run Length Encoding - Generates a string where consecutive elements are represented as a data value and count. - RLE 压缩算法, 只有正则表达式最给力 20. Sublist - Returns whether the first list is a sublist or a superlist of the second list and if not whether it is equal or unequal to the second list. - 什么叫包含, 这是个逻辑问题, 逐一描述明确就好 21. Scrabble Score - Calculate the scrabble score for the word - Strings/binaries/char/list 要区分清楚, - 不然: `protocol Enumerable not implemented for "aeioulnrst" of type BitString. This protocol is implemented for the following type(s): GenEvent.Stream, Function, Map, File.Stream, Range, IO.Stream, MapSet, HashSet, List, Stream, Date.Range, HashDict` 这错误反复触发... - IEx.Info.info('k') 值得多使用... 22. Sum of Multiples - Adds up all numbers from 1 to a given end number that are multiples of the factors provided. - Enum 宝藏... 23. Pangram - Determines if a word or sentence is a pangram. - 本质上就是提纯后是否为 26 24. Simple Linked List - ... - ? 25. Anagram - Returns all candidates that are anagrams of, but not equal to, 'base'. - 同字母异序词 === diff list 为空 26. Matrix - ... - ? 27. Matching Brackets - Checks that all the brackets and braces in the string are matched correctly, and nested correctly - 太复杂, 只能靠谱正则表达式魔法了... 28. Phone Number - ... - ? 29. Nth Prime - ... - ? 30. All Your Base - ... - ? 31. Hamming - ... - ? 32. Triangle - Return the kind of triangle of a triangle with 'a', 'b' and 'c' as lengths. - 声明式, 声明清楚所有清楚就好 33. Isogram - Determines if a word or sentence is an isogram - 同`Pangram`, 嘦 uniq 没变化就对了 34. Grade School - Simulate students in a school - 论 map/dict 的数据库职能潜力... 35. Flatten Array - Accept a list and return the list flattened without nil values. - 内置函式值得使用 36. Leap - ... - ? 37. Kindergarten Garden - ... - ? 38. ETL - ... - ? 39. Grains - ... - ? 40. Change - ... - ? 41. Binary - ... - ? 42. Gigasecond - ... - ? 43. Pascal's Triangle - ... - ? 44. Hexadecimal - ... - ? 45. Binary Search - ... - ? 46. Binary Search Tree - ... - ? 47. Prime Factors - ... - ? 48. Perfect Numbers - ... - ? 49. Atbash Cipher - ... - ? 50. Simple Cipher - ... - ? 51. Grep - ... - ? 52. Say - ... - ? 53. Collatz Conjecture - Collatz 猜想 - 还是声明式, 将要求的计算给描述出来, 并用其它条件完成过滤就好 54. ISBN Verifier - ... - ? 55. Two Fer - Two-fer or 2-fer is short for two for one. One for you and one for me. - 丢出 raise 场景少见... 56. Armstrong Numbers - ... - ? 57. D&D Character - For a game of [Dungeons & Dragons][DND] - 文化差异,游戏数值核算很无感, 合理使用 erlng 内部库是要点 58. Resistor Color - Resistors have color coded bands, where each color maps to a number. - 无脑完成最简易的数据结构就好 --- ## "Medium" difficulty exercises: 1. Robot Simulator 2. List Ops 3. Markdown **IN PROGRESS** - Refactoring exercise from hell (Nested functions, single letter variables) 4. Bank Account 5. Tournament 6. Meetup 7. Parallel Letter Frequency 8. Scale Generator 9. Luhn 10. Queen Attack 11. Saddle Points 12. Diamond 13. Diffie Hellman 14. Sieve 15. Wordy 16. Largest Series Product 17. Crypto Square 18. Pythagorean Triplet 19. Allergies 20. Palindrome Products 21. Rail Fence Cipher 22. Minesweeper 23. Connect 24. Difference Of Squares 25. Poker 26. Custom Set 27. Clock 28. OCR Numbers 29. Dominoes 30. Transpose 31. Spiral Matrix 32. Alphametics --- ## "Hard" difficulty exercises: 1. Zipper 2. Bowling 3. Forth 4. DOT DSL ## refer. Elixir Examples https://elixir-examples.github.io/ Elixir: Binary to Decimal - DEV https://dev.to/adnanbabakan/elixir-binary-to-decimal-2l84 Cannot pipe [1, 2, 3] into &(IO.inspect(&1)) - Questions / Help - Elixir Programming Language Forum https://elixirforum.com/t/cannot-pipe-1-2-3-into-io-inspect-1/15822/2 Well, you can in fact use anonymous functions with pipes, but like this: > [1, 2, 3] |> (&(IO.inspect &1)).() …or: > [1, 2, 3] |> (fn x -> IO.inspect x end).() It’s a little more obvious to see what was wrong with your initial syntax if you include the parentheses: [1, 2, 3] |> &IO.inspect/2 # wrong [1, 2, 3] |> IO.inspect() # correct Piping requires function calls, but in the first case you were trying to send the data to a function reference/definition. That’s why the following works as @jwarlander said (because they’re calls to anonymous functions as you’ll notice with the .()): [1, 2, 3] |> (&(IO.inspect &1)).() [1, 2, 3] |> (fn x -> IO.inspect x end).() So Many Ways to Update a Map with Elixir! - DEV https://dev.to/noelworden/so-many-ways-to-update-a-map-with-elixir-1aie ## logging - 201013 zoomquiet init.