From c94243bd264f3e4203c2f88aa8be72cb5d570364 Mon Sep 17 00:00:00 2001 From: alangnt Date: Sat, 21 Mar 2026 18:55:54 +0100 Subject: [PATCH 1/3] chore: updated README with today's challenge link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f5dd0c2..c6df21f 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Feel free to explore, learn, and share your own approaches. - [ ] **3/18:** [Flight Vouchers](https://github.com/codedex-io/daily-challenges/tree/main/march-2026/3-18-flight-vouchers) 🏖️ - [ ] **3/19:** [March Madness](https://github.com/codedex-io/daily-challenges/tree/main/march-2026/3-19-march-madness) 🏀 - [ ] **3/20:** Cherry Blossoms 🌸 -- [ ] **3/21:** First Tweet 🐦 +- [x] **3/21:** [First Tweet](https://github.com/codedex-io/daily-challenges/tree/main/march-2026/3-21-first-tweet) 🐦 - [ ] **3/22:** ❓❓❓ - [ ] **3/23:** ❓❓❓ - [ ] **3/24:** ❓❓❓ From 359845687a4a0bd8a89dd44e469c63d7b243d162 Mon Sep 17 00:00:00 2001 From: alangnt Date: Sat, 21 Mar 2026 18:57:09 +0100 Subject: [PATCH 2/3] feat: first tweet python solution with explanations --- march-2026/3-20-first-tweet/first-tweet.py | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 march-2026/3-20-first-tweet/first-tweet.py diff --git a/march-2026/3-20-first-tweet/first-tweet.py b/march-2026/3-20-first-tweet/first-tweet.py new file mode 100644 index 0000000..3ac577c --- /dev/null +++ b/march-2026/3-20-first-tweet/first-tweet.py @@ -0,0 +1,29 @@ +def tweet_balance(tweet): + # first we split the tweet and initialize the char count + split_tweet = tweet.split(" ") + char_count = 0 + + # for each word in the split tweet + for word in split_tweet: + # if @ add 20 + if word.startswith("@"): + char_count += 20 + # if url add 23 + elif word.startswith("http://") or word.startswith("https://"): + char_count += 23 + else: + # for each character + for char in word: + # if ascii value more than 0x1F000 it means it's an emoji + if ord(char) > 0x1F000: + char_count += 2 + else: + char_count += 1 + + # space after each word + char_count += 1 + + # no trailing space after last word + char_count -= 1 + + return (140 - char_count) \ No newline at end of file From 19602f3f9911e9b76f7f403fc0770630bd663f52 Mon Sep 17 00:00:00 2001 From: alangnt Date: Sat, 21 Mar 2026 19:04:05 +0100 Subject: [PATCH 3/3] fix: checks if ascii is >= 0x1F000 --- march-2026/3-20-first-tweet/first-tweet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/march-2026/3-20-first-tweet/first-tweet.py b/march-2026/3-20-first-tweet/first-tweet.py index 3ac577c..b3d8416 100644 --- a/march-2026/3-20-first-tweet/first-tweet.py +++ b/march-2026/3-20-first-tweet/first-tweet.py @@ -14,8 +14,8 @@ def tweet_balance(tweet): else: # for each character for char in word: - # if ascii value more than 0x1F000 it means it's an emoji - if ord(char) > 0x1F000: + # if ascii value at least 0x1F000 it means it's an emoji + if ord(char) >= 0x1F000: char_count += 2 else: char_count += 1