Difference between revisions of "GetCredits"

From Sega Retro

(Created page with "{{#vardefine:text|{{#lst:Rail Chase 2|credits_arcade}}}} {{#vardefine:name|Mie Kumagai}} {{#var:text}} {{#var:name}} ==who can write the best algorithm???== Given "text" and...")
 
Line 20: Line 20:
 
etc.
 
etc.
 
</pre>
 
</pre>
 +
 +
==My attempt==
 +
<pre>
 +
{{#vardefine:text|{{#replace:{{#var:text}}|*'''|* '''}}}}{{#vardefine:text|{{#replace:{{#var:text}}|**|}}}}
 +
{{#loop: i
 +
| 0
 +
| {{#expr:{{charcount|{{#var:text}}|* '''}}-1}}
 +
| {{#vardefine:subtext|{{#explode:{{#var:text}}|* '''|{{#var:i}}}}}} {{#if: {{#pos:{{#var:subtext}}|{{#var:name}}}} | {{#vardefine:role|{{#explode:{{#var:subtext}}|:|0}}}} }}
 +
}}
 +
{{#var:role}}
 +
</pre>
 +
 +
{{#vardefine:text|{{#replace:{{#var:text}}|*'''|* '''}}}}{{#vardefine:text|{{#replace:{{#var:text}}|**|}}}}
 +
{{#loop: i
 +
| 0
 +
| {{#expr:{{charcount|{{#var:text}}|* '''}}-1}}
 +
| {{#vardefine:subtext|{{#explode:{{#var:text}}|* '''|{{#var:i}}}}}} {{#if: {{#pos:{{#var:subtext}}|{{#var:name}}}} | {{#vardefine:role|{{#explode:{{#var:subtext}}|:|0}}}} }}
 +
}}
 +
{{#var:role}}
 +
 +
- [[User:Hivebrain|Hivebrain]] ([[User talk:Hivebrain|talk]]) 14:35, 10 August 2017 (CDT)

Revision as of 14:35, 10 August 2017



Mie Kumagai

who can write the best algorithm???

Given "text" and "name", find role. We don't have Regex. GO -Black Squirrel (talk) 13:58, 10 August 2017 (CDT)


//Squirrel's "can't be arsed after a long day's work" attempt #1

while not at end of string
{{#vardefine:namePos|{{#pos:{{#var:text}}|{{#var:name}}}}}}
rpos ''':
rpos *'''
get the role
{{#vardefine:namePos|{{#pos:{{#var:text}}|{{#var:name}}|{{#var:namePos}}}}}}
etc.

My attempt

{{#vardefine:text|{{#replace:{{#var:text}}|*'''|* '''}}}}{{#vardefine:text|{{#replace:{{#var:text}}|**|}}}}
{{#loop: i
| 0
| {{#expr:{{charcount|{{#var:text}}|* '''}}-1}}
| {{#vardefine:subtext|{{#explode:{{#var:text}}|* '''|{{#var:i}}}}}} {{#if: {{#pos:{{#var:subtext}}|{{#var:name}}}} | {{#vardefine:role|{{#explode:{{#var:subtext}}|:|0}}}} }}
}}
{{#var:role}}



- Hivebrain (talk) 14:35, 10 August 2017 (CDT)