scene.org File Archive

File download

<root>­/­parties­/­2024­/­vccc24­/­christmas_challenge/art-top_pc_php_97b_vc3-2024.zip

File size:
15 794 bytes (15.42K)
File date:
2024-12-29 14:13:04
Download count:
all-time: 0

Preview

  • file_id.diz 1.47K
  • result.png 15.58K
  • vc24.php 97B

file_id.diz

vc24

Author: Art-top
Category: Christmas Challenge
System:   PC
Language: PHP
Source code size: 97
Instructions:

Source code in vc24.php
You can run it using PHP from terminal/command prompt:
php.exe vc24.php
or
php vc24.php

Description:

At the beginning "gift bow" characters are printed.
In the main block of the program there are two loops: an outer one - for the Y coordinate
and an inner one - for the X coordinate. The current coordinates determine which character
should be printed.

Original program:

<?php echo"	\O/";$s="! +-";for($y=19;$y--;){echo"
";for($x=19;$x--;)echo$s[2*!($y%9)|$x%9>0];}?>

Program with comments (formatted for convenience):

<?php
echo"	\O/";					// print "gift bow" (first character - tabulation)
$s="! +-";					// set of characters in string $s
for($y=19;$y--;){				// vertical cycle (Y from 18 to 0)
	echo"
";						// print line feed
	for($x=19;$x--;)			// horizontal cycle (X from 18 to 0)
		echo$s[2*!($y%9)|$x%9>0];	// expression $x%9>0 returns true or false depending on the X counter's miltiple 9
						// expression |$x%9>0 converts a boolean result to a numeric one (0 or 1)
						// expression !($y%9) returns true or false depending on the Y counter's miltiple 9
						// expression 2*!($y%9) converts a boolean result to a numeric one (0 or 2)
						// $s[2*!($y%9)|$x%9>0] returns character of the string $s with index from 0 to 3
						// character will be printed
}
?>

Comments:
It was very interesting.