![Exercism](/img/default-banner.jpg)
- 91
- 281 059
Exercism
United Kingdom
Приєднався 17 сер 2018
The official channel of Exercism. Visit us at exercism.org
Using Pattern Matching & Regular Expressions to solve Pig Latin on Exercism
We look at 8 different solutions to Exercism's Pig Latin exercise - exploring solutions using different approaches to pattern matching and regular expressions in Go, Kotlin, Scala, Prolog, AWK, JavaScript, C#. and Python
Kick back and enjoy 30mins of learning with Jeremy and Erik, then go solve the exercise in your favourite way on Exercism.
Solve the exercise at: exercism.org/exercises/pig-latin
Join #48in24 at: exercism.org/challenges/48in24
Featured solutions:
- exercism.org/tracks/go/exercises/pig-latin/solutions/bobahop
- exercism.org/tracks/kotlin/exercises/pig-latin/solutions/dsdebastiani
- exercism.org/tracks/scala/exercises/pig-latin/solutions/jaratma
- exercism.org/tracks/prolog/exercises/pig-latin/solutions/jinwoo
- exercism.org/tracks/awk/exercises/pig-latin/solutions/glennj
- exercism.org/tracks/awk/exercises/pig-latin/solutions/glennj
- exercism.org/tracks/javascript/exercises/pig-latin/solutions/glennj
- exercism.org/tracks/python/exercises/pig-latin/solutions/dfhwze
Timestamps:
00:00:00 Introduction
00:01:13 Go: for loops and maps
00:09:43 Kotlin: rotate using special cases
00:18:57 Scala: rotate using pattern matching
00:23:30 Prolog: define relations and use unification
00:33:22 AWK: regex matches
00:37:27 JS: regex matches using pig latinified functions
00:40:43 C#: conditional regex replace
00:47:31 Python: single regex replace
00:44:37 Conclusion
Kick back and enjoy 30mins of learning with Jeremy and Erik, then go solve the exercise in your favourite way on Exercism.
Solve the exercise at: exercism.org/exercises/pig-latin
Join #48in24 at: exercism.org/challenges/48in24
Featured solutions:
- exercism.org/tracks/go/exercises/pig-latin/solutions/bobahop
- exercism.org/tracks/kotlin/exercises/pig-latin/solutions/dsdebastiani
- exercism.org/tracks/scala/exercises/pig-latin/solutions/jaratma
- exercism.org/tracks/prolog/exercises/pig-latin/solutions/jinwoo
- exercism.org/tracks/awk/exercises/pig-latin/solutions/glennj
- exercism.org/tracks/awk/exercises/pig-latin/solutions/glennj
- exercism.org/tracks/javascript/exercises/pig-latin/solutions/glennj
- exercism.org/tracks/python/exercises/pig-latin/solutions/dfhwze
Timestamps:
00:00:00 Introduction
00:01:13 Go: for loops and maps
00:09:43 Kotlin: rotate using special cases
00:18:57 Scala: rotate using pattern matching
00:23:30 Prolog: define relations and use unification
00:33:22 AWK: regex matches
00:37:27 JS: regex matches using pig latinified functions
00:40:43 C#: conditional regex replace
00:47:31 Python: single regex replace
00:44:37 Conclusion
Переглядів: 961
Відео
Understanding Randomness: 7 Ways to Solve D&D Character
Переглядів 1,2 тис.Місяць тому
We look at 7 different solutions to Exercism's D&D Character exercise - exploring solutions using different approaches to randomness and metaprogramming in Kotlin, Nim, Racket, Tcl, Python, C and Haskell. Kick back and enjoy 30mins of learning with Jeremy and Erik, then go solve the exercise in your favourite way on Exercism. Solve the exercise at: exercism.org/exercises/dnd-character Join #48i...
7 Ways to Solve Minesweeper
Переглядів 1,6 тис.Місяць тому
We look at 7 different solutions to Exercism's Minesweeper exercise - exploring solutions using nested loops, clever use of min/max to simplify bounds checking, functional pipelines and using two-dimensional matrices in Julia, C , F#, Rust, Ruby, Crystal, and Java. Kick back and enjoy 30mins of learning with Jeremy and Erik, then go solve the exercise in your favourite way on Exercism. Solve th...
10 ways to check if a word is a Pangram
Переглядів 1,6 тис.2 місяці тому
We look at 10 different solutions to Exercism's Pangram exercise - exploring approaches including string manipulation, sets and bitshifting! This is a really interesting exercise for finding the right balance between CPU usage, memory allocation, and readability! Kick back and enjoy 30mins of learning with Jeremy and Erik, then go solve the exercise in your favourite way on Exercism. Solve the ...
10 ways to solve Scrabble Score on Exercism
Переглядів 9302 місяці тому
In this video, we explore 10 different approaches to solve the Scrabble Score exercise on Exercism. We explore pattern matching, higher order functions, generator expressions, helper classes and more! We look at a variety of different languages including Go, F#, Python, Groovy, Ruby, Raku, Rust, AWK, JavaScript, and MIPS Assembly Kick back and enjoy half an hour of learning with Jeremy and Erik...
How to validate credit card numbers (Solving Luhn on Exercism)
Переглядів 1,5 тис.2 місяці тому
In this video, we explore 9 different ways to solve the Lunn exercise on Exercism. We explore guards, method chains, vectorised operations, and a fun SQLite solution! We look at a variety of different languages including Swift, C , Ruby, Gleam, R, Pharo, Tcl, Raku and SQLite. Kick back and enjoy an hour of learning with Jeremy and Erik, then go solve the exercise in your favourite way on Exerci...
Coding "The Sieve of Eratosthenes": An ancient algorithm for calculating prime numbers.
Переглядів 1,8 тис.2 місяці тому
In this video, we explore 7 different approaches to coding The Sieve of Eratosthenes. We look at solutions in C , C#, Python, Raku, Julia, R and F#, looking at nested loops, lazy evaluation, and recursion. Kick back and enjoy 30mins of learning with Jeremy and Erik, then go solve the exercise in your favourite way on Exercism. Solve the exercise at: exercism.org/exercises/sieve Join #48in24 at:...
Bit Shifting, Bitwise Comparisons and other Binary Number Magic (Solving Allergies on Exercism)
Переглядів 1,6 тис.3 місяці тому
In this video, we explore 8 different approaches to solving Allergies, focussing on Binary numbers and techniques like bitshifting and bitwise comparison. We look at solutions from Clojure, Ruby, JavaScript, C#, Nim, Python, Gleam and Erlang! Kick back and enjoy 30mins of learning with Jeremy and Erik, then go solve the exercise in your favourite way on Exercism. Solve the exercise at: exercism...
Parallelism vs Concurrency (Solving Parallel Letter Frequency on Exercism)
Переглядів 1 тис.3 місяці тому
In this video, we explore the differences between Parallelism and Concurrency and look at 8 examples in solving Parallel Letter Frequency in JavaScript, Go, Delphi, Java, C#, Elixir and Rust. Kick back and enjoy 50mins of learning with Jeremy and Erik, then go solve the exercise in your favourite way on Exercism. Solve the exercise at: exercism.org/exercises/parallel-letter-frequency Join #48in...
6 Ways to Code Circular Buffers
Переглядів 2,4 тис.3 місяці тому
In this video, we explore 6 different approaches to creating Circular Buffers, exploring solutions in C#, Python, Crystal, C , Elm and Erlang. We explore queues, static and dynamic arrays, immutable data structures and a fun agent based implementation. Circular Buffers are First In, First Out (FIFO) queues that are a fixed size. They're usually backed by an array, which gives it great spatial/d...
Regular Expressions: A hands on introduction (Solving Acronym on Exercism)
Переглядів 2 тис.3 місяці тому
In this video we take a gentle dive into regular expressions as we solve the Acronym exercise. We look at the most basic solutions (such splitting on whitespace) and end up with unicode and negative lookbehinds. We finish off by looking at some other approaches to Acronym including state machines! Sit back and enjoy 45mins of learning with Jeremy and Erik, then go solve the exercise in your fav...
Recursion: A Practical Introduction (via a deep dive into List Ops!)
Переглядів 3,1 тис.4 місяці тому
In this video, Jeremy introduces us to recursion and Erik explains tail-call recursion and accumulator functions. It's a live coding, practical video that's perfect for people new to functional programming, but also has some deeper topics for those more experienced! Enjoy an hour of learning with Jeremy and Erik, then go solve the List Ops exercise yourself in your favourite language on Exercis...
11 Ways to Solve Protein Translation on Exercism
Переглядів 1,7 тис.4 місяці тому
11 Ways to Solve Protein Translation on Exercism
12 ways to Convert Arabic Numbers to Roman Numerals
Переглядів 2,8 тис.4 місяці тому
12 ways to Convert Arabic Numbers to Roman Numerals
14 Ways to Solve Raindrops (FizzBuzz, but harder!)
Переглядів 4,4 тис.4 місяці тому
14 Ways to Solve Raindrops (FizzBuzz, but harder!)
14 Ways to Reverse a String! (And solve the exercise on Exercism)
Переглядів 7 тис.5 місяців тому
14 Ways to Reverse a String! (And solve the exercise on Exercism)
Introducing #48in24 - Exercism's new programming challenge for 2024!
Переглядів 6 тис.5 місяців тому
Introducing #48in24 - Exercism's new programming challenge for 2024!
December Diversions: ColdFusion, Groovy, Lua, Vimscript & Wren
Переглядів 8176 місяців тому
December Diversions: ColdFusion, Groovy, Lua, Vimscript & Wren
A Brief Introduction to WebAssembly
Переглядів 1,7 тис.7 місяців тому
A Brief Introduction to WebAssembly
Nibbly November: An intro to Assembly (x86-64, MIPS, and WASM)
Переглядів 1,7 тис.7 місяців тому
Nibbly November: An intro to Assembly (x86-64, MIPS, and WASM)
Object Oriented October: An intro to C#, Ruby, Powershell and Crystal!
Переглядів 1 тис.8 місяців тому
Object Oriented October: An intro to C#, Ruby, Powershell and Crystal!
Slimline September: An intro to 8th, AWK, Bash, JQ, Perl and Raku!
Переглядів 1,5 тис.9 місяців тому
Slimline September: An intro to 8th, AWK, Bash, JQ, Perl and Raku!
New features: Feedback in the editor, track trophies, grouped community solutions, and more!
Переглядів 25610 місяців тому
New features: Feedback in the editor, track trophies, grouped community solutions, and more!
Adding Concept Detectors to Exercism [Insiders Preview]
Переглядів 22310 місяців тому
Adding Concept Detectors to Exercism [Insiders Preview]
It's Appy August: Introductions to 14 different languages (see the thumbnail!)
Переглядів 2 тис.10 місяців тому
It's Appy August: Introductions to 14 different languages (see the thumbnail!)
An intro to Cobol, Fortran, and Visual Basic for Jurassic July!
Переглядів 1 тис.11 місяців тому
An intro to Cobol, Fortran, and Visual Basic for Jurassic July!
Nim: import os,strutils echo if( let year = parseInt paramStr 1; year mod 400 == 0 or year mod 100 == 0 or year mod 4 == 0 ):true else:false
Why does the philosophy of this language seem to be that everyone has 3 hours to wade through cruft to learn how to just get some code running?
For the Python solution (@ 5:50 ) would it be quicker to convert the string/sentence to lowercase once before running the comparison? ( s = s.lower() ) and then run all(c in s for c in ascii_lowercase)
Great video, as always.
for Rust: pub fn reverse(input: &str) -> String { let mut reverse_str = String::new(); for c in input.chars().rev() { reverse_str.push(c); } reverse_str }
4:09 I'm always a bit envious of those that can read the instructions of an exercise that says "Solve without using X" and think to themselves: "Ok, but what's the next best way that I can cheat?" Why don't I think like that?
I did it in Elixir: No regex, but efficient tail call-recursion with multiple clauses and pattern matching, which declares the domain rules quite nicely IMO. Btw: The function `split_swappable/2` is a simple example, how one can implement a state machine (what every parser essentially is) with recursion in a functional language. ```elixir defmodule PigLatin do @vowels [?a, ?e, ?i, ?o, ?u] @consonants Enum.to_list(?a..?z) -- @vowels @spec translate(phrase :: String.t()) :: String.t() def translate(phrase), do: with( words <- String.split(phrase), do: Enum.map_join(words, " ", &to_pig_latin/1)) defp to_pig_latin(word), do: with( {swappable, rest} <- split_swappable(word), do: rest <> swappable <> "ay") # splits word into the swappable prefix and the rest by the following rules: defp split_swappable(word, swappable \\ <<>>) # word starts with x or y followed by consonant -> no swap at all defp split_swappable(word = <<?x, c, _ :: binary>>, <<>>) when c in @consonants, do: {<<>>, word} defp split_swappable(word = <<?y, c, _ :: binary>>, <<>>) when c in @consonants, do: {<<>>, word} # y or a vowel terminate the swappable part defp split_swappable(rest = <<?y, _::binary>>, swappable=<<_, _::binary>>), do: {swappable, rest} defp split_swappable(rest = <<v, _::binary>>, swappable) when v in @vowels, do: {swappable, rest} # a consonant grows the swappable part, # "qu" are treated as consonant, not as consonant/vowel pair defp split_swappable("qu" <> rest, swappable), do: split_swappable(rest, swappable <> "qu") defp split_swappable(<<c, rest::binary>>, swappable) when c in @consonants, do: split_swappable(rest, swappable <> <<c>>) end ```
starting here good luck to me, and thanks for your work
Thanks! Good luck!
great video, thanks!
thank you pewdiepie
Regular expressions just keep coming up. Maybe it's finally time to finally sit down and learn them 😅 Also, loved the pigified source code in JS was so fun!
Ha! Yeah, that was a great effort by Glenn! Thanks for the encouragement - glad you're enjoying the videos!
Our acronym video (ua-cam.com/video/ofzqp4MFHvM/v-deo.htmlsi=s4cgoyjClPAVkgVL) goes into a lot more detail on regular expressions. That might be useful.
I am rather opiniated on regular expressions: They are mighty, but basically a further and for some quite scary language. Introducing them to code just like that, can decay readability and maintainability. Therefore they should never be introduced without consideration. I suggest to always check: - Can I do that without regex with means of my main language. If you have an expressive declarative language, you should prefer staying in it (my solution in Elixir shows, that it is possible, more efficient and IMHO more readable) - Are RegEx accepted in my project? (since every new technology introduced comes with risks)
Thanks for another great video! Enjoyed and learned something new. Keep it up! 👊
Thanks so much for the support!
39:35, Jeremy, sooo sorry for not inventing a new avajayiptscray language. I’ll get right on that. Easily do-able in Tcl though ...
Thank you! I hope my deep sense of disappointment showed! 😁
Thanks Erik Sage of Programming ! ;)
So.... Did you solve the exercise or the just get the tests to pass? 😈
Honestly, this should have conveyed more real life benefits of FP, such as Data Modeling with ADTs - "WHY is this better than looping and creating OOP classes" - why folds perfectly abstract away the need to write explicit recursion every time - the elegance of function composition - Monadic laws that guarantee that data types are safe and sound (without mentioning Monads obv). Tutorials like this are why FP is seen as a niche when a JS, Python, C++, Go or whatever dev comes to see this. No one is going to see an adder function or a pattern match on a list of numbers and think: WOW, this is much better than my language of choice which... oh wait, is already on the way to adopting pattern matching (like most modern imperative languages already did or are doing). As much as I love to see people passionate about FP, such videos need to be more comprehensive and practical in demonstrating the real-world advantages of functional programming. They need to highlight how FP can simplify complex tasks, enhance code maintainability, and improve reliability through concepts that go beyond basic examples. EVEN FOR A BEGINNER, because we're assuming coders are dumb otherwise.
This video is intended more as an introduction to the programming languages rather than functional programming itself. We put out a video every week that shows up different paradigms and approaches and we nearly always show things like pattern matching and recursion as elegant solutions to problems, so those might be more to your taste. Thanks for the feedback 🙂
Another useless programming language.
What programming languages do you find useful? What did you hope Gleam would do that others don't?
Thank you for sharing this video! I love exercism! Have a nice week!
Thanks so much! Really appreciate the comment! 😊
That is a great introduction to the language, thank you! :)
Great that it was useful! Thanks for commenting :)
I was planning to solve this exercise before the video came up using Elm, which I started my journey on exercism this year primarily with it, (plus some Go & Python "haven't solved it in either of them yet") and I refrained from watching the video until I solve it. I found that when I try to solve an exercise, I over complicate the problem if there is no obvious guidelines to solve it. Should I go for the mines '*' or clear '.'? Should I find the number of mines and then turn it to character 'n' in place for each character at a time, or should I go and scan for mines and then start counting?! Can my solution be generalized?? And different languages has different "flavours" of programming. For example Elm and Go are both simple and minimalistic languages, but the way I would solve it in Go would be dramatically different from the way I solved it in Elm. (And I got 250-ish lines to solve it, while the rest of the community is under 150) and this makes me go backwards and look for ways to optimise my solution which is more intuitive for me. (I'm not an optimization-first guy) Watching these videos is quite helpful, because unlike scrolling through communities' solutions, each exercise is getting a deep explanation and understanding for its different ways of solving it and optimise it. For example, I would never tried any bitwise solutions from the first try. Great work have been put into these videos, website, exercises, and communities. Thanks a lot for your and everyone's efforts. Maybe at the end of this year's challenge you can make a bounce video about how to tackle a problem and different optimisation technics. And next year the challenge could be 3-level project for each month similar to last year's theme "appy, analytic, system, ..."
Thanks for the nice comment!
Kotlin has floorDiv too!
Good to know. Thanks!
Thank you for the video, it was interesting, as always. Seeing it, I got some ideeas on how I could improve my solution also and hopefully I did :). I liked the way Erik explained the issue with the pseudo-random number ganarators during the C++ solution presentation. I also found the Kotlin and Python solutions very nice. They are readable and concise.
Thanks for the comment! Yeah - generating ideas of how to improve my solutions as we record these videos is definitely one of the joys of them - I'm glad that translates to watching them too! :)
Hi, thanks for the video! But IMHO the Erlang solution is ridiculously repetitive and frankly bad and error-prone code. What if there were far more allergies? This is particularly sad here, since Erlang has fantastic bitstring pattern matching, which is highly optimized (stemming from its history in telecom signal processing). So you would probably never implement it like that in an Erlang production system. People get a totally wrong impression of a language, when such code is showcased in your videos. Here is a clause from iteration 2 of my Elixir solution to illustrate, how one would rather code that (as you might know Elixir is pretty close to Erlang with a more modern syntax). This tail-call-recursive function consumes all known allergies together with the bits of the flags, which are shifted to the right in each recursion. Here is the clause, that adds the allergy, if the current LSB is set (the 1::1 in the pattern is the bit in question). The advantage of this solution is, that it has no repetition and would work efficiently with thousands of allergies (by a simple change of one module attribute holding their symbols), since we are using bitstrings and not limited integers: ```elixir defp decode_allergies( [allergy_marked_by_lsb | allergies], <<flags::@trailing_bits_before_lsb, 1::1>>, decoded_allergies ), do: decode_allergies(allergies, <<flags::@significant_bits>>, [ allergy_marked_by_lsb | decoded_allergies ]) ``` But in Elixir, there is an even more elegant way to implement this efficiently and maintainably: With the fantastic meta-programming. Interested? Checkout my solution and the comments below it. exercism.org/tracks/elixir/exercises/allergies/solutions/Pul
We don't always mention it, but the idea isn't to show the idiomatic solution in a language, but to show an approach in any language. That means that we regularly feature solutions that are not optimal for a language, just to showcase the approach. We've also featured some really nice Erlang solutions in other videos, but this one is indeed very verbose, but still illustrative of the approach.
We put out posts on the forum a week or two before recording, where people share their solutions for us to feature. If you've got good Erlang versions we can showcase, please do add them there in advance! :) Also - love the comments on your solutions - always great to understand the motivations and learnings from the different iterations :)
@@ErikSchierboom Thanks for your answer, even if I don't necessarily agree with that policy. If I were to get in first contact with a language via such a video, I would like to get a realistic impression, how the language really feels and if it might be interesting for me. And that is unfortunately not the case here: Anybody who doesn't know Erlang could turn away from this mess (which is really diametral to how one would actually implement it) and say "This Erlang crap doesn't look interesting" as if they just had seen some convoluted imperative language. I mean not to criticize you, just to give smoe feedback. In general, you guys are doing an amazing job. Thank you for bringing a glimpse of diversity into the far too mainstreamed world of software, which is in urgent need of new horizons!
@@exercism_org > Also - love the comments on your solutions - always great to understand the motivations and learnings from the different iterations :) Thanks! I do that on full purpose, since I think, that it is a great opportunity to share insights additionally to the one-on-one mentoring. I wished, the comment section wasn't so orphaned and would be more used for discussions on solution approaches. And since I am wishing anyway: It would be great to have some benchmarking in the solution overview as well. From many mentoring sessions I know, that people often have no clue about the runtime complexity of their solutions, but most are open to it. And many are shocked, when they are shown, that their solution performs 100+x worse than it could. Having some indicator about the relative performance of ones solution would probably help more than the "slow tests" in some exercises, who are IMO swiftly ignored by most people (particularly if they don't work locally).
@exercism_org I meant to link my Elixir solution (tracks/elixir/exercises/minesweeper/solutions/Pul) here, which has a quite unusual approach I explained in its comment section. But once again, my comment vanished twice without any transparency about the cause or reason (I did the link right this time). It's not fun contributing under these circumstances...
Thanks! Yeah - UA-cam sometimes deletes comments randomly without us knowing. Also, certain comments only appear when "Sort By" is set to "Newest", not "Top comments" - again I have no idea why. Maybe to do with whether you have a profile picture or not - that's the only consistency I can see. Anyway, thank you for posting and we'll take a look at your solution!
It's funny that I wanted to take a look at this for this week's 48in24 puzzle :). I stopped it, solved it, and now will continue. I saw some very nice comunity solution, including your's (Erik's), and one that is using reflection to initialize the fields of the object. Thank you, for the intro, and to all the contributors for the excelent content on the site.
Thanks!
I like these grid navigation style exercises and I love that Crystal implementation! But it does sound a bit weird when someone talks about a Crystal method... which I just checked is what they are referred to officially. Maybe they want to change that to function. I half expected a more pure OOP version with a Point class that has its own Neighbours array. I used a Span<char> in C# (which is sort of like a slice in Rust, I think) that I pre-allocate with the size of the first string and then, since there is an action on each character, you can keep using the same span in every row loop, and create a string in the result array based on the span at the end of the loop.
I learn so much from these conversations meets tech-talks. Also love the chemistry too, just two dudes hanging out and talking about something they care about, nothing beats that sincerity. I would love to see more developer talk plainly about how/why they do X or Y. Really glad y'all are doing what you do!
Thanks so much! What a lovely comment
Love to read. Thanks for all your comments and support - really always appreciate them! :)
thank you!
Hi. I liked Jeremy's solution most, along with the next one - probably because I went for the same strategy. I also liked the Julia and F# solutions. I have tried to put a comment with a link to my solution, but I guess it is not allowed :), so I'll try something else: /tracks/cpp/exercises/minesweeper/solutions/ionutsimion. I had several iterations, but the algorithm is the same.
First time someone's liked my solution the most - whoop! :D Thanks for sharing your solutions - we'll take a look!
At 34:56 Erik's comment that "the author had to use mutable" in F# made me intrigued! So much so that I went to install dotnet and run the F# interactive shell. After reading the docs and a few attempts, @Exercism turns out there is a short and readable way to sum items in a 2D array: > let a = array2D [[' '; '*'; ' ']; [' '; ' '; '*']; ['*'; '*'; '*']];; val a: char[,] = [[' '; '*'; ' '] [' '; ' '; '*'] ['*'; '*'; '*']] > a.[0..2, 0..2] |> Seq.cast<char> |> Seq.map (fun x -> if x = '*' then 1 else 0) |> Seq.sum;; val it: int = 5 > a.[0..2, 0..2] |> Seq.cast<char> |> Seq.filter ((=) '*') |> Seq.length;;
Oh, and the whole "board" can be removed too. Indexing out of bounds is apparently ok, so not need to do explicit bounds check either :)
That's really cool. What I meant to say was that the author tried to use Array2D functions primarily, and that they don't lend themselves well to the summing
@@ErikSchierboom Yeah, I love your commentary and how you and Jeremy interact. You're always very insightful! When I saw "mutable" on the screen I almost immediately paused the video and went "there must be a better way to do it", only later did I listen to the rest and realized the nuance you added to it. Spot on!
This is what it looks like in Phix (no such track yet, but soon) global function annotate(sequence board) integer h = length(board) sequence res = repeat(0,h) if h then integer w = length(board[1]) for y,line in board do string outline = "" for x,ch in line do if ch!='*' then integer m = 0 for i=y-(y>1) to y+(y<h) do for j=x-(x>1) to x+(x<w) do m += board[i][j]=='*' end for end for if m then ch = '0'+m end if end if outline &= ch end for res[y] = outline end for end if return res end function
Nice! Phix is similar to our Euphoria, I think? Have you played with the OpenEuphoria track yet? exercism.org/tracks/openeuphoria
@@exercism_org yes, and yes!
Great video, thank guys. "Minesweeper" should be re-classified to "medium". It's above the level of other "easy" exercises on exercism.
Thanks! Exercises are rated differently per track as they can vary wildly in difficulty. If there's a specific track that you found it misclassified in, please do open an issue in the forum (forum.exercism.org) and the maintainers of that track can take a look! :)
ua-cam.com/video/0IkSLj-oCZ8/v-deo.html my take on prolog and ai
Great stuff. I would have also liked to hear drawbacks of Lisp and its dialects. I mean, there must be reasons why the languages are not widely used in the enterprise world, for example.
Lisps are pretty widely used, but definitely nowhere as near as common as other languages. A lot of it comes down to where there's been investment and/or huge players, which subsequently means investment in performance, ecosystem tooling etc. Java makes a lot of money for Oracle for example, and there is a huge industry around something like Java (think editors, training, etc). Often languages that have been around for a long time and very niche become more mainstream over time - Haskell is a good example, and maybe the resurgence of BEAM (Erlang stack too). Thanks for the comment! :)
I like your enthusiasm.
Thanks!
what app are you using to code in?
That's Visual Studio Code: code.visualstudio.com/
Can't read the terminal part, covered by UA-cam UI Overlay (Title + Tags)
Yeah - it's annoying how mobile covers 1/3 of the video with its UI!
@@exercism_org 100% agree
Lovely walkthrough each step, thanks for your effort guys, I really appreciate it.
You're very welcome! Thanks for commenting :)
Nim could also write the same solution as julia using the <= operator on sets while still being as efficient as the bitset-based solutions as Nim's set type is actually a bitset for ordinals. proc isPangram*(s: string): bool = {'a'..'z'} <= s.toLower.toSet
That's lovely!
Hi, can anyone let me know why 'score & 1 << allergen' gives the answer to ''is_allergic_to' function? I know how & and << operators work but how do you know that you should perform & ? What is reason / logic behind performing & here?
It's (ab)using the fact that 0 is falsy and not zero is truthy. If the (1 << allergen) bit was not set in score, the returned value will be zero (false). Consequently, if the bit was set in both numbers, it will return a non-zero number (true).
What a contrast between the vibe of Golang development and management vs Luis and Gleam. Great work, Jeremy.
Thanks! And yeah, I can imagine different people/mindsets really gravitating to the alternate approaches.
This is very informative. Thank you for making this
Awesome. Glad you enjoyed it!
Correction to the description: Lua starts at 10:36 at 11:07, Lua patterns use `%a` for "letters" (a for alphabetic, I assume), and `%l` is lowercase letters.
Fixed. Thank you!
Awesome video, many thanks Erik!
Thanks for the video! I liked particularly the elegance of Julia and the bitmap idea (in Rust, which can also be done in FP with recursion as I show below in Elixir). I added the bitmap approach to my existing Elixir solutions and have now 4 iterations/versions: 1. Creating and counting a unique downcase set (must be size of alphabet) 2. Subtracting the downcase charlist from the alphabet (must be empty) 3. Recursion over the sentence filling a bitmap (just an integer) until all chars are set or no characters left 4. like 3 but with clauses generated with metaprogramming Iteration 3 is the fastest, if we have long strings, in which a complete pangram can early be detected, since it terminates early, while 1 and 2 always process the whole input. Iteration 2 has the best tradeoff between performance and readability. Checkit out here: exercism.org/tracks/elixir/exercises/pangram/solutions/Pul
Awesome. Really cool to see those different approaches. Thanks for commenting and sharing!
Minor correction: there of course _is_ a character class for lowercase letters, namely [[:lower:]]
That's not necessarily only ASCII lowercase (probably depends on the regex flavour)
watching this I just realized how unoptimized my python code looks lol, nice video though 😃
Ha. Yes. We here this a lot! (And find it ourselves when making them :D)
Another great video! I really like what ya'll are doing. I really hope more folks (students and job-seekers especially) find Exercism. I think Exercism does a great service of being a learning tool first and foremost. Keep it up :-)
Thanks so much!
The best video on recursion 👏👏
Awesome! Thanks :)
About the ASCII code difference between lower case and upper case, it was actually very good design. There are exactly 2^5 characters between corresponding letters ('a' and 'A' etc.), which means that it's enough to use bitwise OR to transform from upper-case to lower-case: c | 0b100000 or c | 0x20. Also, it's not very difficult to transform for lower-case to upper-case.
Yeah - we go on to discover that in the next solution we show! :)
I guess you can do xor to get to uppercase, in Python this yields "Z": chr(ord('z') ^ 0x20)
@@nitkonigde1381 I think it's NAND - AND with the bitwise complement of 0x20. XOR toggles between lower case and upper case.
@@iosimion Thanks!