Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

3 of 3
Commonmark migration

JavaScript (ES6) 110 (削除) 116 (削除ここまで)

Straightforward:scan string, c is current digit, l is last digit, o is operator.

F=x=>(l='',[for(c of x)10-c?(v=!l||v&&(o<'<'?l!=c:(o[1]&&c==l)||(o<'='?l<c:o<'>'?c==l:l>c)),l=c,o=''):o+=c],v)

Test In Firefox / FireBug console

;['3<=4!=9>3==3','3<=4!=4','5>5','8==8<9>0!=2>=1']
.forEach(s=>console.log(s,F(s)))

3<=4!=9>3==3 true
3<=4!=4 false
5>5 false
8==8<9>0!=2>=1 true

edc65
  • 32.3k
  • 3
  • 37
  • 90

AltStyle によって変換されたページ (->オリジナル) /