Raised Fist0

Conditional Code

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong

Introduction

Conditional Code கேள்விகளில் letters, digits, words ஆகியவை ஒரு condition அடிப்படையில் encode செய்யப்படுகின்றன - உதாரணம்: vowels vs consonants, odd vs even digits, prime index, word length போன்றவை.

reasoning tests-ல் இத்தகைய conditional rules difficulty-ஐ அதிகப்படுத்த பயன்படுத்தப்படுகின்றன: முதலில் input-ஐ வகைப்படுத்த வேண்டும், பின்னர் அந்த வகைக்கு ஏற்ப rule-ஐ பயன்படுத்த வேண்டும்.

Pattern: Conditional Code

Pattern: Conditional Code

முக்கிய கருத்து: encoding condition-ஐ சார்ந்தது - ஒரு குழுவிற்கு ஒரு rule, மற்ற குழுவிற்கு மற்றொரு rule பயன்படுத்தப்படும் (உதாரணம்: vowels → next letter, consonants → previous letter; even digits → +2, odd digits → -1).

ஒவ்வொரு முறையும் கவனிக்க வேண்டியவை:

  • Condition-ஐ கண்டறிதல்: split property என்ன? (vowel/consonant, odd/even, prime index, length ≤3 போன்றவை)
  • Branch mapping: ஒவ்வொரு குழுவிற்கும் விதி என்ன என்பதை தெளிவாக எழுதவும்.
  • Edge cases: alphabet இலுள்ள boundaries (A/Z), digits (0/9), repeated characters, capitalisation ஆகியவற்றைப் பார்க்கவும்.
  • Order independence: ஒவ்வொரு character-க்கும் தனியாக rule பயன்படுத்தப்படுகிறதா அல்லது முழு word/number-ஐ classify செய்த பின்னரா rule வருகிறது என்பதைச் சரிபார்க்கவும்.
  • Inverse check: முடிந்தால் reverse rule பயன்படுத்தி original input கிடைக்கிறதா என்பதைச் சரிபார்க்கவும்.

Step-by-Step Example

Question

ஒரு code-ல் vowels → next letter (A→B, E→F, I→J, O→P, U→V) மற்றும் consonants → previous letter (B→A, C→B, D→C, ...) எனில் NAME என்னாக எழுதப்படும்?

Solution

  1. Step 1: ஒவ்வொரு letter-ன் வகையை கண்டறியுங்கள்

    N = consonant, A = vowel, M = consonant, E = vowel.
  2. Step 2: Conditional rules பயன்படுத்தவும்

    • N (consonant) → previous letter = M
    • A (vowel) → next letter = B
    • M (consonant) → previous letter = L
    • E (vowel) → next letter = F
  3. Step 3: மாற்றப்பட்ட letters-ஐ சேர்க்கவும்

    Result = MBLF.
  4. Final Answer:

    MBLF
  5. Quick Check:

    Reverse rules பயன்படுத்தினால்: M→N, B→A, L→M, F→E → NAME கிடைக்கிறது. ✅

Quick Variations

1. Vowel/consonant split உடன் வேறு shifts (vowels +2, consonants -2).

2. Digit rule: odd digits -1, even digits +2 (0/9 boundaries கவனிக்கவும்).

3. Position-based: odd positions rule A, even positions rule B.

4. Word-length condition: short words reverse, long words letters shift.

5. Mixed rules: prime positions-ல் உள்ள vowels → +1, இல்லையெனில் -1.

Trick to Always Use

  • Step 1: Tokens-ஐ உடனடியாக classify செய்யவும் (vowel/consonant, odd/even).
  • Step 2: ஒவ்வொரு குழுவிற்கும் ஒரு example letter-க்கு rule-ஐ எழுதிக் காட்டி logic சரியாக உள்ளதா பார்க்கவும்.
  • Step 3: மாற்றங்களை ஒரே மாதிரி பயன்படுத்தி, இறுதியில் reverse-check செய்யவும்.

Summary

  • Conditional codes-ல் வகைபடுத்தப்பட்ட inputs-க்கு வேறு operations பயன்படுத்தப்படும்.
  • Condition-ஐ முதலில் கண்டறிந்து, branch rules-ஐ தெளிவாக எழுத வேண்டும்.
  • A/Z, 0/9 போன்ற boundary characters கவனமாக கையாள வேண்டும்.
  • Reverse-check மூலம் correctness-ஐ உறுதி செய்யலாம்.

Practice

(1/5)
1. Rule: vowels → next letter (A→B, E→F, I→J, O→P, U→V). Consonants → previous letter (B→A, C→B, D→C, ...). How is the word 'GAME' written in this code?
easy
A. FBLF
B. HBLF
C. FCLF
D. FBLG

Solution

  1. Step 1: Identify each letter type

    G = consonant, A = vowel, M = consonant, E = vowel.
  2. Step 2: Apply the conditional rules

    • G (consonant) → previous letter = F
    • A (vowel) → next letter = B
    • M (consonant) → previous letter = L
    • E (vowel) → next letter = F
  3. Step 3: Combine transformed letters

    Result = FBLF.
  4. Final Answer:

    FBLF → Option A
  5. Quick Check:

    Reverse rules (F→G, B→A, L→M, F→E) recover GAME ✅
Hint: Classify each letter (vowel/consonant) first, then apply the respective shift.
Common Mistakes: Applying the wrong direction (e.g., shifting vowels backward or consonants forward).
2. Rule: For digits - odd digits add 1, even digits subtract 1. What is the code for the number 476?
easy
A. 385
B. 367
C. 3850
D. 387

Solution

  1. Step 1: Classify each digit

    4 = even, 7 = odd, 6 = even.
  2. Step 2: Apply the conditional rule

    • 4 (even) → 4 - 1 = 3
    • 7 (odd) → 7 + 1 = 8
    • 6 (even) → 6 - 1 = 5
  3. Step 3: Combine results

    Result = 385.
  4. Final Answer:

    385 → Option A
  5. Quick Check:

    Check examples: even→-1, odd→+1; mapping applied consistently ✅
Hint: Remember: odd → +1, even → -1; process digits independently left→right.
Common Mistakes: Forgetting to treat each digit independently or mishandling 0 (not present here).
3. Rule: letters in odd positions (1st, 3rd, ...) are shifted +2; letters in even positions (2nd, 4th, ...) are shifted -1. How is the word 'POWER' encoded?
easy
A. RNYDT
B. RNXDT
C. QNYDS
D. RMYDT

Solution

  1. Step 1: Number positions and list letters

    1:P, 2:O, 3:W, 4:E, 5:R.
  2. Step 2: Apply conditional shifts

    • Pos1 P → +2 → P→R
    • Pos2 O → -1 → O→N
    • Pos3 W → +2 → W→Y
    • Pos4 E → -1 → E→D
    • Pos5 R → +2 → R→T
  3. Step 3: Combine transformed letters

    Result = RNYDT.
  4. Final Answer:

    RNYDT → Option A
  5. Quick Check:

    Reverse: R→P (-2), N→O (+1), Y→W (-2), D→E (+1), T→R (-2) → recovers POWER ✅
Hint: Mark positions first (odd/even) - then apply +2 or -1 accordingly.
Common Mistakes: Shifting in the wrong direction for odd/even positions.
4. Rule: If a letter is a vowel, replace it with its position number (A=1, E=5, I=9, O=15, U=21). If a letter is a consonant, replace it with its next letter (B→C, C→D, Z→A). What is the code for 'BAT'?
medium
A. C1U
B. C1S
C. C1V
D. C2U

Solution

  1. Step 1: Classify each letter

    B = consonant, A = vowel, T = consonant.
  2. Step 2: Apply conditional rules

    • B (consonant) → next letter → C
    • A (vowel) → replace with position number → 1
    • T (consonant) → next letter → U
  3. Step 3: Combine results

    Result = C1U.
  4. Final Answer:

    C1U → Option A
  5. Quick Check:

    Consonants shifted +1 → B→C, T→U; vowel A→1 ✅
Hint: Vowels become numbers, consonants move forward by one letter.
Common Mistakes: Using previous letter for consonants instead of next.
5. Rule: If the word length is even → reverse the word; if odd → shift every letter +1. How is the word 'NOTE' encoded?
medium
A. OPUF
B. ETON
C. OPUE
D. ETNO

Solution

  1. Step 1: Check word length

    'NOTE' has 4 letters → even.
  2. Step 2: Apply the even-word rule

    Even → reverse the word. 'NOTE' reversed → ETON.
  3. Final Answer:

    ETON → Option B
  4. Quick Check:

    If the word were odd (e.g., 'NOT'), rule would shift letters: N→O, O→P, T→U → 'OPU' ✅
Hint: Determine word length first - even means reverse, odd means shift +1.
Common Mistakes: Applying the wrong rule for word length.