Skip to content · ⁨الانتقال إلى المحتوى⁩

Run-length encoding · ⁨ترميز المسارات⁩

English

Run-length encoding

Compress a string by replacing each run of the same character with that character followed by how many times it repeats: aaabbc → a3b2c1. Always write the count, even when it is 1.

Walk the string tracking the current character and how long its run is. When the next character differs, write out the run (character + count) and start a fresh run. Don't forget to write the last run after the loop ends.

العربية

ترميز طول التسلسل

ضغط سلسلة عن طريق استبدال كل تتابع من نفس الحرف بالحرف يليه كم مرة يتكرر: aaabbc → a3b2c1. اكتب دائماً العدد، حتى عندما يكون 1.

تجول في السلسلة متتبعاً الحرف الحالي ومدى تطاول تتابعه. عندما يختلف الحرف التالي، اكتب التتابع (الحرف + العدد) وابدأ تتابعاً جديداً. لا تنسَ كتابة التتابع الأخير بعد انتهاء الحلقة.

Log in or create account · ⁨تسجيل الدخول أو إنشاء حساب⁩

IGCSE, A-Level & AP