This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Matrix(val n: Int, val m: Int) { | |
require(n > 0 && m > 0, "Matrix dimensions should be positive integers!") | |
val elements: Array[Array[Int]] = Array.fill(n)(Array.fill(m)(0)) | |
override def toString: String = { | |
elements.map(_.mkString(",")).mkString("\n") | |
} | |
def setElement(i: Int, j: Int, newValue: Int): Unit = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSArray<NSString *> *) setToArray:(NSCharacterSet *) charset{ | |
NSMutableArray *array = [NSMutableArray array]; | |
for (int plane = 0; plane <= 16; plane++) { | |
if ([charset hasMemberInPlane:plane]) { | |
UTF32Char c; | |
for (c = plane << 16; c < (plane+1) << 16; c++) { | |
if ([charset longCharacterIsMember:c]) { | |
UTF32Char c1 = OSSwapHostToLittleInt32(c); // To make it byte-order safe | |
NSString *s = [[NSString alloc] initWithBytes:&c1 length:4 encoding:NSUTF32LittleEndianStringEncoding]; | |
[array addObject:s]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program diffusion | |
! 2D diffusion equation | |
implicit none | |
integer :: t, m, n | |
real, parameter :: D=5.0 | |
real :: dx, dy, dt, a, b, c | |
real, dimension(:), allocatable :: u | |
real, dimension(:,:), allocatable :: u1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mpi.h> | |
#include <stdio.h> | |
#include <math.h> | |
#include <iostream> | |
#include <fstream> | |
#include <iomanip> | |
#include <sstream> | |
using namespace std; | |
void printMatrix(double* matrix, int n, int t) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val input = Map("ACBED" -> 5, "ADECB" -> 5, "BEDAC" -> 8, "CABED" -> 3, "CAEBD" -> 7, "CBADE" -> 2, "DCEBA" -> 7, "EBADC" -> 8) | |
val allVotes = input.values.sum | |
val points = (for { | |
key <- input.keys | |
point <- key | |
} yield point).toSet.toList.sorted | |
val table1 = (for { |